KNewStuff

providersmodel.h
1/*
2 SPDX-FileCopyrightText: 2021 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef KNSCORE_PROVIDERSMODELL_H
8#define KNSCORE_PROVIDERSMODELL_H
9
10#include <QAbstractListModel>
11
12#include "enginebase.h"
13
14#include "knewstuffcore_export.h"
15
16#include <memory>
17
18namespace KNSCore
19{
20class ProvidersModelPrivate;
21/**
22 * @brief A model which holds information on all known Providers for a specific Engine
23 *
24 * @since 5.85
25 */
26class KNEWSTUFFCORE_EXPORT ProvidersModel : public QAbstractListModel
27{
28 Q_OBJECT
29 /**
30 * The Engine for which this model displays Providers
31 */
32 Q_PRIVATE_PROPERTY(d, EngineBase *engine READ getEngine WRITE setEngine NOTIFY engineChanged)
33public:
34 explicit ProvidersModel(QObject *parent = nullptr);
35 ~ProvidersModel() override;
36
37 enum Roles {
38 IdRole = Qt::UserRole + 1,
39 NameRole,
40 VersionRole,
41 WebsiteRole,
42 HostRole,
43 ContactEmailRole,
44 SupportsSslRole,
45 IconRole,
46 ObjectRole, ///< The actual Provider object. Do not hold this locally and expect it to disappear at a moment's notice
47 };
48 Q_ENUM(Roles)
49
50 QHash<int, QByteArray> roleNames() const override;
51 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
52 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
53
54 // TODO KF7: Port property to back to public getter/setter, narrow types to EngineBase
55 QObject *engine() const;
56 void setEngine(QObject *engine);
57 Q_SIGNAL void engineChanged();
58
59private:
60 std::unique_ptr<ProvidersModelPrivate> d;
61};
62}
63
64#endif // KNSCORE_PROVIDERSMODELL_H
KNewStuff engine.
Definition enginebase.h:52
A model which holds information on all known Providers for a specific Engine.
@ ObjectRole
The actual Provider object. Do not hold this locally and expect it to disappear at a moment's notice.
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:56:35 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.