mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-30 04:39:57 +01:00
The balance fiat display does not 'round to ceiling' anymore, instead introduced some more decimals:
 New fiat columns in the history table: - Historical price (`balance * historical fiat price`) - Historical rate (the historical fiat price at that date) - Current price (`balance * current fiat price`)  When preferred fiat is changed (in the settings), the balance fiat display now follows accordingly. Requires https://git.wownero.com/wowlet/wowlet-backend/pulls/19
This commit is contained in:
@@ -53,10 +53,10 @@ int TransactionHistoryModel::columnCount(const QModelIndex &parent) const {
|
||||
|
||||
// When wowlet is in QtWidgets mode, it will only use the first 5 columns,
|
||||
// the rest should be hidden, because it shows in the GUI. So by default we'll
|
||||
// use 5 as column count. When in QtQuick (QML) mode, we want to expose more columns
|
||||
// use 6 as column count. When in QtQuick (QML) mode, we want to expose more columns
|
||||
// so we can change the column count here.
|
||||
|
||||
return AppContext::isQML ? this->COUNT : 5;
|
||||
return AppContext::isQML ? this->COUNT : 7;
|
||||
}
|
||||
|
||||
QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const {
|
||||
@@ -76,7 +76,9 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
|
||||
else if (role == Qt::TextAlignmentRole) {
|
||||
switch (index.column()) {
|
||||
case TransactionInfoRole::Amount:
|
||||
case TransactionInfoRole::FiatAmount:
|
||||
case TransactionInfoRole::HistoricalPrice:
|
||||
case TransactionInfoRole::HistoricalRate:
|
||||
case TransactionInfoRole::CurrentPrice:
|
||||
result = Qt::AlignRight;
|
||||
}
|
||||
}
|
||||
@@ -118,7 +120,6 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
else if (role == Qt::ForegroundRole) {
|
||||
switch(index.column()) {
|
||||
case TransactionInfoRole::FiatAmount:
|
||||
case TransactionInfoRole::Amount:
|
||||
{
|
||||
if (tInfo.direction() == TransactionInfo::Direction_Out) {
|
||||
@@ -170,18 +171,16 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tI
|
||||
}
|
||||
case TransactionInfoRole::TxID:
|
||||
return tInfo.hash();
|
||||
case TransactionInfoRole::FiatAmount:
|
||||
case TransactionInfoRole::HistoricalRate: {
|
||||
return tInfo.historicalRateStr();
|
||||
}
|
||||
case TransactionInfoRole::HistoricalPrice:
|
||||
{
|
||||
double usd_price = AppContext::txFiatHistory->get(tInfo.timestamp().toString("yyyyMMdd"));
|
||||
if (usd_price == 0.0)
|
||||
return QVariant("?");
|
||||
|
||||
double usd_amount = usd_price * (tInfo.balanceDelta() / globals::cdiv);
|
||||
if(this->preferredFiatSymbol != "USD")
|
||||
usd_amount = AppContext::prices->convert("USD", this->preferredFiatSymbol, usd_amount);
|
||||
double fiat_rounded = ceil(Utils::roundSignificant(usd_amount, 3) * 100.0) / 100.0;
|
||||
|
||||
return QString("%1").arg(Utils::amountToCurrencyString(fiat_rounded, this->preferredFiatSymbol));
|
||||
return tInfo.historicalPriceStr();
|
||||
}
|
||||
case TransactionInfoRole::CurrentPrice:
|
||||
{
|
||||
return tInfo.currentPriceStr();
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -206,8 +205,12 @@ QVariant TransactionHistoryModel::headerData(int section, Qt::Orientation orient
|
||||
return QString("Amount");
|
||||
case TransactionInfoRole::TxID:
|
||||
return QString("Txid");
|
||||
case TransactionInfoRole::FiatAmount:
|
||||
return QString("Fiat");
|
||||
case TransactionInfoRole::HistoricalPrice:
|
||||
return QString("Historical price");
|
||||
case TransactionInfoRole::HistoricalRate:
|
||||
return QString("Historical rate");
|
||||
case TransactionInfoRole::CurrentPrice:
|
||||
return QString("Current price");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user