mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00: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:
		
							parent
							
								
									73747e05a7
								
							
						
					
					
						commit
						289f9ab1d2
					
				
					 10 changed files with 117 additions and 23 deletions
				
			
		| 
						 | 
					@ -334,6 +334,7 @@ void AppContext::onPreferredFiatCurrencyChanged(const QString &symbol) {
 | 
				
			||||||
        auto *model = this->currentWallet->transactionHistoryModel();
 | 
					        auto *model = this->currentWallet->transactionHistoryModel();
 | 
				
			||||||
        if(model != nullptr) {
 | 
					        if(model != nullptr) {
 | 
				
			||||||
            model->preferredFiatSymbol = symbol;
 | 
					            model->preferredFiatSymbol = symbol;
 | 
				
			||||||
 | 
					            this->currentWallet->transactionHistoryModel()->transactionHistory()->calcFiatInfo();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -379,6 +380,13 @@ void AppContext::onWalletOpened(Wallet *wallet) {
 | 
				
			||||||
    connect(this->currentWallet, &Wallet::heightRefreshed, this, &AppContext::onHeightRefreshed);
 | 
					    connect(this->currentWallet, &Wallet::heightRefreshed, this, &AppContext::onHeightRefreshed);
 | 
				
			||||||
    connect(this->currentWallet, &Wallet::transactionCreated, this, &AppContext::onTransactionCreated);
 | 
					    connect(this->currentWallet, &Wallet::transactionCreated, this, &AppContext::onTransactionCreated);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this->currentWallet->historyModel();  // load historyModel
 | 
				
			||||||
 | 
					    auto *txHistory = this->currentWallet->history();
 | 
				
			||||||
 | 
					    txHistory->refresh(this->currentWallet->currentSubaddressAccount());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    connect(AppContext::prices, &Prices::fiatPricesUpdated, txHistory, &TransactionHistory::calcFiatInfo);
 | 
				
			||||||
 | 
					    connect(AppContext::prices, &Prices::cryptoPricesUpdated, txHistory, &TransactionHistory::calcFiatInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    emit walletOpened(wallet);
 | 
					    emit walletOpened(wallet);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(this->currentWallet, &Wallet::connectionStatusChanged, [this]{
 | 
					    connect(this->currentWallet, &Wallet::connectionStatusChanged, [this]{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,12 @@ TransactionInfo* TransactionHistory::transaction(const QString &id)
 | 
				
			||||||
    return itr != m_tinfo.end() ? *itr : nullptr;
 | 
					    return itr != m_tinfo.end() ? *itr : nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TransactionHistory::calcFiatInfo() {
 | 
				
			||||||
 | 
					    for(const auto &tx: m_tinfo) {
 | 
				
			||||||
 | 
					        tx->calcFiatInfo();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TransactionHistory::refresh(quint32 accountIndex)
 | 
					void TransactionHistory::refresh(quint32 accountIndex)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
 | 
					#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,9 @@ public:
 | 
				
			||||||
    quint64 minutesToUnlock() const;
 | 
					    quint64 minutesToUnlock() const;
 | 
				
			||||||
    bool locked() const;
 | 
					    bool locked() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public slots:
 | 
				
			||||||
 | 
					    void calcFiatInfo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
    void refreshStarted() const;
 | 
					    void refreshStarted() const;
 | 
				
			||||||
    void refreshFinished() const;
 | 
					    void refreshFinished() const;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,8 @@
 | 
				
			||||||
#include "libwalletqt/WalletManager.h"
 | 
					#include "libwalletqt/WalletManager.h"
 | 
				
			||||||
#include "Transfer.h"
 | 
					#include "Transfer.h"
 | 
				
			||||||
#include "Ring.h"
 | 
					#include "Ring.h"
 | 
				
			||||||
 | 
					#include "globals.h"
 | 
				
			||||||
 | 
					#include "appcontext.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TransactionInfo::Direction TransactionInfo::direction() const
 | 
					TransactionInfo::Direction TransactionInfo::direction() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -109,6 +111,21 @@ QDateTime TransactionInfo::timestamp() const
 | 
				
			||||||
    return m_timestamp;
 | 
					    return m_timestamp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString TransactionInfo::currentPriceStr() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return m_currentPriceStr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString TransactionInfo::historicalRateStr() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return m_historicalRateStr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString TransactionInfo::historicalPriceStr() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return m_historicalPriceStr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString TransactionInfo::date() const
 | 
					QString TransactionInfo::date() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return timestamp().date().toString(Qt::ISODate);
 | 
					    return timestamp().date().toString(Qt::ISODate);
 | 
				
			||||||
| 
						 | 
					@ -161,6 +178,37 @@ QString TransactionInfo::rings_formatted() const
 | 
				
			||||||
    return rings;
 | 
					    return rings;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TransactionInfo::calcFiatInfo() {
 | 
				
			||||||
 | 
					    auto const hash = this->hash();
 | 
				
			||||||
 | 
					    auto timestamp = this->timestamp().toString("yyyyMMdd");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(!AppContext::prices->markets.contains("WOW"))
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double fiat_rate = AppContext::prices->markets["WOW"].price_usd;
 | 
				
			||||||
 | 
					    double historical_fiat_rate = AppContext::txFiatHistory->get(timestamp);
 | 
				
			||||||
 | 
					    if (historical_fiat_rate == 0.0)
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    auto const preferredFiat = config()->get(Config::preferredFiatCurrency).toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(preferredFiat != "USD") {
 | 
				
			||||||
 | 
					        historical_fiat_rate = AppContext::prices->convert(
 | 
				
			||||||
 | 
					            "USD", preferredFiat, historical_fiat_rate);
 | 
				
			||||||
 | 
					        fiat_rate = AppContext::prices->convert(
 | 
				
			||||||
 | 
					            "USD", preferredFiat, fiat_rate);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double balance = (this->balanceDelta() / globals::cdiv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_historicalRate = historical_fiat_rate;
 | 
				
			||||||
 | 
					    m_historicalPrice = historical_fiat_rate * balance;
 | 
				
			||||||
 | 
					    m_currentPrice = fiat_rate * balance;
 | 
				
			||||||
 | 
					    m_historicalPriceStr = Utils::amountToCurrencyString(m_historicalPrice, preferredFiat, 2);
 | 
				
			||||||
 | 
					    m_historicalRateStr = Utils::amountToCurrencyString(m_historicalRate, preferredFiat, 5);
 | 
				
			||||||
 | 
					    m_currentPriceStr = Utils::amountToCurrencyString(m_currentPrice, preferredFiat, 2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *parent)
 | 
					TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *parent)
 | 
				
			||||||
    : QObject(parent)
 | 
					    : QObject(parent)
 | 
				
			||||||
    , m_amount(pimpl->amount())
 | 
					    , m_amount(pimpl->amount())
 | 
				
			||||||
| 
						 | 
					@ -193,4 +241,6 @@ TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        m_subaddrIndex.insert(i);
 | 
					        m_subaddrIndex.insert(i);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this->calcFiatInfo();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,6 +71,9 @@ public:
 | 
				
			||||||
    QDateTime timestamp() const;
 | 
					    QDateTime timestamp() const;
 | 
				
			||||||
    QString date() const;
 | 
					    QString date() const;
 | 
				
			||||||
    QString time() const;
 | 
					    QString time() const;
 | 
				
			||||||
 | 
					    QString currentPriceStr() const;
 | 
				
			||||||
 | 
					    QString historicalRateStr() const;
 | 
				
			||||||
 | 
					    QString historicalPriceStr() const;
 | 
				
			||||||
    QString paymentId() const;
 | 
					    QString paymentId() const;
 | 
				
			||||||
    //! only applicable for output transactions
 | 
					    //! only applicable for output transactions
 | 
				
			||||||
    //! used in tx details popup
 | 
					    //! used in tx details popup
 | 
				
			||||||
| 
						 | 
					@ -79,6 +82,9 @@ public:
 | 
				
			||||||
    QList<Transfer*> transfers() const;
 | 
					    QList<Transfer*> transfers() const;
 | 
				
			||||||
    QString rings_formatted() const;
 | 
					    QString rings_formatted() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public slots:
 | 
				
			||||||
 | 
					  void calcFiatInfo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    explicit TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *parent = nullptr);
 | 
					    explicit TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *parent = nullptr);
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
| 
						 | 
					@ -102,6 +108,14 @@ private:
 | 
				
			||||||
    QDateTime m_timestamp;
 | 
					    QDateTime m_timestamp;
 | 
				
			||||||
    quint64 m_unlockTime;
 | 
					    quint64 m_unlockTime;
 | 
				
			||||||
    bool m_coinbase;
 | 
					    bool m_coinbase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    double m_historicalPrice = 0.0;
 | 
				
			||||||
 | 
					    double m_historicalRate = 0.0;
 | 
				
			||||||
 | 
					    double m_currentPrice = 0.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QString m_currentPriceStr = "?";
 | 
				
			||||||
 | 
					    QString m_historicalRateStr = "?";
 | 
				
			||||||
 | 
					    QString m_historicalPriceStr = "?";
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // TRANSACTIONINFO_H
 | 
					#endif // TRANSACTIONINFO_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -282,6 +282,9 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // settings connects
 | 
					    // settings connects
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateFiatBalanceWidget);
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateFiatBalanceWidget);
 | 
				
			||||||
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateWowWidget);
 | 
				
			||||||
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateBTCWidget);
 | 
				
			||||||
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, this, &MainWindow::onUpdateXMRWidget);
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, m_ctx, &AppContext::onPreferredFiatCurrencyChanged);
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, m_ctx, &AppContext::onPreferredFiatCurrencyChanged);
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->suchWowWidget, &SuchWowWidget::onPreferredFiatCurrencyChanged);
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->suchWowWidget, &SuchWowWidget::onPreferredFiatCurrencyChanged);
 | 
				
			||||||
    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
 | 
					    connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
 | 
				
			||||||
| 
						 | 
					@ -1411,7 +1414,12 @@ void MainWindow::onUpdateWowWidget() {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto wowObj = AppContext::prices->markets["WOW"];
 | 
					    auto wowObj = AppContext::prices->markets["WOW"];
 | 
				
			||||||
    auto currencyText = Utils::amountToCurrencyString(wowObj.price_usd, fiatCurrency);
 | 
					
 | 
				
			||||||
 | 
					    double amount = wowObj.price_usd;
 | 
				
			||||||
 | 
					    if(fiatCurrency != "USD")
 | 
				
			||||||
 | 
					      amount = AppContext::prices->convert("USD", fiatCurrency, amount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    auto currencyText = Utils::amountToCurrencyString(amount, fiatCurrency, 5);
 | 
				
			||||||
    m_tickerWOW->setFiatText(currencyText);
 | 
					    m_tickerWOW->setFiatText(currencyText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    auto pct24h = AppContext::prices->markets["WOW"].price_usd_change_pct_24h;
 | 
					    auto pct24h = AppContext::prices->markets["WOW"].price_usd_change_pct_24h;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,
 | 
					    // 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
 | 
					    // 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.
 | 
					    // 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 {
 | 
					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) {
 | 
					        else if (role == Qt::TextAlignmentRole) {
 | 
				
			||||||
            switch (index.column()) {
 | 
					            switch (index.column()) {
 | 
				
			||||||
                case TransactionInfoRole::Amount:
 | 
					                case TransactionInfoRole::Amount:
 | 
				
			||||||
                case TransactionInfoRole::FiatAmount:
 | 
					                case TransactionInfoRole::HistoricalPrice:
 | 
				
			||||||
 | 
					                case TransactionInfoRole::HistoricalRate:
 | 
				
			||||||
 | 
					                case TransactionInfoRole::CurrentPrice:
 | 
				
			||||||
                    result = Qt::AlignRight;
 | 
					                    result = Qt::AlignRight;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -118,7 +120,6 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (role == Qt::ForegroundRole) {
 | 
					        else if (role == Qt::ForegroundRole) {
 | 
				
			||||||
            switch(index.column()) {
 | 
					            switch(index.column()) {
 | 
				
			||||||
                case TransactionInfoRole::FiatAmount:
 | 
					 | 
				
			||||||
                case TransactionInfoRole::Amount:
 | 
					                case TransactionInfoRole::Amount:
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (tInfo.direction() == TransactionInfo::Direction_Out) {
 | 
					                    if (tInfo.direction() == TransactionInfo::Direction_Out) {
 | 
				
			||||||
| 
						 | 
					@ -170,18 +171,16 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tI
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        case TransactionInfoRole::TxID:
 | 
					        case TransactionInfoRole::TxID:
 | 
				
			||||||
            return tInfo.hash();
 | 
					            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"));
 | 
					            return tInfo.historicalPriceStr();
 | 
				
			||||||
            if (usd_price == 0.0)
 | 
					        }
 | 
				
			||||||
                return QVariant("?");
 | 
					        case TransactionInfoRole::CurrentPrice:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            double usd_amount = usd_price * (tInfo.balanceDelta() / globals::cdiv);
 | 
					            return tInfo.currentPriceStr();
 | 
				
			||||||
            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));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -206,8 +205,12 @@ QVariant TransactionHistoryModel::headerData(int section, Qt::Orientation orient
 | 
				
			||||||
                return QString("Amount");
 | 
					                return QString("Amount");
 | 
				
			||||||
            case TransactionInfoRole::TxID:
 | 
					            case TransactionInfoRole::TxID:
 | 
				
			||||||
                return QString("Txid");
 | 
					                return QString("Txid");
 | 
				
			||||||
            case TransactionInfoRole::FiatAmount:
 | 
					            case TransactionInfoRole::HistoricalPrice:
 | 
				
			||||||
                return QString("Fiat");
 | 
					                return QString("Historical price");
 | 
				
			||||||
 | 
					            case TransactionInfoRole::HistoricalRate:
 | 
				
			||||||
 | 
					                return QString("Historical rate");
 | 
				
			||||||
 | 
					            case TransactionInfoRole::CurrentPrice:
 | 
				
			||||||
 | 
					                return QString("Current price");
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                return QVariant();
 | 
					                return QVariant();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,9 @@ public:
 | 
				
			||||||
        Description,
 | 
					        Description,
 | 
				
			||||||
        Amount,
 | 
					        Amount,
 | 
				
			||||||
        TxID,
 | 
					        TxID,
 | 
				
			||||||
        FiatAmount,
 | 
					        HistoricalPrice,
 | 
				
			||||||
 | 
					        HistoricalRate,
 | 
				
			||||||
 | 
					        CurrentPrice,
 | 
				
			||||||
        TransactionIsOutRole,
 | 
					        TransactionIsOutRole,
 | 
				
			||||||
        TransactionFailedRole,
 | 
					        TransactionFailedRole,
 | 
				
			||||||
        TransactionPendingRole,
 | 
					        TransactionPendingRole,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -418,14 +418,14 @@ double Utils::roundUp(double value, int decimal_places) {
 | 
				
			||||||
    return std::ceil(value * multiplier) / multiplier;
 | 
					    return std::ceil(value * multiplier) / multiplier;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode) {
 | 
					QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode, int precision) {
 | 
				
			||||||
    QLocale locale = getCurrencyLocale(currencyCode);
 | 
					    QLocale locale = getCurrencyLocale(currencyCode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // \xC2\xA0 = UTF-8 non-breaking space, it looks off.
 | 
					    // \xC2\xA0 = UTF-8 non-breaking space, it looks off.
 | 
				
			||||||
    if (currencyCode == "USD")
 | 
					    if (currencyCode == "USD")
 | 
				
			||||||
        return locale.toCurrencyString(amount, "$").remove("\xC2\xA0");
 | 
					        return locale.toCurrencyString(amount, "$", precision).remove("\xC2\xA0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return locale.toCurrencyString(amount).remove("\xC2\xA0");
 | 
					    return locale.toCurrencyString(amount, nullptr, precision).remove("\xC2\xA0");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int Utils::maxLength(const QVector<QString> &array) {
 | 
					int Utils::maxLength(const QVector<QString> &array) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@ public:
 | 
				
			||||||
    static double roundSignificant(double N, double n);
 | 
					    static double roundSignificant(double N, double n);
 | 
				
			||||||
    static QString formatBytes(quint64 bytes);
 | 
					    static QString formatBytes(quint64 bytes);
 | 
				
			||||||
    static QLocale getCurrencyLocale(const QString ¤cyCode);
 | 
					    static QLocale getCurrencyLocale(const QString ¤cyCode);
 | 
				
			||||||
    static QString amountToCurrencyString(double amount, const QString ¤cyCode);
 | 
					    static QString amountToCurrencyString(double amount, const QString ¤cyCode, int precision = 2);
 | 
				
			||||||
    static int maxLength(const QVector<QString> &array);
 | 
					    static int maxLength(const QVector<QString> &array);
 | 
				
			||||||
    static double roundUp(double value, int decimal_places);
 | 
					    static double roundUp(double value, int decimal_places);
 | 
				
			||||||
    static QMap<QString, QLocale> localeCache;
 | 
					    static QMap<QString, QLocale> localeCache;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue