KNewStuff
provider.h
Go to the documentation of this file.
00001 /* 00002 knewstuff3/provider.h 00003 This file is part of KNewStuff2. 00004 Copyright (c) 2009 Jeremy Whiting <jpwhiting@kde.org> 00005 Copyright (C) 2009 Frederik Gladhorn <gladhorn@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 #ifndef KNEWSTUFF3_PROVIDER_H 00021 #define KNEWSTUFF3_PROVIDER_H 00022 00023 #include <QtCore/QList> 00024 #include <QtCore/QString> 00025 00026 #include <kurl.h> 00027 00028 #include "entryinternal.h" 00029 00030 class KJob; 00031 00032 namespace KNS3 00033 { 00046 class Provider: public QObject 00047 { 00048 Q_OBJECT 00049 public: 00050 typedef QList<Provider*> List; 00051 00052 enum SortMode { 00053 Newest, 00054 Alphabetical, 00055 Rating, 00056 Downloads, 00057 Installed, // only installed items 00058 Updates // entries that can be updated 00059 }; 00060 00064 struct SearchRequest { 00065 SortMode sortMode; 00066 QString searchTerm; 00067 QStringList categories; 00068 int page; 00069 int pageSize; 00070 00071 SearchRequest(SortMode sortMode_ = Newest, const QString& searchTerm_ = QString(), const QStringList& categories_ = QStringList(), int page_ = -1, int pageSize_ = 20) 00072 :sortMode(sortMode_), searchTerm(searchTerm_), categories(categories_), page(page_), pageSize(pageSize_) 00073 {} 00074 00075 QString hashForRequest() const; 00076 }; 00077 00081 Provider(); 00082 00086 virtual ~Provider(); 00087 00091 virtual QString id() const = 0; 00092 00097 virtual bool setProviderXML(const QDomElement & xmldata) = 0; 00098 00099 virtual bool isInitialized() const = 0; 00100 00101 virtual void setCachedEntries(const KNS3::EntryInternal::List& cachedEntries) = 0; 00102 00108 virtual QString name() const; 00109 00115 virtual KUrl icon() const; // FIXME use KIcon or pixmap? 00116 00125 virtual void loadEntries(const KNS3::Provider::SearchRequest& request) = 0; 00126 virtual void loadEntryDetails(const KNS3::EntryInternal&) {} 00127 virtual void loadPayloadLink(const EntryInternal& entry, int linkId) = 0; 00128 00129 virtual bool userCanVote() {return false;} 00130 virtual void vote(const EntryInternal& entry, uint rating) { Q_UNUSED(entry) Q_UNUSED(rating) } 00131 00132 virtual bool userCanBecomeFan() {return false;} 00133 virtual void becomeFan(const EntryInternal& entry) { Q_UNUSED(entry) } 00134 00135 signals: 00136 void providerInitialized(KNS3::Provider*); 00137 00138 void loadingFinished(const KNS3::Provider::SearchRequest&, const KNS3::EntryInternal::List&) const; 00139 void loadingFailed(const KNS3::Provider::SearchRequest&); 00140 00141 void entryDetailsLoaded(const KNS3::EntryInternal&); 00142 void payloadLinkLoaded(const KNS3::EntryInternal&); 00143 00144 void signalInformation(const QString&) const; 00145 void signalError(const QString&) const; 00146 00147 protected: 00148 QString mName; 00149 KUrl mIcon; 00150 00151 private: 00152 Q_DISABLE_COPY(Provider) 00153 }; 00154 } 00155 00156 #endif
KDE 4.6 API Reference