Kitlist  1.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
KitListGui Class Reference

Encapsulates the methods for the application's GUI front end. More...

#include <kitlistgui.hpp>

Public Member Functions

 KitListGui (int argc, char **argv, Service &service)
 
 ~KitListGui ()
 
virtual void open_file (const Glib::ustring &filename)
 Opens an existing XML document. More...
 
virtual void raise ()
 Make this application topmost. More...
 
virtual void safe_open_file (const Glib::ustring &filename)
 Opens an existing XML document, checking for unsaved changes. More...
 
void run ()
 Starts the GUI application running. More...
 

Protected Member Functions

virtual void init ()
 
virtual gint get_max_recent_files ()
 
virtual ModelItemContainerget_selected_items ()
 Returns a list of items selected in the item list. More...
 
virtual void add_items (const ModelItemContainer &items)
 Associates the passed list of items with the currently selected category. More...
 
virtual void set_page_title (const Glib::ustring page_title)
 
virtual void close_preferences_window ()
 
virtual void cancel_preferences_window ()
 
virtual void close_add_item_window ()
 
virtual void cancel_add_item_window ()
 
virtual void close_add_category_window ()
 Called when the add/rename category dialog is closed using the 'OK' button. More...
 
virtual void cancel_add_category_window ()
 Called when the add/rename category dialog is closed using the 'Cancel' button. More...
 
virtual long get_selected_category ()
 Returns the ID of the currently selected Category. More...
 
virtual void init_add_item_window ()
 
virtual void delete_selected_items ()
 Deletes the currently selected items. More...
 
virtual ModelItemContainercopy_selected_items_to_clipboard ()
 
virtual bool confirm_lose_changes (const Glib::ustring &message)
 Shows a confirmation message. More...
 
virtual void update_recent_files_menu ()
 Updates the recent files sub menu. More...
 
virtual void update_recent_files (const Glib::ustring &filename)
 
virtual bool on_delete_event (GdkEventAny *event)
 Called when the application is closed by the user. More...
 
virtual void on_menu_quit ()
 Called when the user chooses to quit the application. More...
 
virtual void on_menu_file_new ()
 Creates a new empty model. More...
 
virtual void on_menu_file_open ()
 Allows the user to open an existing XML document. More...
 
virtual void on_menu_save ()
 Saves the current application state. More...
 
virtual void on_menu_save_as ()
 Saves the current application state in a new document. More...
 
void on_printoperation_done (Gtk::PrintOperationResult result, const Glib::RefPtr< Gtk::PrintOperation > &op)
 Called when the printer operation is done. More...
 
void on_printoperation_status_changed (const Glib::RefPtr< Gtk::PrintOperation > &op)
 Called when the print status changes. More...
 
virtual void on_menu_print ()
 Prints the kit list. More...
 
virtual void on_menu_export_to_pdf ()
 
virtual void on_menu_recent_file (const Glib::ustring &filename)
 displays the most recent files menu More...
 
virtual void on_menu_preferences ()
 
virtual void on_menu_add ()
 
virtual void on_menu_delete ()
 Called when the user chooses to delete items. More...
 
virtual void on_menu_cut ()
 
virtual void on_menu_copy ()
 Called when the use chooses the 'copy' menu option. More...
 
virtual void on_menu_paste ()
 Called when the user chooses the 'paste' menu option. More...
 
virtual void on_menu_show_all ()
 Causes all items to be displayed. More...
 
virtual void on_menu_show_checked ()
 Causes only checked items to be displayed. More...
 
virtual void on_menu_show_unchecked ()
 Causes only unchecked items to be displayed. More...
 
virtual void on_menu_select_all ()
 Called when the user chooses the 'select all' menu option. More...
 
virtual void on_menu_check_selected ()
 Marks all selected items as checked. More...
 
virtual void on_menu_uncheck_selected ()
 Marks all selected items as unchecked. More...
 
virtual void on_menu_create_category ()
 Called when the user chooses to create a new category. More...
 
virtual void on_menu_delete_category ()
 Called when the user chooses the delete category menu option. More...
 
virtual void on_menu_rename_category ()
 Called when the user chooses to rename a category. More...
 
virtual void on_menu_help_about ()
 
virtual void on_clipboard_get (Gtk::SelectionData &selection_date, guint)
 
virtual void on_clipboard_clear ()
 This method gets called after a second 'copy' operation. More...
 
virtual void on_clipboard_received (const Gtk::SelectionData &selection_data)
 
virtual void on_category_change ()
 
virtual void on_cell_edit (const Glib::ustring s)
 Callback method called when a cell has been edited in the item list. More...
 
virtual bool choose_filename (Glib::ustring &filename)
 Displays a file chooser dialog for a user to choose a filename. More...
 
virtual bool choose_pdf_filename (Glib::ustring &filename)
 Displays a file chooser dialog for a user to choose a filename for export to PDF. More...
 
virtual void update_paste_status ()
 Enables or disables the paste menu option. More...
 
virtual void paste_status_received (const Glib::StringArrayHandle &targets_array)
 
virtual void paste_from_xml (const Glib::ustring &document)
 
virtual void refresh_item_list ()
 
virtual void refresh_category_list (long cat_id=-2)
 Refreshes the category combo box list. More...
 
virtual void selected_row_callback (const Gtk::TreeModel::iterator &iter)
 
virtual void set_selected (bool checked)
 
virtual void toggle_selected ()
 
void on_row_changed (const Gtk::TreeModel::Path path, const Gtk::TreeModel::iterator iter)
 Callback method called when an item has been modified in the item list. More...
 
virtual void update_item_count (size_t n)
 

Protected Attributes

Glib::ustring m_filename
 The filename currently associated with the loaded model. More...
 
Glib::ustring m_page_title
 The page title to be used when printing the item list. More...
 
Glib::ustring m_clipboard_items
 Holder for items pasted to the clipboard. More...
 
bool m_ignore_list_events
 Temporarily ignore events on the item list. More...
 
Gtk::Main m_kit
 The main application. More...
 
Gtk::Window * m_window
 The main application window. More...
 
Gtk::Window * m_window_preferences
 The 'Preferences' dialog. More...
 
Gtk::Entry * m_entry_page_title
 the text entry field for the page title More...
 
Gtk::Window * m_window_add_item
 The 'Add Item' dialog. More...
 
Gtk::Window * m_window_add_category
 The 'Add Category' dialog. More...
 
Gtk::Entry * m_entry_add_item
 The text entry field of the 'Add Item' dialog. More...
 
Gtk::Entry * m_entry_add_category
 The text entry field of the 'Add Category' dialog. More...
 
Gtk::ImageMenuItem * m_file_save_menu_item
 The file save menu item. More...
 
Gtk::ToolButton * m_file_save_tool_button
 The file save toolbar button. More...
 
Gtk::MenuItem * m_recent_files_menu_item
 The recent files menu item. More...
 
Gtk::ImageMenuItem * m_paste_menu_item
 The menu paste button. More...
 
Gtk::ToolButton * m_paste_tool_button
 The toolbar paste button. More...
 
Gtk::CheckButton * m_checkbutton_add_item
 The check button field of the 'Add Item' dialog. More...
 
Gtk::ComboBox * m_category_combo
 The combo box holding a list of categories. More...
 
Glib::RefPtr< Gtk::ListStore > m_ref_category_list_store
 The model backing the category combo box. More...
 
ModelCategoryColumns m_category_cols
 The definition of the category combo box columns. More...
 
Gtk::TreeView * m_item_tree_view
 The item list view definition. More...
 
ModelItemColumns m_item_cols
 The definition of the item list's columns. More...
 
Servicem_service
 The business/service object. More...
 
Glib::RefPtr< Gtk::ListStore > m_ref_item_tree_model
 The model backing the item list. More...
 
Gtk::Statusbar * m_status_bar
 The application status bar. More...
 
Glib::RefPtr< Gtk::PageSetup > m_ref_page_setup
 Printer page setup settings. More...
 
Glib::RefPtr< Gtk::PrintSettings > m_ref_printer_settings
 Printer settings. More...
 
enum gui_state m_state
 Indicates whether a category is being created or renamed. More...
 
long m_current_cat_id
 temporary reference to a category id, usually being renamed More...
 

Private Attributes

YamlConfig m_yaml_config
 

Detailed Description

Encapsulates the methods for the application's GUI front end.

This is the GTK+ implementation.

Definition at line 99 of file kitlistgui.hpp.

Constructor & Destructor Documentation

◆ KitListGui()

KitListGui::KitListGui ( int  argc,
char **  argv,
Service service 
)

Constructor to create the GUI application.

Parameters
argccommand line argument count passed to Gtk::Main
argvcommand line arguments passed to Gtk::Main
servicea reference to the Service object, providing all business/service methods.

Definition at line 193 of file kitlistgui.cpp.

References init(), m_ref_page_setup, and m_ref_printer_settings.

◆ ~KitListGui()

KitListGui::~KitListGui ( )

Definition at line 221 of file kitlistgui.cpp.

Member Function Documentation

◆ add_items()

void KitListGui::add_items ( const ModelItemContainer items)
protectedvirtual

Associates the passed list of items with the currently selected category.

Where items already exist in the Category, then are not duplicated, just silently ignored.

Definition at line 1172 of file kitlistgui.cpp.

References Service::copy_items(), get_selected_category(), m_service, and refresh_item_list().

Referenced by paste_from_xml().

◆ cancel_add_category_window()

void KitListGui::cancel_add_category_window ( )
protectedvirtual

Called when the add/rename category dialog is closed using the 'Cancel' button.

Definition at line 1022 of file kitlistgui.cpp.

References m_window_add_category.

Referenced by init().

◆ cancel_add_item_window()

void KitListGui::cancel_add_item_window ( )
protectedvirtual

Called when the user closes the 'Add Item' dialog using the 'Cancel' button.

Definition at line 1746 of file kitlistgui.cpp.

References m_window_add_item.

Referenced by init().

◆ cancel_preferences_window()

void KitListGui::cancel_preferences_window ( )
protectedvirtual

Definition at line 1674 of file kitlistgui.cpp.

References m_window_preferences.

Referenced by init().

◆ choose_filename()

bool KitListGui::choose_filename ( Glib::ustring &  filename)
protectedvirtual

Displays a file chooser dialog for a user to choose a filename.

If the file already exists, the user is asked to confirm whether to overwrite.

Parameters
filenameA reference to a string to populate with the chosen filename.
Returns
true if the user selects OK, false otherwise.

Definition at line 1276 of file kitlistgui.cpp.

References anonymous_namespace{kitlistgui.cpp}::DEFAULT_FILENAME_EXTENSION, file_exists(), and m_window.

Referenced by on_menu_save_as().

◆ choose_pdf_filename()

bool KitListGui::choose_pdf_filename ( Glib::ustring &  filename)
protectedvirtual

Displays a file chooser dialog for a user to choose a filename for export to PDF.

If the file already exists, the user is asked to confirm whether to overwrite.

Parameters
filenameA reference to a string to populate with the chosen filename.
Returns
true if the user selects OK, false otherwise.

Definition at line 1374 of file kitlistgui.cpp.

References file_exists(), m_window, and anonymous_namespace{kitlistgui.cpp}::PDF_FILENAME_EXTENSION.

Referenced by on_menu_export_to_pdf().

◆ close_add_category_window()

void KitListGui::close_add_category_window ( )
protectedvirtual

Called when the add/rename category dialog is closed using the 'OK' button.

The same dialog is used for both creating a new category and renaming an existing one. m_state is used to indicate which operation is relevant (create or rename) and m_current_cat_id is used to indicate the category being renamed for the rename operation.

Definition at line 997 of file kitlistgui.cpp.

References ADD_CATEGORY, Service::create_category(), Service::find_category(), Category::get_id(), m_current_cat_id, m_entry_add_category, m_service, m_state, m_window_add_category, refresh_category_list(), refresh_item_list(), Service::set_model_dirty(), and Category::set_name().

Referenced by init().

◆ close_add_item_window()

void KitListGui::close_add_item_window ( )
protectedvirtual

Called when the user closes the 'Add Item' dialog using the 'OK' button.

Definition at line 1726 of file kitlistgui.cpp.

References Service::create_item(), get_selected_category(), m_checkbutton_add_item, m_entry_add_item, m_service, m_window_add_item, refresh_item_list(), Item::set_checked(), and Item::set_description().

Referenced by init().

◆ close_preferences_window()

void KitListGui::close_preferences_window ( )
protectedvirtual

Called when the user closes the 'Preferences' dialog using the 'OK' button.

Definition at line 1668 of file kitlistgui.cpp.

References m_entry_page_title, m_window_preferences, and set_page_title().

Referenced by init().

◆ confirm_lose_changes()

bool KitListGui::confirm_lose_changes ( const Glib::ustring &  message)
protectedvirtual

◆ copy_selected_items_to_clipboard()

ModelItemContainer * KitListGui::copy_selected_items_to_clipboard ( )
protectedvirtual

◆ delete_selected_items()

void KitListGui::delete_selected_items ( )
protectedvirtual

Deletes the currently selected items.

The items are flagged as deleted. When save is called, they will no longer be persisted, i.e. they will be permanently deleted.

Definition at line 823 of file kitlistgui.cpp.

References Service::delete_item(), ModelItemColumns::m_col_num, m_item_cols, m_item_tree_view, m_ref_item_tree_model, m_service, refresh_item_list(), and selected_row_callback().

Referenced by on_menu_delete().

◆ get_max_recent_files()

gint KitListGui::get_max_recent_files ( )
protectedvirtual

Definition at line 240 of file kitlistgui.cpp.

References DEFAULT_MAX_RECENT_FILES.

Referenced by update_recent_files().

◆ get_selected_category()

long KitListGui::get_selected_category ( )
protectedvirtual

Returns the ID of the currently selected Category.

Returns -1 if no Category is currently selected, or the 'all items' option is selected.

Definition at line 1709 of file kitlistgui.cpp.

References m_category_cols, m_category_combo, and ModelCategoryColumns::m_col_num.

Referenced by add_items(), close_add_item_window(), on_menu_cut(), on_menu_delete_category(), on_menu_export_to_pdf(), on_menu_print(), on_menu_rename_category(), refresh_category_list(), and refresh_item_list().

◆ get_selected_items()

ModelItemContainer * KitListGui::get_selected_items ( )
protectedvirtual

Returns a list of items selected in the item list.

Definition at line 777 of file kitlistgui.cpp.

References Service::find_item(), ModelItemColumns::m_col_num, m_item_cols, m_item_tree_view, m_ref_item_tree_model, and m_service.

Referenced by copy_selected_items_to_clipboard(), set_selected(), and toggle_selected().

◆ init()

void KitListGui::init ( )
protectedvirtual

Initialises all the GUI components prior to the GUI application being run.

Definition at line 1770 of file kitlistgui.cpp.

References cancel_add_category_window(), cancel_add_item_window(), cancel_preferences_window(), close_add_category_window(), close_add_item_window(), close_preferences_window(), anonymous_namespace{kitlistgui.cpp}::DEFAULT_FILENAME, DEFAULT_PAGE_TITLE, file_exists(), anonymous_namespace{kitlistgui.cpp}::GCONF_KEY, anonymous_namespace{kitlistgui.cpp}::GCONF_KEY_CURRENT_FILENAME, anonymous_namespace{kitlistgui.cpp}::GCONF_KEY_PAGE_TITLE, YamlConfig::get_current_filename(), YamlConfig::get_debug_log_filename(), get_glade_ref_ptr(), Service::get_items(), YamlConfig::get_page_title(), anonymous_namespace{kitlistgui.cpp}::GLADE_APP_FILE, m_category_cols, m_category_combo, m_checkbutton_add_item, ModelItemColumns::m_col_checked, ModelItemColumns::m_col_num, ModelItemColumns::m_col_text, m_entry_add_category, m_entry_add_item, m_entry_page_title, m_file_save_menu_item, m_file_save_tool_button, m_filename, m_ignore_list_events, m_item_cols, m_item_tree_view, m_page_title, m_paste_menu_item, m_paste_tool_button, m_recent_files_menu_item, m_ref_category_list_store, m_ref_item_tree_model, m_service, m_status_bar, m_window, m_window_add_category, m_window_add_item, m_window_preferences, m_yaml_config, on_category_change(), on_delete_event(), on_menu_add(), on_menu_check_selected(), on_menu_copy(), on_menu_create_category(), on_menu_cut(), on_menu_delete(), on_menu_delete_category(), on_menu_export_to_pdf(), on_menu_file_new(), on_menu_file_open(), on_menu_help_about(), on_menu_paste(), on_menu_preferences(), on_menu_print(), on_menu_quit(), on_menu_rename_category(), on_menu_save(), on_menu_save_as(), on_menu_select_all(), on_menu_show_all(), on_menu_show_checked(), on_menu_show_unchecked(), on_menu_uncheck_selected(), on_row_changed(), Service::open_as_xml(), refresh_category_list(), refresh_item_list(), Service::require_filename(), Service::set_model_dirty(), toggle_selected(), update_item_count(), and update_recent_files_menu().

Referenced by KitListGui().

◆ init_add_item_window()

void KitListGui::init_add_item_window ( )
protectedvirtual

Initialises the 'Add Item' dialog prior to it being displayed.

Definition at line 1696 of file kitlistgui.cpp.

References m_entry_add_item.

Referenced by on_menu_add().

◆ on_category_change()

void KitListGui::on_category_change ( )
protectedvirtual

Called after the user has changed the currently selected Category.

Definition at line 1754 of file kitlistgui.cpp.

References m_ignore_list_events, and refresh_item_list().

Referenced by init().

◆ on_cell_edit()

void KitListGui::on_cell_edit ( const Glib::ustring  s)
protectedvirtual

Callback method called when a cell has been edited in the item list.

Flags the model as dirty.

Definition at line 1259 of file kitlistgui.cpp.

References m_ignore_list_events, m_service, and Service::set_model_dirty().

◆ on_clipboard_clear()

void KitListGui::on_clipboard_clear ( )
protectedvirtual

This method gets called after a second 'copy' operation.

i.e. if we have previously called Clipboard::set() and then called it a second time. However, I think this is intended to only clean up data objects that may have been allocated by a previous call to on_clipboard_get() where we might have created an expensive object based on a list of IDs or something. This gives us the opportunity to release the big object.

However, in the way we're using the clipboard, we're holding the expensive object (in this case an XML document). We should probably be holding the list of selected ID's and only creating the XML document when the clipboard contents are requested.

As things are, we don't want to clear the XML document... m_clipboard_items.clear();

Definition at line 1161 of file kitlistgui.cpp.

Referenced by copy_selected_items_to_clipboard().

◆ on_clipboard_get()

void KitListGui::on_clipboard_get ( Gtk::SelectionData &  selection_data,
guint   
)
protectedvirtual

Called when the current clipboard contents are required.

Definition at line 1130 of file kitlistgui.cpp.

References anonymous_namespace{kitlistgui.cpp}::item_target_custom, anonymous_namespace{kitlistgui.cpp}::item_target_text, and m_clipboard_items.

Referenced by copy_selected_items_to_clipboard().

◆ on_clipboard_received()

void KitListGui::on_clipboard_received ( const Gtk::SelectionData &  selection_data)
protectedvirtual

Callback notification method for capturing clipboard contents.

Definition at line 1220 of file kitlistgui.cpp.

References anonymous_namespace{kitlistgui.cpp}::item_target_custom, anonymous_namespace{kitlistgui.cpp}::item_target_text, and m_clipboard_items.

Referenced by on_menu_paste().

◆ on_delete_event()

bool KitListGui::on_delete_event ( GdkEventAny *  event)
protectedvirtual

Called when the application is closed by the user.

Definition at line 356 of file kitlistgui.cpp.

References confirm_lose_changes(), Service::is_model_dirty(), m_service, and Service::set_model_dirty().

Referenced by init().

◆ on_menu_add()

void KitListGui::on_menu_add ( )
protectedvirtual

Called when the users chooses to create a new Item.

Definition at line 1682 of file kitlistgui.cpp.

References init_add_item_window(), m_entry_add_item, and m_window_add_item.

Referenced by init().

◆ on_menu_check_selected()

virtual void KitListGui::on_menu_check_selected ( )
inlineprotectedvirtual

Marks all selected items as checked.

Definition at line 225 of file kitlistgui.hpp.

Referenced by init().

◆ on_menu_copy()

void KitListGui::on_menu_copy ( )
protectedvirtual

Called when the use chooses the 'copy' menu option.

Definition at line 937 of file kitlistgui.cpp.

References copy_selected_items_to_clipboard().

Referenced by init().

◆ on_menu_create_category()

void KitListGui::on_menu_create_category ( )
protectedvirtual

Called when the user chooses to create a new category.

Definition at line 971 of file kitlistgui.cpp.

References ADD_CATEGORY, m_current_cat_id, m_entry_add_category, m_state, and m_window_add_category.

Referenced by init().

◆ on_menu_cut()

void KitListGui::on_menu_cut ( )
protectedvirtual

◆ on_menu_delete()

void KitListGui::on_menu_delete ( )
protectedvirtual

Called when the user chooses to delete items.

The user is prompted to confirm deletion, prior to the items being flagged as deleted in the model. Once the model is saved, the will be permanently deleted from the persistence store.

Definition at line 855 of file kitlistgui.cpp.

References delete_selected_items(), and m_window.

Referenced by init().

◆ on_menu_delete_category()

void KitListGui::on_menu_delete_category ( )
protectedvirtual

Called when the user chooses the delete category menu option.

Displays a confirmation box before deleting the currently selected category.

Definition at line 1033 of file kitlistgui.cpp.

References Service::delete_category(), get_selected_category(), m_service, m_status_bar, m_window, refresh_category_list(), refresh_item_list(), and anonymous_namespace{kitlistgui.cpp}::SB_MSG.

Referenced by init().

◆ on_menu_export_to_pdf()

void KitListGui::on_menu_export_to_pdf ( )
protectedvirtual

◆ on_menu_file_new()

void KitListGui::on_menu_file_new ( )
protectedvirtual

◆ on_menu_file_open()

void KitListGui::on_menu_file_open ( )
protectedvirtual

Allows the user to open an existing XML document.

If there are unsaved changes, the user is first prompted to discard them or cancel the operation.

Definition at line 432 of file kitlistgui.cpp.

References confirm_lose_changes(), anonymous_namespace{kitlistgui.cpp}::DEFAULT_FILENAME_EXTENSION, Service::is_model_dirty(), m_service, m_status_bar, m_window, open_file(), and anonymous_namespace{kitlistgui.cpp}::SB_SAVE.

Referenced by init().

◆ on_menu_help_about()

void KitListGui::on_menu_help_about ( )
protectedvirtual

Shows the help about dialog

Definition at line 1093 of file kitlistgui.cpp.

Referenced by init().

◆ on_menu_paste()

void KitListGui::on_menu_paste ( )
protectedvirtual

Called when the user chooses the 'paste' menu option.

Definition at line 946 of file kitlistgui.cpp.

References anonymous_namespace{kitlistgui.cpp}::item_target_text, m_clipboard_items, on_clipboard_received(), paste_from_xml(), and update_paste_status().

Referenced by init().

◆ on_menu_preferences()

void KitListGui::on_menu_preferences ( )
protectedvirtual

Called when the user chooses the preferences option from the menu.

Definition at line 1633 of file kitlistgui.cpp.

References m_entry_page_title, m_page_title, and m_window_preferences.

Referenced by init().

◆ on_menu_print()

void KitListGui::on_menu_print ( )
protectedvirtual

◆ on_menu_quit()

void KitListGui::on_menu_quit ( )
protectedvirtual

Called when the user chooses to quit the application.

Definition at line 370 of file kitlistgui.cpp.

References confirm_lose_changes(), Service::is_model_dirty(), m_service, m_window, and Service::set_model_dirty().

Referenced by init().

◆ on_menu_recent_file()

void KitListGui::on_menu_recent_file ( const Glib::ustring &  filename)
protectedvirtual

◆ on_menu_rename_category()

void KitListGui::on_menu_rename_category ( )
protectedvirtual

◆ on_menu_save()

void KitListGui::on_menu_save ( )
protectedvirtual

◆ on_menu_save_as()

void KitListGui::on_menu_save_as ( )
protectedvirtual

◆ on_menu_select_all()

void KitListGui::on_menu_select_all ( )
protectedvirtual

Called when the user chooses the 'select all' menu option.

Definition at line 960 of file kitlistgui.cpp.

References m_item_tree_view.

Referenced by init().

◆ on_menu_show_all()

virtual void KitListGui::on_menu_show_all ( )
inlineprotectedvirtual

Causes all items to be displayed.

Definition at line 218 of file kitlistgui.hpp.

References Service::show_all().

Referenced by init().

◆ on_menu_show_checked()

virtual void KitListGui::on_menu_show_checked ( )
inlineprotectedvirtual

Causes only checked items to be displayed.

Definition at line 220 of file kitlistgui.hpp.

References Service::show_checked_only().

Referenced by init().

◆ on_menu_show_unchecked()

virtual void KitListGui::on_menu_show_unchecked ( )
inlineprotectedvirtual

Causes only unchecked items to be displayed.

Definition at line 222 of file kitlistgui.hpp.

References Service::show_unchecked_only().

Referenced by init().

◆ on_menu_uncheck_selected()

virtual void KitListGui::on_menu_uncheck_selected ( )
inlineprotectedvirtual

Marks all selected items as unchecked.

Definition at line 227 of file kitlistgui.hpp.

Referenced by init().

◆ on_printoperation_done()

void KitListGui::on_printoperation_done ( Gtk::PrintOperationResult  result,
const Glib::RefPtr< Gtk::PrintOperation > &  op 
)
protected

Called when the printer operation is done.

Definition at line 648 of file kitlistgui.cpp.

References m_ref_printer_settings, m_window, and on_printoperation_status_changed().

Referenced by on_menu_print().

◆ on_printoperation_status_changed()

void KitListGui::on_printoperation_status_changed ( const Glib::RefPtr< Gtk::PrintOperation > &  op)
protected

Called when the print status changes.

Definition at line 633 of file kitlistgui.cpp.

References m_status_bar, and anonymous_namespace{kitlistgui.cpp}::SB_PRINT.

Referenced by on_printoperation_done().

◆ on_row_changed()

void KitListGui::on_row_changed ( const Gtk::TreeModel::Path  path,
const Gtk::TreeModel::iterator  iter 
)
protected

Callback method called when an item has been modified in the item list.

Sets the model as dirty and copies the row details to the appropriate Item in the model. The item's state is also set to dirty.

Definition at line 1497 of file kitlistgui.cpp.

References ModelItemColumns::m_col_checked, ModelItemColumns::m_col_num, ModelItemColumns::m_col_text, m_ignore_list_events, m_item_cols, m_service, Service::set_model_dirty(), and Service::update_item().

Referenced by init().

◆ open_file()

void KitListGui::open_file ( const Glib::ustring &  filename)
virtual

◆ paste_from_xml()

void KitListGui::paste_from_xml ( const Glib::ustring &  document)
protectedvirtual

Performs a paste of items from the clipboard.

Definition at line 1184 of file kitlistgui.cpp.

References add_items(), Service::find_item(), m_service, and anonymous_namespace{kitlistgui.cpp}::XML_ELEMENT_ID.

Referenced by on_menu_paste().

◆ paste_status_received()

void KitListGui::paste_status_received ( const Glib::StringArrayHandle &  targets_array)
protectedvirtual

Callback method for enabling or disabling the paste menu option based on the clipboard contents.

See also
KitListGui::update_paste_status()

Definition at line 1470 of file kitlistgui.cpp.

References anonymous_namespace{kitlistgui.cpp}::item_target_custom, anonymous_namespace{kitlistgui.cpp}::item_target_text, m_paste_menu_item, and m_paste_tool_button.

Referenced by update_paste_status().

◆ raise()

void KitListGui::raise ( )
virtual

Make this application topmost.

Definition at line 1762 of file kitlistgui.cpp.

References m_window.

◆ refresh_category_list()

void KitListGui::refresh_category_list ( long  cat_id = -2)
protectedvirtual

Refreshes the category combo box list.

Parameters
cat_idthe id of the category to select in the combo box. If set to -2 the currently selected category is used, otherwise the specified category ID is used. If the category ID does not exist, or if -1 is specified, then no category is selected.

Definition at line 1582 of file kitlistgui.cpp.

References Service::get_categories(), Category::get_id(), Category::get_name(), get_selected_category(), GuiState::is_deleted(), m_category_cols, m_category_combo, ModelCategoryColumns::m_col_num, ModelCategoryColumns::m_col_text, m_ignore_list_events, m_ref_category_list_store, and m_service.

Referenced by close_add_category_window(), init(), on_menu_delete_category(), on_menu_file_new(), on_menu_recent_file(), and open_file().

◆ refresh_item_list()

void KitListGui::refresh_item_list ( )
protectedvirtual

◆ run()

void KitListGui::run ( )

Starts the GUI application running.

Definition at line 232 of file kitlistgui.cpp.

References Service::is_model_dirty(), m_kit, m_service, and m_window.

◆ safe_open_file()

void KitListGui::safe_open_file ( const Glib::ustring &  filename)
virtual

Opens an existing XML document, checking for unsaved changes.

If there are unsaved changes, the user is first prompted to discard them or cancel the operation.

Definition at line 514 of file kitlistgui.cpp.

References confirm_lose_changes(), Service::is_model_dirty(), m_service, m_status_bar, open_file(), and anonymous_namespace{kitlistgui.cpp}::SB_SAVE.

◆ selected_row_callback()

void KitListGui::selected_row_callback ( const Gtk::TreeModel::iterator &  iter)
protectedvirtual

Called to delete an Item referenced by a row iterator.

Definition at line 1513 of file kitlistgui.cpp.

References Service::delete_item(), ModelItemColumns::m_col_num, m_item_cols, and m_service.

Referenced by delete_selected_items().

◆ set_page_title()

void KitListGui::set_page_title ( const Glib::ustring  page_title)
protectedvirtual

◆ set_selected()

void KitListGui::set_selected ( bool  checked)
protectedvirtual

Checks or unchecks the currently selected items.

Definition at line 1108 of file kitlistgui.cpp.

References get_selected_items(), m_service, refresh_item_list(), and Service::select_items().

◆ toggle_selected()

void KitListGui::toggle_selected ( )
protectedvirtual

Toggles the checked state of the currently selected items.

Definition at line 1119 of file kitlistgui.cpp.

References get_selected_items(), m_service, refresh_item_list(), and Service::toggle_selected_items().

Referenced by init().

◆ update_item_count()

void KitListGui::update_item_count ( size_t  n)
protectedvirtual

Writes the count of currently displayed items to the status bar.

Definition at line 1234 of file kitlistgui.cpp.

References m_status_bar, and anonymous_namespace{kitlistgui.cpp}::SB_ITEM_COUNT.

Referenced by init(), and refresh_item_list().

◆ update_paste_status()

void KitListGui::update_paste_status ( )
protectedvirtual

Enables or disables the paste menu option.

Definition at line 1458 of file kitlistgui.cpp.

References paste_status_received().

Referenced by copy_selected_items_to_clipboard(), and on_menu_paste().

◆ update_recent_files()

void KitListGui::update_recent_files ( const Glib::ustring &  filename)
protectedvirtual

Updates the list of most recently used files.

Parameters
filenameThe filename to append to the list if it does not already exist.

Definition at line 324 of file kitlistgui.cpp.

References YamlConfig::add_recent_filename(), anonymous_namespace{kitlistgui.cpp}::GCONF_KEY_RECENT_FILES, get_max_recent_files(), m_yaml_config, and update_recent_files_menu().

Referenced by on_menu_recent_file(), on_menu_save(), on_menu_save_as(), and open_file().

◆ update_recent_files_menu()

void KitListGui::update_recent_files_menu ( )
protectedvirtual

Member Data Documentation

◆ m_category_cols

ModelCategoryColumns KitListGui::m_category_cols
protected

The definition of the category combo box columns.

Definition at line 158 of file kitlistgui.hpp.

Referenced by get_selected_category(), init(), and refresh_category_list().

◆ m_category_combo

Gtk::ComboBox* KitListGui::m_category_combo
protected

The combo box holding a list of categories.

Definition at line 154 of file kitlistgui.hpp.

Referenced by get_selected_category(), init(), and refresh_category_list().

◆ m_checkbutton_add_item

Gtk::CheckButton* KitListGui::m_checkbutton_add_item
protected

The check button field of the 'Add Item' dialog.

Definition at line 152 of file kitlistgui.hpp.

Referenced by close_add_item_window(), and init().

◆ m_clipboard_items

Glib::ustring KitListGui::m_clipboard_items
protected

Holder for items pasted to the clipboard.

Definition at line 122 of file kitlistgui.hpp.

Referenced by copy_selected_items_to_clipboard(), on_clipboard_get(), on_clipboard_received(), and on_menu_paste().

◆ m_current_cat_id

long KitListGui::m_current_cat_id
protected

temporary reference to a category id, usually being renamed

Definition at line 181 of file kitlistgui.hpp.

Referenced by close_add_category_window(), on_menu_create_category(), and on_menu_rename_category().

◆ m_entry_add_category

Gtk::Entry* KitListGui::m_entry_add_category
protected

The text entry field of the 'Add Category' dialog.

Definition at line 140 of file kitlistgui.hpp.

Referenced by close_add_category_window(), init(), on_menu_create_category(), and on_menu_rename_category().

◆ m_entry_add_item

Gtk::Entry* KitListGui::m_entry_add_item
protected

The text entry field of the 'Add Item' dialog.

Definition at line 138 of file kitlistgui.hpp.

Referenced by close_add_item_window(), init(), init_add_item_window(), and on_menu_add().

◆ m_entry_page_title

Gtk::Entry* KitListGui::m_entry_page_title
protected

the text entry field for the page title

Definition at line 132 of file kitlistgui.hpp.

Referenced by close_preferences_window(), init(), and on_menu_preferences().

◆ m_file_save_menu_item

Gtk::ImageMenuItem* KitListGui::m_file_save_menu_item
protected

The file save menu item.

Definition at line 142 of file kitlistgui.hpp.

Referenced by init().

◆ m_file_save_tool_button

Gtk::ToolButton* KitListGui::m_file_save_tool_button
protected

The file save toolbar button.

Definition at line 144 of file kitlistgui.hpp.

Referenced by init().

◆ m_filename

Glib::ustring KitListGui::m_filename
protected

The filename currently associated with the loaded model.

Should be an empty string if not related to a file.

Definition at line 114 of file kitlistgui.hpp.

Referenced by confirm_lose_changes(), init(), on_menu_file_new(), on_menu_recent_file(), on_menu_save(), on_menu_save_as(), and open_file().

◆ m_ignore_list_events

bool KitListGui::m_ignore_list_events
protected

Temporarily ignore events on the item list.

Definition at line 124 of file kitlistgui.hpp.

Referenced by init(), on_category_change(), on_cell_edit(), on_row_changed(), refresh_category_list(), and refresh_item_list().

◆ m_item_cols

ModelItemColumns KitListGui::m_item_cols
protected

The definition of the item list's columns.

Definition at line 162 of file kitlistgui.hpp.

Referenced by delete_selected_items(), get_selected_items(), init(), on_row_changed(), refresh_item_list(), and selected_row_callback().

◆ m_item_tree_view

Gtk::TreeView* KitListGui::m_item_tree_view
protected

The item list view definition.

Definition at line 160 of file kitlistgui.hpp.

Referenced by delete_selected_items(), get_selected_items(), init(), and on_menu_select_all().

◆ m_kit

Gtk::Main KitListGui::m_kit
protected

The main application.

Definition at line 126 of file kitlistgui.hpp.

Referenced by run().

◆ m_page_title

Glib::ustring KitListGui::m_page_title
protected

The page title to be used when printing the item list.

Definition at line 116 of file kitlistgui.hpp.

Referenced by init(), on_menu_export_to_pdf(), on_menu_preferences(), on_menu_print(), and set_page_title().

◆ m_paste_menu_item

Gtk::ImageMenuItem* KitListGui::m_paste_menu_item
protected

The menu paste button.

Definition at line 148 of file kitlistgui.hpp.

Referenced by init(), and paste_status_received().

◆ m_paste_tool_button

Gtk::ToolButton* KitListGui::m_paste_tool_button
protected

The toolbar paste button.

Definition at line 150 of file kitlistgui.hpp.

Referenced by init(), and paste_status_received().

◆ m_recent_files_menu_item

Gtk::MenuItem* KitListGui::m_recent_files_menu_item
protected

The recent files menu item.

Definition at line 146 of file kitlistgui.hpp.

Referenced by init(), and update_recent_files_menu().

◆ m_ref_category_list_store

Glib::RefPtr<Gtk::ListStore> KitListGui::m_ref_category_list_store
protected

The model backing the category combo box.

Definition at line 156 of file kitlistgui.hpp.

Referenced by init(), and refresh_category_list().

◆ m_ref_item_tree_model

Glib::RefPtr<Gtk::ListStore> KitListGui::m_ref_item_tree_model
protected

The model backing the item list.

Definition at line 166 of file kitlistgui.hpp.

Referenced by delete_selected_items(), get_selected_items(), init(), and refresh_item_list().

◆ m_ref_page_setup

Glib::RefPtr<Gtk::PageSetup> KitListGui::m_ref_page_setup
protected

Printer page setup settings.

Definition at line 170 of file kitlistgui.hpp.

Referenced by KitListGui(), on_menu_export_to_pdf(), and on_menu_print().

◆ m_ref_printer_settings

Glib::RefPtr<Gtk::PrintSettings> KitListGui::m_ref_printer_settings
protected

Printer settings.

Definition at line 172 of file kitlistgui.hpp.

Referenced by KitListGui(), on_menu_export_to_pdf(), on_menu_print(), and on_printoperation_done().

◆ m_service

Service& KitListGui::m_service
protected

◆ m_state

enum gui_state KitListGui::m_state
protected

Indicates whether a category is being created or renamed.

Only used whilst the 'Add/Rename dialog is being displayed', or when it has been closed to determine the correct action.

Definition at line 180 of file kitlistgui.hpp.

Referenced by close_add_category_window(), on_menu_create_category(), and on_menu_rename_category().

◆ m_status_bar

Gtk::Statusbar* KitListGui::m_status_bar
protected

◆ m_window

Gtk::Window* KitListGui::m_window
protected

◆ m_window_add_category

Gtk::Window* KitListGui::m_window_add_category
protected

◆ m_window_add_item

Gtk::Window* KitListGui::m_window_add_item
protected

The 'Add Item' dialog.

Definition at line 134 of file kitlistgui.hpp.

Referenced by cancel_add_item_window(), close_add_item_window(), init(), and on_menu_add().

◆ m_window_preferences

Gtk::Window* KitListGui::m_window_preferences
protected

The 'Preferences' dialog.

Definition at line 130 of file kitlistgui.hpp.

Referenced by cancel_preferences_window(), close_preferences_window(), init(), and on_menu_preferences().

◆ m_yaml_config

YamlConfig KitListGui::m_yaml_config
private

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

Copyright 2008-2021 Frank Dean