9 : QObject(parent), m_value(false)
18 qmlRegisterType<ZAndGate>(
"org.zuble.qml", 1, 0,
"ZAndGate");
28 const QString& propertyName,
29 const QString& signalName)
37 QString message =
ptrStr(targetObject);
43 if(signalName.isEmpty())
44 sigName = QString(
"%1Changed()").arg(propertyName);
52 QByteArray normalSig = QMetaObject::normalizedSignature(sigName.toUtf8().constData());
58 const QMetaObject *mo = targetObject->metaObject();
60 int sigIndex = mo->indexOfSignal(QMetaObject::normalizedSignature(sigName.toUtf8().constData()));
64 QMetaMethod metaSignal = mo->method(sigIndex);
66 int slotIndex = metaObject()->indexOfSlot(
"onPropChanged()");
70 QMetaMethod metaSlot = metaObject()->method(slotIndex);
74 m_props.insertMulti(targetObject,
proxy(propertyName,targetObject->property(propertyName.toUtf8().constData()).toBool()));
78 connect(targetObject, metaSignal,
this, metaSlot);
87 qDebug(
"ZAndGate ==> Oops! removeInputProperty not implemented! Sorry.");
111 QObject* targetObj = sender();
113 QString message =
ptrStr(targetObj);
114 QString strThis =
ptrStr(
this);
119 bool valueChanged =
false;
120 bool foundObject =
false;
128 proxy next = i.value();
130 if(i.key() != targetObj)
142 if(next.second != nextValue)
149 i.setValue(
proxy(next.first,nextValue));
182 retValue = targetObj->property(
cStr(name));
186 QMetaObject::invokeMethod(targetObj,
"property",
187 Qt::BlockingQueuedConnection,
188 Q_RETURN_ARG(QVariant, retValue),
189 Q_ARG(
const QString&,name));
206 proxy next = i.value();
propMap m_props
A map of object property proxies, by object pointer. Each proxy identifies one property. Multiple proxies may exist per input object.
QMutableMapIterator< QObject *, proxy > propIterator
iterator for object/propertyName/value triplet maps
static void registerType()
Registers ZAndGate as a QML type.
Q_INVOKABLE void removeAllProperties()
Removes all properties from the watched properties list.
Q_INVOKABLE bool removeInputProperty(QObject *targetObject, const QString &propertyName)
Removes a property from the watched properties list.
bool m_value
Current output value of the AND gate. True if all input properties are true, false otherwise...
#define ZBL_SLOT_BEGIN_TRY
ZAndGate(QObject *parent=nullptr)
QPair< QString, bool > proxy
propertyName/value
bool inObjectThread(const QObject &object)
QVariant waitGetProperty(QObject *targetObj, const QString &name)
#define ZBL_SLOT_END_RETURN(return_success, return_failed, facility, code, error_message)
Q_INVOKABLE bool addInputProperty(QObject *targetObject, const QString &propertyName, const QString &signalName=QString())
Adds a property to the watched properties list.