Browse Source
We haven't used the viewModified signal in ages, so we can use a normal QDataWidgetMapper.0.10
Wladimir J. van der Laan
10 years ago
5 changed files with 4 additions and 80 deletions
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "monitoreddatamapper.h" |
||||
|
||||
#include <QMetaObject> |
||||
#include <QMetaProperty> |
||||
#include <QWidget> |
||||
|
||||
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); |
||||
} |
||||
} |
@ -1,34 +0,0 @@
@@ -1,34 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#ifndef MONITOREDDATAMAPPER_H |
||||
#define MONITOREDDATAMAPPER_H |
||||
|
||||
#include <QDataWidgetMapper> |
||||
|
||||
QT_BEGIN_NAMESPACE |
||||
class QWidget; |
||||
QT_END_NAMESPACE |
||||
|
||||
/** Data to Widget mapper that watches for edits and notifies listeners when a field is edited.
|
||||
This can be used, for example, to enable a commit/apply button in a configuration dialog. |
||||
*/ |
||||
class MonitoredDataMapper : public QDataWidgetMapper |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit MonitoredDataMapper(QObject *parent=0); |
||||
|
||||
void addMapping(QWidget *widget, int section); |
||||
void addMapping(QWidget *widget, int section, const QByteArray &propertyName); |
||||
|
||||
private: |
||||
void addChangeMonitor(QWidget *widget); |
||||
|
||||
signals: |
||||
void viewModified(); |
||||
}; |
||||
|
||||
#endif // MONITOREDDATAMAPPER_H
|
Loading…
Reference in new issue