paysages3d/src/interface/modeler/quickapp/IntPropertyBind.cpp

31 lines
941 B
C++
Raw Normal View History

#include "IntPropertyBind.h"
#include "MainModelerWindow.h"
#include "IntNode.h"
#include "Logs.h"
IntPropertyBind::IntPropertyBind(MainModelerWindow *window, const QString &object_name, const QString &property_name,
IntNode *node)
: QObject(window), node(node), property(property_name) {
item = window->findQmlObject(object_name);
if (item) {
node->addWatcher(this, true);
connect(item, SIGNAL(changed(int)), this, SLOT(propertyChanged(int)));
} else {
item = NULL;
2015-12-10 23:36:50 +00:00
Logs::error() << "Can't find object :" << object_name.toStdString() << endl;
}
}
void IntPropertyBind::nodeChanged(const DefinitionNode *, const DefinitionDiff *) {
if (item) {
item->setProperty(property.toLocal8Bit(), node->getValue());
}
}
void IntPropertyBind::propertyChanged(int value) {
if (value != node->getValue()) {
node->setValue(value);
}
}