Issue QT transaction history table #10
This commit is contained in:
parent
7aa6e66e89
commit
37bcd16a2a
@ -289,7 +289,7 @@ public:
|
||||
const std::vector<CTxIn> vin;
|
||||
const std::vector<CTxOut> vout;
|
||||
const uint32_t nLockTime;
|
||||
const std::string strFloData;
|
||||
std::string strFloData;
|
||||
|
||||
private:
|
||||
/** Memory only. */
|
||||
|
||||
@ -241,6 +241,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty())
|
||||
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
|
||||
|
||||
//
|
||||
// FLO Data
|
||||
//
|
||||
if (!wtx.tx->strFloData.empty())
|
||||
strHTML += "<br><b>" + tr("FLO Data") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.tx->strFloData, true) + "<br>";
|
||||
|
||||
|
||||
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + rec->getTxID() + "<br>";
|
||||
strHTML += "<b>" + tr("Transaction total size") + ":</b> " + QString::number(wtx.tx->GetTotalSize()) + " bytes<br>";
|
||||
strHTML += "<b>" + tr("Output index") + ":</b> " + QString::number(rec->getOutputIndex()) + "<br>";
|
||||
@ -271,10 +278,6 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
strHTML += "<br>" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(numBlocksToMaturity)) + "<br>";
|
||||
}
|
||||
|
||||
// FLO Data
|
||||
if (!wtx.tx->strFloData.empty())
|
||||
strHTML += "<br><b>" + tr("FLO Data") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.tx->strFloData, true) + "<br>";
|
||||
|
||||
//
|
||||
// Debug view
|
||||
//
|
||||
|
||||
@ -34,6 +34,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
|
||||
CAmount nNet = nCredit - nDebit;
|
||||
uint256 hash = wtx.GetHash();
|
||||
std::string flodata = "";
|
||||
if (!wtx.tx->strFloData.empty())
|
||||
{
|
||||
flodata = wtx.tx->strFloData;
|
||||
}
|
||||
std::map<std::string, std::string> mapValue = wtx.mapValue;
|
||||
|
||||
if (nNet > 0 || wtx.IsCoinBase())
|
||||
@ -51,6 +56,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
CTxDestination address;
|
||||
sub.idx = i; // vout index
|
||||
sub.credit = txout.nValue;
|
||||
sub.flodata = flodata;
|
||||
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
|
||||
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
|
||||
{
|
||||
@ -70,7 +76,8 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
sub.type = TransactionRecord::Generated;
|
||||
}
|
||||
|
||||
parts.append(sub);
|
||||
if (sub.credit != 0)
|
||||
parts.append(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,7 +106,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
CAmount nChange = wtx.GetChange();
|
||||
|
||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
|
||||
-(nDebit - nChange), nCredit - nChange));
|
||||
-(nDebit - nChange), nCredit - nChange, flodata));
|
||||
parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument
|
||||
}
|
||||
else if (fAllFromMe)
|
||||
@ -114,6 +121,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
const CTxOut& txout = wtx.tx->vout[nOut];
|
||||
TransactionRecord sub(hash, nTime);
|
||||
sub.idx = nOut;
|
||||
sub.flodata = flodata;
|
||||
sub.involvesWatchAddress = involvesWatchAddress;
|
||||
|
||||
if(wallet->IsMine(txout))
|
||||
@ -146,7 +154,8 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
}
|
||||
sub.debit = -nValue;
|
||||
|
||||
parts.append(sub);
|
||||
if (sub.debit != 0)
|
||||
parts.append(sub);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -154,7 +163,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
//
|
||||
// Mixed debit transaction, can't break down payees
|
||||
//
|
||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
|
||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0, flodata));
|
||||
parts.last().involvesWatchAddress = involvesWatchAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,21 +87,22 @@ public:
|
||||
static const int RecommendedNumConfirmations = 6;
|
||||
|
||||
TransactionRecord():
|
||||
hash(), time(0), type(Other), address(""), debit(0), credit(0), idx(0)
|
||||
hash(), time(0), type(Other), address(""), debit(0), credit(0), flodata(""), idx(0)
|
||||
{
|
||||
}
|
||||
|
||||
TransactionRecord(uint256 _hash, qint64 _time):
|
||||
hash(_hash), time(_time), type(Other), address(""), debit(0),
|
||||
credit(0), idx(0)
|
||||
credit(0), flodata(""), idx(0)
|
||||
{
|
||||
}
|
||||
|
||||
TransactionRecord(uint256 _hash, qint64 _time,
|
||||
Type _type, const std::string &_address,
|
||||
const CAmount& _debit, const CAmount& _credit):
|
||||
const CAmount& _debit, const CAmount& _credit,
|
||||
const std::string &flodata):
|
||||
hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
|
||||
idx(0)
|
||||
flodata(flodata), idx(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -118,6 +119,7 @@ public:
|
||||
std::string address;
|
||||
CAmount debit;
|
||||
CAmount credit;
|
||||
std::string flodata;
|
||||
/**@}*/
|
||||
|
||||
/** Subtransaction index, for sort key */
|
||||
|
||||
@ -34,6 +34,7 @@ static int column_alignments[] = {
|
||||
Qt::AlignLeft|Qt::AlignVCenter, /* date */
|
||||
Qt::AlignLeft|Qt::AlignVCenter, /* type */
|
||||
Qt::AlignLeft|Qt::AlignVCenter, /* address */
|
||||
Qt::AlignLeft|Qt::AlignVCenter, /* flo-data */
|
||||
Qt::AlignRight|Qt::AlignVCenter /* amount */
|
||||
};
|
||||
|
||||
@ -246,7 +247,7 @@ TransactionTableModel::TransactionTableModel(const PlatformStyle *_platformStyle
|
||||
fProcessingQueuedTransactions(false),
|
||||
platformStyle(_platformStyle)
|
||||
{
|
||||
columns << QString() << QString() << tr("Date") << tr("Type") << tr("Label") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
|
||||
columns << QString() << QString() << tr("Date") << tr("Type") << tr("Label") << tr("FLO Data") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
|
||||
priv->refreshWallet();
|
||||
|
||||
connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
@ -429,6 +430,24 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString TransactionTableModel::formatFloData(const TransactionRecord *wtx, bool tooltip) const
|
||||
{
|
||||
switch(wtx->type)
|
||||
{
|
||||
case TransactionRecord::RecvFromOther:
|
||||
case TransactionRecord::RecvWithAddress:
|
||||
case TransactionRecord::SendToAddress:
|
||||
case TransactionRecord::SendToOther:
|
||||
case TransactionRecord::SendToSelf:
|
||||
return QString::fromStdString(wtx->flodata);
|
||||
case TransactionRecord::Generated:
|
||||
return "";
|
||||
default:
|
||||
return tr("(n/a)");
|
||||
}
|
||||
}
|
||||
|
||||
QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
|
||||
{
|
||||
// Show addresses without label in a less visible color
|
||||
@ -517,6 +536,8 @@ QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
|
||||
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
|
||||
{
|
||||
tooltip += QString(" ") + formatTxToAddress(rec, true);
|
||||
if (rec->flodata.length() > 0)
|
||||
tooltip += QString("\n") + formatFloData(rec, true);
|
||||
}
|
||||
return tooltip;
|
||||
}
|
||||
@ -554,6 +575,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
return formatTxType(rec);
|
||||
case ToAddress:
|
||||
return formatTxToAddress(rec, false);
|
||||
case FloData:
|
||||
return formatFloData(rec, false);
|
||||
case Amount:
|
||||
return formatTxAmount(rec, true, BitcoinUnits::separatorAlways);
|
||||
}
|
||||
@ -572,6 +595,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
return (rec->involvesWatchAddress ? 1 : 0);
|
||||
case ToAddress:
|
||||
return formatTxToAddress(rec, true);
|
||||
case FloData:
|
||||
return formatFloData(rec, false);
|
||||
case Amount:
|
||||
return qint64(rec->credit + rec->debit);
|
||||
}
|
||||
@ -686,6 +711,8 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
|
||||
return tr("Whether or not a watch-only address is involved in this transaction.");
|
||||
case ToAddress:
|
||||
return tr("User-defined intent/purpose of the transaction.");
|
||||
case FloData:
|
||||
return tr("FLO Data");
|
||||
case Amount:
|
||||
return tr("Amount removed from or added to balance.");
|
||||
}
|
||||
|
||||
@ -34,7 +34,8 @@ public:
|
||||
Date = 2,
|
||||
Type = 3,
|
||||
ToAddress = 4,
|
||||
Amount = 5
|
||||
FloData = 5,
|
||||
Amount = 6
|
||||
};
|
||||
|
||||
/** Roles to get specific information from a transaction row.
|
||||
@ -100,6 +101,7 @@ private:
|
||||
QString formatTxType(const TransactionRecord *wtx) const;
|
||||
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const;
|
||||
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::separatorStandard) const;
|
||||
QString formatFloData(const TransactionRecord *wtx, bool tooltip) const;
|
||||
QString formatTooltip(const TransactionRecord *rec) const;
|
||||
QVariant txStatusDecoration(const TransactionRecord *wtx) const;
|
||||
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
|
||||
|
||||
@ -218,6 +218,8 @@ void TransactionView::setModel(WalletModel *_model)
|
||||
transactionView->setColumnWidth(TransactionTableModel::Watchonly, WATCHONLY_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Date, DATE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::ToAddress, ADDRESS_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::FloData, FLODATA_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
|
||||
|
||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH, this);
|
||||
@ -586,7 +588,7 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
|
||||
void TransactionView::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
columnResizingFixer->stretchColumnWidth(TransactionTableModel::ToAddress);
|
||||
columnResizingFixer->stretchColumnWidth(TransactionTableModel::FloData);
|
||||
}
|
||||
|
||||
// Need to override default Ctrl+C action for amount as default behaviour is just to copy DisplayRole text
|
||||
|
||||
@ -55,7 +55,9 @@ public:
|
||||
WATCHONLY_COLUMN_WIDTH = 23,
|
||||
DATE_COLUMN_WIDTH = 120,
|
||||
TYPE_COLUMN_WIDTH = 113,
|
||||
ADDRESS_COLUMN_WIDTH = 240,
|
||||
AMOUNT_MINIMUM_COLUMN_WIDTH = 120,
|
||||
FLODATA_COLUMN_WIDTH = 120,
|
||||
MINIMUM_COLUMN_WIDTH = 23
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user