QElectroTech  0.70
recentfiles.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef RECENT_FILES_H
19 #define RECENT_FILES_H
20 #include <QtCore>
21 #include <QIcon>
22 class QMenu;
26 class RecentFiles : public QObject {
27  Q_OBJECT
28 
29  // constructors, destructor
30  public:
31  RecentFiles(const QString &, int = 10, QObject * = nullptr);
32  ~RecentFiles() override;
33  private:
34  RecentFiles(const RecentFiles &);
35 
36  // methods
37  public:
38  int size() const;
39  QMenu *menu() const;
40  QIcon iconForFiles() const;
41  void setIconForFiles(const QIcon &);
42 
43  public slots:
44  void clear();
45  void save();
46  void fileWasOpened(const QString &);
47 
48  signals:
49  void fileOpeningRequested(const QString &);
50 
51  private:
53  void insertFile(const QString &);
54  void saveFilesToSettings();
55  void buildMenu();
56 
57  private slots:
58  void handleMenuRequest(const QString &);
59 
60  // attributes
61  private:
62  QString identifier_;
63  int size_;
64  QList<QString> list_;
65  QMenu *menu_;
66  QSignalMapper *mapper_;
67  QIcon files_icon_;
68 };
69 #endif
void fileWasOpened(const QString &)
QMenu * menu_
Definition: recentfiles.h:65
void handleMenuRequest(const QString &)
void buildMenu()
QIcon files_icon_
Definition: recentfiles.h:67
QIcon iconForFiles() const
Definition: recentfiles.cpp:68
void fileOpeningRequested(const QString &)
~RecentFiles() override
Definition: recentfiles.cpp:46
QList< QString > list_
Definition: recentfiles.h:64
void saveFilesToSettings()
RecentFiles::saveFilesToSettings Write the list of recent files to settings.
void insertFile(const QString &)
QSignalMapper * mapper_
Definition: recentfiles.h:66
int size() const
Definition: recentfiles.cpp:53
QString identifier_
Definition: recentfiles.h:62
RecentFiles(const QString &, int=10, QObject *=nullptr)
Definition: recentfiles.cpp:29
QMenu * menu() const
Definition: recentfiles.cpp:60
void extractFilesFromSettings()
RecentFiles::extractFilesFromSettings Read the list of recent file from settings. ...
void clear()
Definition: recentfiles.cpp:85
void setIconForFiles(const QIcon &)
Definition: recentfiles.cpp:77