lbrycrd/src/qt/monitoreddatamapper.cpp
Philip Kaufmann 32af5266cf Bitcoin-Qt: massive header and cpp cleanup
- try to enforce the same style to all Qt related files
- remove unneeded includes from the files
- add missing Q_OBJECT, QT_BEGIN_NAMESPACE / QT_END_NAMESPACE
- prepares for a pull-req to include Qt5 compatibility
2013-03-17 18:28:00 +01:00

35 lines
1,009 B
C++

#include "monitoreddatamapper.h"
#include <QWidget>
#include <QMetaObject>
#include <QMetaProperty>
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);
}
}