30 static int column_alignments[] = {
31 Qt::AlignLeft|Qt::AlignVCenter,
32 Qt::AlignLeft|Qt::AlignVCenter,
33 Qt::AlignLeft|Qt::AlignVCenter,
34 Qt::AlignLeft|Qt::AlignVCenter,
35 Qt::AlignLeft|Qt::AlignVCenter,
36 Qt::AlignRight|Qt::AlignVCenter
79 qDebug() <<
"TransactionTablePriv::refreshWallet";
83 for(std::map<uint256, CWalletTx>::iterator it = wallet->
mapWallet.begin(); it != wallet->
mapWallet.end(); ++it)
98 qDebug() <<
"TransactionTablePriv::updateWallet : " + QString::fromStdString(hash.
ToString()) +
" " + QString::number(status);
103 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(hash);
104 bool inWallet = mi != wallet->
mapWallet.end();
107 QList<TransactionRecord>::iterator lower = qLowerBound(
108 cachedWallet.begin(), cachedWallet.end(), hash,
TxLessThan());
109 QList<TransactionRecord>::iterator upper = qUpperBound(
110 cachedWallet.begin(), cachedWallet.end(), hash,
TxLessThan());
111 int lowerIndex = (lower - cachedWallet.begin());
112 int upperIndex = (upper - cachedWallet.begin());
113 bool inModel = (lower != upper);
120 if(showTransaction && !inModel)
122 if(!showTransaction && inModel)
126 qDebug() <<
" inWallet=" + QString::number(inWallet) +
" inModel=" + QString::number(inModel) +
127 " Index=" + QString::number(lowerIndex) +
"-" + QString::number(upperIndex) +
128 " showTransaction=" + QString::number(showTransaction) +
" derivedStatus=" + QString::number(status);
135 qDebug() <<
"TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is already in model";
140 qDebug() <<
"TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is not in wallet";
146 QList<TransactionRecord> toInsert =
148 if(!toInsert.isEmpty())
150 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
151 int insert_idx = lowerIndex;
154 cachedWallet.insert(insert_idx, rec);
157 parent->endInsertRows();
164 qDebug() <<
"TransactionTablePriv::updateWallet : Warning: Got CT_DELETED, but transaction is not in model";
168 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
169 cachedWallet.erase(lower, upper);
170 parent->endRemoveRows();
182 return cachedWallet.size();
187 if(idx >= 0 && idx < cachedWallet.size())
204 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
221 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
232 QAbstractTableModel(parent),
258 updated.
SetHex(hash.toStdString());
298 status = tr(
"Offline");
301 status = tr(
"Unconfirmed");
307 status = tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
310 status = tr(
"Conflicted");
316 status = tr(
"This block was not received by any other nodes and will probably not be accepted!");
319 status = tr(
"Generated but not accepted");
344 description += label;
346 if(label.isEmpty() || tooltip)
348 description += QString(
" (") + QString::fromStdString(address) + QString(
")");
358 return tr(
"Received with");
360 return tr(
"Received from");
363 return tr(
"Sent to");
365 return tr(
"Payment to yourself");
378 return QIcon(
":/icons/tx_mined");
381 return QIcon(
":/icons/tx_input");
384 return QIcon(
":/icons/tx_output");
386 return QIcon(
":/icons/tx_inout");
392 QString watchAddress;
395 watchAddress = wtx->
involvesWatchAddress ? QString(
" (") + tr(
"watch-only") + QString(
")") :
"";
401 return QString::fromStdString(wtx->
address) + watchAddress;
407 return QString::fromStdString(wtx->
address) + watchAddress;
410 return tr(
"(n/a)") + watchAddress;
442 str = QString(
"[") + str + QString(
"]");
458 return QIcon(
":/icons/transaction_0");
462 case 1:
return QIcon(
":/icons/transaction_1");
463 case 2:
return QIcon(
":/icons/transaction_2");
464 case 3:
return QIcon(
":/icons/transaction_3");
465 case 4:
return QIcon(
":/icons/transaction_4");
466 default:
return QIcon(
":/icons/transaction_5");
469 return QIcon(
":/icons/transaction_confirmed");
471 return QIcon(
":/icons/transaction_conflicted");
475 return QIcon(QString(
":/icons/transaction_%1").arg(part));
479 return QIcon(
":/icons/transaction_0");
488 return QIcon(
":/icons/eye");
512 case Qt::DecorationRole:
513 switch(index.column())
523 case Qt::DisplayRole:
524 switch(index.column())
538 switch(index.column())
554 case Qt::ToolTipRole:
556 case Qt::TextAlignmentRole:
557 return column_alignments[index.column()];
558 case Qt::ForegroundRole:
576 return QDateTime::fromTime_t(static_cast<uint>(rec->
time));
584 return QString::fromStdString(rec->
address);
605 if(orientation == Qt::Horizontal)
607 if(role == Qt::DisplayRole)
611 else if (role == Qt::TextAlignmentRole)
613 return column_alignments[section];
614 }
else if (role == Qt::ToolTipRole)
619 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
621 return tr(
"Date and time that the transaction was received.");
623 return tr(
"Type of transaction.");
625 return tr(
"Whether or not a watch-only address is involved in this transaction.");
627 return tr(
"Destination address of transaction.");
629 return tr(
"Amount removed from or added to balance.");
642 return createIndex(row, column,
priv->
index(row));
644 return QModelIndex();
QVariant addressColor(const TransactionRecord *wtx) const
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
int columnCount(const QModelIndex &parent) const
void SetHex(const char *psz)
QVariant data(const QModelIndex &index, int role) const
QVariant txStatusDecoration(const TransactionRecord *wtx) const
QString describe(TransactionRecord *rec, int unit)
TransactionTableModel(CWallet *wallet, WalletModel *parent=0)
Confirmed, but waiting for the recommended number of confirmations.
bool operator()(const uint256 &a, const TransactionRecord &b) const
Transaction not yet final, waiting for block.
Transaction status (TransactionRecord::Status)
#define TRY_LOCK(cs, name)
QString getTxID() const
Return the unique identifier for this transaction (part)
Not sent to any other nodes.
CCriticalSection cs_wallet
Main wallet lock.
Generated (mined) transactions.
void updateWallet(const uint256 &hash, int status)
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
WalletModel * walletModel
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
std::string sortKey
Sorting key based on status.
QString dateTimeStr(const QDateTime &date)
QVariant txAddressDecoration(const TransactionRecord *wtx) const
TransactionRecord * index(int idx)
Not yet mined into a block.
QString lookupAddress(const std::string &address, bool tooltip) const
void updateTransaction(const QString &hash, int status)
#define COLOR_TX_STATUS_OFFLINE
static bool showTransaction(const CWalletTx &wtx)
Decompose CWallet transaction to model transaction records.
AddressTableModel * getAddressTableModel()
TransactionTableModel * parent
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Long description (HTML format)
TransactionTablePriv * priv
QString formatTxStatus(const TransactionRecord *wtx) const
QList< TransactionRecord > cachedWallet
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */...
UI model for a transaction.
TransactionStatus status
Status: can change with block chain update.
static QString format(int unit, qint64 amount, bool plussign=false)
Format as string.
static QList< TransactionRecord > decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true) const
bool operator()(const TransactionRecord &a, const uint256 &b) const
Is transaction confirmed?
bool countsForBalance
Transaction counts towards available balance.
void updateStatus(const CWalletTx &wtx)
Update status from core wallet tx.
Date and time this transaction was created.
UI model for the transaction table of a wallet.
#define COLOR_UNCONFIRMED
Normal (sent/received) transactions.
QString formatTxType(const TransactionRecord *wtx) const
QString formatTooltip(const TransactionRecord *rec) const
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Net amount of transaction.
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
QString labelForAddress(const QString &address) const
Conflicts with other transaction or mempool.
Interface to Anoncoin wallet from Qt view code.
std::string ToString() const
int rowCount(const QModelIndex &parent) const
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Label of address related to transaction.
bool statusUpdateNeeded()
Return whether a status update is needed.
std::map< uint256, CWalletTx > mapWallet
TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent)
#define COLOR_TX_STATUS_OPENUNTILDATE
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
Formatted amount, without brackets when unconfirmed.
void updateConfirmations()
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
static QString toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit)
#define COLOR_BAREADDRESS
QString formatTxDate(const TransactionRecord *wtx) const
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Transaction will likely not mature because no nodes have confirmed.
OptionsModel * getOptionsModel()