blob: abf6e5ff1c74d7ff67583d4f8a7cbe7f3d7d1dfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include "qquickmapboxglmapparameter.hpp"
#include <QByteArray>
#include <QMetaObject>
#include <QMetaProperty>
#include <QSignalMapper>
QQuickMapboxGLMapParameter::QQuickMapboxGLMapParameter(QObject *parent)
: QObject(parent)
, m_metaPropertyOffset(metaObject()->propertyCount())
{
}
void QQuickMapboxGLMapParameter::componentComplete()
{
for (int i = m_metaPropertyOffset; i < metaObject()->propertyCount(); ++i) {
QMetaProperty property = metaObject()->property(i);
if (!property.hasNotifySignal()) {
return;
}
auto mapper = new QSignalMapper(this);
mapper->setMapping(this, i);
const QByteArray signalName = '2' + property.notifySignal().methodSignature();
QObject::connect(this, signalName, mapper, SLOT(map()));
QObject::connect(mapper, SIGNAL(mapped(int)), this, SLOT(onPropertyUpdated(int)));
}
}
void QQuickMapboxGLMapParameter::onPropertyUpdated(int index)
{
emit propertyUpdated(metaObject()->property(index).name());
}
|