Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool SharedProperties::addObject(const QString &key, QObject *object, const QByteArray &propertyName)
- {
- Q_D(SharedProperties);
- QString longKey = ::longKey(d->group, key);
- const QMetaObject *metaObject = object->metaObject();
- int propertyId = metaObject->indexOfProperty(propertyName.constData());
- if (propertyId == -1) {
- qWarning() << "SharedProperties::addObject :" << "Object" << object << "doesn't have property" << propertyName;
- return false;
- }
- Property propertyKey(object, propertyId);
- d->mapKeyToProperty.insert(longKey, propertyKey);
- QMetaProperty metaProperty = metaObject->property(propertyId);
- metaProperty.write(object, value(longKey));
- int notifierId = metaProperty.notifySignalIndex();
- if (notifierId == -1) {
- qWarning() << "SharedProperties::addObject :" << "Property" << propertyName << "doesn't have notifier signal";
- return false;
- }
- Notifier notifierKey(object, notifierId);
- d->mapNotifierToKey.insert(notifierKey, longKey);
- QMetaMethod notifierMethod = metaObject->method(notifierId);
- const QMetaObject *thisMetaObject = this->metaObject();
- int handlerId = thisMetaObject->indexOfSlot(OnValueChangedSlot);
- QMetaMethod handlerMethod = thisMetaObject->method(handlerId);
- connect(object, notifierMethod, this, handlerMethod);
- return true;
- }
Add Comment
Please, Sign In to add comment