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

KNewStuff

itemsmodel.h

Go to the documentation of this file.
00001 /*
00002     This file is part of KNewStuff2.
00003     Copyright (C) 2008 Jeremy Whiting <jeremy@scitools.com>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
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     // the list of entries
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 } // end KNS namespace
00109 
00110 #endif

KNewStuff

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal