KitModel Class Reference

Holds a rich graph of objects representing the application's data model. More...

#include <kitmodel.hpp>

List of all members.

Public Member Functions

 KitModel ()
 Creates an empty data model.
 ~KitModel ()
 Destructor.
void foreach_item_iter (const SlotForeachModelItemIter &slot)
 Calls the provided slot for each item in the map.
void foreach_item (const SlotForeachModelItem &slot)
 Calls the provided slot for each item in the map.
void foreach_category_iter (const SlotForeachCategoryIter &slot)
 Calls the provided slot for each category in the map.
void foreach_category (const SlotForeachCategory &slot)
 Calls the provided slot for each category in the map.
virtual ModelCategoryfind_category (long id)
 Finds a Category by it's unique ID.
virtual ModelItemfind_item (long id)
 Finds an item by it's unique ID.
virtual CategoryContainerget_categories ()
 Returns a list of all categories.
virtual ItemContainerget_all_items ()
 Returns a list of all items.
virtual ItemContainerget_all_items (ItemFunctor &functor)
 Returns a list of all items, filtered by the passed functor.
virtual void add_category (ModelCategory *category)
 Add a category to the model.
virtual void add_item (ModelItem *item)
 Adds an item to the model.
virtual void add_item (ModelItem *item, long cat_id)
 Adds an item to the model and associates it with the specified category.
virtual void copy_items (const ModelItemContainer &items, long cat_id=-1)
 Copies items to the specified category.
virtual bool filter (bool checked)
 Applies the current filter.
virtual void set_dirty (bool dirty=true)
virtual bool is_dirty ()
virtual void show_all ()
 Removes filter. All items are shown.
virtual void show_checked_only ()
 Sets the filter to show only checked items.
virtual void show_unchecked_only ()
 Sets the filter to show only unchecked items.
virtual void reset ()
 Resets all contained objects to their default states.
virtual void purge ()
 Purges deleted categories and items from the model.

Protected Attributes

bool m_dirty
 Indicates whether the model needs saving. I.e it's state has changed.
CategoryMapm_category_map
 Map allowing categories to be located by ID.
ItemMapm_item_map
 Map allowing items to be located by ID.
enum item_filter_types m_item_filter
 Indicates whether and how items are currently filtered.


Detailed Description

Holds a rich graph of objects representing the application's data model.

Definition at line 135 of file kitmodel.hpp.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

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_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_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().

ModelCategory * KitModel::find_category ( long  id  )  [virtual]

ModelItem * KitModel::find_item ( long  id  )  [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().

CategoryContainer * KitModel::get_categories (  )  [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().

ItemContainer * KitModel::get_all_items (  )  [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().

ItemContainer * KitModel::get_all_items ( ItemFunctor functor  )  [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.

void KitModel::add_category ( ModelCategory category  )  [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().

void KitModel::add_item ( ModelItem item  )  [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().

void KitModel::add_item ( ModelItem item,
long  cat_id 
) [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.

void KitModel::copy_items ( const ModelItemContainer items,
long  cat_id = -1 
) [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().

bool KitModel::filter ( bool  checked  )  [virtual]

Applies the current filter.

Parameters:
checked The checked/ticked state of the item being filtered.
Returns:
true if the item should be included.

Definition at line 446 of file kitmodel.cpp.

References ALL, CHECKED, m_item_filter, and UNCHECKED.

Referenced by Service::filter(), and FilterItem::operator()().

virtual void KitModel::set_dirty ( bool  dirty = true  )  [inline, virtual]

virtual bool KitModel::is_dirty (  )  [inline, virtual]

Definition at line 177 of file kitmodel.hpp.

References m_dirty.

Referenced by Service::is_model_dirty().

virtual void KitModel::show_all (  )  [inline, virtual]

Removes filter. All items are shown.

Definition at line 179 of file kitmodel.hpp.

References ALL, and m_item_filter.

Referenced by Service::show_all().

virtual void KitModel::show_checked_only (  )  [inline, virtual]

Sets the filter to show only checked items.

Definition at line 181 of file kitmodel.hpp.

References CHECKED, and m_item_filter.

Referenced by Service::show_checked_only().

virtual void KitModel::show_unchecked_only (  )  [inline, virtual]

Sets the filter to show only unchecked items.

Definition at line 183 of file kitmodel.hpp.

References m_item_filter, and UNCHECKED.

Referenced by Service::show_unchecked_only().

void KitModel::reset (  )  [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().

void KitModel::purge (  )  [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().


Member Data Documentation

bool KitModel::m_dirty [protected]

Indicates whether the model needs saving. I.e it's state has changed.

Definition at line 138 of file kitmodel.hpp.

Referenced by is_dirty(), reset(), and set_dirty().

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().

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().

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(), show_all(), show_checked_only(), and show_unchecked_only().


The documentation for this class was generated from the following files:

Copyright 2008-2010 Frank Dean