mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Merge pull request 'Coins: numerical sort for amount column' (#105) from tobtoht/feather:coins_amount_sort into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/105
This commit is contained in:
commit
20b741d30d
9 changed files with 50 additions and 26 deletions
|
@ -9,12 +9,14 @@
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
#include "appcontext.h"
|
#include "appcontext.h"
|
||||||
|
#include "globals.h"
|
||||||
#include "utils/tails.h"
|
#include "utils/tails.h"
|
||||||
#include "utils/whonix.h"
|
#include "utils/whonix.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "utils/prices.h"
|
#include "utils/prices.h"
|
||||||
#include "utils/networktype.h"
|
#include "utils/networktype.h"
|
||||||
#include "utils/wsclient.h"
|
#include "utils/wsclient.h"
|
||||||
|
#include "utils/config.h"
|
||||||
|
|
||||||
// libwalletqt
|
// libwalletqt
|
||||||
#include "libwalletqt/WalletManager.h"
|
#include "libwalletqt/WalletManager.h"
|
||||||
|
@ -28,7 +30,6 @@
|
||||||
#include "model/SubaddressModel.h"
|
#include "model/SubaddressModel.h"
|
||||||
#include "utils/keysfiles.h"
|
#include "utils/keysfiles.h"
|
||||||
#include "utils/networktype.h"
|
#include "utils/networktype.h"
|
||||||
#include "utils/config.h"
|
|
||||||
|
|
||||||
|
|
||||||
Prices *AppContext::prices = nullptr;
|
Prices *AppContext::prices = nullptr;
|
||||||
|
@ -195,7 +196,7 @@ void AppContext::initWS() {
|
||||||
|
|
||||||
void AppContext::onCancelTransaction(PendingTransaction *tx, const QString &address) {
|
void AppContext::onCancelTransaction(PendingTransaction *tx, const QString &address) {
|
||||||
// tx cancelled by user
|
// tx cancelled by user
|
||||||
double amount = tx->amount() / AppContext::cdiv;
|
double amount = tx->amount() / globals::cdiv;
|
||||||
emit createTransactionCancelled(address, amount);
|
emit createTransactionCancelled(address, amount);
|
||||||
this->currentWallet->disposeTransaction(tx);
|
this->currentWallet->disposeTransaction(tx);
|
||||||
}
|
}
|
||||||
|
@ -234,8 +235,8 @@ void AppContext::onCreateTransaction(const QString &address, const double amount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto balance = this->currentWallet->balance() / AppContext::cdiv;
|
auto balance = this->currentWallet->balance() / globals::cdiv;
|
||||||
auto unlocked_balance = this->currentWallet->unlockedBalance() / AppContext::cdiv;
|
auto unlocked_balance = this->currentWallet->unlockedBalance() / globals::cdiv;
|
||||||
if(!all && amount > unlocked_balance) {
|
if(!all && amount > unlocked_balance) {
|
||||||
emit createTransactionError("Not enough money to spend");
|
emit createTransactionError("Not enough money to spend");
|
||||||
return;
|
return;
|
||||||
|
@ -244,7 +245,7 @@ void AppContext::onCreateTransaction(const QString &address, const double amount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto amount_num = static_cast<quint64>(amount * AppContext::cdiv);
|
auto amount_num = static_cast<quint64>(amount * globals::cdiv);
|
||||||
qDebug() << "creating tx";
|
qDebug() << "creating tx";
|
||||||
if(all || amount == balance)
|
if(all || amount == balance)
|
||||||
this->currentWallet->createTransactionAllAsync(address, "", this->tx_mixin, this->tx_priority);
|
this->currentWallet->createTransactionAllAsync(address, "", this->tx_mixin, this->tx_priority);
|
||||||
|
@ -691,19 +692,19 @@ AppContext::~AppContext() {
|
||||||
// ############################################## LIBWALLET QT #########################################################
|
// ############################################## LIBWALLET QT #########################################################
|
||||||
|
|
||||||
void AppContext::onMoneySpent(const QString &txId, quint64 amount) {
|
void AppContext::onMoneySpent(const QString &txId, quint64 amount) {
|
||||||
auto amount_num = amount / AppContext::cdiv;
|
auto amount_num = amount / globals::cdiv;
|
||||||
qDebug() << Q_FUNC_INFO << txId << " " << QString::number(amount_num);
|
qDebug() << Q_FUNC_INFO << txId << " " << QString::number(amount_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppContext::onMoneyReceived(const QString &txId, quint64 amount) {
|
void AppContext::onMoneyReceived(const QString &txId, quint64 amount) {
|
||||||
// Incoming tx included in a block.
|
// Incoming tx included in a block.
|
||||||
auto amount_num = amount / AppContext::cdiv;
|
auto amount_num = amount / globals::cdiv;
|
||||||
qDebug() << Q_FUNC_INFO << txId << " " << QString::number(amount_num);
|
qDebug() << Q_FUNC_INFO << txId << " " << QString::number(amount_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppContext::onUnconfirmedMoneyReceived(const QString &txId, quint64 amount) {
|
void AppContext::onUnconfirmedMoneyReceived(const QString &txId, quint64 amount) {
|
||||||
// Incoming transaction in pool
|
// Incoming transaction in pool
|
||||||
auto amount_num = amount / AppContext::cdiv;
|
auto amount_num = amount / globals::cdiv;
|
||||||
qDebug() << Q_FUNC_INFO << txId << " " << QString::number(amount_num);
|
qDebug() << Q_FUNC_INFO << txId << " " << QString::number(amount_num);
|
||||||
|
|
||||||
if(this->currentWallet->synchronized()) {
|
if(this->currentWallet->synchronized()) {
|
||||||
|
@ -792,10 +793,10 @@ void AppContext::updateBalance() {
|
||||||
if(!this->currentWallet)
|
if(!this->currentWallet)
|
||||||
throw std::runtime_error("this should not happen, ever");
|
throw std::runtime_error("this should not happen, ever");
|
||||||
|
|
||||||
AppContext::balance = this->currentWallet->balance() / AppContext::cdiv;
|
AppContext::balance = this->currentWallet->balance() / globals::cdiv;
|
||||||
auto balance_str = QString::number(balance, 'f');
|
auto balance_str = QString::number(balance, 'f');
|
||||||
|
|
||||||
double unlocked = this->currentWallet->unlockedBalance() / AppContext::cdiv;
|
double unlocked = this->currentWallet->unlockedBalance() / globals::cdiv;
|
||||||
auto unlocked_str = QString::number(unlocked, 'f');
|
auto unlocked_str = QString::number(unlocked, 'f');
|
||||||
|
|
||||||
emit balanceUpdated(balance, unlocked, balance_str, unlocked_str);
|
emit balanceUpdated(balance, unlocked, balance_str, unlocked_str);
|
||||||
|
|
|
@ -69,7 +69,6 @@ public:
|
||||||
const unsigned int kdfRounds = 1;
|
const unsigned int kdfRounds = 1;
|
||||||
PendingTransaction::Priority tx_priority = PendingTransaction::Priority::Priority_Low;
|
PendingTransaction::Priority tx_priority = PendingTransaction::Priority::Priority_Low;
|
||||||
quint32 tx_mixin = static_cast<const quint32 &>(10);
|
quint32 tx_mixin = static_cast<const quint32 &>(10);
|
||||||
static constexpr const double cdiv = 1e12;
|
|
||||||
QString seedLanguage = "English"; // 14 word `monero-seed` only has English
|
QString seedLanguage = "English"; // 14 word `monero-seed` only has English
|
||||||
|
|
||||||
QNetworkAccessManager *network;
|
QNetworkAccessManager *network;
|
||||||
|
|
|
@ -42,14 +42,14 @@ CoinsWidget::CoinsWidget(QWidget *parent)
|
||||||
// context menu
|
// context menu
|
||||||
ui->coins->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->coins->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
m_thawOutputAction = new QAction("Thaw output");
|
m_thawOutputAction = new QAction("Thaw output", this);
|
||||||
m_freezeOutputAction = new QAction("Freeze output");
|
m_freezeOutputAction = new QAction("Freeze output", this);
|
||||||
|
|
||||||
m_freezeAllSelectedAction = new QAction("Freeze selected");
|
m_freezeAllSelectedAction = new QAction("Freeze selected", this);
|
||||||
m_thawAllSelectedAction = new QAction("Thaw selected");
|
m_thawAllSelectedAction = new QAction("Thaw selected", this);
|
||||||
|
|
||||||
m_viewOutputAction = new QAction(QIcon(":/assets/images/info.png"), "Details");
|
m_viewOutputAction = new QAction(QIcon(":/assets/images/info.png"), "Details", this);
|
||||||
m_sweepOutputAction = new QAction("Sweep output");
|
m_sweepOutputAction = new QAction("Sweep output", this);
|
||||||
connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput);
|
connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput);
|
||||||
connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput);
|
connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput);
|
||||||
connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
|
connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
|
||||||
|
@ -65,7 +65,7 @@ CoinsWidget::CoinsWidget(QWidget *parent)
|
||||||
void CoinsWidget::setModel(CoinsModel * model, Coins * coins) {
|
void CoinsWidget::setModel(CoinsModel * model, Coins * coins) {
|
||||||
m_coins = coins;
|
m_coins = coins;
|
||||||
m_model = model;
|
m_model = model;
|
||||||
m_proxyModel = new CoinsProxyModel;
|
m_proxyModel = new CoinsProxyModel(this);
|
||||||
m_proxyModel->setSourceModel(m_model);
|
m_proxyModel->setSourceModel(m_model);
|
||||||
ui->coins->setModel(m_proxyModel);
|
ui->coins->setModel(m_proxyModel);
|
||||||
ui->coins->setColumnHidden(CoinsModel::Spent, true);
|
ui->coins->setColumnHidden(CoinsModel::Spent, true);
|
||||||
|
@ -207,6 +207,7 @@ void CoinsWidget::onSweepOutput() {
|
||||||
qCritical() << "key image: " << keyImage;
|
qCritical() << "key image: " << keyImage;
|
||||||
|
|
||||||
emit sweepOutput(keyImage, dialog->address(), dialog->churn(), dialog->outputs());
|
emit sweepOutput(keyImage, dialog->address(), dialog->churn(), dialog->outputs());
|
||||||
|
dialog->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::copy(copyField field) {
|
void CoinsWidget::copy(copyField field) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "model/ModelUtils.h"
|
#include "model/ModelUtils.h"
|
||||||
#include "libwalletqt/WalletManager.h"
|
#include "libwalletqt/WalletManager.h"
|
||||||
#include "txconfadvdialog.h"
|
#include "txconfadvdialog.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
@ -31,15 +32,15 @@ TxConfDialog::TxConfDialog(AppContext *ctx, PendingTransaction *tx, const QStrin
|
||||||
};
|
};
|
||||||
|
|
||||||
QString amount = WalletManager::displayAmount(tx->amount());
|
QString amount = WalletManager::displayAmount(tx->amount());
|
||||||
QString amount_fiat = convert(tx->amount() / AppContext::cdiv);
|
QString amount_fiat = convert(tx->amount() / globals::cdiv);
|
||||||
ui->label_amount->setText(QString("%1 (%2 %3)").arg(amount, amount_fiat, preferredCur));
|
ui->label_amount->setText(QString("%1 (%2 %3)").arg(amount, amount_fiat, preferredCur));
|
||||||
|
|
||||||
QString fee = WalletManager::displayAmount(tx->fee());
|
QString fee = WalletManager::displayAmount(tx->fee());
|
||||||
QString fee_fiat = convert(tx->fee() / AppContext::cdiv);
|
QString fee_fiat = convert(tx->fee() / globals::cdiv);
|
||||||
ui->label_fee->setText(QString("%1 (%2 %3)").arg(fee, fee_fiat, preferredCur));
|
ui->label_fee->setText(QString("%1 (%2 %3)").arg(fee, fee_fiat, preferredCur));
|
||||||
|
|
||||||
QString total = WalletManager::displayAmount(tx->amount() + tx->fee());
|
QString total = WalletManager::displayAmount(tx->amount() + tx->fee());
|
||||||
QString total_fiat = convert((tx->amount() + tx->fee()) / AppContext::cdiv);
|
QString total_fiat = convert((tx->amount() + tx->fee()) / globals::cdiv);
|
||||||
ui->label_total->setText(QString("%1 (%2 %3)").arg(total, total_fiat, preferredCur));
|
ui->label_total->setText(QString("%1 (%2 %3)").arg(total, total_fiat, preferredCur));
|
||||||
|
|
||||||
ui->label_address->setText(ModelUtils::displayAddress(address, 2));
|
ui->label_address->setText(ModelUtils::displayAddress(address, 2));
|
||||||
|
|
14
src/globals.h
Normal file
14
src/globals.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
// Copyright (c) 2020, The Monero Project.
|
||||||
|
|
||||||
|
#ifndef FEATHER_GLOBALS_H
|
||||||
|
#define FEATHER_GLOBALS_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
namespace globals
|
||||||
|
{
|
||||||
|
const qreal cdiv = 1e12;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //FEATHER_GLOBALS_H
|
|
@ -6,6 +6,7 @@
|
||||||
#include "Coins.h"
|
#include "Coins.h"
|
||||||
#include <wallet/api/wallet2_api.h>
|
#include <wallet/api/wallet2_api.h>
|
||||||
#include "ModelUtils.h"
|
#include "ModelUtils.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
@ -190,10 +191,14 @@ QVariant CoinsModel::parseTransactionInfo(const CoinsInfo &cInfo, int column, in
|
||||||
case SpentHeight:
|
case SpentHeight:
|
||||||
return cInfo.spentHeight();
|
return cInfo.spentHeight();
|
||||||
case Amount:
|
case Amount:
|
||||||
return QString::number(cInfo.amount() / 1e12, 'f', 12);
|
{
|
||||||
|
if (role == Qt::UserRole) {
|
||||||
|
return cInfo.amount() / globals::cdiv;
|
||||||
|
}
|
||||||
|
return QString::number(cInfo.amount() / globals::cdiv, 'f', 12);
|
||||||
|
}
|
||||||
case Frozen:
|
case Frozen:
|
||||||
return cInfo.frozen();
|
return cInfo.frozen();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
qCritical() << "Unimplemented role";
|
qCritical() << "Unimplemented role";
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
CoinsProxyModel::CoinsProxyModel(QObject *parent)
|
CoinsProxyModel::CoinsProxyModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
|
setSortRole(Qt::UserRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CoinsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
bool CoinsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "TransactionHistoryModel.h"
|
#include "TransactionHistoryModel.h"
|
||||||
#include "TransactionHistory.h"
|
#include "TransactionHistory.h"
|
||||||
#include "TransactionInfo.h"
|
#include "TransactionInfo.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -151,7 +152,7 @@ QVariant TransactionHistoryModel::parseTransactionInfo(const TransactionInfo &tI
|
||||||
}
|
}
|
||||||
case Column::Amount:
|
case Column::Amount:
|
||||||
{
|
{
|
||||||
QString amount = QString::number(tInfo.atomicAmount() / 1e12, 'f', 4);
|
QString amount = QString::number(tInfo.atomicAmount() / globals::cdiv, 'f', 4);
|
||||||
amount = (tInfo.direction() == TransactionInfo::Direction_Out && tInfo.amount() > 0) ? "-" + amount : "+" + amount;
|
amount = (tInfo.direction() == TransactionInfo::Direction_Out && tInfo.amount() > 0) ? "-" + amount : "+" + amount;
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "libwalletqt/Wallet.h"
|
#include "libwalletqt/Wallet.h"
|
||||||
#include "appcontext.h"
|
#include "appcontext.h"
|
||||||
|
#include "globals.h"
|
||||||
#include "utils/xmrto.h"
|
#include "utils/xmrto.h"
|
||||||
|
|
||||||
XmrToOrder::XmrToOrder(AppContext *ctx, UtilsNetworking *network, QString baseUrl, bool clearnet, XmrToRates *rates, QObject *parent) :
|
XmrToOrder::XmrToOrder(AppContext *ctx, UtilsNetworking *network, QString baseUrl, bool clearnet, XmrToRates *rates, QObject *parent) :
|
||||||
|
@ -38,7 +39,7 @@ void XmrToOrder::onTransactionCancelled(const QString &address, double amount) {
|
||||||
void XmrToOrder::onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid) {
|
void XmrToOrder::onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid) {
|
||||||
// listener for all outgoing transactions - will try to match the exact amount to this order.
|
// listener for all outgoing transactions - will try to match the exact amount to this order.
|
||||||
if(this->state == OrderState::Status_OrderUnpaid){
|
if(this->state == OrderState::Status_OrderUnpaid){
|
||||||
if(tx->amount() / AppContext::cdiv == this->incoming_amount_total) {
|
if(tx->amount() / globals::cdiv == this->incoming_amount_total) {
|
||||||
if(!status) {
|
if(!status) {
|
||||||
this->errorMsg = "TX failed to commit";
|
this->errorMsg = "TX failed to commit";
|
||||||
this->changeState(OrderState::Status_OrderFailed);
|
this->changeState(OrderState::Status_OrderFailed);
|
||||||
|
@ -221,7 +222,7 @@ void XmrToOrder::changeState(OrderState _state) {
|
||||||
case OrderState::Status_OrderUnpaid:
|
case OrderState::Status_OrderUnpaid:
|
||||||
// need to send Monero
|
// need to send Monero
|
||||||
if(!m_paymentRequested) {
|
if(!m_paymentRequested) {
|
||||||
auto unlocked_balance = m_ctx->currentWallet->unlockedBalance() / AppContext::cdiv;
|
auto unlocked_balance = m_ctx->currentWallet->unlockedBalance() / globals::cdiv;
|
||||||
if (this->incoming_amount_total >= unlocked_balance) {
|
if (this->incoming_amount_total >= unlocked_balance) {
|
||||||
this->state = OrderState::Status_OrderFailed;
|
this->state = OrderState::Status_OrderFailed;
|
||||||
emit orderFailed(this);
|
emit orderFailed(this);
|
||||||
|
|
Loading…
Reference in a new issue