Browse Source

qt: remove monitoreddatamapper

We haven't used the viewModified signal in ages, so we can use a normal
QDataWidgetMapper.
pull/1/head
Wladimir J. van der Laan 8 years ago
parent
commit
d2833de424
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 3
      src/Makefile.qt.include
  2. 39
      src/qt/monitoreddatamapper.cpp
  3. 34
      src/qt/monitoreddatamapper.h
  4. 4
      src/qt/optionsdialog.cpp
  5. 4
      src/qt/optionsdialog.h

3
src/Makefile.qt.include

@ -110,7 +110,6 @@ QT_MOC_CPP = \ @@ -110,7 +110,6 @@ QT_MOC_CPP = \
qt/moc_intro.cpp \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
qt/moc_monitoreddatamapper.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
qt/moc_optionsdialog.cpp \
@ -177,7 +176,6 @@ BITCOIN_QT_H = \ @@ -177,7 +176,6 @@ BITCOIN_QT_H = \
qt/intro.h \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/monitoreddatamapper.h \
qt/networkstyle.h \
qt/notificator.h \
qt/openuridialog.h \
@ -269,7 +267,6 @@ BITCOIN_QT_CPP = \ @@ -269,7 +267,6 @@ BITCOIN_QT_CPP = \
qt/csvmodelwriter.cpp \
qt/guiutil.cpp \
qt/intro.cpp \
qt/monitoreddatamapper.cpp \
qt/networkstyle.cpp \
qt/notificator.cpp \
qt/optionsdialog.cpp \

39
src/qt/monitoreddatamapper.cpp

@ -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);
}
}

34
src/qt/monitoreddatamapper.h

@ -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

4
src/qt/optionsdialog.cpp

@ -11,7 +11,6 @@ @@ -11,7 +11,6 @@
#include "bitcoinunits.h"
#include "guiutil.h"
#include "monitoreddatamapper.h"
#include "optionsmodel.h"
#include "main.h" // for MAX_SCRIPTCHECK_THREADS
@ -24,6 +23,7 @@ @@ -24,6 +23,7 @@
#include <boost/thread.hpp>
#include <QDataWidgetMapper>
#include <QDir>
#include <QIntValidator>
#include <QLocale>
@ -105,7 +105,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) : @@ -105,7 +105,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
#endif
/* Widget-to-option mapper */
mapper = new MonitoredDataMapper(this);
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
mapper->setOrientation(Qt::Vertical);

4
src/qt/optionsdialog.h

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
#include <QDialog>
class MonitoredDataMapper;
class QDataWidgetMapper;
class OptionsModel;
class QValidatedLineEdit;
@ -52,7 +52,7 @@ signals: @@ -52,7 +52,7 @@ signals:
private:
Ui::OptionsDialog *ui;
OptionsModel *model;
MonitoredDataMapper *mapper;
QDataWidgetMapper *mapper;
bool fProxyIpValid;
};

Loading…
Cancel
Save