|
Kitlist
A list manager for maintaining kit lists
|
A pure virtual class acting as an interface for front-end implementations. More...
#include "kitlist_base_app.hpp"
Classes | |
| class | file_not_found |
| Exception throw when a file is not found. More... | |
Public Member Functions | |
| KitListBaseApp () | |
| Default constructor. | |
| virtual | ~KitListBaseApp () |
| Destructor. | |
| bool | is_dirty () const |
| void | set_dirty (bool dirty=true) const |
| auto | get_current_checked_item_count () const |
| void | new_file () |
| Create a new Model and sets the associated filename to be empty. | |
| virtual void | load_file (const std::string &filename) |
| Loads the specified file. | |
| virtual bool | save () |
| Saves the current Model using the current filename. | |
| virtual bool | save (std::string filename) |
| const std::shared_ptr< Category > | set_category_name (const int32_t id, const std::string &name) |
| Updates the name of passed Category. | |
| const std::shared_ptr< Item > | set_item_name (const int32_t id, const std::string &name) |
| Updates the name of the passed Item. | |
| const std::shared_ptr< Item > | set_item_checked (const int32_t id, const bool state) |
| Updates the checked state of the passed Item. | |
| virtual const std::shared_ptr< Item > | change_checked_state (int32_t id, Model::check_action action) |
| Switches the checked state of the Item referenced by the specified ID according to the specified action. | |
| void | change_all_current_items_checked_states (Model::check_action action) const |
| Switches the checked state of all items in the currently selected Category. | |
| void | set_filename (const std::string &filename) |
| Sets a new filename to associate with the Model. | |
| const std::string | get_filename () const |
| virtual void | initialization_complete () |
| Sets initialized to true. | |
| int32_t | new_item (const std::string &name, bool checked) const |
| creates a new Item in the model using the passed parameters, incrementing Model::max_item_id and assigning it to the Item. | |
| void | delete_category (int32_t id) const |
| Deletes the Category having the passed ID. | |
| void | delete_item (int32_t id) const |
| Deletes the Item having the passed ID. | |
| void | remove_items (const std::vector< std::shared_ptr< Item > > &items) const |
| Removes references to each of the Item instances in the list from the currently selected Category. | |
| void | remove_item (int32_t id) const |
| Removes references to the item from the currently selected Category. | |
| int32_t | new_category (const std::string &name) const |
| Creates a new Category in the Model using the passed parameters, incrementing Model::max_category_id and assigning it to the Category. | |
| const std::shared_ptr< Item > | get_item (int32_t id) const |
| Gets an Item by ID. | |
| const std::shared_ptr< Category > | get_category (int32_t id) const |
| Gets a Category by ID. | |
| const std::vector< std::shared_ptr< Item > > | get_all_items_for_current_selected_category () const |
| Returns all items for the currently selected Category. | |
| const std::vector< std::shared_ptr< Item > > | filter_items_for_current_selected_category () const |
| Filters the list of Item instances based on the currently selected category (Model::selected_category) and checked status (Model::filter). | |
| auto | count_filter_items_for_current_selected_category () const |
| Returns a count of the filtered items in the currently selected category. | |
| void | remove_all_current_checked_items () |
| Removes all checked items from the current category. | |
| void | delete_all_current_checked_items () |
| Deletes all checked items. | |
| void | associate_item_with_category (int32_t item_id, std::shared_ptr< Category > category) |
| Updates the relationships between an Item and a Category that are already in the model, but using only the item's ID as a reference. | |
| void | copy_items_to_categories (std::vector< std::shared_ptr< Item > > &items, std::vector< std::shared_ptr< Category > > &categories) const |
| Copies all of the passed items to each of the passed categories, updating the model relationships. | |
| void | copy_checked_items_to_categories (std::vector< int32_t > cids) const |
| Copies all currently checked items for the currently selected Category to the list of categories. | |
| void | copy_item_to_categories (int32_t item_id, std::vector< int32_t > cids) |
| Copies the specified item to the list of categories. | |
| void | select_category (int32_t id) |
| Sets the selected Category to that of the passed ID. | |
| int32_t | get_selected_category () const |
| Gets the ID of the currently selected Category. | |
| const std::vector< std::shared_ptr< Category > > | get_categories () const |
| Gets the list of categories. | |
| const std::vector< std::shared_ptr< Item > > | get_all_items () const |
| Gets all items, without filtering. | |
| void | set_filter (Model::state_filter state) const |
| Sets filtering of checked items. | |
| Model::state_filter | get_filter () const |
| The current filter. | |
| void | sort_categories () const |
| Sorts all the model's categories. | |
| void | sort () const |
| Sorts everything within the model. | |
Public Attributes | |
| const std::string | all_items_text = "-- Show all items --" |
| Constant string indicating the option to select no category and therefor display all items. | |
Static Public Attributes | |
| static const std::string | DEFAULT_FILE_EXTENSION = ".kit" |
| The application's default filename extension. .kit. | |
Protected Member Functions | |
| virtual void | update_menu_state (bool is_dirty) |
| Called whenever there is a change to the Model state. | |
| virtual void | category_entry_changed (const std::shared_ptr< Category > category) |
| Called when a Category name has changed. | |
| virtual void | item_entry_changed (const std::shared_ptr< Item > item) |
| Called when a Item instance's state has changed. | |
| virtual void | category_name_changed (const std::shared_ptr< Category > category) |
| virtual void | item_name_changed (const std::shared_ptr< Item > item) |
| virtual void | item_checked_changed (const std::shared_ptr< Item > item) |
| virtual void | model_state_changed (bool is_dirty) |
| Called whenever the Model state is changed. | |
Private Attributes | |
| std::unique_ptr< Model > | model |
| The application's data model. | |
| std::string | filename |
| The current filename the Model was loaded from. | |
| bool | initialized |
| Indicates that the application has finished it's initialization stage. | |
Friends | |
| class | Model |
A pure virtual class acting as an interface for front-end implementations.
An implementation may override the following methods:
Definition at line 42 of file kitlist_base_app.hpp.
| KitListBaseApp::KitListBaseApp | ( | ) |
Default constructor.
Definition at line 30 of file kitlist_base_app.cpp.
|
virtual |
Destructor.
Definition at line 37 of file kitlist_base_app.cpp.
|
inline |
Updates the relationships between an Item and a Category that are already in the model, but using only the item's ID as a reference.
| item_id | The ID of the Item within the model. |
| category | A std::shared_ptr to the Category within the model. |
Definition at line 505 of file kitlist_base_app.hpp.
|
inlineprotectedvirtual |
Called when a Category name has changed.
This allows the front-end implementation to update the category list view. The value will be a nullptr if there is no selected Category.
Reimplemented in fdsd::ftxui::KitListFtxui, and KitListGui.
Definition at line 91 of file kitlist_base_app.hpp.
|
inlineprotectedvirtual |
Called whenever a Category name changes.
| category | The Category. |
Definition at line 106 of file kitlist_base_app.hpp.
|
inline |
Switches the checked state of all items in the currently selected Category.
All items are processed without any filtering by their checked state.
| action | The type of Model::check_action to take. |
Definition at line 296 of file kitlist_base_app.hpp.
|
inlinevirtual |
Switches the checked state of the Item referenced by the specified ID according to the specified action.
| id | The ID of the Item to be updated. |
| action | The type of Model::check_action to take. |
Definition at line 281 of file kitlist_base_app.hpp.
|
inline |
Copies all currently checked items for the currently selected Category to the list of categories.
| cids | A list of category IDs to copy all the checked items to. |
Definition at line 529 of file kitlist_base_app.hpp.
|
inline |
Copies the specified item to the list of categories.
| item_id | The ID of the item to be copies. |
| cids | A list of category IDs to copy all the checked items to. |
Definition at line 539 of file kitlist_base_app.hpp.
|
inline |
Copies all of the passed items to each of the passed categories, updating the model relationships.
| items | The source list of Item instance to copy to categories. |
| categories | The target list of Category instances. |
Definition at line 516 of file kitlist_base_app.hpp.
|
inline |
Returns a count of the filtered items in the currently selected category.
If Model::selected_category is Model::no_category then all items are returned subject to the Model::filter state.
Definition at line 473 of file kitlist_base_app.hpp.
|
inline |
Deletes all checked items.
If there is a current category selected, then only those items in the current category are deleted.
Definition at line 490 of file kitlist_base_app.hpp.
|
inline |
Deletes the Category having the passed ID.
The model relationships are updated appropriately.
| id | The ID of the Category to delete. |
Definition at line 354 of file kitlist_base_app.hpp.
|
inline |
Deletes the Item having the passed ID.
The model relationships are updated appropriately.
| id | The ID of the Item to delete. |
Definition at line 366 of file kitlist_base_app.hpp.
|
inline |
Filters the list of Item instances based on the currently selected category (Model::selected_category) and checked status (Model::filter).
If Model::selected_category is Model::no_category then all items are returned subject to the Model::filter state.
Definition at line 462 of file kitlist_base_app.hpp.
|
inline |
Gets all items, without filtering.
Definition at line 578 of file kitlist_base_app.hpp.
|
inline |
Returns all items for the currently selected Category.
All items are returned without any filtering by their checked state.
Definition at line 445 of file kitlist_base_app.hpp.
|
inline |
Gets the list of categories.
Definition at line 568 of file kitlist_base_app.hpp.
|
inline |
Gets a Category by ID.
| id | The ID of the Category. |
Definition at line 433 of file kitlist_base_app.hpp.
|
inline |
Returns the count of items in the current Category.
The count disregards the current filter.
Definition at line 175 of file kitlist_base_app.hpp.
|
inline |
Definition at line 314 of file kitlist_base_app.hpp.
|
inline |
The current filter.
Definition at line 591 of file kitlist_base_app.hpp.
|
inline |
Gets an Item by ID.
| id | the id of the Item. |
Definition at line 422 of file kitlist_base_app.hpp.
|
inline |
Gets the ID of the currently selected Category.
Definition at line 559 of file kitlist_base_app.hpp.
|
inlinevirtual |
Sets initialized to true.
Indicates that the application has finished initializing. Thereafter, the app will be notified via calls to update_menu_state() when the Model state changes.
Definition at line 325 of file kitlist_base_app.hpp.
|
inline |
Definition at line 162 of file kitlist_base_app.hpp.
|
inlineprotectedvirtual |
Called whenever a Item checked state changes.
| item | The Item. |
Definition at line 128 of file kitlist_base_app.hpp.
|
inlineprotectedvirtual |
Called when a Item instance's state has changed.
This allows the front-end implementation to update the item list view. The value will be a nullptr if there is no selected Item.
Reimplemented in fdsd::ftxui::KitListFtxui, and KitListGui.
Definition at line 99 of file kitlist_base_app.hpp.
|
inlineprotectedvirtual |
Called whenever a Item name changes.
| item | The Item. |
Definition at line 117 of file kitlist_base_app.hpp.
|
virtual |
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 | if the file does not exist or cannot be read. |
Reimplemented in KitListGui.
Definition at line 39 of file kitlist_base_app.cpp.
|
inlineprotectedvirtual |
Called whenever the Model state is changed.
In turn, calls model_state_changed() if initialized is true.
| is_dirty | the current Model state. |
Definition at line 141 of file kitlist_base_app.hpp.
|
inline |
Creates a new Category in the Model using the passed parameters, incrementing Model::max_category_id and assigning it to the Category.
| name | The category's name. |
Definition at line 410 of file kitlist_base_app.hpp.
|
inline |
Create a new Model and sets the associated filename to be empty.
Definition at line 180 of file kitlist_base_app.hpp.
|
inline |
creates a new Item in the model using the passed parameters, incrementing Model::max_item_id and assigning it to the Item.
| name | the item's name. |
| checked | an optional boolean, true indicating it is checked. defaults to false. |
Definition at line 342 of file kitlist_base_app.hpp.
|
inline |
Removes all checked items from the current category.
Definition at line 480 of file kitlist_base_app.hpp.
|
inline |
Removes references to the item from the currently selected Category.
The model relationships are updated appropriately.
Definition at line 396 of file kitlist_base_app.hpp.
|
inline |
Removes references to each of the Item instances in the list from the currently selected Category.
All the model relationships are updated appropriately.
| items | A list of shared_ptr to the Item instances being removed from the currently selected Category. |
Definition at line 383 of file kitlist_base_app.hpp.
|
inlinevirtual |
Saves the current Model using the current filename.
Definition at line 201 of file kitlist_base_app.hpp.
|
inlinevirtual |
Definition at line 210 of file kitlist_base_app.hpp.
|
inline |
Sets the selected Category to that of the passed ID.
| id | The ID of the Category |
Definition at line 549 of file kitlist_base_app.hpp.
|
inline |
Updates the name of passed Category.
Implemented such that only calls from an implementation of KitListBaseApp can modify the model and therefore have an opportunity to be aware of the change, updating the user interface appropriately.
Definition at line 226 of file kitlist_base_app.hpp.
|
inline |
Definition at line 166 of file kitlist_base_app.hpp.
|
inline |
Sets a new filename to associate with the Model.
| filename | the new filename. |
Definition at line 307 of file kitlist_base_app.hpp.
|
inline |
Sets filtering of checked items.
Definition at line 583 of file kitlist_base_app.hpp.
|
inline |
Updates the checked state of the passed Item.
Implemented such that only calls from an implementation of KitListBaseApp can modify the model and therefore have an opportunity to be aware of the change, updating the user interface appropriately.
Definition at line 263 of file kitlist_base_app.hpp.
|
inline |
Updates the name of the passed Item.
Implemented such that only calls from an implementation of KitListBaseApp can modify the model and therefore have an opportunity to be aware of the change, updating the user interface appropriately.
Definition at line 244 of file kitlist_base_app.hpp.
|
inline |
Sorts everything within the model.
Definition at line 605 of file kitlist_base_app.hpp.
|
inline |
Sorts all the model's categories.
Definition at line 598 of file kitlist_base_app.hpp.
|
inlineprotectedvirtual |
Called whenever there is a change to the Model state.
This allows the front-end implementation to enable or disabled menu items as appropriate to the new state.
This implementation does nothing, so there is no need for a sub-class to call it.
State changes to the model are ignored if initialized is false.
Reimplemented in KitListGui.
Definition at line 80 of file kitlist_base_app.hpp.
|
friend |
Definition at line 44 of file kitlist_base_app.hpp.
| const std::string KitListBaseApp::all_items_text = "-- Show all items --" |
Constant string indicating the option to select no category and therefor display all items.
Definition at line 156 of file kitlist_base_app.hpp.
|
static |
The application's default filename extension. .kit.
Definition at line 159 of file kitlist_base_app.hpp.
|
private |
The current filename the Model was loaded from.
An empty string indicates no file is currently associated with the Model.
Definition at line 55 of file kitlist_base_app.hpp.
|
private |
Indicates that the application has finished it's initialization stage.
Before the application has fully initialised, it may not be safe to update it's state, e.g. calls to update_menu_state() are skipped until initialized is true.
Definition at line 65 of file kitlist_base_app.hpp.
|
private |
The application's data model.
Definition at line 47 of file kitlist_base_app.hpp.