File indexing completed on 2024-12-15 03:45:05

0001 /*
0002     SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KUSERFEEDBACK_QMLPROVIDEREXTENSION_H
0008 #define KUSERFEEDBACK_QMLPROVIDEREXTENSION_H
0009 
0010 #include "qmlabstractdatasource.h"
0011 
0012 #include <QObject>
0013 #include <QQmlListProperty>
0014 #include <QVector>
0015 
0016 namespace KUserFeedback {
0017 
0018 class QmlProviderExtension : public QObject
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(QQmlListProperty<KUserFeedback::QmlAbstractDataSource> sources READ sources)
0022     Q_CLASSINFO("DefaultProperty", "sources")
0023 
0024 public:
0025     explicit QmlProviderExtension(QObject *parent = nullptr);
0026     ~QmlProviderExtension() override;
0027 
0028     QQmlListProperty<QmlAbstractDataSource> sources();
0029 
0030 private:
0031 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0032     typedef qsizetype sizetype;
0033 #else
0034     typedef int sizetype;
0035 #endif
0036     static void sourceAppend(QQmlListProperty<QmlAbstractDataSource> *prop, QmlAbstractDataSource *value);
0037     static sizetype sourceCount(QQmlListProperty<QmlAbstractDataSource> *prop);
0038     static QmlAbstractDataSource* sourceAt(QQmlListProperty<QmlAbstractDataSource> *prop, sizetype index);
0039     static void sourceClear(QQmlListProperty<QmlAbstractDataSource> *prop);
0040 
0041     QVector<QmlAbstractDataSource*> m_sourceWrappers;
0042 };
0043 
0044 }
0045 
0046 #endif // KUSERFEEDBACK_QMLPROVIDEREXTENSION_H