From 9a3d936fc2e98b1e8234bf27e09cf7bc22811bee Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 14 Feb 2014 07:59:07 +0100 Subject: [PATCH] qt: GUI for conflicted transactions - Exclamation mark icon for conflicted transactions - Show mouseover status for conflicted transactions as "conflicted" - Don't show inactive transactions on overview page overview --- src/qt/Makefile.am | 1 + src/qt/bitcoin.qrc | 1 + src/qt/overviewpage.cpp | 1 + src/qt/res/icons/transaction_conflicted.png | Bin 0 -> 474 bytes src/qt/transactionfilterproxy.cpp | 13 ++++++++++++- src/qt/transactionfilterproxy.h | 4 ++++ src/qt/transactionrecord.cpp | 6 +++++- src/qt/transactionrecord.h | 3 ++- src/qt/transactiontablemodel.cpp | 10 ++++++++-- src/qt/transactiontablemodel.h | 4 +++- 10 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 src/qt/res/icons/transaction_conflicted.png diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am index 7de47291cc..030804db6e 100644 --- a/src/qt/Makefile.am +++ b/src/qt/Makefile.am @@ -243,6 +243,7 @@ RES_ICONS = \ res/icons/toolbar_testnet.png \ res/icons/transaction0.png \ res/icons/transaction2.png \ + res/icons/transaction_conflicted.png \ res/icons/tx_inout.png \ res/icons/tx_input.png \ res/icons/tx_output.png \ diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index 746b5a4092..7c3a7756b7 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -12,6 +12,7 @@ res/icons/connect4_16.png res/icons/transaction0.png res/icons/transaction2.png + res/icons/transaction_conflicted.png res/icons/clock1.png res/icons/clock2.png res/icons/clock3.png diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 016097c5a0..1a9d1de571 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -175,6 +175,7 @@ void OverviewPage::setWalletModel(WalletModel *model) filter->setLimit(NUM_ITEMS); filter->setDynamicSortFilter(true); filter->setSortRole(Qt::EditRole); + filter->setShowInactive(false); filter->sort(TransactionTableModel::Status, Qt::DescendingOrder); ui->listTransactions->setModel(filter); diff --git a/src/qt/res/icons/transaction_conflicted.png b/src/qt/res/icons/transaction_conflicted.png new file mode 100644 index 0000000000000000000000000000000000000000..51fff649abfaf8097bcfe7b69e2f02f5ebfd6107 GIT binary patch literal 474 zcmV<00VV#4P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i^h> z1}rpU_YegD00CM_L_t(I%axO{YQj(yhCiFcv}uisN(TpL2c>ioiXhgd(k@OuflI+h za4q-(E)I2b5?{c@#TO7dskC$o2&I&?$xYIBu|+Tm`cHTG&v!o#oCv{*0vezIKfovO zwR!(15;R>dmnjyDq|<3E%VN1)G8&E8EA4h0;J8w$JT#llr&6hO4@5hi&d$e2egI9= zXti3FuIm?#MkAk0CU1wsp{Uhr)a!KsH5Ab8cIo%~sHz%sT^G;ujOlcW>$;>;DK>iv z2K>dg?GIU&ktFFnm&@Te4y)A)z}^e6ZBQr_7>~!yW-|bBu)$<9VK5l%boMsr^?C>) z4g$os4TKP9ex)!#WZMAv_A5yt08ddAV?Lk18HVw=Uaw#MAYle_B9XYtX0zA2u3rXq z!vH6lOy;gyt>)wL_|4|H4gxr)X}&BL3(L0cXTbAaRM--M7;p-_`<*htFWw%A5tOHp QdH?_b07*qoM6N<$g1DN%wg3PC literal 0 HcmV?d00001 diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp index a14e74a469..f9546fddb5 100644 --- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -5,6 +5,7 @@ #include "transactionfilterproxy.h" #include "transactiontablemodel.h" +#include "transactionrecord.h" #include @@ -22,7 +23,8 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : addrPrefix(), typeFilter(ALL_TYPES), minAmount(0), - limitRows(-1) + limitRows(-1), + showInactive(true) { } @@ -35,7 +37,10 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); + int status = index.data(TransactionTableModel::StatusRole).toInt(); + if(!showInactive && status == TransactionStatus::Conflicted) + return false; if(!(TYPE(type) & typeFilter)) return false; if(datetime < dateFrom || datetime > dateTo) @@ -78,6 +83,12 @@ void TransactionFilterProxy::setLimit(int limit) this->limitRows = limit; } +void TransactionFilterProxy::setShowInactive(bool showInactive) +{ + this->showInactive = showInactive; + invalidateFilter(); +} + int TransactionFilterProxy::rowCount(const QModelIndex &parent) const { if(limitRows != -1) diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index 6d1644d48d..9919bc3fd6 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -36,6 +36,9 @@ public: /** Set maximum number of rows returned, -1 if unlimited. */ void setLimit(int limit); + /** Set whether to show conflicted transactions. */ + void setShowInactive(bool showInactive); + int rowCount(const QModelIndex &parent = QModelIndex()) const; protected: @@ -48,6 +51,7 @@ private: quint32 typeFilter; qint64 minAmount; int limitRows; + bool showInactive; }; #endif // TRANSACTIONFILTERPROXY_H diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index b6614fc371..345ecfb196 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -183,7 +183,11 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) } else { - if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) + if (status.depth < 0) + { + status.status = TransactionStatus::Conflicted; + } + else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) { status.status = TransactionStatus::Offline; } diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 8a7c9044e3..d7be0bc438 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -36,7 +36,8 @@ public: OpenUntilBlock, Offline, Unconfirmed, - HaveConfirmations + HaveConfirmations, + Conflicted }; bool confirmed; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index b29be7e0cb..9386d46272 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -312,7 +312,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons 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); + status = tr("Offline"); break; case TransactionStatus::Unconfirmed: status = tr("Unconfirmed (%1 of %2 confirmations)").arg(wtx->status.depth).arg(TransactionRecord::NumConfirmations); @@ -320,6 +320,9 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons case TransactionStatus::HaveConfirmations: status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth); break; + case TransactionStatus::Conflicted: + status = tr("Conflicted"); + break; } } @@ -471,7 +474,6 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) case TransactionStatus::OpenUntilBlock: case TransactionStatus::OpenUntilDate: return QColor(64,64,255); - break; case TransactionStatus::Offline: return QColor(192,192,192); case TransactionStatus::Unconfirmed: @@ -486,6 +488,8 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) }; case TransactionStatus::HaveConfirmations: return QIcon(":/icons/transaction_confirmed"); + case TransactionStatus::Conflicted: + return QIcon(":/icons/transaction_conflicted"); } } return QColor(0,0,0); @@ -587,6 +591,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const rec->status.maturity != TransactionStatus::Mature); case FormattedAmountRole: return formatTxAmount(rec, false); + case StatusRole: + return rec->status.status; } return QVariant(); } diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index c23c606c31..7b9cf09cbe 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -53,7 +53,9 @@ public: /** Is transaction confirmed? */ ConfirmedRole, /** Formatted amount, without brackets when unconfirmed */ - FormattedAmountRole + FormattedAmountRole, + /** Transaction status (TransactionRecord::Status) */ + StatusRole }; int rowCount(const QModelIndex &parent) const;