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
pull/1/head
Wladimir J. van der Laan 9 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 = \ @@ -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 \

1
src/qt/bitcoin.qrc

@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
<file alias="connect_4">res/icons/connect4_16.png</file>
<file alias="transaction_0">res/icons/transaction0.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_2">res/icons/clock2.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) @@ -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);

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 @@ @@ -5,6 +5,7 @@
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"
#include "transactionrecord.h"
#include <cstdlib>
@ -22,7 +23,8 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : @@ -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 & @@ -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) @@ -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)

4
src/qt/transactionfilterproxy.h

@ -36,6 +36,9 @@ public: @@ -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: @@ -48,6 +51,7 @@ private:
quint32 typeFilter;
qint64 minAmount;
int limitRows;
bool showInactive;
};
#endif // TRANSACTIONFILTERPROXY_H

6
src/qt/transactionrecord.cpp

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

3
src/qt/transactionrecord.h

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

10
src/qt/transactiontablemodel.cpp

@ -312,7 +312,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons @@ -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 @@ -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) @@ -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) @@ -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 @@ -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();
}

4
src/qt/transactiontablemodel.h

@ -53,7 +53,9 @@ public: @@ -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;

Loading…
Cancel
Save