Kitlist
A list manager for maintaining kit lists
Loading...
Searching...
No Matches
KitListGui Class Reference

Implements a GUI front-end for the application using wxWidgets. More...

#include "kitlistgui.hpp"

Inheritance diagram for KitListGui:
KitListBaseApp

Public Member Functions

 KitListGui ()
 Default constructor.
virtual void category_entry_changed (const std::shared_ptr< Category > category) override
 Called whenever a Category name changes.
virtual void item_entry_changed (const std::shared_ptr< Item > item) override
 Called whenever a Item name changes.
virtual void OnInitCmdLine (wxCmdLineParser &parser) override
 Called from OnInit() and initializes the parser with the command line options for the application.
virtual bool OnCmdLineParsed (wxCmdLineParser &parser) override
 Called after the command line has been successfully parsed.
virtual bool OnInit () override
 Initializes the application's main window.
virtual int OnExit () override
 Can be used to cleanup items created during OnInit().
virtual void load_file (const std::string &filename) override
 Loads the specified file.
virtual void update_menu_state (bool is_dirty) override
 Enables or disables various menu options, as appropriate.
Public Member Functions inherited from KitListBaseApp
 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 bool save ()
 Saves the current Model using the current filename.
virtual bool save (std::string filename)
const std::shared_ptr< Categoryset_category_name (const int32_t id, const std::string &name)
 Updates the name of passed Category.
const std::shared_ptr< Itemset_item_name (const int32_t id, const std::string &name)
 Updates the name of the passed Item.
const std::shared_ptr< Itemset_item_checked (const int32_t id, const bool state)
 Updates the checked state of the passed Item.
virtual const std::shared_ptr< Itemchange_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< Itemget_item (int32_t id) const
 Gets an Item by ID.
const std::shared_ptr< Categoryget_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.

Private Attributes

MyFramemy_frame
 The main frame of the application.

Additional Inherited Members

Public Attributes inherited from KitListBaseApp
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 inherited from KitListBaseApp
static const std::string DEFAULT_FILE_EXTENSION = ".kit"
 The application's default filename extension. .kit.
Protected Member Functions inherited from KitListBaseApp
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.

Detailed Description

Implements a GUI front-end for the application using wxWidgets.

See also
https://wxwidgets.org

Definition at line 45 of file kitlistgui.hpp.

Constructor & Destructor Documentation

◆ KitListGui()

KitListGui::KitListGui ( )
inline

Default constructor.

Definition at line 52 of file kitlistgui.hpp.

Member Function Documentation

◆ category_entry_changed()

void KitListGui::category_entry_changed ( const std::shared_ptr< Category > category)
overridevirtual

Called whenever a Category name changes.

Parameters
categoryThe Category.

Reimplemented from KitListBaseApp.

Definition at line 726 of file kitlistgui.cpp.

◆ item_entry_changed()

void KitListGui::item_entry_changed ( const std::shared_ptr< Item > item)
overridevirtual

Called whenever a Item name changes.

Parameters
itemThe Item.

Reimplemented from KitListBaseApp.

Definition at line 738 of file kitlistgui.cpp.

◆ load_file()

void KitListGui::load_file ( const std::string & filename)
overridevirtual

Loads the specified file.

Loads the Model from the specified filename.

Parameters
filenameThe name of the file to load.
Exceptions
KitParser::parse_exceptionThrown if there is an error parsing the file.
KitListBaseApp::file_not_found

Reimplemented from KitListBaseApp.

Definition at line 744 of file kitlistgui.cpp.

◆ OnCmdLineParsed()

bool KitListGui::OnCmdLineParsed ( wxCmdLineParser & parser)
overridevirtual

Called after the command line has been successfully parsed.

Returns
false to terminate the program, true otherwise.

Definition at line 774 of file kitlistgui.cpp.

◆ OnExit()

int KitListGui::OnExit ( )
overridevirtual

Can be used to cleanup items created during OnInit().

Returns
the value provided by the super class.

Definition at line 851 of file kitlistgui.cpp.

◆ OnInit()

bool KitListGui::OnInit ( )
overridevirtual

Initializes the application's main window.

Returns
false to terminate the application immediately, true otherwise.

Definition at line 816 of file kitlistgui.cpp.

◆ OnInitCmdLine()

void KitListGui::OnInitCmdLine ( wxCmdLineParser & parser)
overridevirtual

Called from OnInit() and initializes the parser with the command line options for the application.

Definition at line 758 of file kitlistgui.cpp.

◆ update_menu_state()

void KitListGui::update_menu_state ( bool is_dirty)
overridevirtual

Enables or disables various menu options, as appropriate.

Reimplemented from KitListBaseApp.

Definition at line 752 of file kitlistgui.cpp.

Member Data Documentation

◆ my_frame

MyFrame* KitListGui::my_frame
private

The main frame of the application.

Definition at line 48 of file kitlistgui.hpp.


The documentation for this class was generated from the following files:
Copyright 2008-2025 Frank Dean