Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ class AddressTablePriv
int sizeSend() { return sendNum; }
int sizeRecv() { return recvNum; }
int sizeDell() { return dellNum; }
int SizeColdSend() { return coldSendNum; }
int sizeColdSend() { return coldSendNum; }
int sizeShieldedSend() { return shieldedSendNum; }
int sizeSendAll() { return sizeSend() + sizeColdSend() + sizeShieldedSend(); }

AddressTableEntry* index(int idx)
{
Expand Down Expand Up @@ -338,8 +339,9 @@ int AddressTableModel::columnCount(const QModelIndex& parent) const
int AddressTableModel::sizeSend() const { return priv->sizeSend(); }
int AddressTableModel::sizeRecv() const { return priv->sizeRecv(); }
int AddressTableModel::sizeDell() const { return priv->sizeDell(); }
int AddressTableModel::sizeColdSend() const { return priv->SizeColdSend(); }
int AddressTableModel::sizeColdSend() const { return priv->sizeColdSend(); }
int AddressTableModel::sizeShieldedSend() const { return priv->sizeShieldedSend(); }
int AddressTableModel::sizeSendAll() const { return priv->sizeSendAll(); }

QVariant AddressTableModel::data(const QModelIndex& index, int role) const
{
Expand Down
1 change: 1 addition & 0 deletions src/qt/addresstablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AddressTableModel : public QAbstractTableModel
int sizeDell() const;
int sizeColdSend() const;
int sizeShieldedSend() const;
int sizeSendAll() const;
void notifyChange(const QModelIndex &index);
QVariant data(const QModelIndex& index, int role) const;
bool setData(const QModelIndex& index, const QVariant& value, int role);
Expand Down
28 changes: 14 additions & 14 deletions src/qt/pivx/addresseswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "qt/pivx/addresseswidget.h"
#include "qt/pivx/forms/ui_addresseswidget.h"
#include "qt/pivx/addressfilterproxymodel.h"
#include "qt/pivx/addresslabelrow.h"
#include "qt/pivx/addnewaddressdialog.h"
#include "qt/pivx/tooltipmenu.h"

#include "qt/pivx/addnewcontactdialog.h"
Expand All @@ -23,19 +23,18 @@
class ContactsHolder : public FurListRow<QWidget*>
{
public:
ContactsHolder();

explicit ContactsHolder(bool _isLightTheme) : FurListRow(), isLightTheme(_isLightTheme){}

AddressLabelRow* createHolder(int pos) override{
AddressLabelRow* createHolder(int pos) override
{
if (!cachedRow) cachedRow = new AddressLabelRow();
cachedRow->init(isLightTheme, false);
return cachedRow;
}

void init(QWidget* holder,const QModelIndex &index, bool isHovered, bool isSelected) const override
{
AddressLabelRow* row = static_cast<AddressLabelRow*>(holder);
AddressLabelRow* row = dynamic_cast<AddressLabelRow*>(holder);

row->updateState(isLightTheme, isHovered, isSelected);

Expand Down Expand Up @@ -133,15 +132,15 @@ AddressesWidget::AddressesWidget(PIVXGUI* parent) :
connect(ui->btnAddContact, &OptionButton::clicked, this, &AddressesWidget::onAddContactShowHideClicked);
}

void AddressesWidget::handleAddressClicked(const QModelIndex &index)
void AddressesWidget::handleAddressClicked(const QModelIndex& _index)
{
ui->listAddresses->setCurrentIndex(index);
QRect rect = ui->listAddresses->visualRect(index);
ui->listAddresses->setCurrentIndex(_index);
QRect rect = ui->listAddresses->visualRect(_index);
QPoint pos = rect.topRight();
pos.setX(pos.x() - (DECORATION_SIZE * 2));
pos.setY(pos.y() + (DECORATION_SIZE));

QModelIndex rIndex = filter->mapToSource(index);
QModelIndex rIndex = filter->mapToSource(_index);

if (!this->menu) {
this->menu = new TooltipMenu(window, this);
Expand All @@ -152,7 +151,7 @@ void AddressesWidget::handleAddressClicked(const QModelIndex &index)
} else {
this->menu->hide();
}
this->index = rIndex;
index = rIndex;
menu->move(pos);
menu->show();
}
Expand All @@ -175,7 +174,7 @@ void AddressesWidget::loadWalletModel()

void AddressesWidget::updateListView()
{
bool empty = addressTablemodel->sizeSend() == 0;
bool empty = addressTablemodel->sizeSendAll() == 0;
ui->emptyContainer->setVisible(empty);
ui->listAddresses->setVisible(!empty);
}
Expand Down Expand Up @@ -250,8 +249,9 @@ void AddressesWidget::onEditClicked()
void AddressesWidget::onDeleteClicked()
{
if (walletModel) {
if (ask(tr("Delete Contact"), tr("You are just about to remove the contact:\n\n%1\n\nAre you sure?").arg(index.data(Qt::DisplayRole).toString().toUtf8().constData()))
) {
if (ask(tr("Delete Contact"),
tr("You are just about to remove the contact:\n\n%1\n\nAre you sure?")
.arg(index.data(Qt::DisplayRole).toString().toUtf8().constData()))) {
if (this->walletModel->getAddressTableModel()->removeRows(index.row(), 1, index)) {
updateListView();
inform(tr("Contact Deleted"));
Expand Down Expand Up @@ -299,7 +299,7 @@ void AddressesWidget::sortAddresses()

void AddressesWidget::changeTheme(bool isLightTheme, QString& theme)
{
static_cast<ContactsHolder*>(this->delegate->getRowFactory())->isLightTheme = isLightTheme;
dynamic_cast<ContactsHolder*>(this->delegate->getRowFactory())->isLightTheme = isLightTheme;
}

AddressesWidget::~AddressesWidget()
Expand Down
6 changes: 1 addition & 5 deletions src/qt/pivx/addresseswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

#include "qt/pivx/pwidget.h"
#include "addresstablemodel.h"
#include "qt/pivx/tooltipmenu.h"
#include "furabstractlistitemdelegate.h"
#include "qt/pivx/addressfilterproxymodel.h"

#include <QWidget>

class AddressViewDelegate;
class AddressFilterProxyModel;
class TooltipMenu;
class PIVXGUI;
class WalletModel;
Expand All @@ -35,7 +33,6 @@ class AddressesWidget : public PWidget
~AddressesWidget();

void loadWalletModel() override;
void onNewContactClicked();

private Q_SLOTS:
void handleAddressClicked(const QModelIndex &index);
Expand All @@ -55,7 +52,6 @@ private Q_SLOTS:
AddressTableModel* addressTablemodel = nullptr;
AddressFilterProxyModel *filter = nullptr;

bool isOnMyAddresses = true;
TooltipMenu* menu = nullptr;

// Cached index
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/addressfilterproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "qt/pivx/addressfilterproxymodel.h"
#include <iostream>
#include "qt/addresstablemodel.h"

bool AddressFilterProxyModel::filterAcceptsRow(int row, const QModelIndex& parent) const
{
Expand Down
2 changes: 0 additions & 2 deletions src/qt/pivx/addressfilterproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#define PIVX_CORE_NEW_GUI_ADDRESSFILTERPROXYMODEL_H

#include <QSortFilterProxyModel>
#include "addresstablemodel.h"


class AddressFilterProxyModel final : public QSortFilterProxyModel
{
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/addresslabelrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void AddressLabelRow::init(bool isLightTheme, bool isHover)
updateState(isLightTheme, isHover, false);
}

void AddressLabelRow::updateView(QString address, QString label)
void AddressLabelRow::updateView(const QString& address, const QString& label)
{
ui->lblAddress->setText(address);
ui->lblLabel->setText(label);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/addresslabelrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AddressLabelRow : public QWidget
void init(bool isLightTheme, bool isHover);

void updateState(bool isLightTheme, bool isHovered, bool isSelected);
void updateView(QString address, QString label);
void updateView(const QString& address, const QString& label);
protected:
virtual void enterEvent(QEvent *);
virtual void leaveEvent(QEvent *);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/myaddressrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MyAddressRow::MyAddressRow(QWidget *parent) :
ui->labelDate->setProperty("cssClass", "text-list-caption");
}

void MyAddressRow::updateView(QString address, QString label, QString date){
void MyAddressRow::updateView(const QString& address, const QString& label, const QString& date){
ui->labelName->setText(label);
ui->labelAddress->setText(address);
if (date.isEmpty()){
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/myaddressrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MyAddressRow : public QWidget
explicit MyAddressRow(QWidget *parent = nullptr);
~MyAddressRow();

void updateView(QString address, QString label, QString date);
void updateView(const QString& address, const QString& label, const QString& date);

private:
Ui::MyAddressRow *ui;
Expand Down
10 changes: 5 additions & 5 deletions src/qt/pivx/receivedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include "qt/pivx/receivedialog.h"
#include "qt/pivx/forms/ui_receivedialog.h"
#include "qt/pivx/qtutils.h"
#include "walletmodel.h"
#include <QFile>
#include "qt/walletmodel.h"

#include <QPixmap>

ReceiveDialog::ReceiveDialog(QWidget *parent) :
FocusedDialog(parent),
Expand Down Expand Up @@ -45,7 +46,7 @@ ReceiveDialog::ReceiveDialog(QWidget *parent) :
connect(ui->btnSave, &QPushButton::clicked, this, &ReceiveDialog::onCopy);
}

void ReceiveDialog::updateQr(QString address)
void ReceiveDialog::updateQr(const QString& address)
{
if (!info) info = new SendCoinsRecipient();
info->address = address;
Expand All @@ -55,8 +56,7 @@ void ReceiveDialog::updateQr(QString address)
QString error;
QPixmap pixmap = encodeToQr(uri, error);
if (!pixmap.isNull()) {
qrImage = &pixmap;
ui->labelQrImg->setPixmap(qrImage->scaled(ui->labelQrImg->width(), ui->labelQrImg->height()));
ui->labelQrImg->setPixmap(pixmap.scaled(ui->labelQrImg->width(), ui->labelQrImg->height()));
} else {
ui->labelQrImg->setText(!error.isEmpty() ? error : "Error encoding address");
}
Expand Down
4 changes: 1 addition & 3 deletions src/qt/pivx/receivedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define RECEIVEDIALOG_H

#include "qt/pivx/focuseddialog.h"
#include <QPixmap>

class SendCoinsRecipient;

Expand All @@ -22,13 +21,12 @@ class ReceiveDialog : public FocusedDialog
explicit ReceiveDialog(QWidget *parent = nullptr);
~ReceiveDialog();

void updateQr(QString address);
void updateQr(const QString& address);

private Q_SLOTS:
void onCopy();
private:
Ui::ReceiveDialog *ui{nullptr};
QPixmap *qrImage{nullptr};
SendCoinsRecipient *info{nullptr};
};

Expand Down
12 changes: 5 additions & 7 deletions src/qt/pivx/receivewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "qt/pivx/addnewcontactdialog.h"
#include "qt/pivx/qtutils.h"
#include "qt/pivx/myaddressrow.h"
#include "qt/pivx/furlistrow.h"
#include "qt/pivx/addressholder.h"
#include "walletmodel.h"
#include "guiutil.h"
Expand Down Expand Up @@ -145,11 +144,10 @@ void ReceiveWidget::refreshView(const QModelIndex& tl, const QModelIndex& br)
return refreshView(index.data(Qt::DisplayRole).toString());
}

void ReceiveWidget::refreshView(QString refreshAddress)
void ReceiveWidget::refreshView(const QString& refreshAddress)
{
try {
QString latestAddress = (refreshAddress.isEmpty()) ? this->addressTableModel->getAddressToShow(shieldedMode) : refreshAddress;

const QString& latestAddress = (refreshAddress.isEmpty()) ? addressTableModel->getAddressToShow(shieldedMode) : refreshAddress;
if (latestAddress.isEmpty()) {
// Check for generation errors
ui->labelQrImg->setText(tr("No available address\ntry unlocking the wallet"));
Expand Down Expand Up @@ -189,7 +187,7 @@ void ReceiveWidget::updateLabel()
}
}

void ReceiveWidget::updateQr(QString& address)
void ReceiveWidget::updateQr(const QString& address)
{
info->address = address;
QString uri = GUIUtil::formatBitcoinURI(*info);
Expand All @@ -199,8 +197,7 @@ void ReceiveWidget::updateQr(QString& address)
QColor qrColor("#382d4d");
QPixmap pixmap = encodeToQr(uri, error, qrColor);
if (!pixmap.isNull()) {
qrImage = &pixmap;
ui->labelQrImg->setPixmap(qrImage->scaled(ui->labelQrImg->width(), ui->labelQrImg->height()));
ui->labelQrImg->setPixmap(pixmap.scaled(ui->labelQrImg->width(), ui->labelQrImg->height()));
} else {
ui->labelQrImg->setText(!error.isEmpty() ? error : "Error encoding address");
}
Expand Down Expand Up @@ -236,6 +233,7 @@ void ReceiveWidget::onLabelClicked()
inform(tr("Error storing address label"));
}
}
dialog->deleteLater();
isShowingDialog = false;
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/qt/pivx/receivewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private Q_SLOTS:
void onLabelClicked();
void onCopyClicked();
void refreshView(const QModelIndex& tl, const QModelIndex& br);
void refreshView(QString refreshAddress = QString());
void refreshView(const QString& refreshAddress = QString());
void handleAddressClicked(const QModelIndex &index);
void onSortChanged(int idx);
void onSortOrderChanged(int idx);
Expand All @@ -62,14 +62,12 @@ private Q_SLOTS:

// Cached last address
SendCoinsRecipient *info{nullptr};
// Cached qr
QPixmap *qrImage{nullptr};

// Cached sort type and order
AddressTableModel::ColumnIndex sortType = AddressTableModel::Label;
Qt::SortOrder sortOrder = Qt::AscendingOrder;

void updateQr(QString& address);
void updateQr(const QString& address);
void updateLabel();
void showAddressGenerationDialog(bool isPaymentRequest);
void sortAddresses();
Expand Down
7 changes: 3 additions & 4 deletions src/qt/pivx/requestdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,20 @@ void RequestDialog::showEvent(QShowEvent *event)
if (ui->lineEditAmount) ui->lineEditAmount->setFocus();
}

void RequestDialog::updateQr(QString str)
void RequestDialog::updateQr(const QString& str)
{
QString uri = GUIUtil::formatBitcoinURI(*info);
ui->labelQrImg->setText("");
QString error;
QPixmap pixmap = encodeToQr(uri, error);
if (!pixmap.isNull()) {
qrImage = &pixmap;
ui->labelQrImg->setPixmap(qrImage->scaled(ui->labelQrImg->width(), ui->labelQrImg->height()));
ui->labelQrImg->setPixmap(pixmap.scaled(ui->labelQrImg->width(), ui->labelQrImg->height()));
} else {
ui->labelQrImg->setText(!error.isEmpty() ? error : "Error encoding address");
}
}

void RequestDialog::inform(QString text)
void RequestDialog::inform(const QString& text)
{
if (!snackBar)
snackBar = new SnackBar(nullptr, this);
Expand Down
6 changes: 2 additions & 4 deletions src/qt/pivx/requestdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ private Q_SLOTS:
// Cached last address
SendCoinsRecipient *info{nullptr};

QPixmap *qrImage{nullptr};

void updateQr(QString str);
void inform(QString text);
void updateQr(const QString& str);
void inform(const QString& text);
};

#endif // REQUESTDIALOG_H