2013-11-04 16:20:43 +01:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2011-06-01 14:40:06 +02:00
|
|
|
#include "monitoreddatamapper.h"
|
|
|
|
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QMetaProperty>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QWidget>
|
2011-06-01 14:40:06 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2011-06-18 11:53:25 +02:00
|
|
|
// Watch user property of widget for changes, and connect
|
|
|
|
// the signal to our viewModified signal.
|
2011-06-01 14:40:06 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|