comparison base/RecentFiles.h @ 166:702fc936e6a6

* Pull transforms out of Layer menu (again) and into a separate Transforms menu * Add Recent Transforms submenu * Add effects and generators to the transforms menu (not yet implemented) as well as analysis plugins and data-from-effects (control output ports) * Add a nice dictionary-volume-style alphabetic subdivision of plugin names in plugins By Name menus
author Chris Cannam
date Fri, 22 Sep 2006 16:12:23 +0000
parents 3e4c384f518e
children 6576a208e8e7
comparison
equal deleted inserted replaced
165:5ae5885d6ce3 166:702fc936e6a6
19 #include <QObject> 19 #include <QObject>
20 #include <QString> 20 #include <QString>
21 #include <vector> 21 #include <vector>
22 #include <deque> 22 #include <deque>
23 23
24 /**
25 * RecentFiles manages a list of the names of recently-used objects,
26 * saving and restoring that list via QSettings. The names do not
27 * actually have to refer to files.
28 */
29
24 class RecentFiles : public QObject 30 class RecentFiles : public QObject
25 { 31 {
26 Q_OBJECT 32 Q_OBJECT
27 33
28 public: 34 public:
29 // The maxFileCount argument will only be used the first time this is called 35 /**
30 static RecentFiles *getInstance(int maxFileCount = 10); 36 * Construct a RecentFiles object that saves and restores in the
37 * given QSettings group and truncates when the given count of
38 * strings is reached.
39 */
40 RecentFiles(QString settingsGroup = "RecentFiles", size_t maxCount = 10);
31 41
32 virtual ~RecentFiles(); 42 virtual ~RecentFiles();
33 43
34 int getMaxFileCount() const { return m_maxFileCount; } 44 QString getSettingsGroup() const { return m_settingsGroup; }
35 45
36 std::vector<QString> getRecentFiles() const; 46 int getMaxCount() const { return m_maxCount; }
47
48 std::vector<QString> getRecent() const;
49
50 /**
51 * Add a name that should be treated as a literal string.
52 */
53 void add(QString name);
37 54
38 void addFile(QString filename); 55 /**
56 * Add a name that should be treated as a file path and
57 * canonicalised appropriately.
58 */
59 void addFile(QString name);
39 60
40 signals: 61 signals:
41 void recentFilesChanged(); 62 void recentChanged();
42 63
43 protected: 64 protected:
44 RecentFiles(int maxFileCount); 65 QString m_settingsGroup;
66 size_t m_maxCount;
45 67
46 int m_maxFileCount; 68 std::deque<QString> m_names;
47 std::deque<QString> m_files;
48 69
49 void readFiles(); 70 void read();
50 void writeFiles(); 71 void write();
51 void truncateAndWrite(); 72 void truncateAndWrite();
52
53 static RecentFiles *m_instance;
54 }; 73 };
55 74
56 #endif 75 #endif