Revert "History: add balance column"

This reverts commit 9ec53dc7d5.
This commit is contained in:
tobtoht 2023-10-03 21:55:10 +02:00
parent c5ab083095
commit 1bf05f15ff
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
7 changed files with 10 additions and 40 deletions

2
monero

@ -1 +1 @@
Subproject commit 4401b48de9067b6af566f0d33e95f769350c85cd
Subproject commit db1ac578a16e678f0778fb37001921f93704f0ed

View file

@ -64,22 +64,13 @@ void TransactionHistory::refresh(quint32 accountIndex)
m_locked = false;
m_minutesToUnlock = 0;
quint64 balance = 0;
m_pimpl->refresh();
for (const auto i : m_pimpl->getAll()) {
if (i->subaddrAccount() != accountIndex) {
continue;
}
if (i->direction() == Monero::TransactionInfo::Direction_In) {
balance += i->amount();
}
else if (i->direction() == Monero::TransactionInfo::Direction_Out) {
balance -= i->amount() + i->fee();
}
m_tinfo.append(new TransactionInfo(i, balance, this));
m_tinfo.append(new TransactionInfo(i, this));
const TransactionInfo *ti = m_tinfo.back();
// looking for transactions timestamp scope
@ -168,7 +159,7 @@ bool TransactionHistory::writeCSV(const QString &path) {
});
for (const auto &tx : transactions) {
TransactionInfo info(tx, 0, this);
TransactionInfo info(tx, this);
// collect column data
QDateTime timeStamp = info.timestamp();

View file

@ -37,11 +37,6 @@ quint64 TransactionInfo::balanceDelta() const
return m_amount;
}
quint64 TransactionInfo::balance() const
{
return m_balance;
}
double TransactionInfo::amount() const
{
// there's no unsigned uint64 for JS, so better use double
@ -172,7 +167,7 @@ QString TransactionInfo::rings_formatted() const
return rings;
}
TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, quint64 balance, QObject *parent)
TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *parent)
: QObject(parent)
, m_amount(pimpl->amount())
, m_blockHeight(pimpl->blockHeight())
@ -189,7 +184,6 @@ TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, quint64 b
, m_timestamp(QDateTime::fromSecsSinceEpoch(pimpl->timestamp()))
, m_unlockTime(pimpl->unlockTime())
, m_coinbase(pimpl->isCoinbase())
, m_balance(balance)
{
for (auto const &t: pimpl->transfers())
{

View file

@ -53,7 +53,6 @@ public:
bool isFailed() const;
bool isCoinbase() const;
quint64 balanceDelta() const;
quint64 balance() const;
double amount() const;
quint64 atomicAmount() const;
QString displayAmount() const;
@ -81,7 +80,7 @@ public:
QString rings_formatted() const;
private:
explicit TransactionInfo(const Monero::TransactionInfo *pimpl, quint64 balance, QObject *parent = nullptr);
explicit TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *parent = nullptr);
private:
friend class TransactionHistory;
mutable QList<Transfer*> m_transfers;
@ -103,7 +102,6 @@ private:
QDateTime m_timestamp;
quint64 m_unlockTime;
bool m_coinbase;
quint64 m_balance;
};
#endif // TRANSACTIONINFO_H

View file

@ -181,7 +181,6 @@ void HistoryView::resetViewToDefaults()
header()->showSection(TransactionHistoryModel::Description);
header()->showSection(TransactionHistoryModel::Amount);
header()->showSection(TransactionHistoryModel::FiatAmount);
header()->hideSection(TransactionHistoryModel::Balance);
// Reset column order to logical indices
for (int i = 0; i < header()->count(); ++i) {

View file

@ -67,7 +67,7 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
bool found = m_transactionHistory->transaction(index.row(), [this, &index, &result, &role](const TransactionInfo &tInfo) {
if(role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole) {
result = parseTransactionInfo(tInfo, index.row(), index.column(), role);
result = parseTransactionInfo(tInfo, index.column(), role);
}
else if (role == Qt::TextAlignmentRole) {
switch (index.column()) {
@ -139,14 +139,14 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
return result;
}
QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tInfo, int row, int column, int role) const
QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tInfo, int column, int role) const
{
switch (column)
{
case Column::Date:
{
if (role == Qt::UserRole) {
return row;
return tInfo.timestamp();
}
return tInfo.timestamp().toString(QString("%1 %2 ").arg(conf()->get(Config::dateFormat).toString(),
conf()->get(Config::timeFormat).toString()));
@ -158,7 +158,7 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tI
if (role == Qt::UserRole) {
return tInfo.balanceDelta();
}
auto amount = this->formatAmount(tInfo.balanceDelta());
QString amount = QString::number(tInfo.balanceDelta() / constants::cdiv, 'f', conf()->get(Config::amountPrecision).toInt());
amount = (tInfo.direction() == TransactionInfo::Direction_Out) ? "-" + amount : "+" + amount;
return amount;
}
@ -188,10 +188,6 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tI
double fiat_rounded = ceil(Utils::roundSignificant(usd_amount, 3) * 100.0) / 100.0;
return QString("%1").arg(Utils::amountToCurrencyString(fiat_rounded, preferredFiatCurrency));
}
case Column::Balance:
{
return this->formatAmount(tInfo.balance());
}
default:
{
qCritical() << "Unimplemented role";
@ -200,10 +196,6 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tI
}
}
QString TransactionHistoryModel::formatAmount(quint64 amount) const {
return QString::number(amount / constants::cdiv, 'f', conf()->get(Config::amountPrecision).toInt());
}
QVariant TransactionHistoryModel::headerData(int section, Qt::Orientation orientation, int role) const {
Q_UNUSED(orientation)
if (role != Qt::DisplayRole) {
@ -221,8 +213,6 @@ QVariant TransactionHistoryModel::headerData(int section, Qt::Orientation orient
return QString("Txid");
case Column::FiatAmount:
return QString("Fiat");
case Column::Balance:
return QString("Balance");
default:
return QVariant();
}

View file

@ -27,7 +27,6 @@ public:
Description,
Amount,
FiatAmount,
Balance,
COUNT
};
@ -48,8 +47,7 @@ signals:
void transactionHistoryChanged();
private:
QVariant parseTransactionInfo(const TransactionInfo &tInfo, int row, int column, int role) const;
QString formatAmount(quint64 amount) const;
QVariant parseTransactionInfo(const TransactionInfo &tInfo, int column, int role) const;
TransactionHistory * m_transactionHistory;
};