mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 19:49:28 +00:00
receive: add option to show change addresses
This commit is contained in:
parent
fa33172760
commit
906bd164e4
5 changed files with 30 additions and 7 deletions
|
@ -44,6 +44,8 @@ ReceiveWidget::ReceiveWidget(Wallet *wallet, QWidget *parent)
|
|||
m_headerMenu = new QMenu(this);
|
||||
m_showFullAddressesAction = m_headerMenu->addAction("Show full addresses", this, &ReceiveWidget::setShowFullAddresses);
|
||||
m_showFullAddressesAction->setCheckable(true);
|
||||
m_showChangeAddressesAction = m_headerMenu->addAction("Show change addresses", this, &ReceiveWidget::setShowChangeAddresses);
|
||||
m_showChangeAddressesAction->setCheckable(true);
|
||||
connect(ui->addresses->header(), &QHeaderView::customContextMenuRequested, this, &ReceiveWidget::showHeaderMenu);
|
||||
|
||||
// context menu
|
||||
|
@ -141,6 +143,11 @@ void ReceiveWidget::onShowTransactions() {
|
|||
emit showTransactions(address);
|
||||
}
|
||||
|
||||
void ReceiveWidget::setShowChangeAddresses(bool show) {
|
||||
if (!m_proxyModel) return;
|
||||
m_proxyModel->setShowChangeAddresses(show);
|
||||
}
|
||||
|
||||
void ReceiveWidget::setShowFullAddresses(bool show) {
|
||||
if (!m_model) return;
|
||||
m_model->setShowFullAddresses(show);
|
||||
|
|
|
@ -35,6 +35,7 @@ public slots:
|
|||
void editLabel();
|
||||
void showContextMenu(const QPoint& point);
|
||||
void setShowFullAddresses(bool show);
|
||||
void setShowChangeAddresses(bool show);
|
||||
void setShowUsedAddresses(bool show);
|
||||
void setShowHiddenAddresses(bool show);
|
||||
void setSearchFilter(const QString &filter);
|
||||
|
@ -57,6 +58,7 @@ private:
|
|||
QMenu *m_headerMenu;
|
||||
QAction *m_showFullAddressesAction;
|
||||
QAction *m_showTransactionsAction;
|
||||
QAction *m_showChangeAddressesAction;
|
||||
SubaddressModel *m_model;
|
||||
SubaddressProxyModel *m_proxyModel;
|
||||
|
||||
|
|
|
@ -110,7 +110,15 @@ QVariant SubaddressModel::parseSubaddressRow(const Monero::SubaddressRow &subadd
|
|||
return address;
|
||||
}
|
||||
case Label:
|
||||
return index.row() == 0 ? tr("Primary address") : QString::fromStdString(subaddress.getLabel());
|
||||
{
|
||||
if (m_currentSubaddressAccount == 0 && index.row() == 0) {
|
||||
return "Primary address";
|
||||
}
|
||||
else if (index.row() == 0) {
|
||||
return "Change";
|
||||
}
|
||||
return QString::fromStdString(subaddress.getLabel());
|
||||
}
|
||||
case isUsed:
|
||||
return subaddress.isUsed();
|
||||
default:
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
#include "SubaddressProxyModel.h"
|
||||
|
||||
SubaddressProxyModel::SubaddressProxyModel(QObject *parent, Subaddress *subaddress, bool hidePrimary)
|
||||
SubaddressProxyModel::SubaddressProxyModel(QObject *parent, Subaddress *subaddress, bool showChange)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, m_subaddress(subaddress)
|
||||
, m_searchRegExp("")
|
||||
, m_searchCaseSensitiveRegExp("")
|
||||
, m_hidePrimary(hidePrimary)
|
||||
, m_showChange(showChange)
|
||||
{
|
||||
m_searchRegExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||
}
|
||||
|
@ -23,9 +23,10 @@ bool SubaddressProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &so
|
|||
label = QString::fromStdString(subaddress.getLabel());
|
||||
});
|
||||
|
||||
// Hide primary address
|
||||
if (sourceRow == 0 && m_hidePrimary)
|
||||
// Hide primary/change addresses
|
||||
if (!m_showChange && sourceRow == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_showHidden && m_hiddenAddresses.contains(address)) {
|
||||
return false;
|
||||
|
|
|
@ -12,7 +12,7 @@ class SubaddressProxyModel : public QSortFilterProxyModel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SubaddressProxyModel(QObject* parent, Subaddress *subaddress, bool hidePrimary = true);
|
||||
explicit SubaddressProxyModel(QObject* parent, Subaddress *subaddress, bool hidePrimary = false);
|
||||
bool filterAcceptsRow(int sourceRow,
|
||||
const QModelIndex &sourceParent) const;
|
||||
|
||||
|
@ -38,6 +38,11 @@ public slots:
|
|||
invalidateFilter();
|
||||
}
|
||||
|
||||
void setShowChangeAddresses(const bool showChange) {
|
||||
m_showChange = showChange;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
private:
|
||||
Subaddress *m_subaddress;
|
||||
|
||||
|
@ -46,7 +51,7 @@ private:
|
|||
QRegularExpression m_searchCaseSensitiveRegExp;
|
||||
bool m_showUsed = false;
|
||||
bool m_showHidden = false;
|
||||
bool m_hidePrimary;
|
||||
bool m_showChange = false;
|
||||
};
|
||||
|
||||
#endif //FEATHER_SUBADDRESSPROXYMODEL_H
|
||||
|
|
Loading…
Reference in a new issue