mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-18 23:53:41 +02:00
Merge pull request #235
e1255bd
history: remove unused dependencies (Jaquee)9341d75
history: print destination address in tx details popup (Jaquee)7aea3d3
TransactionInfo: add transfers() and destinations_formatted() (Jaquee)a4c3de9
history: add Transfer class (Jaquee)
This commit is contained in:
commit
bb506a2e92
@ -37,7 +37,7 @@ ListView {
|
|||||||
property var previousItem
|
property var previousItem
|
||||||
property int rowSpacing: 12
|
property int rowSpacing: 12
|
||||||
|
|
||||||
function buildTxDetailsString(tx_id, paymentId, tx_key,tx_note) {
|
function buildTxDetailsString(tx_id, paymentId, tx_key,tx_note, destinations) {
|
||||||
var trStart = '<tr><td width="85" style="padding-top:5px"><b>',
|
var trStart = '<tr><td width="85" style="padding-top:5px"><b>',
|
||||||
trMiddle = '</b></td><td style="padding-left:10px;padding-top:5px;">',
|
trMiddle = '</b></td><td style="padding-left:10px;padding-top:5px;">',
|
||||||
trEnd = "</td></tr>";
|
trEnd = "</td></tr>";
|
||||||
@ -47,6 +47,7 @@ ListView {
|
|||||||
+ (paymentId ? trStart + qsTr("Payment ID:") + trMiddle + paymentId + trEnd : "")
|
+ (paymentId ? trStart + qsTr("Payment ID:") + trMiddle + paymentId + trEnd : "")
|
||||||
+ (tx_key ? trStart + qsTr("Tx key:") + trMiddle + tx_key + trEnd : "")
|
+ (tx_key ? trStart + qsTr("Tx key:") + trMiddle + tx_key + trEnd : "")
|
||||||
+ (tx_note ? trStart + qsTr("Tx note:") + trMiddle + tx_note + trEnd : "")
|
+ (tx_note ? trStart + qsTr("Tx note:") + trMiddle + tx_note + trEnd : "")
|
||||||
|
+ (destinations ? trStart + qsTr("Destinations:") + trMiddle + destinations + trEnd : "")
|
||||||
+ "</table>"
|
+ "</table>"
|
||||||
+ translationManager.emptyString;
|
+ translationManager.emptyString;
|
||||||
}
|
}
|
||||||
@ -72,6 +73,7 @@ ListView {
|
|||||||
width:600
|
width:600
|
||||||
cancelVisible: false
|
cancelVisible: false
|
||||||
okVisible: true
|
okVisible: true
|
||||||
|
width:850
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,12 +99,10 @@ ListView {
|
|||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
text: qsTr("Details")
|
text: qsTr("Details")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log(hash)
|
|
||||||
var tx_key = currentWallet.getTxKey(hash)
|
var tx_key = currentWallet.getTxKey(hash)
|
||||||
var tx_note = currentWallet.getUserNote(hash)
|
var tx_note = currentWallet.getUserNote(hash)
|
||||||
console.log("key",tx_key);
|
|
||||||
detailsPopup.title = "Transaction details";
|
detailsPopup.title = "Transaction details";
|
||||||
detailsPopup.content = buildTxDetailsString(hash,paymentId,tx_key,tx_note);
|
detailsPopup.content = buildTxDetailsString(hash,paymentId,tx_key,tx_note,destinations);
|
||||||
detailsPopup.open();
|
detailsPopup.open();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ HEADERS += \
|
|||||||
src/libwalletqt/TransactionHistory.h \
|
src/libwalletqt/TransactionHistory.h \
|
||||||
src/libwalletqt/TransactionInfo.h \
|
src/libwalletqt/TransactionInfo.h \
|
||||||
src/libwalletqt/QRCodeImageProvider.h \
|
src/libwalletqt/QRCodeImageProvider.h \
|
||||||
|
src/libwalletqt/Transfer.h \
|
||||||
oshelper.h \
|
oshelper.h \
|
||||||
TranslationManager.h \
|
TranslationManager.h \
|
||||||
src/model/TransactionHistoryModel.h \
|
src/model/TransactionHistoryModel.h \
|
||||||
|
@ -41,7 +41,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Wallet;
|
friend class Wallet;
|
||||||
|
|
||||||
Bitmonero::TransactionHistory * m_pimpl;
|
Bitmonero::TransactionHistory * m_pimpl;
|
||||||
mutable QList<TransactionInfo*> m_tinfo;
|
mutable QList<TransactionInfo*> m_tinfo;
|
||||||
mutable QDateTime m_firstDateTime;
|
mutable QDateTime m_firstDateTime;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include "TransactionInfo.h"
|
#include "TransactionInfo.h"
|
||||||
#include "WalletManager.h"
|
#include "WalletManager.h"
|
||||||
|
#include "Transfer.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
TransactionInfo::Direction TransactionInfo::direction() const
|
TransactionInfo::Direction TransactionInfo::direction() const
|
||||||
{
|
{
|
||||||
@ -71,6 +72,31 @@ QString TransactionInfo::paymentId() const
|
|||||||
return QString::fromStdString(m_pimpl->paymentId());
|
return QString::fromStdString(m_pimpl->paymentId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TransactionInfo::destinations_formatted() const
|
||||||
|
{
|
||||||
|
QString destinations;
|
||||||
|
for (auto const& t: transfers()) {
|
||||||
|
if (!destinations.isEmpty())
|
||||||
|
destinations += "<br> ";
|
||||||
|
destinations += WalletManager::instance()->displayAmount(t->amount()) + ": " + t->address();
|
||||||
|
}
|
||||||
|
return destinations;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Transfer*> TransactionInfo::transfers() const
|
||||||
|
{
|
||||||
|
if (!m_transfers.isEmpty()) {
|
||||||
|
return m_transfers;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto const& t: m_pimpl->transfers()) {
|
||||||
|
TransactionInfo * parent = const_cast<TransactionInfo*>(this);
|
||||||
|
Transfer * transfer = new Transfer(t.amount, QString::fromStdString(t.address), parent);
|
||||||
|
m_transfers.append(transfer);
|
||||||
|
}
|
||||||
|
return m_transfers;
|
||||||
|
}
|
||||||
|
|
||||||
TransactionInfo::TransactionInfo(Bitmonero::TransactionInfo *pimpl, QObject *parent)
|
TransactionInfo::TransactionInfo(Bitmonero::TransactionInfo *pimpl, QObject *parent)
|
||||||
: QObject(parent), m_pimpl(pimpl)
|
: QObject(parent), m_pimpl(pimpl)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
class Transfer;
|
||||||
|
|
||||||
class TransactionInfo : public QObject
|
class TransactionInfo : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -21,6 +23,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 destinations_formatted READ destinations_formatted)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Direction {
|
enum Direction {
|
||||||
@ -31,14 +34,6 @@ public:
|
|||||||
|
|
||||||
Q_ENUM(Direction)
|
Q_ENUM(Direction)
|
||||||
|
|
||||||
// TODO: implement as separate class;
|
|
||||||
|
|
||||||
// struct Transfer {
|
|
||||||
// Transfer(uint64_t _amount, const std::string &address);
|
|
||||||
// const uint64_t amount;
|
|
||||||
// const std::string address;
|
|
||||||
// };
|
|
||||||
|
|
||||||
Direction direction() const;
|
Direction direction() const;
|
||||||
bool isPending() const;
|
bool isPending() const;
|
||||||
bool isFailed() const;
|
bool isFailed() const;
|
||||||
@ -53,16 +48,17 @@ public:
|
|||||||
QString date() const;
|
QString date() const;
|
||||||
QString time() const;
|
QString time() const;
|
||||||
QString paymentId() const;
|
QString paymentId() const;
|
||||||
|
|
||||||
|
|
||||||
// TODO: implement it
|
|
||||||
//! only applicable for output transactions
|
//! only applicable for output transactions
|
||||||
// virtual const std::vector<Transfer> & transfers() const = 0;
|
//! used in tx details popup
|
||||||
|
QString destinations_formatted() const;
|
||||||
|
//! Could be useful later when addressbook is implemented
|
||||||
|
Q_INVOKABLE QList<Transfer*> transfers() const;
|
||||||
private:
|
private:
|
||||||
explicit TransactionInfo(Bitmonero::TransactionInfo * pimpl, QObject *parent = 0);
|
explicit TransactionInfo(Bitmonero::TransactionInfo * pimpl, QObject *parent = 0);
|
||||||
private:
|
private:
|
||||||
friend class TransactionHistory;
|
friend class TransactionHistory;
|
||||||
Bitmonero::TransactionInfo * m_pimpl;
|
Bitmonero::TransactionInfo * m_pimpl;
|
||||||
|
mutable QList<Transfer*> m_transfers;
|
||||||
};
|
};
|
||||||
|
|
||||||
// in order to wrap it to QVariant
|
// in order to wrap it to QVariant
|
||||||
|
24
src/libwalletqt/Transfer.h
Normal file
24
src/libwalletqt/Transfer.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef TRANSFER_H
|
||||||
|
#define TRANSFER_H
|
||||||
|
|
||||||
|
#include <wallet/wallet2_api.h>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class Transfer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(quint64 amount READ amount)
|
||||||
|
Q_PROPERTY(QString address READ address)
|
||||||
|
private:
|
||||||
|
explicit Transfer(uint64_t _amount, const QString &_address, QObject *parent = 0): QObject(parent), m_amount(_amount), m_address(_address) {};
|
||||||
|
private:
|
||||||
|
friend class TransactionInfo;
|
||||||
|
quint64 m_amount;
|
||||||
|
QString m_address;
|
||||||
|
public:
|
||||||
|
quint64 amount() const { return m_amount; }
|
||||||
|
QString address() const { return m_address; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSACTIONINFO_H
|
@ -95,6 +95,9 @@ QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const
|
|||||||
case TransactionTimeRole:
|
case TransactionTimeRole:
|
||||||
result = tInfo->time();
|
result = tInfo->time();
|
||||||
break;
|
break;
|
||||||
|
case TransactionDestinationsRole:
|
||||||
|
result = tInfo->destinations_formatted();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -124,6 +127,7 @@ QHash<int, QByteArray> TransactionHistoryModel::roleNames() const
|
|||||||
roleNames.insert(TransactionIsOutRole, "isOut");
|
roleNames.insert(TransactionIsOutRole, "isOut");
|
||||||
roleNames.insert(TransactionDateRole, "date");
|
roleNames.insert(TransactionDateRole, "date");
|
||||||
roleNames.insert(TransactionTimeRole, "time");
|
roleNames.insert(TransactionTimeRole, "time");
|
||||||
|
roleNames.insert(TransactionDestinationsRole, "destinations");
|
||||||
return roleNames;
|
return roleNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ public:
|
|||||||
// extra roles for date and time (as UI wants date and time separately)
|
// extra roles for date and time (as UI wants date and time separately)
|
||||||
TransactionDateRole,
|
TransactionDateRole,
|
||||||
TransactionTimeRole,
|
TransactionTimeRole,
|
||||||
TransactionAtomicAmountRole
|
TransactionAtomicAmountRole,
|
||||||
|
// only for outgoing
|
||||||
|
TransactionDestinationsRole
|
||||||
};
|
};
|
||||||
Q_ENUM(TransactionInfoRole)
|
Q_ENUM(TransactionInfoRole)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user