Applets
searchmodel.h
Go to the documentation of this file.00001 /* 00002 Copyright 2007 Robert Knight <robertknight@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef SEARCHMODEL_H 00021 #define SEARCHMODEL_H 00022 00023 // Qt 00024 #include "core/kickoffmodel.h" 00025 00026 namespace Kickoff 00027 { 00028 00029 class SearchResult 00030 { 00031 public: 00032 QString url; 00033 QString title; 00034 QString subTitle; 00035 }; 00036 typedef QList<SearchResult> ResultList; 00037 00038 class SearchModel : public KickoffModel 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 SearchModel(QObject *parent); 00044 virtual ~SearchModel(); 00045 00046 public Q_SLOTS: 00047 void setQuery(const QString& query); 00048 00049 private Q_SLOTS: 00050 void resultsAvailable(const QStringList& results); 00051 void resultsAvailable(const ResultList& results); 00052 00053 Q_SIGNALS: 00054 void resultsAvailable(); 00055 00056 private: 00057 class Private; 00058 Private * const d; 00059 }; 00060 00061 class SearchInterface : public QObject 00062 { 00063 Q_OBJECT 00064 00065 public: 00066 SearchInterface(QObject *parent); 00067 00068 virtual QString name() const = 0; 00069 virtual void setQuery(const QString& query) = 0; 00070 00071 00072 Q_SIGNALS: 00073 void resultsAvailable(const QStringList& results); 00074 void resultsAvailable(const ResultList& results); 00075 }; 00076 00077 class ApplicationSearch : public SearchInterface 00078 { 00079 Q_OBJECT 00080 00081 public: 00082 ApplicationSearch(QObject *parent); 00083 00084 virtual QString name() const; 00085 virtual void setQuery(const QString& query); 00086 00087 private: 00088 QString mimeNameForQuery(const QString& query) const; 00089 }; 00090 00091 class WebSearch : public SearchInterface 00092 { 00093 Q_OBJECT 00094 00095 public: 00096 WebSearch(QObject *parent); 00097 virtual QString name() const; 00098 virtual void setQuery(const QString& query); 00099 }; 00100 00101 class IndexerSearch : public SearchInterface 00102 { 00103 Q_OBJECT 00104 00105 public: 00106 IndexerSearch(QObject *parent); 00107 virtual QString name() const; 00108 virtual void setQuery(const QString& query); 00109 }; 00110 00111 } 00112 00113 #endif // SEARCHMODEL_H 00114