File indexing completed on 2024-04-14 03:54:09
0001 /* 0002 SPDX-FileCopyrightText: 2019 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 KNSQUICK_AUTHOR_H 0008 #define KNSQUICK_AUTHOR_H 0009 0010 #include <QObject> 0011 #include <QQmlParserStatus> 0012 #include <entry.h> 0013 0014 // TODO This is not a class for exposing data QtQuick, but for implementing it's fetching in the first place. 0015 // Also it sepnds on the QML parser status, this is kindof ugly... 0016 namespace KNewStuffQuick 0017 { 0018 class AuthorPrivate; 0019 /** 0020 * @short Encapsulates a KNSCore::Author for use in Qt Quick 0021 * 0022 * This class takes care of initialisation of a KNSCore::Author when assigned an engine, provider ID and username. 0023 * If the data is not yet cached, it will be requested from the provider, and updated for display 0024 * @since 5.63 0025 */ 0026 class Author : public QObject, public QQmlParserStatus 0027 { 0028 Q_OBJECT 0029 Q_INTERFACES(QQmlParserStatus) 0030 /** 0031 * The NewStuffQuickEngine to interact with servers through 0032 */ 0033 Q_PROPERTY(QObject *engine READ engine WRITE setEngine NOTIFY engineChanged) 0034 /** 0035 * The ID of the provider which the user is registered on 0036 */ 0037 Q_PROPERTY(QString providerId READ providerId WRITE setProviderId NOTIFY providerIdChanged) 0038 /** 0039 * The user ID for the user this object represents 0040 */ 0041 Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) 0042 0043 Q_PROPERTY(QString name READ name NOTIFY dataChanged) 0044 Q_PROPERTY(QString description READ description NOTIFY dataChanged) 0045 Q_PROPERTY(QString homepage READ homepage NOTIFY dataChanged) 0046 Q_PROPERTY(QString profilepage READ profilepage NOTIFY dataChanged) 0047 Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY dataChanged) 0048 public: 0049 explicit Author(QObject *parent = nullptr); 0050 ~Author() override; 0051 void classBegin() override; 0052 void componentComplete() override; 0053 0054 QObject *engine() const; 0055 void setEngine(QObject *newEngine); 0056 Q_SIGNAL void engineChanged(); 0057 0058 QString providerId() const; 0059 void setProviderId(const QString &providerId); 0060 Q_SIGNAL void providerIdChanged(); 0061 0062 QString username() const; 0063 void setUsername(const QString &username); 0064 Q_SIGNAL void usernameChanged(); 0065 0066 QString name() const; 0067 QString description() const; 0068 QString homepage() const; 0069 QString profilepage() const; 0070 QUrl avatarUrl() const; 0071 Q_SIGNAL void dataChanged(); 0072 0073 private: 0074 const std::unique_ptr<AuthorPrivate> d; 0075 }; 0076 } 0077 0078 #endif // KNSQUICK_AUTHOR_H