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 #include "qmlproviderextension.h"
0008 
0009 using namespace KUserFeedback;
0010 
0011 QmlProviderExtension::QmlProviderExtension(QObject* parent) :
0012     QObject(parent)
0013 {
0014 }
0015 
0016 QmlProviderExtension::~QmlProviderExtension()
0017 {
0018 }
0019 
0020 void QmlProviderExtension::sourceAppend(QQmlListProperty<QmlAbstractDataSource> *prop, QmlAbstractDataSource *value)
0021 {
0022     static_cast<QmlProviderExtension*>(prop->object)->m_sourceWrappers.push_back(value);
0023     static_cast<Provider*>(prop->object->parent())->addDataSource(value->source());
0024 }
0025 
0026 QmlProviderExtension::sizetype QmlProviderExtension::sourceCount(QQmlListProperty<QmlAbstractDataSource> *prop)
0027 {
0028     return static_cast<QmlProviderExtension*>(prop->object)->m_sourceWrappers.size();
0029 }
0030 
0031 QmlAbstractDataSource* QmlProviderExtension::sourceAt(QQmlListProperty<QmlAbstractDataSource> *prop, QmlProviderExtension::sizetype index)
0032 {
0033     return static_cast<QmlProviderExtension*>(prop->object)->m_sourceWrappers.at(index);
0034 }
0035 
0036 void QmlProviderExtension::sourceClear(QQmlListProperty<QmlAbstractDataSource> *prop)
0037 {
0038     static_cast<QmlProviderExtension*>(prop->object)->m_sourceWrappers.clear();
0039 }
0040 
0041 QQmlListProperty<QmlAbstractDataSource> QmlProviderExtension::sources()
0042 {
0043     return QQmlListProperty<QmlAbstractDataSource>(this, nullptr,
0044         QmlProviderExtension::sourceAppend, QmlProviderExtension::sourceCount,
0045         QmlProviderExtension::sourceAt, QmlProviderExtension::sourceClear);
0046 }
0047 
0048 #include "moc_qmlproviderextension.cpp"