mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 12:09:57 +00:00
Fix sum of selected transactions being slighty off
due to floating point operations
This commit is contained in:
parent
68736ab834
commit
69146567bf
6 changed files with 28 additions and 5 deletions
|
@ -48,13 +48,19 @@ Rectangle {
|
|||
for (var i = 0; i < count; ++i) {
|
||||
var idx = model.index(i, 0)
|
||||
var isout = model.data(idx, TransactionHistoryModel.TransactionIsOutRole);
|
||||
var amount = model.data(idx, TransactionHistoryModel.TransactionAmountRole);
|
||||
var amount = model.data(idx, TransactionHistoryModel.TransactionAtomicAmountRole);
|
||||
if (isout)
|
||||
total -= amount
|
||||
total = walletManager.subi(total, amount)
|
||||
else
|
||||
total += amount
|
||||
total = walletManager.addi(total, amount)
|
||||
}
|
||||
return count + qsTr(" selected: ") + total;
|
||||
|
||||
var sign = ""
|
||||
if (total < 0) {
|
||||
total = -total
|
||||
sign = "-"
|
||||
}
|
||||
return count + qsTr(" selected: ") + sign + walletManager.displayAmount(total);
|
||||
}
|
||||
|
||||
onModelChanged: {
|
||||
|
|
|
@ -25,6 +25,11 @@ double TransactionInfo::amount() const
|
|||
return WalletManager::instance()->displayAmount(m_pimpl->amount()).toDouble();
|
||||
}
|
||||
|
||||
quint64 TransactionInfo::atomicAmount() const
|
||||
{
|
||||
return m_pimpl->amount();
|
||||
}
|
||||
|
||||
QString TransactionInfo::displayAmount() const
|
||||
{
|
||||
return WalletManager::instance()->displayAmount(m_pimpl->amount());
|
||||
|
|
|
@ -12,6 +12,7 @@ class TransactionInfo : public QObject
|
|||
Q_PROPERTY(bool isPending READ isPending)
|
||||
Q_PROPERTY(bool isFailed READ isFailed)
|
||||
Q_PROPERTY(double amount READ amount)
|
||||
Q_PROPERTY(quint64 atomicAmount READ atomicAmount)
|
||||
Q_PROPERTY(QString displayAmount READ displayAmount)
|
||||
Q_PROPERTY(QString fee READ fee)
|
||||
Q_PROPERTY(quint64 blockHeight READ blockHeight)
|
||||
|
@ -42,6 +43,7 @@ public:
|
|||
bool isPending() const;
|
||||
bool isFailed() const;
|
||||
double amount() const;
|
||||
quint64 atomicAmount() const;
|
||||
QString displayAmount() const;
|
||||
QString fee() const;
|
||||
quint64 blockHeight() const;
|
||||
|
|
|
@ -101,6 +101,11 @@ public:
|
|||
|
||||
void setLogLevel(int logLevel);
|
||||
|
||||
Q_INVOKABLE quint64 add(quint64 x, quint64 y) const { return x + y; }
|
||||
Q_INVOKABLE quint64 sub(quint64 x, quint64 y) const { return x - y; }
|
||||
Q_INVOKABLE qint64 addi(qint64 x, qint64 y) const { return x + y; }
|
||||
Q_INVOKABLE qint64 subi(qint64 x, qint64 y) const { return x - y; }
|
||||
|
||||
signals:
|
||||
|
||||
void walletOpened(Wallet * wallet);
|
||||
|
|
|
@ -68,6 +68,9 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
|
|||
case TransactionDisplayAmountRole:
|
||||
result = tInfo->displayAmount();
|
||||
break;
|
||||
case TransactionAtomicAmountRole:
|
||||
result = tInfo->atomicAmount();
|
||||
break;
|
||||
case TransactionFeeRole:
|
||||
result = tInfo->fee();
|
||||
break;
|
||||
|
@ -112,6 +115,7 @@ QHash<int, QByteArray> TransactionHistoryModel::roleNames() const
|
|||
roleNames.insert(TransactionFailedRole, "isFailed");
|
||||
roleNames.insert(TransactionAmountRole, "amount");
|
||||
roleNames.insert(TransactionDisplayAmountRole, "displayAmount");
|
||||
roleNames.insert(TransactionAtomicAmountRole, "atomicAmount");
|
||||
roleNames.insert(TransactionFeeRole, "fee");
|
||||
roleNames.insert(TransactionBlockHeightRole, "blockHeight");
|
||||
roleNames.insert(TransactionHashRole, "hash");
|
||||
|
|
|
@ -32,7 +32,8 @@ public:
|
|||
TransactionIsOutRole,
|
||||
// extra roles for date and time (as UI wants date and time separately)
|
||||
TransactionDateRole,
|
||||
TransactionTimeRole
|
||||
TransactionTimeRole,
|
||||
TransactionAtomicAmountRole
|
||||
};
|
||||
Q_ENUM(TransactionInfoRole)
|
||||
|
||||
|
|
Loading…
Reference in a new issue