| 1 | /* |
| 2 | knewstuff3/ui/itemsmodel.h. |
| 3 | SPDX-FileCopyrightText: 2008 Jeremy Whiting <jpwhiting@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KNEWSTUFF3_ITEMSMODEL_P_H |
| 9 | #define KNEWSTUFF3_ITEMSMODEL_P_H |
| 10 | |
| 11 | #include <QAbstractListModel> |
| 12 | #include <memory> |
| 13 | |
| 14 | #include "entry.h" |
| 15 | #include "knewstuffcore_export.h" |
| 16 | |
| 17 | class KJob; |
| 18 | |
| 19 | namespace KNSCore |
| 20 | { |
| 21 | class EngineBase; |
| 22 | class ItemsModelPrivate; |
| 23 | |
| 24 | class KNEWSTUFFCORE_EXPORT ItemsModel : public QAbstractListModel |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | public: |
| 28 | explicit ItemsModel(EngineBase *engine, QObject *parent = nullptr); |
| 29 | ~ItemsModel() override; |
| 30 | |
| 31 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
| 32 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
| 33 | /** |
| 34 | * The row of the entry passed to the function, or -1 if the entry is not contained |
| 35 | * within the model. |
| 36 | * @since 5.63 |
| 37 | */ |
| 38 | int row(const Entry &entry) const; |
| 39 | |
| 40 | void addEntry(const Entry &entry); |
| 41 | void removeEntry(const Entry &entry); |
| 42 | |
| 43 | bool hasPreviewImages() const; |
| 44 | |
| 45 | Q_SIGNALS: |
| 46 | void jobStarted(KJob *, const QString &label); |
| 47 | void loadPreview(const KNSCore::Entry &entry, KNSCore::Entry::PreviewType type); |
| 48 | |
| 49 | public Q_SLOTS: |
| 50 | void slotEntryChanged(const KNSCore::Entry &entry); |
| 51 | void slotEntriesLoaded(const KNSCore::Entry::List &entries); |
| 52 | void clearEntries(); |
| 53 | void slotEntryPreviewLoaded(const KNSCore::Entry &entry, KNSCore::Entry::PreviewType type); |
| 54 | |
| 55 | private: |
| 56 | const std::unique_ptr<ItemsModelPrivate> d; |
| 57 | }; |
| 58 | |
| 59 | } // end KNS namespace |
| 60 | |
| 61 | #endif |
| 62 | |