File indexing completed on 2024-04-28 15:28:58
0001 /* 0002 knewstuff3/ui/itemsmodel.h. 0003 SPDX-FileCopyrightText: 2008 Jeremy Whiting <jpwhiting@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef KNEWSTUFF3_ITEMSMODEL_P_H 0009 #define KNEWSTUFF3_ITEMSMODEL_P_H 0010 0011 #include <QAbstractListModel> 0012 0013 #include "entryinternal.h" 0014 #include "knewstuffcore_export.h" 0015 0016 class KJob; 0017 0018 namespace KNSCore 0019 { 0020 class Engine; 0021 0022 class KNEWSTUFFCORE_EXPORT ItemsModel : public QAbstractListModel 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit ItemsModel(Engine *engine, QObject *parent = nullptr); 0027 ~ItemsModel() override; 0028 0029 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0030 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0031 /** 0032 * The row of the entry passed to the function, or -1 if the entry is not contained 0033 * within the model. 0034 * @since 5.63 0035 */ 0036 int row(const EntryInternal &entry) const; 0037 0038 void addEntry(const EntryInternal &entry); 0039 void removeEntry(const EntryInternal &entry); 0040 0041 bool hasPreviewImages() const; 0042 bool hasWebService() const; 0043 0044 Q_SIGNALS: 0045 void jobStarted(KJob *, const QString &label); 0046 0047 public Q_SLOTS: 0048 void slotEntryChanged(const KNSCore::EntryInternal &entry); 0049 void slotEntriesLoaded(const KNSCore::EntryInternal::List &entries); 0050 void clearEntries(); 0051 void slotEntryPreviewLoaded(const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::PreviewType type); 0052 0053 private: 0054 Engine *const m_engine; 0055 // the list of entries 0056 QList<EntryInternal> m_entries; 0057 bool m_hasPreviewImages = false; 0058 }; 0059 0060 } // end KNS namespace 0061 0062 Q_DECLARE_METATYPE(KNSCore::EntryInternal) 0063 0064 #endif