aboutsummaryrefslogtreecommitdiff
path: root/src/qt/monitoreddatamapper.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-06-11 22:11:58 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-06-11 22:11:58 +0200
commitba4081c1fcaddf361abd61b2721994eff5475bb3 (patch)
tree8667eac9e13bde9d006407b55b73bacc830f46e6 /src/qt/monitoreddatamapper.cpp
parent5813089e0b5ab9cff50192f0068d256eb2602316 (diff)
move back to original directory structure
Diffstat (limited to 'src/qt/monitoreddatamapper.cpp')
-rw-r--r--src/qt/monitoreddatamapper.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/qt/monitoreddatamapper.cpp b/src/qt/monitoreddatamapper.cpp
new file mode 100644
index 0000000000..e70aa7ebf6
--- /dev/null
+++ b/src/qt/monitoreddatamapper.cpp
@@ -0,0 +1,39 @@
+#include "monitoreddatamapper.h"
+
+#include <QWidget>
+#include <QMetaObject>
+#include <QMetaProperty>
+#include <QDebug>
+
+
+MonitoredDataMapper::MonitoredDataMapper(QObject *parent) :
+ QDataWidgetMapper(parent)
+{
+}
+
+
+void MonitoredDataMapper::addMapping(QWidget *widget, int section)
+{
+ QDataWidgetMapper::addMapping(widget, section);
+ addChangeMonitor(widget);
+}
+
+void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName)
+{
+ QDataWidgetMapper::addMapping(widget, section, propertyName);
+ addChangeMonitor(widget);
+}
+
+void MonitoredDataMapper::addChangeMonitor(QWidget *widget)
+{
+ /* Watch user property of widget for changes, and connect
+ the signal to our viewModified signal.
+ */
+ QMetaProperty prop = widget->metaObject()->userProperty();
+ int signal = prop.notifySignalIndex();
+ int method = this->metaObject()->indexOfMethod("viewModified()");
+ if(signal != -1 && method != -1)
+ {
+ QMetaObject::connect(widget, signal, this, method);
+ }
+}