2015-09-08 21:52:34 +00:00
|
|
|
#include "IntPropertyBind.h"
|
|
|
|
|
|
|
|
#include "MainModelerWindow.h"
|
|
|
|
#include "IntNode.h"
|
|
|
|
#include "Logs.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
IntPropertyBind::IntPropertyBind(MainModelerWindow *window, const QString &object_name, const QString &property_name,
|
|
|
|
IntNode *node)
|
|
|
|
: QObject(window), node(node), property(property_name) {
|
2015-09-08 21:52:34 +00:00
|
|
|
item = window->findQmlObject(object_name);
|
2015-11-09 21:30:46 +00:00
|
|
|
if (item) {
|
2015-09-08 21:52:34 +00:00
|
|
|
node->addWatcher(this, true);
|
|
|
|
connect(item, SIGNAL(changed(int)), this, SLOT(propertyChanged(int)));
|
2015-11-09 21:30:46 +00:00
|
|
|
} else {
|
2015-09-08 21:52:34 +00:00
|
|
|
item = NULL;
|
2015-12-13 19:08:38 +00:00
|
|
|
Logs::error("UI") << "Can't find object :" << object_name.toStdString() << endl;
|
2015-09-08 21:52:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void IntPropertyBind::nodeChanged(const DefinitionNode *, const DefinitionDiff *) {
|
|
|
|
if (item) {
|
2015-09-08 21:52:34 +00:00
|
|
|
item->setProperty(property.toLocal8Bit(), node->getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void IntPropertyBind::propertyChanged(int value) {
|
|
|
|
if (value != node->getValue()) {
|
2015-09-08 21:52:34 +00:00
|
|
|
node->setValue(value);
|
|
|
|
}
|
|
|
|
}
|