svcore  1.9
RecentFiles.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _RECENT_FILES_H_
17 #define _RECENT_FILES_H_
18 
19 #include <QObject>
20 #include <QString>
21 #include <vector>
22 #include <deque>
23 
30 class RecentFiles : public QObject
31 {
32  Q_OBJECT
33 
34 public:
40  RecentFiles(QString settingsGroup = "RecentFiles", int maxCount = 10);
41 
42  virtual ~RecentFiles();
43 
44  QString getSettingsGroup() const { return m_settingsGroup; }
45 
46  int getMaxCount() const { return m_maxCount; }
47 
48  std::vector<QString> getRecent() const;
49 
53  void add(QString name);
54 
64  void addFile(QString name);
65 
66 signals:
67  void recentChanged();
68 
69 protected:
70  QString m_settingsGroup;
72 
73  std::deque<QString> m_names;
74 
75  void read();
76  void write();
77  void truncateAndWrite();
78 };
79 
80 #endif
void recentChanged()
QString m_settingsGroup
Definition: RecentFiles.h:70
std::deque< QString > m_names
Definition: RecentFiles.h:73
void addFile(QString name)
Add a name that is known to be either a file path or a URL.
virtual ~RecentFiles()
Definition: RecentFiles.cpp:31
void write()
Definition: RecentFiles.cpp:55
void add(QString name)
Add a name that should be treated as a literal string.
Definition: RecentFiles.cpp:92
QString getSettingsGroup() const
Definition: RecentFiles.h:44
int getMaxCount() const
Definition: RecentFiles.h:46
std::vector< QString > getRecent() const
Definition: RecentFiles.cpp:80
int m_maxCount
Definition: RecentFiles.h:71
RecentFiles manages a list of the names of recently-used objects, saving and restoring that list via ...
Definition: RecentFiles.h:30
void truncateAndWrite()
Definition: RecentFiles.cpp:71
RecentFiles(QString settingsGroup="RecentFiles", int maxCount=10)
Construct a RecentFiles object that saves and restores in the given QSettings group and truncates whe...
Definition: RecentFiles.cpp:24