Skip to content

Commit

Permalink
Bitcoin-Qt: massive header and cpp cleanup
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Philip Kaufmann committed Mar 17, 2013
1 parent 1a9ee5d commit 32af526
Show file tree
Hide file tree
Showing 48 changed files with 91 additions and 110 deletions.
8 changes: 4 additions & 4 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#include "csvmodelwriter.h"
#include "guiutil.h"

#ifdef USE_QRCODE
#include "qrcodedialog.h"
#endif

#include <QSortFilterProxyModel>
#include <QClipboard>
#include <QMessageBox>
#include <QMenu>

#ifdef USE_QRCODE
#include "qrcodedialog.h"
#endif

AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
QDialog(parent),
ui(new Ui::AddressBookPage),
Expand Down
2 changes: 1 addition & 1 deletion src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "addresstablemodel.h"

#include "guiutil.h"
#include "walletmodel.h"

#include "wallet.h"
#include "base58.h"

#include <QFont>
#include <QColor>

const QString AddressTableModel::Send = "S";
const QString AddressTableModel::Receive = "R";
Expand Down
1 change: 1 addition & 0 deletions src/qt/addresstablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class WalletModel;
class AddressTableModel : public QAbstractTableModel
{
Q_OBJECT

public:
explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0);
~AddressTableModel();
Expand Down
1 change: 0 additions & 1 deletion src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace Ui {
class AskPassphraseDialog;
}

class WalletModel;

/** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase.
Expand Down
4 changes: 3 additions & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*
* W.J. van der Laan 2011-2012
*/

#include <QApplication>

#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
Expand All @@ -11,7 +14,6 @@
#include "ui_interface.h"
#include "paymentserver.h"

#include <QApplication>
#include <QMessageBox>
#include <QTextCodec>
#include <QLocale>
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<RCC>
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/icons">
<file alias="bitcoin">res/icons/bitcoin.png</file>
<file alias="address-book">res/icons/address-book.png</file>
Expand Down
7 changes: 2 additions & 5 deletions src/qt/bitcoinaddressvalidator.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
#ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H

#include <QRegExpValidator>
#include <QValidator>

/** Base48 entry widget validator.
Corrects near-miss characters and refuses characters that are no part of base48.
*/
class BitcoinAddressValidator : public QValidator
{
Q_OBJECT

public:
explicit BitcoinAddressValidator(QObject *parent = 0);

State validate(QString &input, int &pos) const;

static const int MaxAddressLength = 35;
signals:

public slots:

};

#endif // BITCOINADDRESSVALIDATOR_H
8 changes: 2 additions & 6 deletions src/qt/bitcoinamountfield.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#include "bitcoinamountfield.h"

#include "qvaluecombobox.h"
#include "bitcoinunits.h"

#include "guiconstants.h"

#include <QLabel>
#include <QLineEdit>
#include <QRegExpValidator>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QApplication>
#include <qmath.h>
#include <qmath.h> // for qPow()

BitcoinAmountField::BitcoinAmountField(QWidget *parent):
QWidget(parent), amount(0), currentUnit(-1)
Expand Down
3 changes: 2 additions & 1 deletion src/qt/bitcoinamountfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ QT_END_NAMESPACE
class BitcoinAmountField: public QWidget
{
Q_OBJECT

Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true)

public:
explicit BitcoinAmountField(QWidget *parent = 0);

Expand Down Expand Up @@ -56,5 +58,4 @@ private slots:

};


#endif // BITCOINAMOUNTFIELD_H
11 changes: 5 additions & 6 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
* W.J. van der Laan 2011-2012
* The Bitcoin Developers 2011-2012
*/

#include <QApplication>

#include "bitcoingui.h"

#include "transactiontablemodel.h"
#include "addressbookpage.h"
#include "sendcoinsdialog.h"
Expand All @@ -31,19 +35,13 @@
#include "macdockiconhandler.h"
#endif

#include <QApplication>
#include <QMainWindow>
#include <QMenuBar>
#include <QMenu>
#include <QIcon>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QToolBar>
#include <QStatusBar>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QLocale>
#include <QMessageBox>
#include <QProgressBar>
#include <QStackedWidget>
Expand All @@ -54,6 +52,7 @@
#include <QTimer>
#include <QDragEnterEvent>
#include <QUrl>
#include <QMimeData>
#include <QStyle>

#include <iostream>
Expand Down
5 changes: 1 addition & 4 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ class RPCConsole;

QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QTableView;
class QAbstractItemModel;
class QModelIndex;
class QProgressBar;
class QStackedWidget;
class QUrl;
QT_END_NAMESPACE

/**
Expand All @@ -33,6 +29,7 @@ QT_END_NAMESPACE
class BitcoinGUI : public QMainWindow
{
Q_OBJECT

public:
explicit BitcoinGUI(QWidget *parent = 0);
~BitcoinGUI();
Expand Down
3 changes: 3 additions & 0 deletions src/qt/bitcoinunits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
class BitcoinUnits: public QAbstractListModel
{
Q_OBJECT

public:
explicit BitcoinUnits(QObject *parent);

Expand Down Expand Up @@ -58,6 +60,7 @@ class BitcoinUnits: public QAbstractListModel
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
///@}

private:
QList<BitcoinUnits::Unit> unitlist;
};
Expand Down
1 change: 1 addition & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "clientmodel.h"

#include "guiconstants.h"
#include "optionsmodel.h"
#include "addresstablemodel.h"
Expand Down
2 changes: 2 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum BlockSource {
class ClientModel : public QObject
{
Q_OBJECT

public:
explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0);
~ClientModel();
Expand Down Expand Up @@ -66,6 +67,7 @@ class ClientModel : public QObject

void subscribeToCoreSignals();
void unsubscribeFromCoreSignals();

signals:
void numConnectionsChanged(int count);
void numBlocksChanged(int count, int countOfPeers);
Expand Down
6 changes: 1 addition & 5 deletions src/qt/csvmodelwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ QT_END_NAMESPACE
class CSVModelWriter : public QObject
{
Q_OBJECT

public:
explicit CSVModelWriter(const QString &filename, QObject *parent = 0);

Expand All @@ -36,11 +37,6 @@ class CSVModelWriter : public QObject
int role;
};
QList<Column> columns;

signals:

public slots:

};

#endif // CSVMODELWRITER_H
1 change: 1 addition & 0 deletions src/qt/editaddressdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "editaddressdialog.h"
#include "ui_editaddressdialog.h"

#include "addresstablemodel.h"
#include "guiutil.h"

Expand Down
8 changes: 4 additions & 4 deletions src/qt/editaddressdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

#include <QDialog>

QT_BEGIN_NAMESPACE
class QDataWidgetMapper;
QT_END_NAMESPACE

namespace Ui {
class EditAddressDialog;
}
class AddressTableModel;

QT_BEGIN_NAMESPACE
class QDataWidgetMapper;
QT_END_NAMESPACE

/** Dialog for editing an address and associated information.
*/
class EditAddressDialog : public QDialog
Expand Down
6 changes: 4 additions & 2 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#include <QApplication>

#include "guiutil.h"

#include "bitcoinaddressvalidator.h"
#include "walletmodel.h"
#include "bitcoinunits.h"

#include "util.h"
#include "init.h"

#include <QString>
#include <QDateTime>
#include <QDoubleValidator>
#include <QFont>
#include <QLineEdit>
#include <QUrl>
#include <QTextDocument> // For Qt::escape
#include <QAbstractItemView>
#include <QApplication>
#include <QClipboard>
#include <QFileDialog>
#include <QDesktopServices>
Expand Down
3 changes: 2 additions & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <QObject>
#include <QMessageBox>

class SendCoinsRecipient;

QT_BEGIN_NAMESPACE
class QFont;
class QLineEdit;
Expand All @@ -13,7 +15,6 @@ class QDateTime;
class QUrl;
class QAbstractItemView;
QT_END_NAMESPACE
class SendCoinsRecipient;

/** Utility functions used by the Bitcoin Qt UI.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/qt/macdockiconhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

#include <QObject>

QT_BEGIN_NAMESPACE
class QMenu;
class QIcon;
class QWidget;
QT_END_NAMESPACE

#ifdef __OBJC__
@class DockIconClickEventHandler;
Expand All @@ -18,6 +20,7 @@ class DockIconClickEventHandler;
class MacDockIconHandler : public QObject
{
Q_OBJECT

public:
~MacDockIconHandler();

Expand All @@ -31,8 +34,6 @@ class MacDockIconHandler : public QObject
signals:
void dockIconClicked();

public slots:

private:
MacDockIconHandler();

Expand Down
1 change: 0 additions & 1 deletion src/qt/macdockiconhandler.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "macdockiconhandler.h"

#include <QMenu>
Expand Down
1 change: 0 additions & 1 deletion src/qt/monitoreddatamapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ MonitoredDataMapper::MonitoredDataMapper(QObject *parent) :
{
}


void MonitoredDataMapper::addMapping(QWidget *widget, int section)
{
QDataWidgetMapper::addMapping(widget, section);
Expand Down
5 changes: 2 additions & 3 deletions src/qt/monitoreddatamapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ QT_END_NAMESPACE
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
2 changes: 1 addition & 1 deletion src/qt/notificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <QImageWriter>

#ifdef USE_DBUS
#include <QtDBus/QtDBus>
#include <QtDBus>
#include <stdint.h>
#endif

Expand Down
Loading

0 comments on commit 32af526

Please sign in to comment.