annotate base/RecentFiles.h @ 245:4cd620bd4c61 sv1-1.0pre1

* Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default.
author Chris Cannam
date Fri, 02 Mar 2007 14:00:12 +0000
parents 6576a208e8e7
children 3b8008d09541
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@209 56 * Add a name that is known to be either a file path or a URL. If
Chris@209 57 * it looks like a URL, add it literally; otherwise treat it as a
Chris@209 58 * file path and canonicalise it appropriately.
Chris@166 59 */
Chris@166 60 void addFile(QString name);
Chris@149 61
Chris@149 62 signals:
Chris@166 63 void recentChanged();
Chris@149 64
Chris@149 65 protected:
Chris@166 66 QString m_settingsGroup;
Chris@166 67 size_t m_maxCount;
Chris@149 68
Chris@166 69 std::deque<QString> m_names;
Chris@149 70
Chris@166 71 void read();
Chris@166 72 void write();
Chris@149 73 void truncateAndWrite();
Chris@149 74 };
Chris@149 75
Chris@149 76 #endif