Kitlist
1.1.0
|
Holds a rich graph of objects representing the application's data model. More...
#include <kitmodel.hpp>
Public Member Functions | |
KitModel () | |
Creates an empty data model. More... | |
~KitModel () | |
Destructor. More... | |
void | foreach_item_iter (const SlotForeachModelItemIter &slot) |
Calls the provided slot for each item in the map. More... | |
void | foreach_item (const SlotForeachModelItem &slot) |
Calls the provided slot for each item in the map. More... | |
void | foreach_category_iter (const SlotForeachCategoryIter &slot) |
Calls the provided slot for each category in the map. More... | |
void | foreach_category (const SlotForeachCategory &slot) |
Calls the provided slot for each category in the map. More... | |
virtual ModelCategory * | find_category (long id) |
Finds a Category by it's unique ID. More... | |
virtual ModelItem * | find_item (long id) |
Finds an item by it's unique ID. More... | |
virtual CategoryContainer * | get_categories () |
Returns a list of all categories. More... | |
virtual ItemContainer * | get_all_items () |
Returns a list of all items. More... | |
virtual ItemContainer * | get_all_items (ItemFunctor &functor) |
Returns a list of all items, filtered by the passed functor. More... | |
virtual void | add_category (ModelCategory *category) |
Add a category to the model. More... | |
virtual void | add_item (ModelItem *item) |
Adds an item to the model. More... | |
virtual void | add_item (ModelItem *item, long cat_id) |
Adds an item to the model and associates it with the specified category. More... | |
virtual void | copy_items (const ModelItemContainer &items, long cat_id=-1) |
Copies items to the specified category. More... | |
virtual bool | filter (bool checked) |
Applies the current filter. More... | |
virtual void | set_dirty (bool dirty=true) |
virtual bool | is_dirty () |
virtual void | show_all () |
Removes filter. All items are shown. More... | |
virtual void | show_checked_only () |
Sets the filter to show only checked items. More... | |
virtual void | show_unchecked_only () |
Sets the filter to show only unchecked items. More... | |
virtual void | reset () |
Resets all contained objects to their default states. More... | |
virtual void | purge () |
Purges deleted categories and items from the model. More... | |
Protected Attributes | |
bool | m_dirty |
Indicates whether the model needs saving. I.e it's state has changed. More... | |
CategoryMap * | m_category_map |
Map allowing categories to be located by ID. More... | |
ItemMap * | m_item_map |
Map allowing items to be located by ID. More... | |
enum item_filter_types | m_item_filter |
Indicates whether and how items are currently filtered. More... | |
Holds a rich graph of objects representing the application's data model.
Definition at line 135 of file kitmodel.hpp.
KitModel::KitModel | ( | ) |
Creates an empty data model.
Definition at line 187 of file kitmodel.cpp.
References m_category_map, and m_item_map.
KitModel::~KitModel | ( | ) |
Destructor.
Deletes all items and categories belonging to the model.
Definition at line 198 of file kitmodel.cpp.
References m_category_map, and m_item_map.
|
virtual |
Add a category to the model.
The category is included in the model's map.
Definition at line 361 of file kitmodel.cpp.
References Category::get_id(), and m_category_map.
Referenced by Service::create_category(), and KitParser::process_category().
|
virtual |
Adds an item to the model.
The item is included in the model's map.
Definition at line 371 of file kitmodel.cpp.
References Item::get_id(), and m_item_map.
Referenced by Service::create_item(), and KitParser::process_item().
|
virtual |
Adds an item to the model and associates it with the specified category.
The category must have already been added to the model's map.
Definition at line 382 of file kitmodel.cpp.
References ModelCategory::add_item(), find_category(), Item::get_id(), and m_item_map.
|
virtual |
Copies items to the specified category.
Only copies those items that do not already exist in the target category.
Definition at line 399 of file kitmodel.cpp.
References ModelCategory::add_item(), find_category(), Category::m_items, and GuiState::set_dirty().
Referenced by Service::copy_items().
|
virtual |
Applies the current filter.
checked | The checked/ticked state of the item being filtered. |
Definition at line 446 of file kitmodel.cpp.
References ALL, CHECKED, m_item_filter, and UNCHECKED.
Referenced by Service::filter(), and FilterItem::operator()().
|
virtual |
Finds a Category by it's unique ID.
Definition at line 265 of file kitmodel.cpp.
References m_category_map.
Referenced by add_item(), copy_items(), Service::delete_category(), Service::find_category(), Service::get_filtered_items(), and Service::get_items().
|
virtual |
Finds an item by it's unique ID.
Definition at line 278 of file kitmodel.cpp.
References m_item_map.
Referenced by Service::delete_item(), Service::find_item(), KitParser::process_category_item(), and Service::update_item().
void KitModel::foreach_category | ( | const SlotForeachCategory & | slot | ) |
Calls the provided slot for each category in the map.
Definition at line 254 of file kitmodel.cpp.
References m_category_map.
Referenced by XmlDao::save_model().
void KitModel::foreach_category_iter | ( | const SlotForeachCategoryIter & | slot | ) |
Calls the provided slot for each category in the map.
Definition at line 242 of file kitmodel.cpp.
References m_category_map.
void KitModel::foreach_item | ( | const SlotForeachModelItem & | slot | ) |
Calls the provided slot for each item in the map.
Definition at line 230 of file kitmodel.cpp.
References m_item_map.
Referenced by XmlDao::save_model().
void KitModel::foreach_item_iter | ( | const SlotForeachModelItemIter & | slot | ) |
Calls the provided slot for each item in the map.
Definition at line 218 of file kitmodel.cpp.
References m_item_map.
|
virtual |
Returns a list of all items.
Excluded items are excluded from the list. The caller is responsible for deleting the returned item list.
Definition at line 327 of file kitmodel.cpp.
References m_item_map.
Referenced by Service::get_filtered_items(), Service::get_items(), and XmlDao::get_model().
|
virtual |
Returns a list of all items, filtered by the passed functor.
Excluded items are excluded from the list. The caller is responsible for deleting the returned item list.
Definition at line 345 of file kitmodel.cpp.
References m_item_map.
|
virtual |
Returns a list of all categories.
Definition at line 300 of file kitmodel.cpp.
References GuiState::is_deleted(), and m_category_map.
Referenced by Service::get_categories(), and XmlDao::get_model().
|
inlinevirtual |
Definition at line 177 of file kitmodel.hpp.
References GuiState::m_dirty.
Referenced by Service::is_model_dirty().
|
virtual |
Purges deleted categories and items from the model.
Typically, this method is called after a save operation, but before calling KitModel::reset()
Definition at line 486 of file kitmodel.cpp.
References GuiState::is_deleted(), m_category_map, m_item_map, and ModelCategory::purge().
Referenced by XmlDao::save_model().
|
virtual |
Resets all contained objects to their default states.
This method needs to be called after load or save operations to ensure all the dirty, deleted and new flags of each object are reset.
After a save operation, KitModel::purge() should be called before this method.
Definition at line 466 of file kitmodel.cpp.
References GuiState::is_deleted(), m_category_map, m_dirty, m_item_map, GuiState::reset(), and ModelCategory::reset().
Referenced by Service::create_default_model(), XmlDao::get_model(), and XmlDao::save_model().
|
inlinevirtual |
Definition at line 176 of file kitmodel.hpp.
Referenced by Service::copy_items(), Service::create_category(), Service::create_item(), Service::delete_category(), Service::delete_item(), Service::select_items(), Service::set_model_dirty(), and Service::toggle_selected_items().
|
inlinevirtual |
Removes filter. All items are shown.
Definition at line 179 of file kitmodel.hpp.
References ALL.
Referenced by Service::show_all().
|
inlinevirtual |
Sets the filter to show only checked items.
Definition at line 181 of file kitmodel.hpp.
References CHECKED.
Referenced by Service::show_checked_only().
|
inlinevirtual |
Sets the filter to show only unchecked items.
Definition at line 183 of file kitmodel.hpp.
References GuiState::reset(), and UNCHECKED.
Referenced by Service::show_unchecked_only().
|
protected |
Map allowing categories to be located by ID.
The map's key is the category ID, with the second field of the pair containing a pointer to the ModelCategory instance.
Definition at line 145 of file kitmodel.hpp.
Referenced by add_category(), find_category(), foreach_category(), foreach_category_iter(), get_categories(), KitModel(), purge(), reset(), and ~KitModel().
|
protected |
Indicates whether the model needs saving. I.e it's state has changed.
Definition at line 138 of file kitmodel.hpp.
Referenced by reset().
|
protected |
Indicates whether and how items are currently filtered.
One of ALL, CHECKED or UNCHECKED.
Definition at line 158 of file kitmodel.hpp.
Referenced by filter().
|
protected |
Map allowing items to be located by ID.
The map's key is the item ID, with the second field of the pair containing a pointer to the ModelItem instance.
Definition at line 152 of file kitmodel.hpp.
Referenced by add_item(), find_item(), foreach_item(), foreach_item_iter(), get_all_items(), KitModel(), purge(), reset(), and ~KitModel().