22 static int column_alignments[] = {
23 Qt::AlignLeft|Qt::AlignVCenter,
24 Qt::AlignLeft|Qt::AlignVCenter,
25 Qt::AlignLeft|Qt::AlignVCenter,
26 Qt::AlignLeft|Qt::AlignVCenter,
27 Qt::AlignRight|Qt::AlignVCenter
73 for(std::map<uint256, CWalletTx>::iterator it = wallet->
mapWallet.begin(); it != wallet->
mapWallet.end(); ++it)
93 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(hash);
94 bool inWallet = mi != wallet->
mapWallet.end();
97 QList<TransactionRecord>::iterator lower = qLowerBound(
99 QList<TransactionRecord>::iterator upper = qUpperBound(
101 int lowerIndex = (lower - cachedWallet.begin());
102 int upperIndex = (upper - cachedWallet.begin());
103 bool inModel = (lower != upper);
110 if(showTransaction && !inModel)
112 if(!showTransaction && inModel)
116 OutputDebugStringF(
" inWallet=%i inModel=%i Index=%i-%i showTransaction=%i derivedStatus=%i\n",
117 inWallet, inModel, lowerIndex, upperIndex, showTransaction, status);
124 OutputDebugStringF(
"Warning: updateWallet: Got CT_NEW, but transaction is already in model\n");
129 OutputDebugStringF(
"Warning: updateWallet: Got CT_NEW, but transaction is not in wallet\n");
135 QList<TransactionRecord> toInsert =
137 if(!toInsert.isEmpty())
139 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
140 int insert_idx = lowerIndex;
143 cachedWallet.insert(insert_idx, rec);
146 parent->endInsertRows();
153 OutputDebugStringF(
"Warning: updateWallet: Got CT_DELETED, but transaction is not in model\n");
157 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
158 cachedWallet.erase(lower, upper);
159 parent->endRemoveRows();
171 return cachedWallet.size();
176 if(idx >= 0 && idx < cachedWallet.size())
187 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
207 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
219 QAbstractTableModel(parent),
225 columns << QString() << tr(
"Date") << tr(
"Type") << tr(
"Address") << tr(
"Amount");
229 QTimer *timer =
new QTimer(
this);
231 timer->start(MODEL_UPDATE_DELAY);
244 updated.
SetHex(hash.toStdString());
288 status = tr(
"Offline (%1 confirmations)").arg(wtx->
status.
depth);
294 status = tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
302 status +=
"\n" + tr(
"Mined balance will be available when it matures in %n more block(s)",
"", wtx->
status.
matures_in);
307 status +=
"\n" + tr(
"This block was not received by any other nodes and will probably not be accepted!");
310 status +=
"\n" + tr(
"Generated but not accepted");
339 description += label + QString(
" ");
343 description += QString(
"(") + QString::fromStdString(address) + QString(
")");
353 return tr(
"Received with");
355 return tr(
"Received from");
358 return tr(
"Sent to");
360 return tr(
"Payment to yourself");
373 return QIcon(
":/icons/tx_mined");
376 return QIcon(
":/icons/tx_input");
379 return QIcon(
":/icons/tx_output");
381 return QIcon(
":/icons/tx_inout");
391 return QString::fromStdString(wtx->
address);
397 return QString::fromStdString(wtx->
address);
432 str = QString(
"[") + str + QString(
"]");
447 return QIcon(QString(
":/icons/transaction_%1").
arg(part));
450 return QIcon(
":/icons/transaction_confirmed");
453 return QIcon(
":/icons/transaction_0");
462 return QColor(64,64,255);
465 return QColor(192,192,192);
469 case 0:
return QIcon(
":/icons/transaction_0");
470 case 1:
return QIcon(
":/icons/transaction_1");
471 case 2:
return QIcon(
":/icons/transaction_2");
472 case 3:
return QIcon(
":/icons/transaction_3");
473 case 4:
return QIcon(
":/icons/transaction_4");
474 default:
return QIcon(
":/icons/transaction_5");
477 return QIcon(
":/icons/transaction_confirmed");
480 return QColor(0,0,0);
502 case Qt::DecorationRole:
503 switch(index.column())
511 case Qt::DisplayRole:
512 switch(index.column())
526 switch(index.column())
540 case Qt::ToolTipRole:
542 case Qt::TextAlignmentRole:
543 return column_alignments[index.column()];
544 case Qt::ForegroundRole:
562 return QDateTime::fromTime_t(static_cast<uint>(rec->
time));
566 return QString::fromStdString(rec->
address);
572 return QString::fromStdString(rec->
getTxID());
585 if(orientation == Qt::Horizontal)
587 if(role == Qt::DisplayRole)
591 else if (role == Qt::TextAlignmentRole)
593 return column_alignments[section];
594 }
else if (role == Qt::ToolTipRole)
599 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
601 return tr(
"Date and time that the transaction was received.");
603 return tr(
"Type of transaction.");
605 return tr(
"Destination address of transaction.");
607 return tr(
"Amount removed from or added to balance.");
620 return createIndex(row, column,
priv->
index(row));
624 return QModelIndex();
QVariant addressColor(const TransactionRecord *wtx) const
int columnCount(const QModelIndex &parent) const
void SetHex(const char *psz)
QVariant data(const QModelIndex &index, int role) const
static QString toHTML(CWallet *wallet, CWalletTx &wtx)
QVariant txStatusDecoration(const TransactionRecord *wtx) const
TransactionTableModel(CWallet *wallet, WalletModel *parent=0)
bool operator()(const uint256 &a, const TransactionRecord &b) const
CCriticalSection cs_wallet
void updateWallet(const uint256 &hash, int status)
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
WalletModel * walletModel
std::string getTxID()
Return the unique identifier for this transaction (part)
QString dateTimeStr(const QDateTime &date)
QVariant txAddressDecoration(const TransactionRecord *wtx) const
TransactionRecord * index(int idx)
QString lookupAddress(const std::string &address, bool tooltip) const
void updateTransaction(const QString &hash, int status)
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
QString describe(TransactionRecord *rec)
QList< TransactionRecord > cachedWallet
UI model for a transaction.
TransactionStatus status
Status: can change with block chain update.
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?
void updateStatus(const CWalletTx &wtx)
Update status from core wallet tx.
Date and time this transaction was created.
static const int NumConfirmations
Number of confirmation needed for transaction.
UI model for the transaction table of a wallet.
#define COLOR_UNCONFIRMED
bool getDisplayAddresses()
int OutputDebugStringF(const char *pszFormat,...)
QString formatTxType(const TransactionRecord *wtx) const
QString formatTooltip(const TransactionRecord *rec) const
Transaction will likely not mature because no nodes have confirmed.
int64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
Net amount of transaction.
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
QString labelForAddress(const QString &address) const
Interface to Bitcoin wallet from Qt view code.
std::string ToString() const
int rowCount(const QModelIndex &parent) const
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)
Formatted amount, without brackets when unconfirmed.
void updateConfirmations()
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
#define COLOR_BAREADDRESS
static QString format(int unit, qint64 amount, bool plussign=false)
Format as string.
QString formatTxDate(const TransactionRecord *wtx) const
OptionsModel * getOptionsModel()