OGS
|
The RecentFiles class provides functionality to store information about recently used files (e.g. loaded or saved files). Example Usage:
with:
Definition at line 38 of file RecentFiles.h.
#include <RecentFiles.h>
Public Slots | |
void | setCurrentFile (const QString &filename) |
Should be called from the application when a file was used. | |
Public Member Functions | |
RecentFiles (QObject *parent, const char *slot, QString settingsName) | |
~RecentFiles () override | |
QMenu * | menu () |
Returns the created menu. Add this menu to your QMainWindow menu. | |
Private Types | |
enum | { _maxFiles = 5 } |
Private Member Functions | |
void | updateRecentFileActions () |
Updates the recent files list and writes it to the settings. | |
QString | strippedName (const QString &fullFileName) |
Returns the filename from a full file path. | |
Private Attributes | |
QMenu * | _filesMenu |
QString | _currentFile |
QString | _settingsName |
QAction * | _fileActions [_maxFiles] |
|
private |
RecentFiles::RecentFiles | ( | QObject * | parent, |
const char * | slot, | ||
QString | settingsName ) |
Constructor. Example Usage:
parent | The parent object. Normally the QMainWindow instance |
slot | A slot on parent which is called when a recent file is clicked. Use this with Qts SLOT() macro! |
settingsName | The setting key |
Definition at line 22 of file RecentFiles.cpp.
References _fileActions, _filesMenu, and updateRecentFileActions().
|
override |
QMenu * RecentFiles::menu | ( | ) |
Returns the created menu. Add this menu to your QMainWindow menu.
Definition at line 42 of file RecentFiles.cpp.
References _filesMenu.
Referenced by MainWindow::MainWindow().
|
slot |
Should be called from the application when a file was used.
Definition at line 46 of file RecentFiles.cpp.
References _currentFile, _maxFiles, _settingsName, and updateRecentFileActions().
|
private |
Returns the filename from a full file path.
Definition at line 84 of file RecentFiles.cpp.
Referenced by updateRecentFileActions().
|
private |
Updates the recent files list and writes it to the settings.
Definition at line 63 of file RecentFiles.cpp.
References _fileActions, _maxFiles, _settingsName, and strippedName().
Referenced by RecentFiles(), and setCurrentFile().
|
private |
Definition at line 69 of file RecentFiles.h.
Referenced by setCurrentFile().
|
private |
Definition at line 72 of file RecentFiles.h.
Referenced by RecentFiles(), and updateRecentFileActions().
|
private |
Definition at line 68 of file RecentFiles.h.
Referenced by RecentFiles(), ~RecentFiles(), and menu().
|
private |
Definition at line 70 of file RecentFiles.h.
Referenced by setCurrentFile(), and updateRecentFileActions().