refactor: consolidate wallet_api into libwalletqt [1/?]

This commit is contained in:
tobtoht
2023-11-17 14:05:31 +01:00
parent a13ca973cc
commit 769af188e2
46 changed files with 928 additions and 687 deletions
+7 -4
View File
@@ -64,7 +64,7 @@ void AccountSwitcherDialog::switchAccount() {
return;
}
m_wallet->switchSubaddressAccount(row->getRowId());
m_wallet->switchSubaddressAccount(row->getRow());
}
void AccountSwitcherDialog::copyLabel() {
@@ -73,7 +73,7 @@ void AccountSwitcherDialog::copyLabel() {
return;
}
Utils::copyToClipboard(QString::fromStdString(row->getLabel()));
Utils::copyToClipboard(row->getLabel());
}
void AccountSwitcherDialog::copyBalance() {
@@ -82,7 +82,7 @@ void AccountSwitcherDialog::copyBalance() {
return;
}
Utils::copyToClipboard(QString::fromStdString(row->getBalance()));
Utils::copyToClipboard(row->getBalance());
}
void AccountSwitcherDialog::editLabel() {
@@ -93,6 +93,9 @@ void AccountSwitcherDialog::editLabel() {
void AccountSwitcherDialog::updateSelection() {
QModelIndex index = m_model->index(m_wallet->currentSubaddressAccount(), 0);
if (!index.isValid()) {
return;
}
ui->accounts->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}
@@ -111,7 +114,7 @@ void AccountSwitcherDialog::showContextMenu(const QPoint &point) {
menu->popup(ui->accounts->viewport()->mapToGlobal(point));
}
Monero::SubaddressAccountRow* AccountSwitcherDialog::currentEntry() {
AccountRow* AccountSwitcherDialog::currentEntry() {
QModelIndex index = m_proxyModel->mapToSource(ui->accounts->currentIndex());
return m_wallet->subaddressAccountModel()->entryFromIndex(index);
}
+1 -1
View File
@@ -34,7 +34,7 @@ private:
void copyBalance();
void editLabel();
Monero::SubaddressAccountRow* currentEntry();
AccountRow* currentEntry();
QScopedPointer<Ui::AccountSwitcherDialog> ui;
Wallet *m_wallet;
-3
View File
@@ -16,9 +16,6 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeView" name="accounts">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "components.h"
#include "libwalletqt/Coins.h"
#include "libwalletqt/CoinsInfo.h"
#include "libwalletqt/rows/CoinsInfo.h"
namespace Ui {
class OutputInfoDialog;
+1 -1
View File
@@ -7,7 +7,7 @@
#include <QDialog>
#include "components.h"
#include "libwalletqt/CoinsInfo.h"
#include "libwalletqt/rows/CoinsInfo.h"
namespace Ui {
class OutputSweepDialog;
+8 -8
View File
@@ -10,14 +10,14 @@
#include "config.h"
#include "constants.h"
#include "libwalletqt/Coins.h"
#include "libwalletqt/CoinsInfo.h"
#include "libwalletqt/rows/CoinsInfo.h"
#include "libwalletqt/TransactionHistory.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/WalletManager.h"
#include "utils/Icons.h"
#include "utils/Utils.h"
TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent)
TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionRow *txInfo, QWidget *parent)
: QDialog(parent)
, ui(new Ui::TxInfoDialog)
, m_wallet(wallet)
@@ -41,7 +41,7 @@ TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *par
this->setData(txInfo);
if ((txInfo->isFailed() || txInfo->isPending()) && txInfo->direction() != TransactionInfo::Direction_In) {
if ((txInfo->isFailed() || txInfo->isPending()) && txInfo->direction() != TransactionRow::Direction_In) {
connect(ui->btn_rebroadcastTx, &QPushButton::pressed, [this]{
emit resendTranscation(m_txid);
});
@@ -49,7 +49,7 @@ TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *par
ui->btn_rebroadcastTx->hide();
}
if (txInfo->direction() == TransactionInfo::Direction_In) {
if (txInfo->direction() == TransactionRow::Direction_In) {
ui->btn_CopyTxKey->setDisabled(true);
ui->btn_CopyTxKey->setToolTip("No tx secret key available for incoming transactions.");
}
@@ -106,7 +106,7 @@ void TxInfoDialog::adjustHeight(QTextEdit *textEdit, qreal docHeight) {
textEdit->verticalScrollBar()->hide();
}
void TxInfoDialog::setData(TransactionInfo *tx) {
void TxInfoDialog::setData(TransactionRow *tx) {
QString blockHeight = QString::number(tx->blockHeight());
if (tx->isFailed()) {
@@ -131,13 +131,13 @@ void TxInfoDialog::setData(TransactionInfo *tx) {
ui->label_lock->setText("Lock: Outputs are spendable");
}
QString direction = tx->direction() == TransactionInfo::Direction_In ? "received" : "sent";
QString direction = tx->direction() == TransactionRow::Direction_In ? "received" : "sent";
ui->label_amount->setText(QString("Amount %1: %2 XMR").arg(direction, tx->displayAmount()));
QString fee;
if (tx->isCoinbase())
fee = "Not applicable";
else if (tx->direction() == TransactionInfo::Direction_In)
else if (tx->direction() == TransactionRow::Direction_In)
fee = "Paid by sender";
else if (tx->fee().isEmpty())
fee = "N/A";
@@ -149,7 +149,7 @@ void TxInfoDialog::setData(TransactionInfo *tx) {
}
void TxInfoDialog::updateData() {
TransactionInfo *tx = m_wallet->history()->transaction(m_txid);
TransactionRow *tx = m_wallet->history()->transaction(m_txid);
if (!tx) return;
this->setData(tx);
}
+4 -3
View File
@@ -10,6 +10,7 @@
#include <QSvgWidget>
#include "dialog/TxProofDialog.h"
#include "libwalletqt/rows/TransactionRow.h"
namespace Ui {
class TxInfoDialog;
@@ -20,7 +21,7 @@ class TxInfoDialog : public QDialog
Q_OBJECT
public:
explicit TxInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent = nullptr);
explicit TxInfoDialog(Wallet *wallet, TransactionRow *txInfo, QWidget *parent = nullptr);
~TxInfoDialog() override;
signals:
@@ -30,14 +31,14 @@ private:
void copyTxID();
void copyTxKey();
void createTxProof();
void setData(TransactionInfo *tx);
void setData(TransactionRow *tx);
void updateData();
void adjustHeight(QTextEdit *textEdit, qreal docHeight);
void viewOnBlockExplorer();
QScopedPointer<Ui::TxInfoDialog> ui;
Wallet *m_wallet;
TransactionInfo *m_txInfo;
TransactionRow *m_txInfo;
TxProofDialog *m_txProofDialog;
QString m_txid;
};
+3 -3
View File
@@ -10,7 +10,7 @@
#include "utils/Icons.h"
#include "utils/Utils.h"
TxProofDialog::TxProofDialog(QWidget *parent, Wallet *wallet, TransactionInfo *txInfo)
TxProofDialog::TxProofDialog(QWidget *parent, Wallet *wallet, TransactionRow *txInfo)
: WindowModalDialog(parent)
, ui(new Ui::TxProofDialog)
, m_wallet(wallet)
@@ -70,7 +70,7 @@ void TxProofDialog::selectSpendProof() {
m_mode = Mode::SpendProof;
this->resetFrames();
if (m_direction == TransactionInfo::Direction_In) {
if (m_direction == TransactionRow::Direction_In) {
this->showWarning("Your wallet did not construct this transaction. Creating a SpendProof is not possible.");
return;
}
@@ -107,7 +107,7 @@ void TxProofDialog::selectInProof() {
m_mode = Mode::InProof;
this->resetFrames();
if (m_direction == TransactionInfo::Direction_Out) {
if (m_direction == TransactionRow::Direction_Out) {
this->showWarning("Can't create InProofs for outgoing transactions.");
return;
}
+3 -3
View File
@@ -7,8 +7,8 @@
#include <QDialog>
#include "components.h"
#include "libwalletqt/TransactionInfo.h"
#include "libwalletqt/Wallet.h"
#include "rows/TransactionRow.h"
namespace Ui {
class TxProofDialog;
@@ -19,7 +19,7 @@ class TxProofDialog : public WindowModalDialog
Q_OBJECT
public:
explicit TxProofDialog(QWidget *parent, Wallet *wallet, TransactionInfo *txid);
explicit TxProofDialog(QWidget *parent, Wallet *wallet, TransactionRow *txid);
~TxProofDialog() override;
void setTxId(const QString &txid);
void getTxKey();
@@ -52,7 +52,7 @@ private:
QString m_txid;
QString m_txKey;
Mode m_mode;
TransactionInfo::Direction m_direction;
TransactionRow::Direction m_direction;
};
#endif //FEATHER_TXPROOFDIALOG_H