xref: /glogg/src/savedsearches.h (revision bb02e0acf44ddb4e4f83d6127a1e488789162922) !
1 /*
2  * Copyright (C) 2009, 2011 Nicolas Bonnefon and other contributors
3  *
4  * This file is part of glogg.
5  *
6  * glogg is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * glogg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef SAVEDSEARCHES_H
21 #define SAVEDSEARCHES_H
22 
23 #include <QString>
24 #include <QStringList>
25 #include <QMetaType>
26 
27 #include "persistable.h"
28 
29 // Keeps track of the previously used searches and allows the application
30 // to retrieve them.
31 class SavedSearches : public Persistable
32 {
33   public:
34     // Creates an empty set of saved searches
35     SavedSearches();
36 
37     // Adds the passed search to the list of recently used searches
38     void addRecent( const QString& text );
39 
40     // Returns a list of recent searches (newer first)
41     QStringList recentSearches() const;
42 
43     // Operators for serialization
44     // (only for migrating pre 0.8.2 settings, will be removed)
45     friend QDataStream& operator<<( QDataStream& out, const SavedSearches& object );
46     friend QDataStream& operator>>( QDataStream& in, SavedSearches& object );
47 
48     // Reads/writes the current config in the QSettings object passed
49     void saveToStorage( QSettings& settings ) const;
50     void retrieveFromStorage( QSettings& settings );
51 
52   private:
53     static const int SAVEDSEARCHES_VERSION;
54     static const int maxNumberOfRecentSearches;
55 
56     QStringList savedSearches_;
57 };
58 
59 Q_DECLARE_METATYPE(SavedSearches)
60 
61 #endif
62