Merge pull request #3572

544cff7 TransactionHistory: add description to csv export (selsta)
57c2052 TransactionInfo: add isCoinbase and description (selsta)
This commit is contained in:
luigi1111 2021-09-05 12:58:39 -04:00
commit edb0358916
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
3 changed files with 22 additions and 3 deletions

View File

@ -170,7 +170,7 @@ QString TransactionHistory::writeCSV(quint32 accountIndex, QString out)
// write header // write header
QTextStream output(&data); QTextStream output(&data);
output << "blockHeight,epoch,date,direction,amount,atomicAmount,fee,txid,label,subaddrAccount,paymentId\n"; output << "blockHeight,epoch,date,direction,amount,atomicAmount,fee,txid,label,subaddrAccount,paymentId,description\n";
QReadLocker locker(&m_lock); QReadLocker locker(&m_lock);
for (const auto &tx : m_pimpl->getAll()) { for (const auto &tx : m_pimpl->getAll()) {
@ -198,6 +198,8 @@ QString TransactionHistory::writeCSV(quint32 accountIndex, QString out)
} }
QString label = info.label(); QString label = info.label();
label.remove(QChar('"')); // reserved label.remove(QChar('"')); // reserved
QString description = info.description();
description.remove(QChar('"')); // reserved
quint64 blockHeight = info.blockHeight(); quint64 blockHeight = info.blockHeight();
QDateTime timeStamp = info.timestamp(); QDateTime timeStamp = info.timestamp();
QString date = info.date() + " " + info.time(); QString date = info.date() + " " + info.time();
@ -209,11 +211,11 @@ QString TransactionHistory::writeCSV(quint32 accountIndex, QString out)
} }
// format and write // format and write
QString line = QString("%1,%2,%3,%4,%5,%6,%7,%8,\"%9\",%10,%11\n") QString line = QString("%1,%2,%3,%4,%5,%6,%7,%8,\"%9\",%10,%11,\"%12\"\n")
.arg(QString::number(blockHeight), QString::number(epoch), date) .arg(QString::number(blockHeight), QString::number(epoch), date)
.arg(direction, displayAmount, QString::number(atomicAmount)) .arg(direction, displayAmount, QString::number(atomicAmount))
.arg(info.fee(), info.hash(), label, QString::number(subaddrAccount)) .arg(info.fee(), info.hash(), label, QString::number(subaddrAccount))
.arg(paymentId); .arg(paymentId, description);
output << line; output << line;
} }

View File

@ -47,6 +47,10 @@ bool TransactionInfo::isFailed() const
return m_failed; return m_failed;
} }
bool TransactionInfo::isCoinbase() const
{
return m_coinbase;
}
double TransactionInfo::amount() const double TransactionInfo::amount() const
{ {
@ -126,6 +130,11 @@ QString TransactionInfo::paymentId() const
return m_paymentId; return m_paymentId;
} }
QString TransactionInfo::description() const
{
return m_description;
}
QString TransactionInfo::destinations_formatted() const QString TransactionInfo::destinations_formatted() const
{ {
QString destinations; QString destinations;
@ -144,10 +153,12 @@ TransactionInfo::TransactionInfo(const Monero::TransactionInfo *pimpl, QObject *
, m_confirmations(pimpl->confirmations()) , m_confirmations(pimpl->confirmations())
, m_direction(static_cast<Direction>(pimpl->direction())) , m_direction(static_cast<Direction>(pimpl->direction()))
, m_failed(pimpl->isFailed()) , m_failed(pimpl->isFailed())
, m_coinbase(pimpl->isCoinbase())
, m_fee(pimpl->fee()) , m_fee(pimpl->fee())
, m_hash(QString::fromStdString(pimpl->hash())) , m_hash(QString::fromStdString(pimpl->hash()))
, m_label(QString::fromStdString(pimpl->label())) , m_label(QString::fromStdString(pimpl->label()))
, m_paymentId(QString::fromStdString(pimpl->paymentId())) , m_paymentId(QString::fromStdString(pimpl->paymentId()))
, m_description(QString::fromStdString(pimpl->description()))
, m_pending(pimpl->isPending()) , m_pending(pimpl->isPending())
, m_subaddrAccount(pimpl->subaddrAccount()) , m_subaddrAccount(pimpl->subaddrAccount())
, m_timestamp(QDateTime::fromTime_t(pimpl->timestamp())) , m_timestamp(QDateTime::fromTime_t(pimpl->timestamp()))

View File

@ -42,6 +42,7 @@ class TransactionInfo : public QObject
Q_PROPERTY(Direction direction READ direction) Q_PROPERTY(Direction direction READ direction)
Q_PROPERTY(bool isPending READ isPending) Q_PROPERTY(bool isPending READ isPending)
Q_PROPERTY(bool isFailed READ isFailed) Q_PROPERTY(bool isFailed READ isFailed)
Q_PROPERTY(bool isCoinbase READ isCoinbase)
Q_PROPERTY(double amount READ amount) Q_PROPERTY(double amount READ amount)
Q_PROPERTY(quint64 atomicAmount READ atomicAmount) Q_PROPERTY(quint64 atomicAmount READ atomicAmount)
Q_PROPERTY(QString displayAmount READ displayAmount) Q_PROPERTY(QString displayAmount READ displayAmount)
@ -57,6 +58,7 @@ class TransactionInfo : public QObject
Q_PROPERTY(QString date READ date) Q_PROPERTY(QString date READ date)
Q_PROPERTY(QString time READ time) Q_PROPERTY(QString time READ time)
Q_PROPERTY(QString paymentId READ paymentId) Q_PROPERTY(QString paymentId READ paymentId)
Q_PROPERTY(QString description READ description)
Q_PROPERTY(QString destinations_formatted READ destinations_formatted) Q_PROPERTY(QString destinations_formatted READ destinations_formatted)
public: public:
@ -71,6 +73,7 @@ public:
Direction direction() const; Direction direction() const;
bool isPending() const; bool isPending() const;
bool isFailed() const; bool isFailed() const;
bool isCoinbase() const;
double amount() const; double amount() const;
quint64 atomicAmount() const; quint64 atomicAmount() const;
QString displayAmount() const; QString displayAmount() const;
@ -87,6 +90,7 @@ public:
QString date() const; QString date() const;
QString time() const; QString time() const;
QString paymentId() const; QString paymentId() const;
QString description() const;
//! only applicable for output transactions //! only applicable for output transactions
//! used in tx details popup //! used in tx details popup
QString destinations_formatted() const; QString destinations_formatted() const;
@ -104,7 +108,9 @@ private:
QString m_hash; QString m_hash;
QString m_label; QString m_label;
QString m_paymentId; QString m_paymentId;
QString m_description;
bool m_pending; bool m_pending;
bool m_coinbase;
quint32 m_subaddrAccount; quint32 m_subaddrAccount;
QSet<quint32> m_subaddrIndex; QSet<quint32> m_subaddrIndex;
QDateTime m_timestamp; QDateTime m_timestamp;