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)
This commit is contained in:
Philip Kaufmann 2013-11-16 17:37:31 +01:00
parent af6e093f06
commit 0689f46cc7
14 changed files with 72 additions and 105 deletions

View File

@ -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 #ifndef COINCONTROL_H
#define COINCONTROL_H #define COINCONTROL_H

View File

@ -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 "coincontroldialog.h"
#include "ui_coincontroldialog.h" #include "ui_coincontroldialog.h"
#include "init.h"
#include "bitcoinunits.h"
#include "walletmodel.h"
#include "addresstablemodel.h" #include "addresstablemodel.h"
#include "optionsmodel.h" #include "bitcoinunits.h"
#include "guiutil.h" #include "guiutil.h"
#include "init.h"
#include "optionsmodel.h"
#include "walletmodel.h"
#include "coincontrol.h" #include "coincontrol.h"
#include "main.h" #include "main.h"
#include "wallet.h" #include "wallet.h"
#include <QApplication> #include <QApplication>
#include <QCheckBox> #include <QCheckBox>
#include <QClipboard>
#include <QColor> #include <QColor>
#include <QCursor> #include <QCursor>
#include <QDateTime> #include <QDateTime>
@ -98,7 +102,11 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int))); connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int)));
// click on header // click on header
#if QT_VERSION < 0x050000
ui->treeWidget->header()->setClickable(true); ui->treeWidget->header()->setClickable(true);
#else
ui->treeWidget->header()->setSectionsClickable(true);
#endif
connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int))); connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int)));
// ok button // ok button

View File

@ -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 #ifndef COINCONTROLDIALOG_H
#define COINCONTROLDIALOG_H #define COINCONTROLDIALOG_H

View File

@ -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 "coincontroltreewidget.h"
#include "coincontroldialog.h" #include "coincontroldialog.h"

View File

@ -1,11 +1,16 @@
// 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 #ifndef COINCONTROLTREEWIDGET_H
#define COINCONTROLTREEWIDGET_H #define COINCONTROLTREEWIDGET_H
#include <QKeyEvent> #include <QKeyEvent>
#include <QTreeWidget> #include <QTreeWidget>
class CoinControlTreeWidget : public QTreeWidget { class CoinControlTreeWidget : public QTreeWidget
Q_OBJECT {
Q_OBJECT
public: public:
explicit CoinControlTreeWidget(QWidget *parent = 0); explicit CoinControlTreeWidget(QWidget *parent = 0);

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Coin Control</string> <string>Coin Control Address Selection</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
@ -48,12 +48,6 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="labelCoinControlQuantity"> <widget class="QLabel" name="labelCoinControlQuantity">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
@ -80,12 +74,6 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="labelCoinControlBytes"> <widget class="QLabel" name="labelCoinControlBytes">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
@ -128,12 +116,6 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="labelCoinControlAmount"> <widget class="QLabel" name="labelCoinControlAmount">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
@ -160,21 +142,12 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="labelCoinControlPriority"> <widget class="QLabel" name="labelCoinControlPriority">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum> <enum>Qt::ActionsContextMenu</enum>
</property> </property>
<property name="text">
<string/>
</property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property> </property>
@ -208,12 +181,6 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="labelCoinControlFee"> <widget class="QLabel" name="labelCoinControlFee">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
@ -246,12 +213,6 @@
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
@ -294,12 +255,6 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="labelCoinControlAfterFee"> <widget class="QLabel" name="labelCoinControlAfterFee">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>
@ -332,12 +287,6 @@
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
</property> </property>

View File

@ -369,7 +369,7 @@
<string>Whether to show coin control features or not.</string> <string>Whether to show coin control features or not.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Display coin &amp;control features (experts only!)</string> <string>Display coin &amp;control features (experts only)</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -292,11 +292,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
case Language: case Language:
settings.setValue("language", value); settings.setValue("language", value);
break; break;
case CoinControlFeatures: { case CoinControlFeatures:
fCoinControlFeatures = value.toBool(); fCoinControlFeatures = value.toBool();
settings.setValue("fCoinControlFeatures", fCoinControlFeatures); settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
emit coinControlFeaturesChanged(fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures);
}
break; break;
default: default:
break; break;
@ -312,11 +311,6 @@ qint64 OptionsModel::getTransactionFee()
return (qint64) nTransactionFee; return (qint64) nTransactionFee;
} }
bool OptionsModel::getCoinControlFeatures()
{
return fCoinControlFeatures;
}
bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const
{ {
std::string proxy = GetArg("-proxy", ""); std::string proxy = GetArg("-proxy", "");

View File

@ -55,7 +55,7 @@ public:
bool getDisplayAddresses() { return bDisplayAddresses; } bool getDisplayAddresses() { return bDisplayAddresses; }
QString getLanguage() { return language; } QString getLanguage() { return language; }
bool getProxySettings(QString& proxyIP, quint16 &proxyPort) const; bool getProxySettings(QString& proxyIP, quint16 &proxyPort) const;
bool getCoinControlFeatures(); bool getCoinControlFeatures() { return fCoinControlFeatures; }
private: private:
int nDisplayUnit; int nDisplayUnit;

View File

@ -5,17 +5,17 @@
#include "sendcoinsdialog.h" #include "sendcoinsdialog.h"
#include "ui_sendcoinsdialog.h" #include "ui_sendcoinsdialog.h"
#include "addresstablemodel.h"
#include "bitcoinunits.h" #include "bitcoinunits.h"
#include "coincontroldialog.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "sendcoinsentry.h" #include "sendcoinsentry.h"
#include "walletmodel.h" #include "walletmodel.h"
#include "coincontroldialog.h"
#include "addresstablemodel.h"
#include "base58.h" #include "base58.h"
#include "ui_interface.h"
#include "coincontrol.h" #include "coincontrol.h"
#include "ui_interface.h"
#include <QMessageBox> #include <QMessageBox>
#include <QScrollBar> #include <QScrollBar>
@ -34,7 +34,6 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
ui->sendButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon());
#endif #endif
#if QT_VERSION >= 0x040700 #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)")); ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
#endif #endif

View File

@ -27,7 +27,6 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) :
ui->payToLayout->setSpacing(4); ui->payToLayout->setSpacing(4);
#endif #endif
#if QT_VERSION >= 0x040700 #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->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)")); ui->payTo->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
#endif #endif

View File

@ -10,22 +10,23 @@
#include "allocators.h" /* for SecureString */ #include "allocators.h" /* for SecureString */
#include <QObject>
#include <vector>
#include <map> #include <map>
#include <vector>
#include <QObject>
class AddressTableModel; class AddressTableModel;
class OptionsModel; class OptionsModel;
class TransactionTableModel; class TransactionTableModel;
class WalletModelTransaction; 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 CWallet;
class uint256;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTimer; class QTimer;
@ -88,7 +89,7 @@ public:
AddressTableModel *getAddressTableModel(); AddressTableModel *getAddressTableModel();
TransactionTableModel *getTransactionTableModel(); TransactionTableModel *getTransactionTableModel();
qint64 getBalance(const CCoinControl *coinControl=NULL) const; qint64 getBalance(const CCoinControl *coinControl = NULL) const;
qint64 getUnconfirmedBalance() const; qint64 getUnconfirmedBalance() const;
qint64 getImmatureBalance() const; qint64 getImmatureBalance() const;
int getNumTransactions() const; int getNumTransactions() const;
@ -100,13 +101,13 @@ public:
// Return status record for SendCoins, contains error id + information // Return status record for SendCoins, contains error id + information
struct SendCoinsReturn struct SendCoinsReturn
{ {
SendCoinsReturn(StatusCode status=Aborted): SendCoinsReturn(StatusCode status = Aborted):
status(status) {} status(status) {}
StatusCode status; StatusCode status;
}; };
// prepare transaction for getting txfee before sending coins // 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 // Send coins to a list of recipients
SendCoinsReturn sendCoins(WalletModelTransaction &transaction); SendCoinsReturn sendCoins(WalletModelTransaction &transaction);

View File

@ -6,8 +6,8 @@
#include "wallet.h" #include "wallet.h"
#include "base58.h" #include "base58.h"
#include "net.h"
#include "coincontrol.h" #include "coincontrol.h"
#include "net.h"
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h> #include <stdint.h>

View File

@ -24,11 +24,11 @@
#include <vector> #include <vector>
class CAccountingEntry; class CAccountingEntry;
class CCoinControl;
class COutput; class COutput;
class CReserveKey; class CReserveKey;
class CScript; class CScript;
class CWalletTx; class CWalletTx;
class CCoinControl;
/** (client) version numbers for particular wallet features */ /** (client) version numbers for particular wallet features */
enum WalletFeature enum WalletFeature
@ -88,7 +88,7 @@ public:
class CWallet : public CCryptoKeyStore, public CWalletInterface class CWallet : public CCryptoKeyStore, public CWalletInterface
{ {
private: private:
bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const; bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL) const;
CWalletDB *pwalletdbEncryption; CWalletDB *pwalletdbEncryption;
@ -153,7 +153,7 @@ public:
// check whether we are allowed to upgrade (or already support) to the named feature // check whether we are allowed to upgrade (or already support) to the named feature
bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; } bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; }
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const; void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL) const;
bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const; bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
bool IsLockedCoin(uint256 hash, unsigned int n) const; bool IsLockedCoin(uint256 hash, unsigned int n) const;
void LockCoin(COutPoint& output); void LockCoin(COutPoint& output);
@ -213,9 +213,9 @@ public:
int64_t GetUnconfirmedBalance() const; int64_t GetUnconfirmedBalance() const;
int64_t GetImmatureBalance() const; int64_t GetImmatureBalance() const;
bool CreateTransaction(const std::vector<std::pair<CScript, int64_t> >& vecSend, bool CreateTransaction(const std::vector<std::pair<CScript, int64_t> >& 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, 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); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false); 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); std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);