annotate base/RecentFiles.h @ 149:3e4c384f518e

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 12:03:45 +0000
parents
children 702fc936e6a6
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@149 24 class RecentFiles : public QObject
Chris@149 25 {
Chris@149 26 Q_OBJECT
Chris@149 27
Chris@149 28 public:
Chris@149 29 // The maxFileCount argument will only be used the first time this is called
Chris@149 30 static RecentFiles *getInstance(int maxFileCount = 10);
Chris@149 31
Chris@149 32 virtual ~RecentFiles();
Chris@149 33
Chris@149 34 int getMaxFileCount() const { return m_maxFileCount; }
Chris@149 35
Chris@149 36 std::vector<QString> getRecentFiles() const;
Chris@149 37
Chris@149 38 void addFile(QString filename);
Chris@149 39
Chris@149 40 signals:
Chris@149 41 void recentFilesChanged();
Chris@149 42
Chris@149 43 protected:
Chris@149 44 RecentFiles(int maxFileCount);
Chris@149 45
Chris@149 46 int m_maxFileCount;
Chris@149 47 std::deque<QString> m_files;
Chris@149 48
Chris@149 49 void readFiles();
Chris@149 50 void writeFiles();
Chris@149 51 void truncateAndWrite();
Chris@149 52
Chris@149 53 static RecentFiles *m_instance;
Chris@149 54 };
Chris@149 55
Chris@149 56 #endif