Add confirmations column to Transactions Table. (#168)
* Add confirmations column to Transactions table. * Fix unsigned int wrapping for confirmation count.
This commit is contained in:
committed by
adityapk00
parent
bd1edf9f0c
commit
486ee5c2e6
@@ -506,7 +506,7 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto amount = i["amount"].get<json::number_float_t>();
|
auto amount = i["amount"].get<json::number_float_t>();
|
||||||
auto confirmations = (unsigned long)txidInfo["confirmations"].get<json::number_unsigned_t>();
|
auto confirmations = static_cast<long>(txidInfo["confirmations"].get<json::number_integer_t>());
|
||||||
|
|
||||||
TransactionItem tx{ QString("receive"), timestamp, zaddr, txid, amount,
|
TransactionItem tx{ QString("receive"), timestamp, zaddr, txid, amount,
|
||||||
confirmations, "", memos.value(zaddr + txid, "") };
|
confirmations, "", memos.value(zaddr + txid, "") };
|
||||||
@@ -879,7 +879,7 @@ void RPC::refreshTransactions() {
|
|||||||
address,
|
address,
|
||||||
QString::fromStdString(it["txid"]),
|
QString::fromStdString(it["txid"]),
|
||||||
it["amount"].get<json::number_float_t>() + fee,
|
it["amount"].get<json::number_float_t>() + fee,
|
||||||
(unsigned long)it["confirmations"].get<json::number_unsigned_t>(),
|
static_cast<long>(it["confirmations"].get<json::number_unsigned_t>()),
|
||||||
"", "" };
|
"", "" };
|
||||||
|
|
||||||
txdata.push_back(tx);
|
txdata.push_back(tx);
|
||||||
@@ -936,7 +936,7 @@ void RPC::refreshSentZTrans() {
|
|||||||
continue;
|
continue;
|
||||||
auto error = j["confirmations"].is_null();
|
auto error = j["confirmations"].is_null();
|
||||||
if (!error)
|
if (!error)
|
||||||
sentTx.confirmations = j["confirmations"].get<json::number_unsigned_t>();
|
sentTx.confirmations = j["confirmations"].get<json::number_integer_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionsTableModel->addZSentData(newSentZTxs);
|
transactionsTableModel->addZSentData(newSentZTxs);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ struct TransactionItem {
|
|||||||
QString address;
|
QString address;
|
||||||
QString txid;
|
QString txid;
|
||||||
double amount;
|
double amount;
|
||||||
unsigned long confirmations;
|
long confirmations;
|
||||||
QString fromAddr;
|
QString fromAddr;
|
||||||
QString memo;
|
QString memo;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
TxTableModel::TxTableModel(QObject *parent)
|
TxTableModel::TxTableModel(QObject *parent)
|
||||||
: QAbstractTableModel(parent) {
|
: QAbstractTableModel(parent) {
|
||||||
headers << QObject::tr("Type") << QObject::tr("Address") << QObject::tr("Date/Time") << QObject::tr("Amount");
|
headers << QObject::tr("Type") << QObject::tr("Address") << QObject::tr("Date/Time") << QObject::tr("Confirmations") << QObject::tr("Amount");
|
||||||
}
|
}
|
||||||
|
|
||||||
TxTableModel::~TxTableModel() {
|
TxTableModel::~TxTableModel() {
|
||||||
@@ -104,11 +104,12 @@ void TxTableModel::updateAllData() {
|
|||||||
|
|
||||||
QVariant TxTableModel::data(const QModelIndex &index, int role) const
|
QVariant TxTableModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
// Align column 4 (amount) right
|
// Align column 5 (amount) right
|
||||||
if (role == Qt::TextAlignmentRole && index.column() == 3) return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
if (role == Qt::TextAlignmentRole && index.column() >= 3) return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto dat = modeldata->at(index.row());
|
||||||
if (role == Qt::ForegroundRole) {
|
if (role == Qt::ForegroundRole) {
|
||||||
if (modeldata->at(index.row()).confirmations == 0) {
|
if (dat.confirmations <= 0) {
|
||||||
QBrush b;
|
QBrush b;
|
||||||
b.setColor(Qt::red);
|
b.setColor(Qt::red);
|
||||||
return b;
|
return b;
|
||||||
@@ -120,19 +121,19 @@ void TxTableModel::updateAllData() {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dat = modeldata->at(index.row());
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return dat.type;
|
case 0: return dat.type;
|
||||||
case 1: {
|
case 1: {
|
||||||
auto addr = modeldata->at(index.row()).address;
|
auto addr = dat.address;
|
||||||
if (addr.trimmed().isEmpty())
|
if (addr.trimmed().isEmpty())
|
||||||
return "(Shielded)";
|
return "(Shielded)";
|
||||||
else
|
else
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
case 2: return QDateTime::fromMSecsSinceEpoch(modeldata->at(index.row()).datetime * (qint64)1000).toLocalTime().toString();
|
case 2: return QDateTime::fromMSecsSinceEpoch(dat.datetime * (qint64)1000).toLocalTime().toString();
|
||||||
case 3: return Settings::getZECDisplayFormat(modeldata->at(index.row()).amount);
|
case 3: return QString::number(dat.confirmations);
|
||||||
|
case 4: return Settings::getZECDisplayFormat(dat.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +155,8 @@ void TxTableModel::updateAllData() {
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
case 2: return QDateTime::fromMSecsSinceEpoch(modeldata->at(index.row()).datetime * (qint64)1000).toLocalTime().toString();
|
case 2: return QDateTime::fromMSecsSinceEpoch(modeldata->at(index.row()).datetime * (qint64)1000).toLocalTime().toString();
|
||||||
case 3: return Settings::getInstance()->getUSDFromZecAmount(modeldata->at(index.row()).amount);
|
case 3: return QString("%1 Network Confirmations").arg(QString::number(dat.confirmations));
|
||||||
|
case 4: return Settings::getInstance()->getUSDFromZecAmount(modeldata->at(index.row()).amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +185,7 @@ void TxTableModel::updateAllData() {
|
|||||||
|
|
||||||
QVariant TxTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant TxTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (role == Qt::TextAlignmentRole && section == 3) return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
if (role == Qt::TextAlignmentRole && section == 4) return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
|
||||||
if (role == Qt::FontRole) {
|
if (role == Qt::FontRole) {
|
||||||
QFont f;
|
QFont f;
|
||||||
@@ -224,4 +226,4 @@ QString TxTableModel::getType(int row) const {
|
|||||||
|
|
||||||
QString TxTableModel::getAmt(int row) const {
|
QString TxTableModel::getAmt(int row) const {
|
||||||
return Settings::getDecimalString(modeldata->at(row).amount);
|
return Settings::getDecimalString(modeldata->at(row).amount);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user