11#include <private/qqmldebugservice_p.h>
12#include <private/qqmlproperty_p.h>
13#include <private/qqmlvaluetype_p.h>
15#include <QtCore/qmetaobject.h>
16#include <QtCore/qdebug.h>
45 QMetaProperty m_property;
47 QQmlExpression *m_expr;
58 QObject::connect(m_expr, &QQmlExpression::valueChanged,
59 this, &QQmlWatchProxy::notifyValueChanged);
62QQmlWatchProxy::QQmlWatchProxy(
int id, QObject *object,
int debugId,
const QMetaProperty &prop,
72 static int refreshIdx = -1;
74 refreshIdx = QQmlWatchProxy::staticMetaObject.indexOfMethod(
"notifyValueChanged()");
76 if (prop.hasNotifySignal())
77 QQmlPropertyPrivate::connect(m_object, prop.notifySignalIndex(),
this, refreshIdx);
84 v = m_expr->evaluate();
86 v = m_property.read(m_object);
87 emit m_watch->propertyChanged(m_id, m_debugId, m_property, v);
98 QObject *object = QQmlDebugService::objectForId(debugId);
100 int propCount = object->metaObject()->propertyCount();
101 for (
int ii=0; ii<propCount; ii++)
102 addPropertyWatch(id, object, debugId, object->metaObject()->property(ii));
110 QObject *object = QQmlDebugService::objectForId(debugId);
112 int index = object->metaObject()->indexOfProperty(property.constData());
114 addPropertyWatch(id, object, debugId, object->metaObject()->property(index));
121bool QQmlWatcher::addWatch(
int id, quint32 objectId,
const QString &expr)
123 QObject *object = QQmlDebugService::objectForId(objectId);
124 QQmlContext *context = qmlContext(object);
126 QQmlExpression *exprObj =
new QQmlExpression(context, object, expr);
127 exprObj->setNotifyOnValueChanged(
true);
129 exprObj->setParent(proxy);
130 m_proxies[id].append(proxy);
131 proxy->notifyValueChanged();
139 if (!m_proxies.contains(id))
142 QList<QPointer<QQmlWatchProxy> > proxies = m_proxies.take(id);
147void QQmlWatcher::addPropertyWatch(
int id, QObject *object, quint32 debugId,
const QMetaProperty &property)
150 m_proxies[id].append(proxy);
152 proxy->notifyValueChanged();
157#include <qqmlwatcher.moc>
159#include "moc_qqmlwatcher.cpp"
QQmlWatchProxy(int id, QQmlExpression *exp, int debugId, QQmlWatcher *parent=nullptr)
bool addWatch(int id, quint32 objectId)
bool addWatch(int id, quint32 objectId, const QByteArray &property)
Combined button and popup list for selecting options.