Skip to content

Commit 798c3e9

Browse files
committed
GUI: addresses widget files overall code cleanup.
Github-Pull: #2555 Rebased-From: 23af3d9
1 parent 51f6555 commit 798c3e9

File tree

8 files changed

+19
-25
lines changed

8 files changed

+19
-25
lines changed

src/qt/pivx/addresseswidget.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include "qt/pivx/addresseswidget.h"
66
#include "qt/pivx/forms/ui_addresseswidget.h"
7+
#include "qt/pivx/addressfilterproxymodel.h"
78
#include "qt/pivx/addresslabelrow.h"
8-
#include "qt/pivx/addnewaddressdialog.h"
99
#include "qt/pivx/tooltipmenu.h"
1010

1111
#include "qt/pivx/addnewcontactdialog.h"
@@ -23,19 +23,18 @@
2323
class ContactsHolder : public FurListRow<QWidget*>
2424
{
2525
public:
26-
ContactsHolder();
27-
2826
explicit ContactsHolder(bool _isLightTheme) : FurListRow(), isLightTheme(_isLightTheme){}
2927

30-
AddressLabelRow* createHolder(int pos) override{
28+
AddressLabelRow* createHolder(int pos) override
29+
{
3130
if (!cachedRow) cachedRow = new AddressLabelRow();
3231
cachedRow->init(isLightTheme, false);
3332
return cachedRow;
3433
}
3534

3635
void init(QWidget* holder,const QModelIndex &index, bool isHovered, bool isSelected) const override
3736
{
38-
AddressLabelRow* row = static_cast<AddressLabelRow*>(holder);
37+
AddressLabelRow* row = dynamic_cast<AddressLabelRow*>(holder);
3938

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

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

136-
void AddressesWidget::handleAddressClicked(const QModelIndex &index)
135+
void AddressesWidget::handleAddressClicked(const QModelIndex& _index)
137136
{
138-
ui->listAddresses->setCurrentIndex(index);
139-
QRect rect = ui->listAddresses->visualRect(index);
137+
ui->listAddresses->setCurrentIndex(_index);
138+
QRect rect = ui->listAddresses->visualRect(_index);
140139
QPoint pos = rect.topRight();
141140
pos.setX(pos.x() - (DECORATION_SIZE * 2));
142141
pos.setY(pos.y() + (DECORATION_SIZE));
143142

144-
QModelIndex rIndex = filter->mapToSource(index);
143+
QModelIndex rIndex = filter->mapToSource(_index);
145144

146145
if (!this->menu) {
147146
this->menu = new TooltipMenu(window, this);
@@ -152,7 +151,7 @@ void AddressesWidget::handleAddressClicked(const QModelIndex &index)
152151
} else {
153152
this->menu->hide();
154153
}
155-
this->index = rIndex;
154+
index = rIndex;
156155
menu->move(pos);
157156
menu->show();
158157
}
@@ -250,8 +249,9 @@ void AddressesWidget::onEditClicked()
250249
void AddressesWidget::onDeleteClicked()
251250
{
252251
if (walletModel) {
253-
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()))
254-
) {
252+
if (ask(tr("Delete Contact"),
253+
tr("You are just about to remove the contact:\n\n%1\n\nAre you sure?")
254+
.arg(index.data(Qt::DisplayRole).toString().toUtf8().constData()))) {
255255
if (this->walletModel->getAddressTableModel()->removeRows(index.row(), 1, index)) {
256256
updateListView();
257257
inform(tr("Contact Deleted"));
@@ -299,7 +299,7 @@ void AddressesWidget::sortAddresses()
299299

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

305305
AddressesWidget::~AddressesWidget()

src/qt/pivx/addresseswidget.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
#include "qt/pivx/pwidget.h"
99
#include "addresstablemodel.h"
10-
#include "qt/pivx/tooltipmenu.h"
1110
#include "furabstractlistitemdelegate.h"
12-
#include "qt/pivx/addressfilterproxymodel.h"
1311

1412
#include <QWidget>
1513

16-
class AddressViewDelegate;
14+
class AddressFilterProxyModel;
1715
class TooltipMenu;
1816
class PIVXGUI;
1917
class WalletModel;
@@ -35,7 +33,6 @@ class AddressesWidget : public PWidget
3533
~AddressesWidget();
3634

3735
void loadWalletModel() override;
38-
void onNewContactClicked();
3936

4037
private Q_SLOTS:
4138
void handleAddressClicked(const QModelIndex &index);
@@ -55,7 +52,6 @@ private Q_SLOTS:
5552
AddressTableModel* addressTablemodel = nullptr;
5653
AddressFilterProxyModel *filter = nullptr;
5754

58-
bool isOnMyAddresses = true;
5955
TooltipMenu* menu = nullptr;
6056

6157
// Cached index

src/qt/pivx/addressfilterproxymodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include "qt/pivx/addressfilterproxymodel.h"
6-
#include <iostream>
6+
#include "qt/addresstablemodel.h"
77

88
bool AddressFilterProxyModel::filterAcceptsRow(int row, const QModelIndex& parent) const
99
{

src/qt/pivx/addressfilterproxymodel.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#define PIVX_CORE_NEW_GUI_ADDRESSFILTERPROXYMODEL_H
77

88
#include <QSortFilterProxyModel>
9-
#include "addresstablemodel.h"
10-
119

1210
class AddressFilterProxyModel final : public QSortFilterProxyModel
1311
{

src/qt/pivx/addresslabelrow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void AddressLabelRow::init(bool isLightTheme, bool isHover)
1919
updateState(isLightTheme, isHover, false);
2020
}
2121

22-
void AddressLabelRow::updateView(QString address, QString label)
22+
void AddressLabelRow::updateView(const QString& address, const QString& label)
2323
{
2424
ui->lblAddress->setText(address);
2525
ui->lblLabel->setText(label);

src/qt/pivx/addresslabelrow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AddressLabelRow : public QWidget
2222
void init(bool isLightTheme, bool isHover);
2323

2424
void updateState(bool isLightTheme, bool isHovered, bool isSelected);
25-
void updateView(QString address, QString label);
25+
void updateView(const QString& address, const QString& label);
2626
protected:
2727
virtual void enterEvent(QEvent *);
2828
virtual void leaveEvent(QEvent *);

src/qt/pivx/myaddressrow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MyAddressRow::MyAddressRow(QWidget *parent) :
1515
ui->labelDate->setProperty("cssClass", "text-list-caption");
1616
}
1717

18-
void MyAddressRow::updateView(QString address, QString label, QString date){
18+
void MyAddressRow::updateView(const QString& address, const QString& label, const QString& date){
1919
ui->labelName->setText(label);
2020
ui->labelAddress->setText(address);
2121
if (date.isEmpty()){

src/qt/pivx/myaddressrow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MyAddressRow : public QWidget
1919
explicit MyAddressRow(QWidget *parent = nullptr);
2020
~MyAddressRow();
2121

22-
void updateView(QString address, QString label, QString date);
22+
void updateView(const QString& address, const QString& label, const QString& date);
2323

2424
private:
2525
Ui::MyAddressRow *ui;

0 commit comments

Comments
 (0)