diff options
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoinunits.cpp | 5 | ||||
-rw-r--r-- | src/qt/coincontroldialog.cpp | 4 | ||||
-rw-r--r-- | src/qt/overviewpage.cpp | 2 | ||||
-rw-r--r-- | src/qt/paymentserver.cpp | 8 | ||||
-rw-r--r-- | src/qt/recentrequeststablemodel.h | 12 | ||||
-rw-r--r-- | src/qt/test/paymentrequestdata.h | 4 | ||||
-rw-r--r-- | src/qt/test/paymentservertests.cpp | 9 | ||||
-rw-r--r-- | src/qt/test/paymentservertests.h | 8 | ||||
-rw-r--r-- | src/qt/test/test_main.cpp | 7 | ||||
-rw-r--r-- | src/qt/test/uritests.cpp | 4 | ||||
-rw-r--r-- | src/qt/test/uritests.h | 4 | ||||
-rw-r--r-- | src/qt/transactiondesc.cpp | 2 | ||||
-rw-r--r-- | src/qt/transactionrecord.cpp | 2 | ||||
-rw-r--r-- | src/qt/transactiontablemodel.cpp | 14 | ||||
-rw-r--r-- | src/qt/transactionview.cpp | 2 | ||||
-rw-r--r-- | src/qt/walletmodel.cpp | 20 | ||||
-rw-r--r-- | src/qt/walletmodel.h | 37 |
17 files changed, 85 insertions, 59 deletions
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 6f506d3f25..3215363fa0 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -115,11 +115,6 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus, SeparatorStyle sepa for (int i = 3; i < q_size; i += 3) quotient_str.insert(q_size - i, thin_sp); - int r_size = remainder_str.size(); - if (separators == separatorAlways || (separators == separatorStandard && r_size > 4)) - for (int i = 3, adj = 0; i < r_size ; i += 3, adj++) - remainder_str.insert(i + adj, thin_sp); - if (n < 0) quotient_str.insert(0, '-'); else if (fPlus && n > 0) diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 7b30f8de09..d10463fd8f 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -705,7 +705,7 @@ void CoinControlDialog::updateView() QString sAddress = ""; if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress)) { - sAddress = CBitcoinAddress(outputAddress).ToString().c_str(); + sAddress = QString::fromStdString(CBitcoinAddress(outputAddress).ToString()); // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs if (!treeMode || (!(sAddress == sWalletAddress))) @@ -752,7 +752,7 @@ void CoinControlDialog::updateView() // transaction hash uint256 txhash = out.tx->GetHash(); - itemOutput->setText(COLUMN_TXHASH, txhash.GetHex().c_str()); + itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex())); // vout index itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 15501b8a8a..90762bea5d 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -172,7 +172,7 @@ void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 // for symmetry reasons also show immature label when the watch-only one is shown ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature); ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature); - ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance + ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance } // show/hide watch-only labels diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index f6a4b599de..219a685faf 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -10,6 +10,7 @@ #include "optionsmodel.h" #include "base58.h" +#include "chainparams.h" #include "ui_interface.h" #include "util.h" #include "wallet.h" @@ -200,8 +201,11 @@ bool PaymentServer::ipcParseCommandLine(int argc, char* argv[]) { CBitcoinAddress address(r.address.toStdString()); - SelectParams(CBaseChainParams::MAIN); - if (!address.IsValid()) + if (address.IsValid(Params(CBaseChainParams::MAIN))) + { + SelectParams(CBaseChainParams::MAIN); + } + else if (address.IsValid(Params(CBaseChainParams::TESTNET))) { SelectParams(CBaseChainParams::TESTNET); } diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h index a558aa4942..3df5971823 100644 --- a/src/qt/recentrequeststablemodel.h +++ b/src/qt/recentrequeststablemodel.h @@ -24,23 +24,19 @@ public: QDateTime date; SendCoinsRecipient recipient; - IMPLEMENT_SERIALIZE; + ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { - bool fRead = ser_action.ForRead(); - - RecentRequestEntry* pthis = const_cast<RecentRequestEntry*>(this); - unsigned int nDate = date.toTime_t(); - READWRITE(pthis->nVersion); - nVersion = pthis->nVersion; + READWRITE(this->nVersion); + nVersion = this->nVersion; READWRITE(id); READWRITE(nDate); READWRITE(recipient); - if (fRead) + if (ser_action.ForRead()) date = QDateTime::fromTime_t(nDate); } }; diff --git a/src/qt/test/paymentrequestdata.h b/src/qt/test/paymentrequestdata.h index 49558165f0..aeaa7d89a0 100644 --- a/src/qt/test/paymentrequestdata.h +++ b/src/qt/test/paymentrequestdata.h @@ -1,3 +1,7 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + // // Data for paymentservertests.cpp // diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp index e92a7d2b1a..5d7fe96285 100644 --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include "paymentservertests.h" #include "optionsmodel.h" @@ -21,7 +25,6 @@ X509 *parse_b64der_cert(const char* cert_data) return cert; } - // // Test payment request handling // @@ -30,7 +33,7 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig { RecipientCatcher sigCatcher; QObject::connect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), - &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); + &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); // Write data to a temp file: QTemporaryFile f; @@ -48,7 +51,7 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig QCoreApplication::sendEvent(&object, &event); QObject::disconnect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), - &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); + &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); // Return results from sigCatcher return sigCatcher.recipient; diff --git a/src/qt/test/paymentservertests.h b/src/qt/test/paymentservertests.h index 884e535a60..9b6400b0d5 100644 --- a/src/qt/test/paymentservertests.h +++ b/src/qt/test/paymentservertests.h @@ -1,3 +1,7 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef PAYMENTSERVERTESTS_H #define PAYMENTSERVERTESTS_H @@ -15,8 +19,8 @@ private slots: }; // Dummy class to receive paymentserver signals. -// If SendCoinsRecipient was a proper QObject, then we could use -// QSignalSpy... but it's not. +// If SendCoinsRecipient was a proper QObject, then +// we could use QSignalSpy... but it's not. class RecipientCatcher : public QObject { Q_OBJECT diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 03a2381c06..f2161c2f79 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -1,11 +1,16 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" #endif +#include "uritests.h" + #ifdef ENABLE_WALLET #include "paymentservertests.h" #endif -#include "uritests.h" #include <QCoreApplication> #include <QObject> diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp index 5c0f4406a7..78a7b1b9b4 100644 --- a/src/qt/test/uritests.cpp +++ b/src/qt/test/uritests.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include "uritests.h" #include "guiutil.h" diff --git a/src/qt/test/uritests.h b/src/qt/test/uritests.h index 17d4280a90..1ea6d9f075 100644 --- a/src/qt/test/uritests.h +++ b/src/qt/test/uritests.h @@ -1,3 +1,7 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef URITESTS_H #define URITESTS_H diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 8258e719a3..727b8dc66d 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -11,7 +11,7 @@ #include "db.h" #include "main.h" #include "paymentserver.h" -#include "script.h" +#include "script/script.h" #include "transactionrecord.h" #include "timedata.h" #include "ui_interface.h" diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index d7bd25e08b..20c1449c92 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -170,7 +170,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) // Find the block the tx is in CBlockIndex* pindex = NULL; - std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(wtx.hashBlock); + BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock); if (mi != mapBlockIndex.end()) pindex = (*mi).second; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 1a1f726bf8..734c7afc4e 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -394,19 +394,25 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const { + QString watchAddress; + if (tooltip) { + // Mark transactions involving watch-only addresses by adding " (watch-only)" + watchAddress = wtx->involvesWatchAddress ? QString(" (") + tr("watch-only") + QString(")") : ""; + } + switch(wtx->type) { case TransactionRecord::RecvFromOther: - return QString::fromStdString(wtx->address); + return QString::fromStdString(wtx->address) + watchAddress; case TransactionRecord::RecvWithAddress: case TransactionRecord::SendToAddress: case TransactionRecord::Generated: - return lookupAddress(wtx->address, tooltip); + return lookupAddress(wtx->address, tooltip) + watchAddress; case TransactionRecord::SendToOther: - return QString::fromStdString(wtx->address); + return QString::fromStdString(wtx->address) + watchAddress; case TransactionRecord::SendToSelf: default: - return tr("(n/a)"); + return tr("(n/a)") + watchAddress; } } diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 2d34d58129..a7ba100cd2 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -331,7 +331,7 @@ void TransactionView::exportClicked() writer.setModel(transactionProxyModel); writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); if (model && model->haveWatchOnly()) - writer.addColumn(tr("Watchonly"), TransactionTableModel::Watchonly); + writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly); writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 92c22f5692..8d2c2e96d8 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -36,6 +36,7 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p { fProcessingQueuedTransactions = false; fHaveWatchOnly = wallet->HaveWatchOnly(); + fForceCheckBalanceChanged = false; addressTableModel = new AddressTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); @@ -121,8 +122,10 @@ void WalletModel::pollBalanceChanged() if(!lockWallet) return; - if(chainActive.Height() != cachedNumBlocks) + if(fForceCheckBalanceChanged || chainActive.Height() != cachedNumBlocks) { + fForceCheckBalanceChanged = false; + // Balance and number of transactions might have changed cachedNumBlocks = chainActive.Height(); @@ -167,7 +170,7 @@ void WalletModel::updateTransaction(const QString &hash, int status) transactionTableModel->updateTransaction(hash, status); // Balance and number of transactions might have changed - checkBalanceChanged(); + fForceCheckBalanceChanged = true; } void WalletModel::updateAddressBook(const QString &address, const QString &label, @@ -344,6 +347,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran } emit coinsSent(wallet, rcp, transaction_array); } + checkBalanceChanged(); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits return SendCoinsReturn(OK); } @@ -473,11 +477,6 @@ static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress) { - // emits signal "showProgress" - QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection, - Q_ARG(QString, QString::fromStdString(title)), - Q_ARG(int, nProgress)); - if (nProgress == 0) fQueueNotifications = true; @@ -495,6 +494,11 @@ static void ShowProgress(WalletModel *walletmodel, const std::string &title, int } std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear } + + // emits signal "showProgress" + QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection, + Q_ARG(QString, QString::fromStdString(title)), + Q_ARG(int, nProgress)); } static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly) @@ -618,7 +622,7 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) CTxDestination address; if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue; - mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out); + mapCoins[QString::fromStdString(CBitcoinAddress(address).ToString())].push_back(out); } } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 2a9ac4650f..111ae2178c 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -59,24 +59,20 @@ public: static const int CURRENT_VERSION = 1; int nVersion; - IMPLEMENT_SERIALIZE; + ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { - bool fRead = ser_action.ForRead(); - - SendCoinsRecipient* pthis = const_cast<SendCoinsRecipient*>(this); - - std::string sAddress = pthis->address.toStdString(); - std::string sLabel = pthis->label.toStdString(); - std::string sMessage = pthis->message.toStdString(); + std::string sAddress = address.toStdString(); + std::string sLabel = label.toStdString(); + std::string sMessage = message.toStdString(); std::string sPaymentRequest; - if (!fRead && pthis->paymentRequest.IsInitialized()) - pthis->paymentRequest.SerializeToString(&sPaymentRequest); - std::string sAuthenticatedMerchant = pthis->authenticatedMerchant.toStdString(); + if (!ser_action.ForRead() && paymentRequest.IsInitialized()) + paymentRequest.SerializeToString(&sPaymentRequest); + std::string sAuthenticatedMerchant = authenticatedMerchant.toStdString(); - READWRITE(pthis->nVersion); - nVersion = pthis->nVersion; + READWRITE(this->nVersion); + nVersion = this->nVersion; READWRITE(sAddress); READWRITE(sLabel); READWRITE(amount); @@ -84,14 +80,14 @@ public: READWRITE(sPaymentRequest); READWRITE(sAuthenticatedMerchant); - if (fRead) + if (ser_action.ForRead()) { - pthis->address = QString::fromStdString(sAddress); - pthis->label = QString::fromStdString(sLabel); - pthis->message = QString::fromStdString(sMessage); + address = QString::fromStdString(sAddress); + label = QString::fromStdString(sLabel); + message = QString::fromStdString(sMessage); if (!sPaymentRequest.empty()) - pthis->paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size())); - pthis->authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant); + paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size())); + authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant); } } }; @@ -203,6 +199,7 @@ private: CWallet *wallet; bool fProcessingQueuedTransactions; bool fHaveWatchOnly; + bool fForceCheckBalanceChanged; // Wallet has an options model for wallet-specific options // (transaction fee, for example) @@ -260,7 +257,7 @@ public slots: void updateTransaction(const QString &hash, int status); /* New, updated or removed address book entry */ void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status); - /* Watchonly added */ + /* Watch-only added */ void updateWatchOnlyFlag(bool fHaveWatchonly); /* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */ void pollBalanceChanged(); |