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