• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KNewStuff

  • sources
  • kde-4.14
  • kdelibs
  • knewstuff
  • knewstuff2
  • ui
knewstuff2/ui/itemsmodel.h
Go to the documentation of this file.
1 /*
2  This file is part of KNewStuff2.
3  Copyright (C) 2008 Jeremy Whiting <jpwhiting@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef KNEWSTUFF2_UI_ITEMSMODEL_H
20 #define KNEWSTUFF2_UI_ITEMSMODEL_H
21 
22 #include <QAbstractListModel>
23 #include <QtGui/QImage>
24 
25 #include <knewstuff2/core/entry.h>
26 
27 namespace KNS
28 {
29 static const int kPreviewWidth = 96;
30 static const int kPreviewHeight = 72;
31 
32 
33 class ItemsModel: public QAbstractListModel
34 {
35  Q_OBJECT
36 public:
37  explicit ItemsModel(QObject * parent = NULL, bool hasWebService = false);
38  ~ItemsModel();
39 
40  enum EntryRoles {
42  kNameRole = Qt::UserRole,
44  kCategory,
46  kAuthorName,
48  kAuthorEmail,
50  kAuthorJabber,
52  kAuthorHomepage,
54  kLicense,
56  kSummary,
58  kVersion,
60  kRelease,
62  kReleaseDate,
64  kPayload,
66  kPreview,
68  kPreviewPixmap,
70  kLargePreviewPixmap,
72  kRating,
74  kDownloads,
76  kStatus
77  };
78 
79  int rowCount(const QModelIndex & parent = QModelIndex()) const;
80 
81  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
82 
83  void addEntry(Entry * entry);
84 
85  void removeEntry(Entry * entry);
86 
87  KNS::Entry* entryForIndex(const QModelIndex & index) const;
88 
89  bool hasPreviewImages() const;
90 
91  bool hasWebService() const;
92 
93 public slots:
94  void slotEntryChanged(KNS::Entry * entry);
95 private slots:
96  void slotEntryPreviewLoaded(const QString &url, const QImage & pix);
97 private:
98 
99  // the list of entries
100  QList<Entry *> m_entries;
101  QMap<QString, QImage> m_previewImages;
102  QMap<QString, QImage> m_largePreviewImages;
103  QMap<QString, QModelIndex> m_imageIndexes;
104  bool m_hasPreviewImages;
105  bool m_hasWebService;
106 };
107 
108 } // end KNS namespace
109 
110 #endif
KNS::ItemsModel::kRelease
the release number
Definition: knewstuff2/ui/itemsmodel.h:60
QModelIndex
KNS::ItemsModel::~ItemsModel
~ItemsModel()
Definition: knewstuff2/ui/itemsmodel.cpp:31
KNS::ItemsModel
Definition: knewstuff2/ui/itemsmodel.h:33
KNS::ItemsModel::kDownloads
the number of downloads for the entry
Definition: knewstuff2/ui/itemsmodel.h:74
KNS::ItemsModel::kAuthorEmail
the e-mail address of the author
Definition: knewstuff2/ui/itemsmodel.h:48
KNS::ItemsModel::ItemsModel
ItemsModel(QObject *parent=NULL, bool hasWebService=false)
Definition: knewstuff2/ui/itemsmodel.cpp:26
KNS::Entry
KNewStuff data entry container.
Definition: knewstuff2/core/entry.h:46
KNS::ItemsModel::kNameRole
the name of the entry
Definition: knewstuff2/ui/itemsmodel.h:42
KNS::ItemsModel::EntryRoles
EntryRoles
Definition: knewstuff2/ui/itemsmodel.h:40
entry.h
QMap< QString, QImage >
KNS::kPreviewHeight
static const int kPreviewHeight
Definition: knewstuff2/ui/itemsmodel.h:30
KNS::ItemsModel::hasPreviewImages
bool hasPreviewImages() const
Definition: knewstuff2/ui/itemsmodel.cpp:178
KNS::ItemsModel::kReleaseDate
the release date
Definition: knewstuff2/ui/itemsmodel.h:62
KNS::ItemsModel::slotEntryChanged
void slotEntryChanged(KNS::Entry *entry)
Definition: knewstuff2/ui/itemsmodel.cpp:147
KNS::ItemsModel::kAuthorHomepage
the authors homepage
Definition: knewstuff2/ui/itemsmodel.h:52
QObject
QAbstractListModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
QAbstractListModel
KNS::ItemsModel::kPayload
the payload
Definition: knewstuff2/ui/itemsmodel.h:64
KNS::ItemsModel::kStatus
the status of this entry
Definition: knewstuff2/ui/itemsmodel.h:76
KNS::ItemsModel::addEntry
void addEntry(Entry *entry)
Definition: knewstuff2/ui/itemsmodel.cpp:116
KNS::ItemsModel::removeEntry
void removeEntry(Entry *entry)
Definition: knewstuff2/ui/itemsmodel.cpp:136
QString
QList< Entry * >
KNS::ItemsModel::kLargePreviewPixmap
the unscaled preview image
Definition: knewstuff2/ui/itemsmodel.h:70
KNS::ItemsModel::hasWebService
bool hasWebService() const
Definition: knewstuff2/ui/itemsmodel.cpp:183
QImage
KNS::ItemsModel::kSummary
a summary of the entry
Definition: knewstuff2/ui/itemsmodel.h:56
KNS::ItemsModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: knewstuff2/ui/itemsmodel.cpp:35
KNS::ItemsModel::kPreview
the preview url
Definition: knewstuff2/ui/itemsmodel.h:66
KNS::ItemsModel::entryForIndex
KNS::Entry * entryForIndex(const QModelIndex &index) const
Definition: knewstuff2/ui/itemsmodel.cpp:108
KNS::ItemsModel::kPreviewPixmap
the preview image
Definition: knewstuff2/ui/itemsmodel.h:68
KNS::ItemsModel::kVersion
a string of the version e.g.
Definition: knewstuff2/ui/itemsmodel.h:58
KNS::ItemsModel::kLicense
the license of the entry
Definition: knewstuff2/ui/itemsmodel.h:54
KNS::kPreviewWidth
static const int kPreviewWidth
Definition: knewstuff2/ui/itemsmodel.h:29
KNS::ItemsModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: knewstuff2/ui/itemsmodel.cpp:40
KNS::ItemsModel::kRating
the rating of the entry
Definition: knewstuff2/ui/itemsmodel.h:72
KNS::ItemsModel::kAuthorName
the name of the author of the entry
Definition: knewstuff2/ui/itemsmodel.h:46
QObject::parent
QObject * parent() const
KNS::ItemsModel::kAuthorJabber
the jabber of the author
Definition: knewstuff2/ui/itemsmodel.h:50
KNS::ItemsModel::kCategory
the category of the entry
Definition: knewstuff2/ui/itemsmodel.h:44
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:25:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KNewStuff

Skip menu "KNewStuff"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal