File indexing completed on 2024-04-28 15:28:58
0001 /* 0002 SPDX-FileCopyrightText: 2021 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef KNSCORE_PROVIDERSMODELL_H 0008 #define KNSCORE_PROVIDERSMODELL_H 0009 0010 #include <QAbstractListModel> 0011 0012 #include "engine.h" 0013 #include "knewstuffcore_export.h" 0014 0015 #include <memory> 0016 0017 namespace KNSCore 0018 { 0019 class ProvidersModelPrivate; 0020 /** 0021 * @brief A model which holds information on all known Providers for a specific Engine 0022 * 0023 * @since 5.85 0024 */ 0025 class KNEWSTUFFCORE_EXPORT ProvidersModel : public QAbstractListModel 0026 { 0027 Q_OBJECT 0028 /** 0029 * The Engine for which this model displays Providers 0030 */ 0031 Q_PROPERTY(QObject *engine READ engine WRITE setEngine NOTIFY engineChanged) 0032 public: 0033 explicit ProvidersModel(QObject *parent = nullptr); 0034 ~ProvidersModel() override; 0035 0036 enum Roles { 0037 IdRole = Qt::UserRole + 1, 0038 NameRole, 0039 VersionRole, 0040 WebsiteRole, 0041 HostRole, 0042 ContactEmailRole, 0043 SupportsSslRole, 0044 IconRole, 0045 ObjectRole, ///< The actual Provider object. Do not hold this locally and expect it to disappear at a moment's notice 0046 }; 0047 Q_ENUM(Roles) 0048 0049 QHash<int, QByteArray> roleNames() const override; 0050 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0051 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0052 0053 QObject *engine() const; 0054 void setEngine(QObject *engine); 0055 Q_SIGNAL void engineChanged(); 0056 0057 private: 0058 std::unique_ptr<ProvidersModelPrivate> d; 0059 }; 0060 } 0061 0062 #endif // KNSCORE_PROVIDERSMODELL_H