Skip to content

Commit

Permalink
Merge pull request cryptonotefoundation#25 from aivve/feature/txs_state
Browse files Browse the repository at this point in the history
Mark failed or canceled transaction
  • Loading branch information
aivve authored Dec 31, 2019
2 parents 4cb4b89 + 7e45f24 commit c356c72
Show file tree
Hide file tree
Showing 17 changed files with 471 additions and 388 deletions.
15 changes: 12 additions & 3 deletions src/gui/TransactionsModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@ QVariant TransactionsModel::getEditRole(const QModelIndex& _index) const {
QVariant TransactionsModel::getToolTipRole(const QModelIndex& _index) const {
quint64 numberOfConfirmations = _index.data(ROLE_NUMBER_OF_CONFIRMATIONS).value<quint64>();
TransactionType transactionType = static_cast<TransactionType>(_index.data(ROLE_TYPE).value<quint8>());

if(numberOfConfirmations == 0) {
TransactionState transactionState = static_cast<TransactionState>(_index.data(ROLE_STATE).value<quint8>());
if (transactionState != TransactionState::ACTIVE && transactionState != TransactionState::SENDING) {
return QString(tr("Canceled or failed transaction"));
} else if (numberOfConfirmations == 0) {
if (transactionType == TransactionType::INPUT)
return QString(tr("Incoming transaction, unconfirmed"));

Expand Down Expand Up @@ -369,7 +371,11 @@ QVariant TransactionsModel::getToolTipRole(const QModelIndex& _index) const {
QVariant TransactionsModel::getDecorationRole(const QModelIndex& _index) const {
if(_index.column() == COLUMN_STATE) {
quint64 numberOfConfirmations = _index.data(ROLE_NUMBER_OF_CONFIRMATIONS).value<quint64>();
if(numberOfConfirmations == 0) {
TransactionState transactionState = static_cast<TransactionState>(_index.data(ROLE_STATE).value<quint8>());

if (transactionState != TransactionState::ACTIVE && transactionState != TransactionState::SENDING) {
return QPixmap(":icons/cancel");
} else if (numberOfConfirmations == 0) {
return QPixmap(":icons/unconfirmed");
} else if(numberOfConfirmations < 2) {
return QPixmap(":icons/clock1");
Expand Down Expand Up @@ -398,6 +404,9 @@ QVariant TransactionsModel::getAlignmentRole(const QModelIndex& _index) const {
QVariant TransactionsModel::getUserRole(const QModelIndex& _index, int _role, CryptoNote::TransactionId _transactionId,
CryptoNote::WalletLegacyTransaction& _transaction, CryptoNote::TransferId _transferId, CryptoNote::WalletLegacyTransfer& _transfer) const {
switch(_role) {
case ROLE_STATE:
return static_cast<quint8>(_transaction.state);

case ROLE_DATE:
return (_transaction.timestamp > 0 ? QDateTime::fromTime_t(_transaction.timestamp) : QDateTime());

Expand Down
8 changes: 5 additions & 3 deletions src/gui/TransactionsModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace WalletGui {

enum class TransactionType : quint8 {MINED, INPUT, OUTPUT, INOUT, FUSION};

enum class TransactionState : quint8 {ACTIVE, DELETED, SENDING, CANCELLED, FAILED};

typedef QPair<CryptoNote::TransactionId, CryptoNote::TransferId> TransactionTransferId;

class TransactionsModel : public QAbstractItemModel {
Expand All @@ -22,14 +24,14 @@ class TransactionsModel : public QAbstractItemModel {
Q_ENUMS(Roles)

public:
enum Columns{
enum Columns {
COLUMN_STATE = 0, COLUMN_DATE, COLUMN_AMOUNT, COLUMN_FEE, COLUMN_ADDRESS, COLUMN_PAYMENT_ID, COLUMN_HASH,
COLUMN_HEIGHT, COLUMN_TYPE, COLUMN_SECRET_KEY
};

enum Roles{
enum Roles {
ROLE_DATE = Qt::UserRole, ROLE_TYPE, ROLE_HASH, ROLE_ADDRESS, ROLE_AMOUNT, ROLE_PAYMENT_ID, ROLE_ICON,
ROLE_TRANSACTION_ID, ROLE_HEIGHT, ROLE_FEE, ROLE_NUMBER_OF_CONFIRMATIONS, ROLE_SECRET_KEY, ROLE_COLUMN, ROLE_ROW
ROLE_TRANSACTION_ID, ROLE_HEIGHT, ROLE_FEE, ROLE_NUMBER_OF_CONFIRMATIONS, ROLE_SECRET_KEY, ROLE_COLUMN, ROLE_ROW, ROLE_STATE
};

static TransactionsModel& instance();
Expand Down
Loading

0 comments on commit c356c72

Please sign in to comment.