File indexing completed on 2024-04-21 03:56:24

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 "knewstuffcore_export.h"
0013 
0014 #include <memory>
0015 
0016 namespace KNSCore
0017 {
0018 class ProvidersModelPrivate;
0019 /**
0020  * @brief A model which holds information on all known Providers for a specific Engine
0021  *
0022  * @since 5.85
0023  */
0024 class KNEWSTUFFCORE_EXPORT ProvidersModel : public QAbstractListModel
0025 {
0026     Q_OBJECT
0027     /**
0028      * The Engine for which this model displays Providers
0029      */
0030     Q_PROPERTY(QObject *engine READ engine WRITE setEngine NOTIFY engineChanged)
0031 public:
0032     explicit ProvidersModel(QObject *parent = nullptr);
0033     ~ProvidersModel() override;
0034 
0035     enum Roles {
0036         IdRole = Qt::UserRole + 1,
0037         NameRole,
0038         VersionRole,
0039         WebsiteRole,
0040         HostRole,
0041         ContactEmailRole,
0042         SupportsSslRole,
0043         IconRole,
0044         ObjectRole, ///< The actual Provider object. Do not hold this locally and expect it to disappear at a moment's notice
0045     };
0046     Q_ENUM(Roles)
0047 
0048     QHash<int, QByteArray> roleNames() const override;
0049     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0050     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0051 
0052     QObject *engine() const;
0053     void setEngine(QObject *engine);
0054     Q_SIGNAL void engineChanged();
0055 
0056 private:
0057     std::unique_ptr<ProvidersModelPrivate> d;
0058 };
0059 }
0060 
0061 #endif // KNSCORE_PROVIDERSMODELL_H