File indexing completed on 2024-04-28 07:45:13
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 #include <memory> 0013 0014 #include "entry.h" 0015 #include "knewstuffcore_export.h" 0016 0017 class KJob; 0018 0019 namespace KNSCore 0020 { 0021 class EngineBase; 0022 class ItemsModelPrivate; 0023 0024 class KNEWSTUFFCORE_EXPORT ItemsModel : public QAbstractListModel 0025 { 0026 Q_OBJECT 0027 public: 0028 explicit ItemsModel(EngineBase *engine, QObject *parent = nullptr); 0029 ~ItemsModel() override; 0030 0031 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0032 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0033 /** 0034 * The row of the entry passed to the function, or -1 if the entry is not contained 0035 * within the model. 0036 * @since 5.63 0037 */ 0038 int row(const Entry &entry) const; 0039 0040 void addEntry(const Entry &entry); 0041 void removeEntry(const Entry &entry); 0042 0043 bool hasPreviewImages() const; 0044 bool hasWebService() const; 0045 0046 Q_SIGNALS: 0047 void jobStarted(KJob *, const QString &label); 0048 void loadPreview(const KNSCore::Entry &entry, KNSCore::Entry::PreviewType type); 0049 0050 public Q_SLOTS: 0051 void slotEntryChanged(const KNSCore::Entry &entry); 0052 void slotEntriesLoaded(const KNSCore::Entry::List &entries); 0053 void clearEntries(); 0054 void slotEntryPreviewLoaded(const KNSCore::Entry &entry, KNSCore::Entry::PreviewType type); 0055 0056 private: 0057 const std::unique_ptr<ItemsModelPrivate> d; 0058 }; 0059 0060 } // end KNS namespace 0061 0062 #endif