annotate base/RecentFiles.h @ 181:9c652f2c39b1

* Various improvements to colour 3d plot layer, particularly for large and/or dense plots. Still a work in progress
author Chris Cannam
date Fri, 06 Oct 2006 16:53:25 +0000
parents 702fc936e6a6
children 6576a208e8e7
rev   line source
Chris@149 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@149 2
Chris@149 3 /*
Chris@149 4 Sonic Visualiser
Chris@149 5 An audio file viewer and annotation editor.
Chris@149 6 Centre for Digital Music, Queen Mary, University of London.
Chris@149 7 This file copyright 2006 Chris Cannam.
Chris@149 8
Chris@149 9 This program is free software; you can redistribute it and/or
Chris@149 10 modify it under the terms of the GNU General Public License as
Chris@149 11 published by the Free Software Foundation; either version 2 of the
Chris@149 12 License, or (at your option) any later version. See the file
Chris@149 13 COPYING included with this distribution for more information.
Chris@149 14 */
Chris@149 15
Chris@149 16 #ifndef _RECENT_FILES_H_
Chris@149 17 #define _RECENT_FILES_H_
Chris@149 18
Chris@149 19 #include <QObject>
Chris@149 20 #include <QString>
Chris@149 21 #include <vector>
Chris@149 22 #include <deque>
Chris@149 23
Chris@166 24 /**
Chris@166 25 * RecentFiles manages a list of the names of recently-used objects,
Chris@166 26 * saving and restoring that list via QSettings. The names do not
Chris@166 27 * actually have to refer to files.
Chris@166 28 */
Chris@166 29
Chris@149 30 class RecentFiles : public QObject
Chris@149 31 {
Chris@149 32 Q_OBJECT
Chris@149 33
Chris@149 34 public:
Chris@166 35 /**
Chris@166 36 * Construct a RecentFiles object that saves and restores in the
Chris@166 37 * given QSettings group and truncates when the given count of
Chris@166 38 * strings is reached.
Chris@166 39 */
Chris@166 40 RecentFiles(QString settingsGroup = "RecentFiles", size_t maxCount = 10);
Chris@149 41
Chris@149 42 virtual ~RecentFiles();
Chris@149 43
Chris@166 44 QString getSettingsGroup() const { return m_settingsGroup; }
Chris@149 45
Chris@166 46 int getMaxCount() const { return m_maxCount; }
Chris@166 47
Chris@166 48 std::vector<QString> getRecent() const;
Chris@166 49
Chris@166 50 /**
Chris@166 51 * Add a name that should be treated as a literal string.
Chris@166 52 */
Chris@166 53 void add(QString name);
Chris@149 54
Chris@166 55 /**
Chris@166 56 * Add a name that should be treated as a file path and
Chris@166 57 * canonicalised appropriately.
Chris@166 58 */
Chris@166 59 void addFile(QString name);
Chris@149 60
Chris@149 61 signals:
Chris@166 62 void recentChanged();
Chris@149 63
Chris@149 64 protected:
Chris@166 65 QString m_settingsGroup;
Chris@166 66 size_t m_maxCount;
Chris@149 67
Chris@166 68 std::deque<QString> m_names;
Chris@149 69
Chris@166 70 void read();
Chris@166 71 void write();
Chris@149 72 void truncateAndWrite();
Chris@149 73 };
Chris@149 74
Chris@149 75 #endif