File indexing completed on 2024-05-26 11:49:59

0001 /*
0002     SPDX-FileCopyrightText: 2019 Cyril Rossi <cyril.rossi@enioka.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPROPERTYWRITER_H
0008 #define KPROPERTYWRITER_H
0009 
0010 #include <QObject>
0011 #include <QVariant>
0012 
0013 class KPropertyWriter : public QObject
0014 {
0015     Q_OBJECT
0016 
0017     Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
0018     Q_PROPERTY(QString propertyName READ propertyName WRITE setPropertyName NOTIFY propertyNameChanged)
0019 
0020 public:
0021     using QObject::QObject;
0022 
0023     QObject *target() const;
0024     QString propertyName() const;
0025 
0026     Q_INVOKABLE bool writeProperty(const QVariant &value);
0027 
0028 public Q_SLOTS:
0029     void setTarget(QObject *target);
0030     void setPropertyName(const QString &propertyName);
0031 
0032 Q_SIGNALS:
0033     void targetChanged(QObject *target);
0034     void propertyNameChanged(const QString &propertyName);
0035 
0036 private:
0037     QObject *m_target = nullptr;
0038     QString m_propertyName;
0039 };
0040 
0041 #endif // KPROPERTYWRITER_H