QElectroTech  0.8-dev
recentfiles.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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:
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
RecentFiles::extractFilesFromSettings
void extractFilesFromSettings()
RecentFiles::extractFilesFromSettings Read the list of recent file from settings.
Definition: recentfiles.cpp:117
RecentFiles::size
int size() const
Definition: recentfiles.cpp:53
RecentFiles::iconForFiles
QIcon iconForFiles() const
Definition: recentfiles.cpp:68
RecentFiles::identifier_
QString identifier_
Definition: recentfiles.h:62
RecentFiles
Definition: recentfiles.h:26
RecentFiles::RecentFiles
RecentFiles(const RecentFiles &)
RecentFiles::insertFile
void insertFile(const QString &)
Definition: recentfiles.cpp:135
RecentFiles::files_icon_
QIcon files_icon_
Definition: recentfiles.h:67
RecentFiles::setIconForFiles
void setIconForFiles(const QIcon &)
Definition: recentfiles.cpp:77
qeticons.h
RecentFiles::handleMenuRequest
void handleMenuRequest(const QString &)
Definition: recentfiles.cpp:100
RecentFiles::fileOpeningRequested
void fileOpeningRequested(const QString &)
recentfiles.h
RecentFiles::saveFilesToSettings
void saveFilesToSettings()
RecentFiles::saveFilesToSettings Write the list of recent files to settings.
Definition: recentfiles.cpp:154
RecentFiles::menu_
QMenu * menu_
Definition: recentfiles.h:65
RecentFiles::save
void save()
Definition: recentfiles.cpp:93
RecentFiles::~RecentFiles
~RecentFiles() override
Definition: recentfiles.cpp:46
RecentFiles::buildMenu
void buildMenu()
Definition: recentfiles.cpp:167
RecentFiles::clear
void clear()
Definition: recentfiles.cpp:85
RecentFiles::fileWasOpened
void fileWasOpened(const QString &)
Definition: recentfiles.cpp:108
RecentFiles::RecentFiles
RecentFiles(const QString &, int=10, QObject *=nullptr)
Definition: recentfiles.cpp:29
RecentFiles::size_
int size_
Definition: recentfiles.h:63
RecentFiles::menu
QMenu * menu() const
Definition: recentfiles.cpp:60
RecentFiles::mapper_
QSignalMapper * mapper_
Definition: recentfiles.h:66
RecentFiles::list_
QList< QString > list_
Definition: recentfiles.h:64