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
00027 namespace KNS
00028 {
00029 static const int kPreviewWidth = 96;
00030 static const int kPreviewHeight = 72;
00031
00032
00033 class ItemsModel: public QAbstractListModel
00034 {
00035 Q_OBJECT
00036 public:
00037 explicit ItemsModel(QObject * parent = NULL, bool hasWebService = false);
00038 ~ItemsModel();
00039
00040 enum EntryRoles {
00042 kNameRole = Qt::UserRole,
00044 kCategory,
00046 kAuthorName,
00048 kAuthorEmail,
00050 kAuthorJabber,
00052 kAuthorHomepage,
00054 kLicense,
00056 kSummary,
00058 kVersion,
00060 kRelease,
00062 kReleaseDate,
00064 kPayload,
00066 kPreview,
00068 kPreviewPixmap,
00070 kLargePreviewPixmap,
00072 kRating,
00074 kDownloads,
00076 kStatus
00077 };
00078
00079 int rowCount(const QModelIndex & parent = QModelIndex()) const;
00080
00081 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
00082
00083 void addEntry(Entry * entry);
00084
00085 void removeEntry(Entry * entry);
00086
00087 KNS::Entry* entryForIndex(const QModelIndex & index) const;
00088
00089 bool hasPreviewImages() const;
00090
00091 bool hasWebService() const;
00092
00093 public slots:
00094 void slotEntryChanged(KNS::Entry * entry);
00095 private slots:
00096 void slotEntryPreviewLoaded(const QString &url, const QImage & pix);
00097 private:
00098
00099
00100 QList<Entry *> m_entries;
00101 QMap<QString, QImage> m_previewImages;
00102 QMap<QString, QImage> m_largePreviewImages;
00103 QMap<QString, QModelIndex> m_imageIndexes;
00104 bool m_hasPreviewImages;
00105 bool m_hasWebService;
00106 };
00107
00108 }
00109
00110 #endif