14 : path(apath), id(anid), used(adate)
44 : files(), groupName(), next_id(0), menu(NULL)
56 next_id = settings.value(
"next_id").toUInt();
58 QStringList children = settings.childGroups();
59 foreach(QString
id, children)
61 settings.beginGroup(
id);
62 QString path = settings.value(
"path").toString();
64 if (QFileInfo::exists(path))
66 QDateTime used = settings.value(
"used").toDateTime();
82 for(
int idx=0; idx <
files.size(); ++idx)
103 recent->setEnabled(!
files.isEmpty());
104 recent->setMenu(
menu);
114 settings.setValue(
"next_id",(uint)
next_id);
117 settings.beginGroup(QString::number(
files[idx].
id));
120 settings.setValue(
"path",
files[idx].path);
121 settings.setValue(
"used",
files[idx].used);
136 QAction* action = (QAction*) QObject::sender();
137 size_t id = action->data().toUInt();
147 for(
int i=0; i <
files.size(); ++i)
148 if (
files[i].
id ==
id)
155 QFileInfo finfo(e.
path);
156 QAction* action =
menu->addAction(finfo.fileName());
157 action->setData((uint)e.
id);
159 connect(action,SIGNAL(triggered()),
this, SLOT(
onMenuSelected()));
167 menu->actions().move(from,to);
172 for(
int i=0; i <
files.size(); ++i)
173 if (
files[i].path == path)
void onMenuSelected()
called when an item from the Open Recent menu is selected
bool operator<(const FileEntry &that) const
compare files by their last-used date
QString groupName
group identifier if preferences
void restore(QSettings &settings)
read settings from application preferences
void attachMenu(QAction *recent)
attach sub-menu
global definitions for all algorithms.
int indexOf(QString path)
find file by name
QAction * createMenuItem(const FileEntry &entry, int position)
create a new menu item in File/Open Recent
QString path
absolute path to file
FileEntry(QString apath, size_t id, QDateTime adate=QDateTime::currentDateTime())
default constructor
size_t next_id
next identifier
an entry in the recently opened file list
void open(QString)
raised when a file is selected from the "Open Recent" menu
void beginFile(QSettings &settings, size_t id, bool forWrite=false)
begin reading or updating file specific settings
size_t id
unique identifier issued by FileHistory
QDateTime used
time when the file was last used
FileHistory()
empty constructor
void endFile(QSettings &settings)
end updating file specific settings
QMenu * menu
pointer to File/Open Recent menu
QList< FileEntry > files
list of file IDs; sorted by LRU
void moveMenuItem(int from, int to)
move a menu item
size_t insert(QString path, QDateTime date=QDateTime::currentDateTime())
insert a new file into the list
void init(QString agroup)
initialize file list and menu