diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index c8329bb2..bd314ba0 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -161,13 +161,13 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu rec->label = value.toString(); break; case Address: - // Refuse to set invalid address + // Refuse to set invalid address, set error status and return false if(!walletModel->validateAddress(value.toString())) { editStatus = INVALID_ADDRESS; return false; } - // Double-check that we're not overwriting receiving address + // Double-check that we're not overwriting a receiving address if(rec->type == AddressTableEntry::Sending) { CRITICAL_BLOCK(wallet->cs_mapAddressBook) @@ -234,7 +234,7 @@ QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & pa void AddressTableModel::updateList() { - // Update internal model from Bitcoin core + // Update address book model from Bitcoin core beginResetModel(); priv->refreshAddressTable(); endResetModel(); @@ -247,7 +247,6 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con editStatus = OK; - if(type == Send) { if(!walletModel->validateAddress(address)) @@ -255,7 +254,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con editStatus = INVALID_ADDRESS; return QString(); } - // Check for duplicate + // Check for duplicate addresses CRITICAL_BLOCK(wallet->cs_mapAddressBook) { if(wallet->mapAddressBook.count(strAddress)) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index a21983b7..cdd69e31 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) { { // Put this in a block, so that BitcoinGUI is cleaned up properly before - // calling shutdown. + // calling Shutdown(). BitcoinGUI window; splash.finish(&window); OptionsModel optionsModel(pwalletMain); diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index 1af582f6..ea38cc86 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -44,7 +44,7 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent): connect(decimals, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged())); connect(unit, SIGNAL(currentIndexChanged(int)), this, SLOT(unitChanged(int))); - // TODO: set default based on configuration + // Set default based on configuration unitChanged(unit->currentIndex()); } @@ -67,7 +67,6 @@ void BitcoinAmountField::clear() { amount->clear(); decimals->clear(); - // TODO: set default based on configuration unit->setCurrentIndex(0); } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 2c9c25d5..dd94652e 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -52,6 +52,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): resize(850, 550); setWindowTitle(tr("Bitcoin Wallet")); setWindowIcon(QIcon(":icons/bitcoin")); + // Accept D&D of URIs + setAcceptDrops(true); createActions(); @@ -68,8 +70,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QMenu *help = menuBar()->addMenu("&Help"); help->addAction(aboutAction); - // Toolbar - QToolBar *toolbar = addToolBar("Main toolbar"); + // Toolbars + QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolbar->addAction(overviewAction); toolbar->addAction(sendCoinsAction); @@ -77,19 +79,17 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): toolbar->addAction(historyAction); toolbar->addAction(addressBookAction); - QToolBar *toolbar2 = addToolBar("Transactions toolbar"); + QToolBar *toolbar2 = addToolBar(tr("Actions toolbar")); toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolbar2->addAction(exportAction); - // Overview page + // Create tabs overviewPage = new OverviewPage(); - QVBoxLayout *vbox = new QVBoxLayout(); + transactionsPage = new QWidget(this); + QVBoxLayout *vbox = new QVBoxLayout(); transactionView = new TransactionView(this); - connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails())); vbox->addWidget(transactionView); - - transactionsPage = new QWidget(this); transactionsPage->setLayout(vbox); addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab); @@ -109,7 +109,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Create status bar statusBar(); - // Status bar "Blocks" notification + // Status bar notification icons QFrame *frameBlocks = new QFrame(); //frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken); frameBlocks->setContentsMargins(0,0,0,0); @@ -141,10 +141,11 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this); - // Clicking on a transaction simply sends you to transaction history page + // Clicking on a transaction on the overview page simply sends you to transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage())); - setAcceptDrops(true); + // Doubleclicking on a transaction on the transaction history page shows details + connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails())); gotoOverviewPage(); } @@ -252,7 +253,6 @@ void BitcoinGUI::createTrayIcon() { QMenu *trayIconMenu = new QMenu(this); trayIconMenu->addAction(openBitcoinAction); - trayIconMenu->addAction(sendCoinsAction); trayIconMenu->addAction(optionsAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); @@ -268,7 +268,7 @@ void BitcoinGUI::createTrayIcon() void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) { - if(reason == QSystemTrayIcon::DoubleClick) + if(reason == QSystemTrayIcon::Trigger) { // Doubleclick on system tray icon triggers "open bitcoin" openBitcoinAction->trigger(); @@ -347,31 +347,22 @@ void BitcoinGUI::setNumBlocks(int count) text = tr("%n day(s) ago","",secs/(60*60*24)); } - // In the label we want to be less specific - bool spinning = true; + // Set icon state: spinning if catching up, tick otherwise if(secs < 30*60) { tooltip = tr("Up to date") + QString("\n") + tooltip; - spinning = false; + labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(16,16)); } else { tooltip = tr("Catching up...") + QString("\n") + tooltip; + labelBlocksIcon->setMovie(syncIconMovie); + syncIconMovie->start(); } tooltip += QString("\n"); tooltip += tr("Last received block was generated %1.").arg(text); - if(spinning) - { - labelBlocksIcon->setMovie(syncIconMovie); - syncIconMovie->start(); - } - else - { - labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(16,16)); - } - labelBlocksIcon->setToolTip(tooltip); progressBarLabel->setToolTip(tooltip); progressBar->setToolTip(tooltip); @@ -439,12 +430,14 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee) void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end) { + if(start == end) + return; TransactionTableModel *ttm = walletModel->getTransactionTableModel(); qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent) .data(Qt::EditRole).toULongLong(); if(!clientModel->inInitialBlockDownload()) { - // On incoming transaction, make an info balloon + // On new transaction, make an info balloon // Unless the initial block download is in progress, to prevent balloon-spam QString date = ttm->index(start, TransactionTableModel::Date, parent) .data().toString(); diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index 4dfdbea0..a7bebbc3 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -4,7 +4,8 @@ #include #include -// Bitcoin unit definitions +// Bitcoin unit definitions, encapsulates parsing and formatting +// and serves as list model for dropdown selection boxes. class BitcoinUnits: public QAbstractListModel { public: diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 845ad10d..15387056 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -12,7 +12,7 @@ QT_BEGIN_NAMESPACE class QDateTime; QT_END_NAMESPACE -// Interface to Bitcoin network client +// Model for Bitcoin network client class ClientModel : public QObject { Q_OBJECT diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 74863e15..158b84a2 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -12,12 +12,12 @@ #include #include -QString GUIUtil::DateTimeStr(qint64 nTime) +QString GUIUtil::dateTimeStr(qint64 nTime) { - return DateTimeStr(QDateTime::fromTime_t((qint32)nTime)); + return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } -QString GUIUtil::DateTimeStr(const QDateTime &date) +QString GUIUtil::dateTimeStr(const QDateTime &date) { return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); } @@ -61,8 +61,6 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out) } else // Amount is non-empty { - // TODO: support X (exp = 8-nexp) (https://en.bitcoin.it/wiki/URI_Scheme) - // TODO: support E if(!BitcoinUnits::parse(BitcoinUnits::BTC, amount, &rv.amount)) { return false; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 5f63c16e..bc4ddb8a 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -16,8 +16,8 @@ class GUIUtil { public: // Create human-readable string from date - static QString DateTimeStr(qint64 nTime); - static QString DateTimeStr(const QDateTime &datetime); + static QString dateTimeStr(qint64 nTime); + static QString dateTimeStr(const QDateTime &datetime); // Render bitcoin addresses in monospace font static QFont bitcoinAddressFont(); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index e8180e04..7bade9a7 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -74,7 +74,7 @@ public: painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText); painter->setPen(option.palette.color(QPalette::Text)); - painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::DateTimeStr(date)); + painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::dateTimeStr(date)); painter->restore(); } diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 88dc2d8d..612b5d89 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -1,79 +1,55 @@ #include #include "guiutil.h" +#include "bitcoinunits.h" #include "headers.h" #include "qtui.h" #include - -// Taken straight from ui.cpp -// TODO: Convert to use QStrings, Qt::Escape and tr() -// or: refactor and put describeAsHTML() into bitcoin core but that is unneccesary with better -// UI<->core API, no need to put display logic in core. +#include // For Qt::escape using namespace std; -static string HtmlEscape(const char* psz, bool fMultiLine=false) +QString TransactionDesc::HtmlEscape(const QString& str, bool fMultiLine) { - int len = 0; - for (const char* p = psz; *p; p++) + QString escaped = Qt::escape(str); + if(fMultiLine) { - if (*p == '<') len += 4; - else if (*p == '>') len += 4; - else if (*p == '&') len += 5; - else if (*p == '"') len += 6; - else if (*p == ' ' && p > psz && p[-1] == ' ' && p[1] == ' ') len += 6; - else if (*p == '\n' && fMultiLine) len += 5; - else - len++; + escaped = escaped.replace("\n", "
\n"); } - string str; - str.reserve(len); - for (const char* p = psz; *p; p++) - { - if (*p == '<') str += "<"; - else if (*p == '>') str += ">"; - else if (*p == '&') str += "&"; - else if (*p == '"') str += """; - else if (*p == ' ' && p > psz && p[-1] == ' ' && p[1] == ' ') str += " "; - else if (*p == '\n' && fMultiLine) str += "
\n"; - else - str += *p; - } - return str; + return escaped; } -static string HtmlEscape(const string& str, bool fMultiLine=false) +QString TransactionDesc::HtmlEscape(const std::string& str, bool fMultiLine) { - return HtmlEscape(str.c_str(), fMultiLine); + return HtmlEscape(QString::fromStdString(str), fMultiLine); } -static string FormatTxStatus(const CWalletTx& wtx) +QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) { - // Status if (!wtx.IsFinal()) { - if (wtx.nLockTime < 500000000) - return strprintf(_("Open for %d blocks"), nBestHeight - wtx.nLockTime); + if (wtx.nLockTime < LOCKTIME_THRESHOLD) + return tr("Open for %1 blocks").arg(nBestHeight - wtx.nLockTime); else - return strprintf(_("Open until %s"), GUIUtil::DateTimeStr(wtx.nLockTime).toStdString().c_str()); + return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime)); } else { int nDepth = wtx.GetDepthInMainChain(); if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) - return strprintf(_("%d/offline?"), nDepth); + return tr("%1/offline?").arg(nDepth); else if (nDepth < 6) - return strprintf(_("%d/unconfirmed"), nDepth); + return tr("%1/unconfirmed").arg(nDepth); else - return strprintf(_("%d confirmations"), nDepth); + return tr("%1 confirmations").arg(nDepth); } } -string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) +QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { - string strHTML; + QString strHTML; CRITICAL_BLOCK(wallet->cs_mapAddressBook) { strHTML.reserve(4000); @@ -84,36 +60,33 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) int64 nDebit = wtx.GetDebit(); int64 nNet = nCredit - nDebit; - - - strHTML += _("Status: ") + FormatTxStatus(wtx); + strHTML += tr("Status: ") + FormatTxStatus(wtx); int nRequests = wtx.GetRequestCount(); if (nRequests != -1) { if (nRequests == 0) - strHTML += _(", has not been successfully broadcast yet"); + strHTML += tr(", has not been successfully broadcast yet"); else if (nRequests == 1) - strHTML += strprintf(_(", broadcast through %d node"), nRequests); + strHTML += tr(", broadcast through %1 node").arg(nRequests); else - strHTML += strprintf(_(", broadcast through %d nodes"), nRequests); + strHTML += tr(", broadcast through %1 nodes").arg(nRequests); } strHTML += "
"; - strHTML += _("Date: ") + (nTime ? GUIUtil::DateTimeStr(nTime).toStdString() : "") + "
"; - + strHTML += tr("Date: ") + (nTime ? GUIUtil::dateTimeStr(nTime) : QString("")) + "
"; // // From // if (wtx.IsCoinBase()) { - strHTML += _("Source: Generated
"); + strHTML += tr("Source: Generated
"); } else if (!wtx.mapValue["from"].empty()) { // Online transaction if (!wtx.mapValue["from"].empty()) - strHTML += _("From: ") + HtmlEscape(wtx.mapValue["from"]) + "
"; + strHTML += tr("From: ") + HtmlEscape(wtx.mapValue["from"]) + "
"; } else { @@ -130,13 +103,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { if (wallet->mapAddressBook.count(address)) { - strHTML += string() + _("From: ") + _("unknown") + "
"; - strHTML += _("To: "); + strHTML += tr("From: ") + tr("unknown") + "
"; + strHTML += tr("To: "); strHTML += HtmlEscape(address.ToString()); if (!wallet->mapAddressBook[address].empty()) - strHTML += _(" (yours, label: ") + HtmlEscape(wallet->mapAddressBook[address]) + ")"; + strHTML += tr(" (yours, label: ") + HtmlEscape(wallet->mapAddressBook[address]) + ")"; else - strHTML += _(" (yours)"); + strHTML += tr(" (yours)"); strHTML += "
"; } } @@ -146,7 +119,6 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) } } - // // To // @@ -155,13 +127,12 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { // Online transaction strAddress = wtx.mapValue["to"]; - strHTML += _("To: "); + strHTML += tr("To: "); if (wallet->mapAddressBook.count(strAddress) && !wallet->mapAddressBook[strAddress].empty()) strHTML += HtmlEscape(wallet->mapAddressBook[strAddress]) + " "; strHTML += HtmlEscape(strAddress) + "
"; } - // // Amount // @@ -173,11 +144,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) int64 nUnmatured = 0; BOOST_FOREACH(const CTxOut& txout, wtx.vout) nUnmatured += wallet->GetCredit(txout); - strHTML += _("Credit: "); + strHTML += tr("Credit: "); if (wtx.IsInMainChain()) - strHTML += strprintf(_("(%s matures in %d more blocks)"), FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity()); + strHTML += tr("(%1 matures in %2 more blocks)") + .arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nUnmatured)) + .arg(wtx.GetBlocksToMaturity()); else - strHTML += _("(not accepted)"); + strHTML += tr("(not accepted)"); strHTML += "
"; } else if (nNet > 0) @@ -185,7 +158,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) // // Credit // - strHTML += _("Credit: ") + FormatMoney(nNet) + "
"; + strHTML += tr("Credit: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nNet) + "
"; } else { @@ -213,7 +186,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) CBitcoinAddress address; if (ExtractAddress(txout.scriptPubKey, 0, address)) { - strHTML += _("To: "); + strHTML += tr("To: "); if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " "; strHTML += HtmlEscape(address.ToString()); @@ -221,7 +194,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) } } - strHTML += _("Debit: ") + FormatMoney(-txout.nValue) + "
"; + strHTML += tr("Debit: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -txout.nValue) + "
"; } if (fAllToMe) @@ -229,13 +202,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) // Payment to self int64 nChange = wtx.GetChange(); int64 nValue = nCredit - nChange; - strHTML += _("Debit: ") + FormatMoney(-nValue) + "
"; - strHTML += _("Credit: ") + FormatMoney(nValue) + "
"; + strHTML += tr("Debit: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "
"; + strHTML += tr("Credit: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "
"; } int64 nTxFee = nDebit - wtx.GetValueOut(); if (nTxFee > 0) - strHTML += _("Transaction fee: ") + FormatMoney(-nTxFee) + "
"; + strHTML += tr("Transaction fee: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-nTxFee) + "
"; } else { @@ -244,27 +217,25 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) // BOOST_FOREACH(const CTxIn& txin, wtx.vin) if (wallet->IsMine(txin)) - strHTML += _("Debit: ") + FormatMoney(-wallet->GetDebit(txin)) + "
"; + strHTML += tr("Debit: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-wallet->GetDebit(txin)) + "
"; BOOST_FOREACH(const CTxOut& txout, wtx.vout) if (wallet->IsMine(txout)) - strHTML += _("Credit: ") + FormatMoney(wallet->GetCredit(txout)) + "
"; + strHTML += tr("Credit: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,wallet->GetCredit(txout)) + "
"; } } - strHTML += _("Net amount: ") + FormatMoney(nNet, true) + "
"; - + strHTML += tr("Net amount: ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,nNet, true) + "
"; // // Message // if (!wtx.mapValue["message"].empty()) - strHTML += string() + "
" + _("Message:") + "
" + HtmlEscape(wtx.mapValue["message"], true) + "
"; + strHTML += QString("
") + tr("Message:") + "
" + HtmlEscape(wtx.mapValue["message"], true) + "
"; if (!wtx.mapValue["comment"].empty()) - strHTML += string() + "
" + _("Comment:") + "
" + HtmlEscape(wtx.mapValue["comment"], true) + "
"; + strHTML += QString("
") + tr("Comment:") + "
" + HtmlEscape(wtx.mapValue["comment"], true) + "
"; if (wtx.IsCoinBase()) - strHTML += string() + "
" + _("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "
"; - + strHTML += QString("
") + tr("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "
"; // // Debug view @@ -274,10 +245,10 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strHTML += "

Debug information

"; BOOST_FOREACH(const CTxIn& txin, wtx.vin) if(wallet->IsMine(txin)) - strHTML += "Debit: " + FormatMoney(-wallet->GetDebit(txin)) + "
"; + strHTML += "Debit: " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-wallet->GetDebit(txin)) + "
"; BOOST_FOREACH(const CTxOut& txout, wtx.vout) if(wallet->IsMine(txout)) - strHTML += "Credit: " + FormatMoney(wallet->GetCredit(txout)) + "
"; + strHTML += "Credit: " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,wallet->GetCredit(txout)) + "
"; strHTML += "
Transaction:
"; strHTML += HtmlEscape(wtx.ToString(), true); @@ -304,9 +275,9 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " "; - strHTML += address.ToString(); + strHTML += QString::fromStdString(address.ToString()); } - strHTML = strHTML + " Amount=" + FormatMoney(vout.nValue); + strHTML = strHTML + " Amount=" + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,vout.nValue); strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? "true" : "false") + ""; } } @@ -315,8 +286,6 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strHTML += ""; } - - strHTML += ""; } return strHTML; diff --git a/src/qt/transactiondesc.h b/src/qt/transactiondesc.h index fde861b6..257b2cbb 100644 --- a/src/qt/transactiondesc.h +++ b/src/qt/transactiondesc.h @@ -1,16 +1,24 @@ #ifndef TRANSACTIONDESC_H #define TRANSACTIONDESC_H +#include +#include #include class CWallet; class CWalletTx; -class TransactionDesc +class TransactionDesc: public QObject { public: - /* Provide human-readable extended HTML description of a transaction */ - static std::string toHTML(CWallet *wallet, CWalletTx &wtx); + // Provide human-readable extended HTML description of a transaction + static QString toHTML(CWallet *wallet, CWalletTx &wtx); +private: + TransactionDesc() {} + + static QString HtmlEscape(const QString& str, bool fMultiLine=false); + static QString HtmlEscape(const std::string &str, bool fMultiLine=false); + static QString FormatTxStatus(const CWalletTx& wtx); }; #endif // TRANSACTIONDESC_H diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 6343fe50..353cd791 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -18,7 +18,7 @@ #include #include -// Credit and Debit columns are right-aligned as they contain numbers +// Amount column is right-aligned it contains numbers static int column_alignments[] = { Qt::AlignLeft|Qt::AlignVCenter, Qt::AlignLeft|Qt::AlignVCenter, @@ -100,10 +100,10 @@ struct TransactionTablePriv for(int update_idx = updated_sorted.size()-1; update_idx >= 0; --update_idx) { const uint256 &hash = updated_sorted.at(update_idx); - /* Find transaction in wallet */ + // Find transaction in wallet std::map::iterator mi = wallet->mapWallet.find(hash); bool inWallet = mi != wallet->mapWallet.end(); - /* Find bounds of this transaction in model */ + // Find bounds of this transaction in model QList::iterator lower = qLowerBound( cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); QList::iterator upper = qUpperBound( @@ -196,7 +196,7 @@ struct TransactionTablePriv std::map::iterator mi = wallet->mapWallet.find(rec->hash); if(mi != wallet->mapWallet.end()) { - return QString::fromStdString(TransactionDesc::toHTML(wallet, mi->second)); + return TransactionDesc::toHTML(wallet, mi->second); } } return QString(""); @@ -274,7 +274,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons status = tr("Open for %n block(s)","",wtx->status.open_for); break; case TransactionStatus::OpenUntilDate: - status = tr("Open until %1").arg(GUIUtil::DateTimeStr(wtx->status.open_for)); + status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for)); break; case TransactionStatus::Offline: status = tr("Offline (%1 confirmations)").arg(wtx->status.depth); @@ -313,7 +313,7 @@ QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const { if(wtx->time) { - return GUIUtil::DateTimeStr(wtx->time); + return GUIUtil::dateTimeStr(wtx->time); } else { @@ -606,11 +606,6 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat return QVariant(); } -Qt::ItemFlags TransactionTableModel::flags(const QModelIndex &index) const -{ - return QAbstractTableModel::flags(index); -} - QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const { Q_UNUSED(parent); diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index 17bfeccd..da55495e 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -51,7 +51,6 @@ public: int columnCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; private: CWallet* wallet; diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 54925f28..f4f815b1 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -24,6 +24,7 @@ public: void setModel(WalletModel *model); + // Date ranges for filter enum DateEnum { All, diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index d8139e9f..10b3738c 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -83,8 +83,6 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList &recipients); private: CWallet *wallet;