1 //----------------------------------------------------------------------------- 2 /** @file pentobi/RecentFiles.h 3 @author Markus Enzenberger 4 @copyright GNU General Public License version 3 or later */ 5 //----------------------------------------------------------------------------- 6 7 #ifndef PENTOBI_RECENT_FILES_H 8 #define PENTOBI_RECENT_FILES_H 9 10 #include <QObject> 11 12 //----------------------------------------------------------------------------- 13 14 class RecentFiles 15 : public QObject 16 { 17 Q_OBJECT 18 19 Q_PROPERTY(QVariantList entries READ entries NOTIFY entriesChanged) 20 21 public: 22 static constexpr int maxRecentFiles = 9; 23 24 25 explicit RecentFiles(QObject* parent = nullptr); 26 27 ~RecentFiles() override; 28 29 30 Q_INVOKABLE void add(const QString& file, const QString& displayName); 31 32 Q_INVOKABLE void clear(const QString& currentFile); 33 entries()34 const QVariantList& entries() const { return m_entries; } 35 36 signals: 37 void entriesChanged(); 38 39 private: 40 QVariantList m_entries; 41 42 43 void checkMax(const QString& currentFile = {}); 44 45 void load(); 46 }; 47 48 //----------------------------------------------------------------------------- 49 50 #endif // PENTOBI_RECENT_FILES_H 51