|
Kitlist
A list manager for maintaining kit lists
|
Implements the main frame of the GUI. More...
#include "kitlistgui.hpp"
Public Member Functions | |
| MyFrame (KitListGui *app, const wxPoint &pos) | |
| Constructor. | |
| virtual | ~MyFrame () |
| Destructor. | |
| void | OnShow (wxShowEvent &event) |
| Event handler for when the window is shown. | |
| void | OnAbout (wxCommandEvent &event) |
| Menu event handler showing an About dialog box. | |
| void | OnNewFile (wxCommandEvent &event) |
| Menu event handler for creating a new blank model. | |
| void | OnOpen (wxCommandEvent &event) |
| Menu event handler to open another file. | |
| void | OnFileHistoryMenuItem (wxCommandEvent &event) |
| Menu event handler to open a file that has been selected from the recent files menu. | |
| void | OnSave (wxCommandEvent &event) |
| Menu event handler to save the current file. | |
| void | OnSaveAs (wxCommandEvent &event) |
| Menu event handler to save the model to a new file. | |
| void | OnQuit (wxCommandEvent &event) |
| Called when the user chooses to quit the application. | |
| void | OnAddItem (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for creating a new Item. | |
| void | OnAddCategory (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for creating a new Category. | |
| void | OnSelectCategory (wxDataViewEvent &event) |
| Event handler called when a user selects a Category from the list. | |
| void | OnSelectItem (wxDataViewEvent &event) |
| Event handler called when a user selects a Item from the list. Calls selected_item_changed(). | |
| void | selected_item_changed () |
| Disables or enables menu items, depending on whether any items have been selected in the Item list. | |
| void | OnCategoryStartEditing (wxDataViewEvent &event) |
| Event handler implemented to disallow editing the first row of the Category list. | |
| void | OnCategoryContextMenu (wxDataViewEvent &event) |
| Implements a pop-up context menu for the Category list. | |
| void | OnItemContextMenu (wxDataViewEvent &event) |
| Implements a pop-up context menu for the Item list. | |
| void | OnCategoryListValueChanged (wxDataViewEvent &event) |
| Event handler called when the Category name is edited. | |
| void | OnItemListValueChanged (wxDataViewEvent &event) |
| Event handler called when the Item name is edited. | |
| void | OnShowAll (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for showing all items. | |
| void | OnShowChecked (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for showing only checked items. | |
| void | OnShowUnchecked (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for showing only unchecked items. | |
| void | OnSelectAllItems (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for selecting all items. | |
| void | OnUnselectAllItems (wxCommandEvent &WXUNUSED(event)) |
| Menu event handler for unselecting all items. | |
| void | OnCheckAll (wxCommandEvent &WXUNUSED(event)) |
| Menu handler called to check all items in the list. | |
| void | OnUncheckAll (wxCommandEvent &WXUNUSED(event)) |
| Menu handler called to uncheck all items in the list. | |
| void | OnToggleAll (wxCommandEvent &WXUNUSED(event)) |
| Menu handler called to toggle the checked state of all items in the list. | |
| void | OnCheckSelected (wxCommandEvent &event) |
| Menu handler called to mark all selected items as checked. | |
| void | OnUncheckSelected (wxCommandEvent &event) |
| Menu handler called to mark all selected items as unchecked. | |
| void | OnToggleSelected (wxCommandEvent &event) |
| Menu handler called to toggle the checked state of all selected items. | |
| void | CopyCheckedToCategories (wxCommandEvent &WXUNUSED(event)) |
| Menu handler called to copy checked items to one or more categories. | |
| void | OnCopySelectedItemsToCategories (wxCommandEvent &event) |
| Menu handler called to copy selected items to one or more categories. | |
| void | OnRemoveSelectedItems (wxCommandEvent &event) |
| Menu handler called to remove selected items from a Category. | |
| void | OnRemoveCheckedItems (wxCommandEvent &WXUNUSED(event)) |
| Menu handler called to remove checked items from a Category. | |
| void | OnDeleteCheckedItems (wxCommandEvent &WXUNUSED(event)) |
| Menu handler called to delete checked items from the model. | |
| wxSize | get_right_panel_width () |
| Returns the minimum width of the right panel (the item list). | |
Static Public Attributes | |
| static const int | VSPLIT_DIST = 200 |
| The initial width of the category column. | |
Private Member Functions | |
| void | load_file (const std::string filename) |
| Loads the specified file. | |
| unsigned | populate_category_list (int32_t select_category=Model::no_category) |
| Rebuilds the list of categories. | |
| void | populate_item_list () |
| Rebuilds the list of items. | |
| void | delete_category (int32_t id) |
| Deletes the specified Category from the model. | |
| void | delete_item (int32_t id) |
| Deletes the specified Item from the model. | |
| void | remove_item (int32_t id) |
| Removes references to the item from the currently selected Category. | |
| void | change_selected_checked_states (Model::check_action action) |
| Switches the checked state of all the currently selected items in the item list. | |
| void | select_and_copy_to_categories (std::vector< std::shared_ptr< Item > > selected_items) |
| Displays a dialog for user to select target categories to copy selected items to. | |
| void | copy_items_to_categories (std::vector< std::shared_ptr< Item > > &items, std::vector< std::shared_ptr< Category > > &categories) |
| Copies each of the passed items to each of the passed categories. | |
| void | save () |
| Saves the current Model using the current KitListBaseApp::filename. | |
| void | update_file_menu (bool is_dirty) |
| void | update_edit_menu () |
| Enables or disables menu items on the Edit menu. | |
| void | setup_rich_text_printing () |
| Sets up rich text printing. | |
| void | OnPrint (wxCommandEvent &event) |
| Prints the list of items. | |
| void | OnPrintPreview (wxCommandEvent &event) |
| Provides a print previews of the list of items. | |
| void | FillBuffer (wxRichTextBuffer &buf) const |
| Fills the passed buffer with rich text to print or preview. | |
| void | do_open (wxString wx_path) |
| Opens the file from the specified path. | |
| wxDECLARE_EVENT_TABLE () | |
| Declares the wxWidgets event handling table. | |
Private Attributes | |
| std::unique_ptr< wxRichTextPrinting > | rich_text_printing |
| Pointer to an instance supporting rich text printing. | |
| KitListGui * | gui_app |
| Pointer to the main GUI class. | |
| wxDataViewListCtrl * | category_list_ctrl |
| The Category list control. | |
| wxMenu * | file_menu |
| The File menu. | |
| wxMenu * | edit_menu |
| The Edit menu. | |
| wxMenu * | file_history_menu |
| The recent files menu. | |
| wxFileHistory * | file_history |
| The list of recent files. | |
| wxMenuItem * | file_history_menu_item |
| A pointer to the recent files menu item. | |
| std::unique_ptr< std::exception > | last_error |
| Holds the most recent exception that occurred or nullptr if no exception. | |
| wxWindow * | left_panel = nullptr |
| Pointer to the left panel containing the list of categories. | |
| wxWindow * | right_panel = nullptr |
| Pointer to the right panel containing the list of items. | |
| wxDataViewListCtrl * | item_list_ctrl = nullptr |
| Pointer to the Item list controller. | |
| wxSplitterWindow * | split_window = nullptr |
| Pointer to the Category list controller. | |
Static Private Attributes | |
| static const int | MIN_PANE_SIZE = 1 |
| The minimum size that the split window can be changed to by the user. | |
| static const int | ITEM_CHECKED_COL = 1 |
| The zero based indexed position of the item checked column. | |
| static const int | ITEM_NAME_COL = 0 |
| The zero based indexed position of the item name column. | |
| static const int | CATEGORY_NAME_COL = 0 |
| The zero based indexed of the category name column. | |
Friends | |
| class | KitListGui |
Implements the main frame of the GUI.
Definition at line 118 of file kitlistgui.hpp.
| MyFrame::MyFrame | ( | KitListGui * | app, |
| const wxPoint & | pos ) |
Constructor.
|
virtual |
Destructor.
Saves the current window position to the application's configuration file.
Definition at line 364 of file kitlistgui.cpp.
|
private |
Switches the checked state of all the currently selected items in the item list.
| action | The type of Model::check_action to take. |
Definition at line 451 of file kitlistgui.cpp.
|
private |
Copies each of the passed items to each of the passed categories.
Each of the items are associated with each of the selected categories. If the category is already associated with the item, the item is ignored, ensuring there are no duplicate items with a Category.
| items | a list of the items to copy. |
| categories | a list of the target categories. |
| void MyFrame::CopyCheckedToCategories | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Menu handler called to copy checked items to one or more categories.
Definition at line 506 of file kitlistgui.cpp.
|
inlineprivate |
Deletes the specified Category from the model.
| id | The ID of the Category to delete. |
Definition at line 417 of file kitlistgui.hpp.
|
inlineprivate |
Deletes the specified Item from the model.
| id | The ID of the Item to delete. |
Definition at line 428 of file kitlistgui.hpp.
|
private |
Opens the file from the specified path.
The current model is replaced with the file's contents.
| wx_path | The pathname of the file to load. |
Definition at line 923 of file kitlistgui.cpp.
|
private |
Fills the passed buffer with rich text to print or preview.
Basically adds a paragraph for each of the items in the current category, or all items. Only items that are not excluded by the current filter are added.
| buf | The buffer to fill. |
Definition at line 718 of file kitlistgui.cpp.
|
inline |
Returns the minimum width of the right panel (the item list).
Definition at line 364 of file kitlistgui.hpp.
|
private |
Loads the specified file.
Loads the Model from the specified filename.
| filename | The name of the file to load. |
| KitParser::parse_exception | Thrown if there is an error parsing the file. |
| KitListBaseApp::file_not_found |
throws KitParser::parse_exception throws KitListGui::file_not_found
Definition at line 945 of file kitlistgui.cpp.
| void MyFrame::OnAbout | ( | wxCommandEvent & | event | ) |
Menu event handler showing an About dialog box.
Definition at line 868 of file kitlistgui.cpp.
| void MyFrame::OnAddCategory | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Menu event handler for creating a new Category.
Definition at line 1008 of file kitlistgui.cpp.
| void MyFrame::OnAddItem | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Menu event handler for creating a new Item.
Definition at line 993 of file kitlistgui.cpp.
| void MyFrame::OnCategoryContextMenu | ( | wxDataViewEvent & | event | ) |
Implements a pop-up context menu for the Category list.
Definition at line 554 of file kitlistgui.cpp.
| void MyFrame::OnCategoryListValueChanged | ( | wxDataViewEvent & | event | ) |
Event handler called when the Category name is edited.
Definition at line 380 of file kitlistgui.cpp.
|
inline |
Event handler implemented to disallow editing the first row of the Category list.
Definition at line 264 of file kitlistgui.hpp.
|
inline |
Menu handler called to check all items in the list.
Definition at line 313 of file kitlistgui.hpp.
| void MyFrame::OnCheckSelected | ( | wxCommandEvent & | event | ) |
Menu handler called to mark all selected items as checked.
Definition at line 433 of file kitlistgui.cpp.
| void MyFrame::OnCopySelectedItemsToCategories | ( | wxCommandEvent & | event | ) |
Menu handler called to copy selected items to one or more categories.
Definition at line 516 of file kitlistgui.cpp.
| void MyFrame::OnDeleteCheckedItems | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Menu handler called to delete checked items from the model.
Definition at line 498 of file kitlistgui.cpp.
| void MyFrame::OnFileHistoryMenuItem | ( | wxCommandEvent & | event | ) |
Menu event handler to open a file that has been selected from the recent files menu.
Definition at line 893 of file kitlistgui.cpp.
| void MyFrame::OnItemContextMenu | ( | wxDataViewEvent & | event | ) |
Implements a pop-up context menu for the Item list.
Definition at line 581 of file kitlistgui.cpp.
| void MyFrame::OnItemListValueChanged | ( | wxDataViewEvent & | event | ) |
Event handler called when the Item name is edited.
Definition at line 395 of file kitlistgui.cpp.
| void MyFrame::OnNewFile | ( | wxCommandEvent & | event | ) |
Menu event handler for creating a new blank model.
Definition at line 880 of file kitlistgui.cpp.
| void MyFrame::OnOpen | ( | wxCommandEvent & | event | ) |
Menu event handler to open another file.
Definition at line 904 of file kitlistgui.cpp.
|
private |
Prints the list of items.
Displays a dialog where the user can choose print parameters.
Definition at line 700 of file kitlistgui.cpp.
|
private |
Provides a print previews of the list of items.
Definition at line 709 of file kitlistgui.cpp.
| void MyFrame::OnQuit | ( | wxCommandEvent & | event | ) |
Called when the user chooses to quit the application.
Definition at line 978 of file kitlistgui.cpp.
| void MyFrame::OnRemoveCheckedItems | ( | wxCommandEvent & | WXUNUSEDevent | ) |
Menu handler called to remove checked items from a Category.
Definition at line 490 of file kitlistgui.cpp.
| void MyFrame::OnRemoveSelectedItems | ( | wxCommandEvent & | event | ) |
Menu handler called to remove selected items from a Category.
Definition at line 465 of file kitlistgui.cpp.
| void MyFrame::OnSave | ( | wxCommandEvent & | event | ) |
Menu event handler to save the current file.
Definition at line 950 of file kitlistgui.cpp.
| void MyFrame::OnSaveAs | ( | wxCommandEvent & | event | ) |
Menu event handler to save the model to a new file.
Definition at line 956 of file kitlistgui.cpp.
|
inline |
Menu event handler for selecting all items.
Definition at line 301 of file kitlistgui.hpp.
| void MyFrame::OnSelectCategory | ( | wxDataViewEvent & | event | ) |
Event handler called when a user selects a Category from the list.
When the user chooses the first row, all items are shown, subject to filtering by their checked status.
Otherwise only items belonging to the selected category are shown, filtered by their checked status.
Definition at line 621 of file kitlistgui.cpp.
| void MyFrame::OnSelectItem | ( | wxDataViewEvent & | event | ) |
Event handler called when a user selects a Item from the list. Calls selected_item_changed().
Definition at line 641 of file kitlistgui.cpp.
| void MyFrame::OnShow | ( | wxShowEvent & | event | ) |
Event handler for when the window is shown.
If there was an error during startup, this method will display the error message to the user.
Definition at line 856 of file kitlistgui.cpp.
|
inline |
Menu event handler for showing all items.
Definition at line 283 of file kitlistgui.hpp.
|
inline |
Menu event handler for showing only checked items.
Definition at line 289 of file kitlistgui.hpp.
|
inline |
Menu event handler for showing only unchecked items.
Definition at line 295 of file kitlistgui.hpp.
|
inline |
Menu handler called to toggle the checked state of all items in the list.
Definition at line 327 of file kitlistgui.hpp.
| void MyFrame::OnToggleSelected | ( | wxCommandEvent & | event | ) |
Menu handler called to toggle the checked state of all selected items.
Definition at line 445 of file kitlistgui.cpp.
|
inline |
Menu handler called to uncheck all items in the list.
Definition at line 320 of file kitlistgui.hpp.
| void MyFrame::OnUncheckSelected | ( | wxCommandEvent & | event | ) |
Menu handler called to mark all selected items as unchecked.
Definition at line 439 of file kitlistgui.cpp.
|
inline |
Menu event handler for unselecting all items.
Definition at line 307 of file kitlistgui.hpp.
|
private |
Rebuilds the list of categories.
Should be called whenever a Category is created, updated, or deleted.
Definition at line 651 of file kitlistgui.cpp.
|
private |
Rebuilds the list of items.
Includes only those items that belong to the selected category or are not excluded by the current filter of their checked states.
Definition at line 673 of file kitlistgui.cpp.
|
inlineprivate |
Removes references to the item from the currently selected Category.
The model relationships are updated appropriately.
Definition at line 442 of file kitlistgui.hpp.
|
private |
Saves the current Model using the current KitListBaseApp::filename.
Definition at line 1023 of file kitlistgui.cpp.
|
private |
Displays a dialog for user to select target categories to copy selected items to.
Each of the items are associated with each of the selected categories. If the category is already associated with the item, the item is ignored, ensuring there are no duplicate items with a Category.
| selected_items | a list of the items to copy. |
Definition at line 533 of file kitlistgui.cpp.
| void MyFrame::selected_item_changed | ( | ) |
Disables or enables menu items, depending on whether any items have been selected in the Item list.
Definition at line 646 of file kitlistgui.cpp.
|
private |
Sets up rich text printing.
Definition at line 688 of file kitlistgui.cpp.
|
private |
Enables or disables menu items on the Edit menu.
Menu items are disabled or enabled depending whether there are any items visible in the item list.
Definition at line 1040 of file kitlistgui.cpp.
|
private |
Enables or disables menu items on the File menu according to the is_dirty flag.
| is_dirty | Flag. True if the model has been modified since it was last saved. |
Definition at line 1033 of file kitlistgui.cpp.
|
private |
Declares the wxWidgets event handling table.
|
friend |
Definition at line 120 of file kitlistgui.hpp.
|
private |
The Category list control.
Definition at line 141 of file kitlistgui.hpp.
|
staticprivate |
The zero based indexed of the category name column.
Definition at line 182 of file kitlistgui.hpp.
|
private |
The Edit menu.
Definition at line 147 of file kitlistgui.hpp.
|
private |
The list of recent files.
The list is populated from the application's configuration file.
Definition at line 157 of file kitlistgui.hpp.
|
private |
The recent files menu.
Definition at line 150 of file kitlistgui.hpp.
|
private |
A pointer to the recent files menu item.
Used to enable or disable the recent files menu option.
Definition at line 164 of file kitlistgui.hpp.
|
private |
The File menu.
Definition at line 144 of file kitlistgui.hpp.
|
private |
|
staticprivate |
The zero based indexed position of the item checked column.
Definition at line 178 of file kitlistgui.hpp.
|
private |
Pointer to the Item list controller.
Definition at line 377 of file kitlistgui.hpp.
|
staticprivate |
The zero based indexed position of the item name column.
Definition at line 180 of file kitlistgui.hpp.
|
private |
Holds the most recent exception that occurred or nullptr if no exception.
Primarily used when attempting to load the most recent file on startup. When an error occurs during startup, the GUI is not sufficiently initialized to be able to show the error to the user. Instead the error is displayed when OnShow() is called.
Definition at line 175 of file kitlistgui.hpp.
|
private |
Pointer to the left panel containing the list of categories.
Definition at line 372 of file kitlistgui.hpp.
|
staticprivate |
The minimum size that the split window can be changed to by the user.
Definition at line 131 of file kitlistgui.hpp.
|
private |
Pointer to an instance supporting rich text printing.
Definition at line 128 of file kitlistgui.hpp.
|
private |
Pointer to the right panel containing the list of items.
Definition at line 374 of file kitlistgui.hpp.
|
private |
Pointer to the Category list controller.
Definition at line 380 of file kitlistgui.hpp.
|
static |
The initial width of the category column.
Definition at line 369 of file kitlistgui.hpp.