Browse Source

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
0.10
Wladimir J. van der Laan 11 years ago committed by Gavin Andresen
parent
commit
9a3d936fc2
  1. 1
      src/qt/Makefile.am
  2. 1
      src/qt/bitcoin.qrc
  3. 1
      src/qt/overviewpage.cpp
  4. BIN
      src/qt/res/icons/transaction_conflicted.png
  5. 13
      src/qt/transactionfilterproxy.cpp
  6. 4
      src/qt/transactionfilterproxy.h
  7. 6
      src/qt/transactionrecord.cpp
  8. 3
      src/qt/transactionrecord.h
  9. 10
      src/qt/transactiontablemodel.cpp
  10. 4
      src/qt/transactiontablemodel.h

1
src/qt/Makefile.am

@ -243,6 +243,7 @@ RES_ICONS = \
res/icons/toolbar_testnet.png \ res/icons/toolbar_testnet.png \
res/icons/transaction0.png \ res/icons/transaction0.png \
res/icons/transaction2.png \ res/icons/transaction2.png \
res/icons/transaction_conflicted.png \
res/icons/tx_inout.png \ res/icons/tx_inout.png \
res/icons/tx_input.png \ res/icons/tx_input.png \
res/icons/tx_output.png \ res/icons/tx_output.png \

1
src/qt/bitcoin.qrc

@ -12,6 +12,7 @@
<file alias="connect_4">res/icons/connect4_16.png</file> <file alias="connect_4">res/icons/connect4_16.png</file>
<file alias="transaction_0">res/icons/transaction0.png</file> <file alias="transaction_0">res/icons/transaction0.png</file>
<file alias="transaction_confirmed">res/icons/transaction2.png</file> <file alias="transaction_confirmed">res/icons/transaction2.png</file>
<file alias="transaction_conflicted">res/icons/transaction_conflicted.png</file>
<file alias="transaction_1">res/icons/clock1.png</file> <file alias="transaction_1">res/icons/clock1.png</file>
<file alias="transaction_2">res/icons/clock2.png</file> <file alias="transaction_2">res/icons/clock2.png</file>
<file alias="transaction_3">res/icons/clock3.png</file> <file alias="transaction_3">res/icons/clock3.png</file>

1
src/qt/overviewpage.cpp

@ -175,6 +175,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
filter->setLimit(NUM_ITEMS); filter->setLimit(NUM_ITEMS);
filter->setDynamicSortFilter(true); filter->setDynamicSortFilter(true);
filter->setSortRole(Qt::EditRole); filter->setSortRole(Qt::EditRole);
filter->setShowInactive(false);
filter->sort(TransactionTableModel::Status, Qt::DescendingOrder); filter->sort(TransactionTableModel::Status, Qt::DescendingOrder);
ui->listTransactions->setModel(filter); ui->listTransactions->setModel(filter);

BIN
src/qt/res/icons/transaction_conflicted.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

13
src/qt/transactionfilterproxy.cpp

@ -5,6 +5,7 @@
#include "transactionfilterproxy.h" #include "transactionfilterproxy.h"
#include "transactiontablemodel.h" #include "transactiontablemodel.h"
#include "transactionrecord.h"
#include <cstdlib> #include <cstdlib>
@ -22,7 +23,8 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
addrPrefix(), addrPrefix(),
typeFilter(ALL_TYPES), typeFilter(ALL_TYPES),
minAmount(0), 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 address = index.data(TransactionTableModel::AddressRole).toString();
QString label = index.data(TransactionTableModel::LabelRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString();
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); 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)) if(!(TYPE(type) & typeFilter))
return false; return false;
if(datetime < dateFrom || datetime > dateTo) if(datetime < dateFrom || datetime > dateTo)
@ -78,6 +83,12 @@ void TransactionFilterProxy::setLimit(int limit)
this->limitRows = limit; this->limitRows = limit;
} }
void TransactionFilterProxy::setShowInactive(bool showInactive)
{
this->showInactive = showInactive;
invalidateFilter();
}
int TransactionFilterProxy::rowCount(const QModelIndex &parent) const int TransactionFilterProxy::rowCount(const QModelIndex &parent) const
{ {
if(limitRows != -1) if(limitRows != -1)

4
src/qt/transactionfilterproxy.h

@ -36,6 +36,9 @@ public:
/** Set maximum number of rows returned, -1 if unlimited. */ /** Set maximum number of rows returned, -1 if unlimited. */
void setLimit(int limit); void setLimit(int limit);
/** Set whether to show conflicted transactions. */
void setShowInactive(bool showInactive);
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
protected: protected:
@ -48,6 +51,7 @@ private:
quint32 typeFilter; quint32 typeFilter;
qint64 minAmount; qint64 minAmount;
int limitRows; int limitRows;
bool showInactive;
}; };
#endif // TRANSACTIONFILTERPROXY_H #endif // TRANSACTIONFILTERPROXY_H

6
src/qt/transactionrecord.cpp

@ -183,7 +183,11 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
} }
else 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; status.status = TransactionStatus::Offline;
} }

3
src/qt/transactionrecord.h

@ -36,7 +36,8 @@ public:
OpenUntilBlock, OpenUntilBlock,
Offline, Offline,
Unconfirmed, Unconfirmed,
HaveConfirmations HaveConfirmations,
Conflicted
}; };
bool confirmed; bool confirmed;

10
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)); status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
break; break;
case TransactionStatus::Offline: case TransactionStatus::Offline:
status = tr("Offline (%1 confirmations)").arg(wtx->status.depth); status = tr("Offline");
break; break;
case TransactionStatus::Unconfirmed: case TransactionStatus::Unconfirmed:
status = tr("Unconfirmed (%1 of %2 confirmations)").arg(wtx->status.depth).arg(TransactionRecord::NumConfirmations); 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: case TransactionStatus::HaveConfirmations:
status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth); status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
break; break;
case TransactionStatus::Conflicted:
status = tr("Conflicted");
break;
} }
} }
@ -471,7 +474,6 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
case TransactionStatus::OpenUntilBlock: case TransactionStatus::OpenUntilBlock:
case TransactionStatus::OpenUntilDate: case TransactionStatus::OpenUntilDate:
return QColor(64,64,255); return QColor(64,64,255);
break;
case TransactionStatus::Offline: case TransactionStatus::Offline:
return QColor(192,192,192); return QColor(192,192,192);
case TransactionStatus::Unconfirmed: case TransactionStatus::Unconfirmed:
@ -486,6 +488,8 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
}; };
case TransactionStatus::HaveConfirmations: case TransactionStatus::HaveConfirmations:
return QIcon(":/icons/transaction_confirmed"); return QIcon(":/icons/transaction_confirmed");
case TransactionStatus::Conflicted:
return QIcon(":/icons/transaction_conflicted");
} }
} }
return QColor(0,0,0); return QColor(0,0,0);
@ -587,6 +591,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
rec->status.maturity != TransactionStatus::Mature); rec->status.maturity != TransactionStatus::Mature);
case FormattedAmountRole: case FormattedAmountRole:
return formatTxAmount(rec, false); return formatTxAmount(rec, false);
case StatusRole:
return rec->status.status;
} }
return QVariant(); return QVariant();
} }

4
src/qt/transactiontablemodel.h

@ -53,7 +53,9 @@ public:
/** Is transaction confirmed? */ /** Is transaction confirmed? */
ConfirmedRole, ConfirmedRole,
/** Formatted amount, without brackets when unconfirmed */ /** Formatted amount, without brackets when unconfirmed */
FormattedAmountRole FormattedAmountRole,
/** Transaction status (TransactionRecord::Status) */
StatusRole
}; };
int rowCount(const QModelIndex &parent) const; int rowCount(const QModelIndex &parent) const;

Loading…
Cancel
Save