KNewStuff
itemsmodel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KNEWSTUFF2_UI_ITEMSMODEL_H
00020 #define KNEWSTUFF2_UI_ITEMSMODEL_H
00021
00022 #include <QAbstractListModel>
00023 #include <QtGui/QImage>
00024
00025 #include <knewstuff2/core/entry.h>
00026 #include <knewstuff2/ui/qasyncpixmap.h>
00027
00028 namespace KNS
00029 {
00030
00031 class ItemsModel: public QAbstractListModel
00032 {
00033 Q_OBJECT
00034 public:
00035 explicit ItemsModel(QObject * parent = NULL, bool hasWebService = false);
00036 ~ItemsModel();
00037
00038 enum EntryRoles {
00040 kNameRole = Qt::UserRole,
00042 kCategory,
00044 kAuthorName,
00046 kAuthorEmail,
00048 kAuthorJabber,
00050 kAuthorHomepage,
00052 kLicense,
00054 kSummary,
00056 kVersion,
00058 kRelease,
00060 kReleaseDate,
00062 kPayload,
00064 kPreview,
00066 kPreviewPixmap,
00068 kLargePreviewPixmap,
00070 kRating,
00072 kDownloads,
00074 kStatus
00075 };
00076
00077 int rowCount(const QModelIndex & parent = QModelIndex()) const;
00078
00079 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
00080
00081 void addEntry(Entry * entry);
00082
00083 void removeEntry(Entry * entry);
00084
00085 KNS::Entry* entryForIndex(const QModelIndex & index) const;
00086
00087 bool hasPreviewImages() const;
00088
00089 bool hasWebService() const;
00090
00091 public slots:
00092 void slotEntryChanged(KNS::Entry * entry);
00093 private slots:
00094 void slotEntryPreviewLoaded(const QString &url, const QPixmap & pix);
00095 private:
00096
00097
00098 QList<Entry *> m_entries;
00099 QMap<QString, QImage> m_previewImages;
00100 QMap<QString, QImage> m_largePreviewImages;
00101 QMap<QString, QModelIndex> m_imageIndexes;
00102 bool m_hasPreviewImages;
00103 bool m_hasWebService;
00104 };
00105
00106 }
00107
00108 #endif