KiCad PCB EDA Suite
|
This class implements a file history object to store a list of files, that can then be added to a menu. More...
#include <file_history.h>
Public Member Functions | |
FILE_HISTORY (size_t aMaxFiles, int aBaseFileId, int aClearId, wxString aClearText=_("Clear Recent Files")) | |
Create a file history object to store a list of files and add them to a menu. | |
void | Load (const APP_SETTINGS_BASE &aSettings) |
Loads history from a JSON settings object. | |
void | Load (const std::vector< wxString > &aList) |
Loads history from a list of strings. | |
void | Save (APP_SETTINGS_BASE &aSettings) |
Saves history into a JSON settings object. | |
void | Save (std::vector< wxString > *aList) |
Saves history into a list of strings. | |
void | AddFileToHistory (const wxString &aFile) override |
Adds a file to the history. | |
void | AddFilesToMenu () override |
Add the files to all registered menus. | |
void | AddFilesToMenu (wxMenu *aMenu) override |
Add the files to the specified menu. | |
void | SetMaxFiles (size_t aMaxFiles) |
Update the number of files that will be contained inside the file history. | |
void | SetClearText (wxString aClearText) |
Set the text displayed on the menu item that clears the entire menu. | |
void | UpdateClearText (wxMenu *aMenu, wxString aClearText) |
Update the text displayed on the menu item that clears the entire menu. | |
void | ClearFileHistory () |
Clear all entries from the file history. | |
Static Public Member Functions | |
static SELECTION_CONDITION | FileHistoryNotEmpty (const FILE_HISTORY &aHistory) |
Create a SELECTION_CONDITION that can be used to enable a menu item when the file history has items in it. | |
Protected Member Functions | |
void | doRemoveClearitem (wxMenu *aMenu) |
Remove the clear menu item and the preceding separator from the given menu. | |
void | doAddClearItem (wxMenu *aMenu) |
Add the clear menu item and the preceding separator to the given menu. | |
Static Private Member Functions | |
static bool | isHistoryNotEmpty (const SELECTION &aSelection, const FILE_HISTORY &aHistory) |
Test if the file history is empty. | |
Private Attributes | |
int | m_clearId |
wxString | m_clearText |
This class implements a file history object to store a list of files, that can then be added to a menu.
This class extends the wxWidgets wxFileHistory class to include KiCad specific items.
Definition at line 42 of file file_history.h.
FILE_HISTORY::FILE_HISTORY | ( | size_t | aMaxFiles, |
int | aBaseFileId, | ||
int | aClearId, | ||
wxString | aClearText = _( "Clear Recent Files" ) |
||
) |
Create a file history object to store a list of files and add them to a menu.
aMaxFiles | is the number of files to store in the history |
aBaseFileId | is the ID to use for the first file menu item |
aClearId | is the ID to use for the clear menu menu item |
aClearText | is the text to use for the menu item that clears the history. |
Definition at line 36 of file file_history.cpp.
|
inlineoverride |
Add the files to all registered menus.
Definition at line 98 of file file_history.h.
Referenced by BITMAP2CMP_FRAME::doReCreateMenuBar(), SCH_EDIT_FRAME::doReCreateMenuBar(), GERBVIEW_FRAME::doReCreateMenuBar(), KICAD_MANAGER_FRAME::doReCreateMenuBar(), PL_EDITOR_FRAME::doReCreateMenuBar(), and PCB_EDIT_FRAME::doReCreateMenuBar().
|
override |
Add the files to the specified menu.
aMenu | is the menu to operate on. |
Definition at line 119 of file file_history.cpp.
References doAddClearItem(), and doRemoveClearitem().
|
override |
Adds a file to the history.
This function overrides the default wxWidgets method to iterate through all menus associated with the file history, remove the added menu items, lets wx add the new files, and then re-adds the clear menu item.
aFile | is the filename of the file to add to the history. |
Definition at line 96 of file file_history.cpp.
References doAddClearItem(), and doRemoveClearitem().
Referenced by Load(), and EDA_BASE_FRAME::UpdateFileHistory().
void FILE_HISTORY::ClearFileHistory | ( | ) |
Clear all entries from the file history.
Definition at line 180 of file file_history.cpp.
Referenced by EDA_BASE_FRAME::ClearFileHistory(), and Load().
|
protected |
Add the clear menu item and the preceding separator to the given menu.
aMenu | is the menu to operate on |
Definition at line 150 of file file_history.cpp.
References _, ID_FILE_LIST_EMPTY, m_clearId, and m_clearText.
Referenced by AddFilesToMenu(), and AddFileToHistory().
|
protected |
Remove the clear menu item and the preceding separator from the given menu.
aMenu | is the menu to operate on |
Definition at line 127 of file file_history.cpp.
References ID_FILE_LIST_EMPTY, and m_clearId.
Referenced by AddFilesToMenu(), and AddFileToHistory().
|
static |
Create a SELECTION_CONDITION that can be used to enable a menu item when the file history has items in it.
aHistory | is the file history to check for items |
Definition at line 187 of file file_history.cpp.
References isHistoryNotEmpty().
Referenced by BITMAP2CMP_FRAME::doReCreateMenuBar(), SCH_EDIT_FRAME::doReCreateMenuBar(), KICAD_MANAGER_FRAME::doReCreateMenuBar(), PL_EDITOR_FRAME::doReCreateMenuBar(), and PCB_EDIT_FRAME::doReCreateMenuBar().
|
staticprivate |
Test if the file history is empty.
This function is designed to be used with a SELECTION_CONDITION to enable/disable the file history menu.
aSelection | is unused |
aHistory | is the file history to test for items |
Definition at line 193 of file file_history.cpp.
Referenced by FileHistoryNotEmpty().
void FILE_HISTORY::Load | ( | const APP_SETTINGS_BASE & | aSettings | ) |
Loads history from a JSON settings object.
aSettings | is the settings object for this application |
Definition at line 45 of file file_history.cpp.
References AddFileToHistory(), ClearFileHistory(), APP_SETTINGS_BASE::SYSTEM::file_history, and APP_SETTINGS_BASE::m_System.
Referenced by EDA_BASE_FRAME::LoadSettings(), and GERBVIEW_FRAME::LoadSettings().
void FILE_HISTORY::Load | ( | const std::vector< wxString > & | aList | ) |
Loads history from a list of strings.
aList | is a list of filenames to load |
Definition at line 58 of file file_history.cpp.
References AddFileToHistory(), and ClearFileHistory().
void FILE_HISTORY::Save | ( | APP_SETTINGS_BASE & | aSettings | ) |
Saves history into a JSON settings object.
aSettings | is the settings object to save into |
Definition at line 67 of file file_history.cpp.
References APP_SETTINGS_BASE::SYSTEM::file_history, and APP_SETTINGS_BASE::m_System.
Referenced by EDA_BASE_FRAME::SaveSettings(), and GERBVIEW_FRAME::SaveSettings().
void FILE_HISTORY::Save | ( | std::vector< wxString > * | aList | ) |
Saves history into a list of strings.
aList | is a pointer to a string vector to clear and fill with the file history |
Definition at line 76 of file file_history.cpp.
|
inline |
Set the text displayed on the menu item that clears the entire menu.
aClearText | is the text to use for the menu item |
Definition at line 123 of file file_history.h.
References m_clearText.
Referenced by GERBVIEW_FRAME::doReCreateMenuBar(), and KICAD_MANAGER_FRAME::doReCreateMenuBar().
void FILE_HISTORY::SetMaxFiles | ( | size_t | aMaxFiles | ) |
Update the number of files that will be contained inside the file history.
aMaxFiles | is the new number of files for the history |
Definition at line 85 of file file_history.cpp.
References MAX_FILE_HISTORY_SIZE.
Referenced by EDA_BASE_FRAME::CommonSettingsChanged(), and GERBVIEW_FRAME::GERBVIEW_FRAME().
void FILE_HISTORY::UpdateClearText | ( | wxMenu * | aMenu, |
wxString | aClearText | ||
) |
Update the text displayed on the menu item that clears the entire menu.
useful after language change.
aMenu | is the menu to operate on. |
aClearText | is the new text to use for the menu item |
Definition at line 168 of file file_history.cpp.
References m_clearId.
Referenced by BITMAP2CMP_FRAME::doReCreateMenuBar(), SCH_EDIT_FRAME::doReCreateMenuBar(), GERBVIEW_FRAME::doReCreateMenuBar(), PL_EDITOR_FRAME::doReCreateMenuBar(), and PCB_EDIT_FRAME::doReCreateMenuBar().
|
private |
Definition at line 176 of file file_history.h.
Referenced by doAddClearItem(), doRemoveClearitem(), and UpdateClearText().
|
private |
Definition at line 177 of file file_history.h.
Referenced by doAddClearItem(), and SetClearText().