Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
monitoreddatamapper.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include "monitoreddatamapper.h"
6 
7 #include <QMetaObject>
8 #include <QMetaProperty>
9 #include <QWidget>
10 
12  QDataWidgetMapper(parent)
13 {
14 }
15 
16 void MonitoredDataMapper::addMapping(QWidget *widget, int section)
17 {
18  QDataWidgetMapper::addMapping(widget, section);
19  addChangeMonitor(widget);
20 }
21 
22 void MonitoredDataMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName)
23 {
24  QDataWidgetMapper::addMapping(widget, section, propertyName);
25  addChangeMonitor(widget);
26 }
27 
29 {
30  // Watch user property of widget for changes, and connect
31  // the signal to our viewModified signal.
32  QMetaProperty prop = widget->metaObject()->userProperty();
33  int signal = prop.notifySignalIndex();
34  int method = this->metaObject()->indexOfMethod("viewModified()");
35  if(signal != -1 && method != -1)
36  {
37  QMetaObject::connect(widget, signal, this, method);
38  }
39 }
void addMapping(QWidget *widget, int section)
MonitoredDataMapper(QObject *parent=0)
void addChangeMonitor(QWidget *widget)