Kitlist
1.1.0
|
Implementation of a KitListDao using XML as the persistence store. More...
#include <xmldao.hpp>
Public Member Functions | |
XmlDao (int verbose=0) | |
KitModel * | get_model () |
Loads the data model from the previously set filename. More... | |
KitModel * | get_model (Glib::ustring filename) |
void | save_model (KitModel *model) |
Saves the model as an XML document. More... | |
void | save_model (KitModel *model, Glib::ustring filename) |
Saves the model as an XML document. More... | |
Category * | get_category (long cat_id, item_choice choice) |
Loads a category. More... | |
ItemContainer * | get_all_items (item_choice choice) |
Returns a list of all items. More... | |
long | add_item (const std::string name) |
long | add_item (const std::string name, long cat_id) |
void | append_items_to_category (long to_cat_id, long from_cat_id, item_choice choice) |
Copies items from one category to another. More... | |
void | associate_item_with_category (long id, long cat_id) |
Associates an existing item with an existing category. More... | |
CategoryContainer | get_categories () |
long | new_category (const std::string name) |
Creates a new category. More... | |
void | delete_item (long id) |
void | update_item_checked_state (ItemContainer &items) |
Persists the state of the 'checked' flag of each item. More... | |
void | remove_item_from_category (long id, long cat_id) |
long | get_next_item_id () |
Returns the next unused unique id for items. More... | |
long | get_next_category_id () |
void | delete_category (long id) |
void | set_item_flag (long id) |
void | unset_item_flag (long id) |
void | set_category_flag (long id) |
void | unset_category_flag (long id) |
void | set_all_flags () |
void | unset_all_flags () |
void | set_filename (Glib::ustring filename) |
virtual bool | require_filename () |
Indicates that this implementation requires a filename. More... | |
![]() | |
KitListDao (int verbose=0) | |
Constructor which will use default database connection parameters. More... | |
virtual | ~KitListDao () |
void | set_verbose (int verbose_flag) |
int | is_verbose () |
Protected Attributes | |
Glib::ustring | m_filename |
The filename to load or save the XML document from. More... | |
xmlpp::Element * | m_items_node |
Temporary reference to the items' node. More... | |
xmlpp::Element * | m_categories_node |
Temporary reference to the categories' node. More... | |
xmlpp::Element * | m_cat_items_node |
Temporary reference to the categories' items' node. More... | |
long | m_max_item_id |
The last used ID for items. More... | |
long | m_max_category_id |
The last used ID for categories. More... | |
![]() | |
int | m_verbose_flag |
Private Member Functions | |
bool | add_item_to_dom (ModelItem &item) |
Adds the passed item to the current items' node. More... | |
bool | add_category_item_to_dom (Item &item) |
Adds the passed item to the current category's node. More... | |
bool | add_category_to_dom (ModelCategory &item) |
Adds the passed item to the current categories' node. More... | |
Implementation of a KitListDao using XML as the persistence store.
Definition at line 42 of file xmldao.hpp.
|
inline |
Definition at line 67 of file xmldao.hpp.
References get_model().
|
private |
Adds the passed item to the current category's node.
Definition at line 106 of file xmldao.cpp.
References Item::get_id().
Referenced by add_category_to_dom().
|
private |
Adds the passed item to the current categories' node.
Definition at line 123 of file xmldao.cpp.
References add_category_item_to_dom(), Category::foreach_item(), Category::get_id(), Category::get_name(), and GuiState::is_deleted().
Referenced by save_model().
|
inlinevirtual |
Creates a new item.
name | The name of the new item. |
Implements KitListDao.
Definition at line 92 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Creates a new item and associates it with a category.
name | The name of the new item. |
Implements KitListDao.
Definition at line 94 of file xmldao.hpp.
References NYI.
|
private |
Adds the passed item to the current items' node.
Definition at line 87 of file xmldao.cpp.
References Item::get_checked(), Item::get_description(), Item::get_id(), and GuiState::is_deleted().
Referenced by save_model().
|
inlinevirtual |
Copies items from one category to another.
Optionally, only checked or unchecked items are copied.
from_cat_id | The ID of the source category. |
to_cat_id | The ID of the target category. |
choice | One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS. |
Implements KitListDao.
Definition at line 96 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Associates an existing item with an existing category.
Implements KitListDao.
Definition at line 98 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Deletes a category.
Implements KitListDao.
Definition at line 114 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Deletes an item by it's ID.
id | the ID of the item to delete. |
Implements KitListDao.
Definition at line 104 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Returns a list of all items.
choice | Which items to load. One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS. |
Implements KitListDao.
Definition at line 90 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Returns a list of all categories.
Implements KitListDao.
Definition at line 100 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Loads a category.
choice | Which items to load for the category. One of ALL_ITEMS, CHECKED_ITEMS or UNCHECKED_ITEMS. |
Implements KitListDao.
Definition at line 88 of file xmldao.hpp.
References NYI.
|
virtual |
Loads the data model from the previously set filename.
The data model holds a rich graph of objects, representing the entire list of categories and items.
The filename must be set before calling this method by calling XmlDao::set_filename(), otherwise an empty model is returned.
Returns | a newly created data model. The caller is responsible for destroying the model. |
Implements KitListDao.
Definition at line 46 of file xmldao.cpp.
References KitModel::get_all_items(), KitModel::get_categories(), Category::get_id(), Item::get_id(), and KitModel::reset().
Referenced by XmlDao().
|
inline |
Definition at line 76 of file xmldao.hpp.
References get_model(), save_model(), and set_filename().
Referenced by get_model().
|
virtual |
Returns the next unused unique id for categories.
Implements KitListDao.
Definition at line 150 of file xmldao.cpp.
Referenced by remove_item_from_category().
|
virtual |
Returns the next unused unique id for items.
Implements KitListDao.
Definition at line 142 of file xmldao.cpp.
Referenced by remove_item_from_category().
|
inlinevirtual |
Creates a new category.
name | the name of the new category. |
Implements KitListDao.
Definition at line 102 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Un-associates the specified item from the specified category.
Implements KitListDao.
Definition at line 108 of file xmldao.hpp.
References get_next_category_id(), get_next_item_id(), and NYI.
|
inlinevirtual |
Indicates that this implementation requires a filename.
This persistence model requires a filename to be chosen before the data can be persisted.
Reimplemented from KitListDao.
Definition at line 138 of file xmldao.hpp.
|
virtual |
Saves the model as an XML document.
The filename must be set before calling this method by calling XmlDao::set_filename();
model | The model to save. |
Implements KitListDao.
Definition at line 163 of file xmldao.cpp.
References add_category_to_dom(), add_item_to_dom(), KitModel::foreach_category(), KitModel::foreach_item(), KitModel::purge(), and KitModel::reset().
Referenced by get_model(), and Service::save_as_xml().
|
inline |
Saves the model as an XML document.
model | The model to save. |
filename | The name of the file to save to. |
Definition at line 86 of file xmldao.hpp.
References save_model(), and set_filename().
Referenced by save_model().
|
inlinevirtual |
Checks/ticks all items.
Implements KitListDao.
Definition at line 124 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Checks/ticks all items in the specified Category.
Implements KitListDao.
Definition at line 120 of file xmldao.hpp.
References NYI.
|
inline |
Definition at line 128 of file xmldao.hpp.
Referenced by get_model(), and save_model().
|
inlinevirtual |
Sets the checked flag for an item.
id | The id of the item to change. |
Implements KitListDao.
Definition at line 116 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Unchecks/unticks all items.
Implements KitListDao.
Definition at line 126 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Unchecks/unticks all items in the specified Category.
Implements KitListDao.
Definition at line 122 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Clears the checked flag for an item.
Implements KitListDao.
Definition at line 118 of file xmldao.hpp.
References NYI.
|
inlinevirtual |
Persists the state of the 'checked' flag of each item.
Implements KitListDao.
Definition at line 106 of file xmldao.hpp.
References NYI.
|
protected |
Temporary reference to the categories' items' node.
Definition at line 60 of file xmldao.hpp.
|
protected |
Temporary reference to the categories' node.
Definition at line 58 of file xmldao.hpp.
|
protected |
The filename to load or save the XML document from.
Definition at line 54 of file xmldao.hpp.
|
protected |
Temporary reference to the items' node.
Definition at line 56 of file xmldao.hpp.
|
protected |
The last used ID for categories.
Definition at line 64 of file xmldao.hpp.
|
protected |
The last used ID for items.
Definition at line 62 of file xmldao.hpp.