Skip to content

Commit 44e3739

Browse files
committed
qml: Updates to SendReview page
Properly output formatted amounts in the SendReview page. In addition, remove the WalletQmlModelTransaction QObject and move the fee and totalAmount values into the SendRecipientsListModel
1 parent 2108d29 commit 44e3739

File tree

10 files changed

+79
-167
lines changed

10 files changed

+79
-167
lines changed

src/Makefile.qt.include

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ QT_MOC_CPP = \
5353
qml/models/moc_snapshotqml.cpp \
5454
qml/models/moc_walletlistmodel.cpp \
5555
qml/models/moc_walletqmlmodel.cpp \
56-
qml/models/moc_walletqmlmodeltransaction.cpp \
5756
qml/moc_appmode.cpp \
5857
qml/moc_bitcoinamount.cpp \
5958
qml/moc_clipboard.cpp \
@@ -147,7 +146,6 @@ BITCOIN_QT_H = \
147146
qml/models/sendrecipientslistmodel.h \
148147
qml/models/walletlistmodel.h \
149148
qml/models/walletqmlmodel.h \
150-
qml/models/walletqmlmodeltransaction.h \
151149
qml/appmode.h \
152150
qml/clipboard.h \
153151
qml/bitcoin.h \
@@ -353,7 +351,6 @@ BITCOIN_QML_BASE_CPP = \
353351
qml/models/sendrecipientslistmodel.cpp \
354352
qml/models/walletlistmodel.cpp \
355353
qml/models/walletqmlmodel.cpp \
356-
qml/models/walletqmlmodeltransaction.cpp \
357354
qml/imageprovider.cpp \
358355
qml/qrimageprovider.cpp \
359356
qml/util.cpp \

src/qml/bitcoin.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <qml/models/sendrecipient.h>
3636
#include <qml/models/walletlistmodel.h>
3737
#include <qml/models/walletqmlmodel.h>
38-
#include <qml/models/walletqmlmodeltransaction.h>
3938
#include <qml/qrimageprovider.h>
4039
#include <qml/util.h>
4140
#include <qml/walletqmlcontroller.h>
@@ -348,8 +347,6 @@ int QmlGuiMain(int argc, char* argv[])
348347
#ifdef ENABLE_WALLET
349348
qmlRegisterUncreatableType<WalletQmlModel>("org.bitcoincore.qt", 1, 0, "WalletQmlModel",
350349
"WalletQmlModel cannot be instantiated from QML");
351-
qmlRegisterUncreatableType<WalletQmlModelTransaction>("org.bitcoincore.qt", 1, 0, "WalletQmlModelTransaction",
352-
"WalletQmlModelTransaction cannot be instantiated from QML");
353350
#endif
354351

355352
engine.load(QUrl(QStringLiteral("qrc:///qml/pages/main.qml")));

src/qml/models/sendrecipientslistmodel.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void SendRecipientsListModel::clear()
148148
Q_EMIT countChanged();
149149
Q_EMIT totalAmountChanged();
150150
Q_EMIT currentRecipientChanged();
151+
Q_EMIT firstRecipientChanged();
151152
Q_EMIT currentIndexChanged();
152153
Q_EMIT listCleared();
153154
}
@@ -176,3 +177,25 @@ void SendRecipientsListModel::clearToFront()
176177
Q_EMIT currentIndexChanged();
177178
}
178179
}
180+
181+
void SendRecipientsListModel::setFee(qint64 fee)
182+
{
183+
if (m_fee != fee) {
184+
m_fee = fee;
185+
Q_EMIT totalAmountChanged();
186+
Q_EMIT feeChanged();
187+
}
188+
}
189+
190+
QString SendRecipientsListModel::fee() const
191+
{
192+
return BitcoinAmount::satsToRichBtcString(m_fee);
193+
}
194+
195+
SendRecipient* SendRecipientsListModel::firstRecipient() const
196+
{
197+
if (m_recipients.size() == 0) {
198+
return nullptr;
199+
}
200+
return m_recipients[0];
201+
}

src/qml/models/sendrecipientslistmodel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class SendRecipientsListModel : public QAbstractListModel
1818
Q_PROPERTY(int currentIndex READ currentIndex NOTIFY currentIndexChanged)
1919
Q_PROPERTY(int count READ count NOTIFY countChanged)
2020
Q_PROPERTY(SendRecipient* current READ currentRecipient NOTIFY currentRecipientChanged)
21+
Q_PROPERTY(SendRecipient* first READ firstRecipient NOTIFY firstRecipientChanged)
2122
Q_PROPERTY(QString totalAmount READ totalAmount NOTIFY totalAmountChanged)
23+
Q_PROPERTY(QString fee READ fee NOTIFY feeChanged)
2224

2325
public:
2426
enum Roles {
@@ -44,16 +46,21 @@ class SendRecipientsListModel : public QAbstractListModel
4446
int currentIndex() const { return m_current + 1; }
4547
void setCurrentIndex(int row);
4648
SendRecipient* currentRecipient() const;
49+
SendRecipient* firstRecipient() const;
4750
int count() const { return m_recipients.size(); }
4851
QList<SendRecipient*> recipients() const { return m_recipients; }
4952
QString totalAmount() const;
5053
qint64 totalAmountSatoshi() const { return m_totalAmount; }
54+
QString fee() const;
55+
void setFee(qint64 fee);
5156

5257
Q_SIGNALS:
5358
void currentIndexChanged();
5459
void currentRecipientChanged();
60+
void firstRecipientChanged();
5561
void countChanged();
5662
void totalAmountChanged();
63+
void feeChanged();
5764
void listCleared();
5865

5966
private:
@@ -63,6 +70,7 @@ class SendRecipientsListModel : public QAbstractListModel
6370
QList<SendRecipient*> m_recipients;
6471
int m_current{0};
6572
qint64 m_totalAmount{0};
73+
qint64 m_fee{0};
6674
};
6775

6876
#endif // BITCOIN_QML_MODELS_SENDRECIPIENTSLISTMODEL_H

src/qml/models/walletqmlmodel.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ WalletQmlModel::~WalletQmlModel()
5151
delete m_coins_list_model;
5252
delete m_send_recipients;
5353
delete m_current_payment_request;
54-
if (m_current_transaction) {
55-
delete m_current_transaction;
56-
}
5754
}
5855

5956
QString WalletQmlModel::balance() const
@@ -162,14 +159,8 @@ bool WalletQmlModel::prepareTransaction()
162159
CAmount nFeeRequired = 0;
163160
const auto& res = m_wallet->createTransaction(vecSend, m_coin_control, true, nChangePosRet, nFeeRequired);
164161
if (res) {
165-
if (m_current_transaction) {
166-
delete m_current_transaction;
167-
}
168-
CTransactionRef newTx = *res;
169-
m_current_transaction = new WalletQmlModelTransaction(m_send_recipients, this);
170-
m_current_transaction->setWtx(newTx);
171-
m_current_transaction->setTransactionFee(nFeeRequired);
172-
Q_EMIT currentTransactionChanged();
162+
m_current_transaction = *res;
163+
m_send_recipients->setFee(nFeeRequired);
173164
return true;
174165
} else {
175166
return false;
@@ -182,7 +173,7 @@ void WalletQmlModel::sendTransaction()
182173
return;
183174
}
184175

185-
CTransactionRef newTx = m_current_transaction->getWtx();
176+
CTransactionRef newTx = m_current_transaction;
186177
if (!newTx) {
187178
return;
188179
}

src/qml/models/walletqmlmodel.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <interfaces/handler.h>
1717
#include <interfaces/wallet.h>
1818
#include <wallet/coincontrol.h>
19+
#include <wallet/wallet.h>
1920

2021
#include <memory>
2122
#include <vector>
@@ -30,7 +31,6 @@ class WalletQmlModel : public QObject
3031
Q_PROPERTY(ActivityListModel* activityListModel READ activityListModel CONSTANT)
3132
Q_PROPERTY(CoinsListModel* coinsListModel READ coinsListModel CONSTANT)
3233
Q_PROPERTY(SendRecipientsListModel* recipients READ sendRecipientList CONSTANT)
33-
Q_PROPERTY(WalletQmlModelTransaction* currentTransaction READ currentTransaction NOTIFY currentTransactionChanged)
3434
Q_PROPERTY(unsigned int targetBlocks READ feeTargetBlocks WRITE setFeeTargetBlocks NOTIFY feeTargetBlocksChanged)
3535
Q_PROPERTY(PaymentRequest* currentPaymentRequest READ currentPaymentRequest CONSTANT)
3636
Q_PROPERTY(bool isWalletLoaded READ isWalletLoaded NOTIFY walletIsLoadedChanged)
@@ -49,7 +49,6 @@ class WalletQmlModel : public QObject
4949
ActivityListModel* activityListModel() const { return m_activity_list_model; }
5050
CoinsListModel* coinsListModel() const { return m_coins_list_model; }
5151
SendRecipientsListModel* sendRecipientList() const { return m_send_recipients; }
52-
WalletQmlModelTransaction* currentTransaction() const { return m_current_transaction; }
5352
Q_INVOKABLE bool prepareTransaction();
5453
Q_INVOKABLE void sendTransaction();
5554

@@ -81,7 +80,6 @@ class WalletQmlModel : public QObject
8180
Q_SIGNALS:
8281
void nameChanged();
8382
void balanceChanged();
84-
void currentTransactionChanged();
8583
void feeTargetBlocksChanged();
8684
void walletIsLoadedChanged();
8785

@@ -93,7 +91,7 @@ class WalletQmlModel : public QObject
9391
ActivityListModel* m_activity_list_model{nullptr};
9492
CoinsListModel* m_coins_list_model{nullptr};
9593
SendRecipientsListModel* m_send_recipients{nullptr};
96-
WalletQmlModelTransaction* m_current_transaction{nullptr};
94+
CTransactionRef m_current_transaction{nullptr};
9795
wallet::CCoinControl m_coin_control;
9896
bool m_is_wallet_loaded{false};
9997
};

src/qml/models/walletqmlmodeltransaction.cpp

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/qml/models/walletqmlmodeltransaction.h

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/qml/pages/wallet/MultipleSendReview.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Page {
108108
Layout.fillWidth: true
109109
}
110110
CoreText {
111-
text: root.transaction.total
111+
text: root.wallet.recipients.totalAmount
112112
font.pixelSize: 20
113113
color: Theme.color.neutral9
114114
}
@@ -130,7 +130,7 @@ Page {
130130
Layout.fillWidth: true
131131
}
132132
CoreText {
133-
text: root.transaction.fee
133+
text: root.wallet.recipients.fee
134134
font.pixelSize: 15
135135
}
136136
}

0 commit comments

Comments
 (0)