From 0689f46cc7f0939c0b52560954a3a210cbad053a Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sat, 16 Nov 2013 17:37:31 +0100 Subject: [PATCH] Coincontrol cleanup (e.g. add missing license) - add missing license headers - make compatible with Qt5 - enforce header cleanup style - small code style cleanups - rename Coin Control dialog into Coin Control Address Selection - use default font for the windows labels (no monospace) --- src/coincontrol.h | 4 +++ src/qt/coincontroldialog.cpp | 18 ++++++++--- src/qt/coincontroldialog.h | 4 +++ src/qt/coincontroltreewidget.cpp | 4 +++ src/qt/coincontroltreewidget.h | 11 +++++-- src/qt/forms/coincontroldialog.ui | 53 +------------------------------ src/qt/forms/optionsdialog.ui | 2 +- src/qt/optionsmodel.cpp | 10 ++---- src/qt/optionsmodel.h | 28 ++++++++-------- src/qt/sendcoinsdialog.cpp | 7 ++-- src/qt/sendcoinsentry.cpp | 1 - src/qt/walletmodel.h | 23 +++++++------- src/wallet.cpp | 2 +- src/wallet.h | 10 +++--- 14 files changed, 72 insertions(+), 105 deletions(-) diff --git a/src/coincontrol.h b/src/coincontrol.h index 0164bf1f84..97c30c2713 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -1,3 +1,7 @@ +// 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 COINCONTROL_H #define COINCONTROL_H diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 58f5113453..4ecc040bfb 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -1,19 +1,23 @@ +// 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 "coincontroldialog.h" #include "ui_coincontroldialog.h" -#include "init.h" -#include "bitcoinunits.h" -#include "walletmodel.h" #include "addresstablemodel.h" -#include "optionsmodel.h" +#include "bitcoinunits.h" #include "guiutil.h" +#include "init.h" +#include "optionsmodel.h" +#include "walletmodel.h" + #include "coincontrol.h" #include "main.h" #include "wallet.h" #include #include -#include #include #include #include @@ -98,7 +102,11 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int))); // click on header +#if QT_VERSION < 0x050000 ui->treeWidget->header()->setClickable(true); +#else + ui->treeWidget->header()->setSectionsClickable(true); +#endif connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int))); // ok button diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h index 2674bab4f2..b9318ca7b0 100644 --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -1,3 +1,7 @@ +// 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 COINCONTROLDIALOG_H #define COINCONTROLDIALOG_H diff --git a/src/qt/coincontroltreewidget.cpp b/src/qt/coincontroltreewidget.cpp index aa75a49ae6..907b5caa05 100644 --- a/src/qt/coincontroltreewidget.cpp +++ b/src/qt/coincontroltreewidget.cpp @@ -1,3 +1,7 @@ +// 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 "coincontroltreewidget.h" #include "coincontroldialog.h" diff --git a/src/qt/coincontroltreewidget.h b/src/qt/coincontroltreewidget.h index e55b98af68..a2cd34eb88 100644 --- a/src/qt/coincontroltreewidget.h +++ b/src/qt/coincontroltreewidget.h @@ -1,17 +1,22 @@ +// 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 COINCONTROLTREEWIDGET_H #define COINCONTROLTREEWIDGET_H #include #include -class CoinControlTreeWidget : public QTreeWidget { -Q_OBJECT +class CoinControlTreeWidget : public QTreeWidget +{ + Q_OBJECT public: explicit CoinControlTreeWidget(QWidget *parent = 0); protected: - virtual void keyPressEvent(QKeyEvent *event); + virtual void keyPressEvent(QKeyEvent *event); }; #endif // COINCONTROLTREEWIDGET_H \ No newline at end of file diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui index 58f6557fa5..055dd1f98d 100644 --- a/src/qt/forms/coincontroldialog.ui +++ b/src/qt/forms/coincontroldialog.ui @@ -11,7 +11,7 @@ - Coin Control + Coin Control Address Selection @@ -48,12 +48,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -80,12 +74,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -128,12 +116,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -160,21 +142,12 @@ - - - Monospace - 10 - - IBeamCursor Qt::ActionsContextMenu - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse @@ -208,12 +181,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -246,12 +213,6 @@ false - - - Monospace - 10 - - IBeamCursor @@ -294,12 +255,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -332,12 +287,6 @@ false - - - Monospace - 10 - - IBeamCursor diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 90d720b089..28b629b38c 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -369,7 +369,7 @@ Whether to show coin control features or not. - Display coin &control features (experts only!) + Display coin &control features (experts only) diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index bd08a46803..15a873d2bd 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -292,12 +292,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in case Language: settings.setValue("language", value); break; - case CoinControlFeatures: { + case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); - } - break; + break; default: break; } @@ -312,11 +311,6 @@ qint64 OptionsModel::getTransactionFee() return (qint64) nTransactionFee; } -bool OptionsModel::getCoinControlFeatures() -{ - return fCoinControlFeatures; -} - bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const { std::string proxy = GetArg("-proxy", ""); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index c716f74c0b..5bb563cc36 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -21,19 +21,19 @@ public: explicit OptionsModel(QObject *parent = 0); enum OptionID { - StartAtStartup, // bool - MinimizeToTray, // bool - MapPortUPnP, // bool - MinimizeOnClose, // bool - ProxyUse, // bool - ProxyIP, // QString - ProxyPort, // int - ProxySocksVersion, // int - Fee, // qint64 - DisplayUnit, // BitcoinUnits::Unit - DisplayAddresses, // bool - Language, // QString - CoinControlFeatures, // bool + StartAtStartup, // bool + MinimizeToTray, // bool + MapPortUPnP, // bool + MinimizeOnClose, // bool + ProxyUse, // bool + ProxyIP, // QString + ProxyPort, // int + ProxySocksVersion, // int + Fee, // qint64 + DisplayUnit, // BitcoinUnits::Unit + DisplayAddresses, // bool + Language, // QString + CoinControlFeatures, // bool OptionIDRowCount, }; @@ -55,7 +55,7 @@ public: bool getDisplayAddresses() { return bDisplayAddresses; } QString getLanguage() { return language; } bool getProxySettings(QString& proxyIP, quint16 &proxyPort) const; - bool getCoinControlFeatures(); + bool getCoinControlFeatures() { return fCoinControlFeatures; } private: int nDisplayUnit; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 71a1eb7618..0adf24691e 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -5,17 +5,17 @@ #include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" +#include "addresstablemodel.h" #include "bitcoinunits.h" +#include "coincontroldialog.h" #include "guiutil.h" #include "optionsmodel.h" #include "sendcoinsentry.h" #include "walletmodel.h" -#include "coincontroldialog.h" -#include "addresstablemodel.h" #include "base58.h" -#include "ui_interface.h" #include "coincontrol.h" +#include "ui_interface.h" #include #include @@ -34,7 +34,6 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) : ui->sendButton->setIcon(QIcon()); #endif #if QT_VERSION >= 0x040700 - /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); #endif diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index f6f86eb820..2641a66af4 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -27,7 +27,6 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) : ui->payToLayout->setSpacing(4); #endif #if QT_VERSION >= 0x040700 - /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); ui->payTo->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); #endif diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index f5afe87260..32ddbbc6f6 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -10,22 +10,23 @@ #include "allocators.h" /* for SecureString */ -#include -#include #include +#include + +#include class AddressTableModel; class OptionsModel; class TransactionTableModel; class WalletModelTransaction; -class CKeyID; -class CPubKey; -class COutput; -class COutPoint; -class uint256; -class CCoinControl; +class CCoinControl; +class CKeyID; +class COutPoint; +class COutput; +class CPubKey; class CWallet; +class uint256; QT_BEGIN_NAMESPACE class QTimer; @@ -88,7 +89,7 @@ public: AddressTableModel *getAddressTableModel(); TransactionTableModel *getTransactionTableModel(); - qint64 getBalance(const CCoinControl *coinControl=NULL) const; + qint64 getBalance(const CCoinControl *coinControl = NULL) const; qint64 getUnconfirmedBalance() const; qint64 getImmatureBalance() const; int getNumTransactions() const; @@ -100,13 +101,13 @@ public: // Return status record for SendCoins, contains error id + information struct SendCoinsReturn { - SendCoinsReturn(StatusCode status=Aborted): + SendCoinsReturn(StatusCode status = Aborted): status(status) {} StatusCode status; }; // prepare transaction for getting txfee before sending coins - SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl=NULL); + SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl = NULL); // Send coins to a list of recipients SendCoinsReturn sendCoins(WalletModelTransaction &transaction); diff --git a/src/wallet.cpp b/src/wallet.cpp index 3e684a7879..31dfe18185 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -6,8 +6,8 @@ #include "wallet.h" #include "base58.h" -#include "net.h" #include "coincontrol.h" +#include "net.h" #include #include diff --git a/src/wallet.h b/src/wallet.h index 928ba3de3f..90209122fd 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -24,11 +24,11 @@ #include class CAccountingEntry; +class CCoinControl; class COutput; class CReserveKey; class CScript; class CWalletTx; -class CCoinControl; /** (client) version numbers for particular wallet features */ enum WalletFeature @@ -88,7 +88,7 @@ public: class CWallet : public CCryptoKeyStore, public CWalletInterface { private: - bool SelectCoins(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; + bool SelectCoins(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL) const; CWalletDB *pwalletdbEncryption; @@ -153,7 +153,7 @@ public: // check whether we are allowed to upgrade (or already support) to the named feature bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; } - void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL) const; bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; bool IsLockedCoin(uint256 hash, unsigned int n) const; void LockCoin(COutPoint& output); @@ -213,9 +213,9 @@ public: int64_t GetUnconfirmedBalance() const; int64_t GetImmatureBalance() const; bool CreateTransaction(const std::vector >& vecSend, - CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl=NULL); + CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL); bool CreateTransaction(CScript scriptPubKey, int64_t nValue, - CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl=NULL); + CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false); std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);