Merge #16706: qt: Replace deprecated QSignalMapper by lambda expressions
0912134039
qt: Remove QSignalMapper from TransactionView (Hennadii Stepanov)9e0c1d676c
qt: Remove QSignalMapper from RPCConsole (Hennadii Stepanov) Pull request description: The [`QSignalMapper`](https://doc.qt.io/qt-5/qsignalmapper.html) class has been [deprecated](https://doc-snapshots.qt.io/qt5-5.10/obsoleteclasses.html) since Qt 5.10. This PR replaces it by lambdas and does not change behavior. ACKs for top commit: jonasschnelli: utACK0912134039
Tree-SHA512: 0c102d5cab4adc8b6252f72e07123ac87c65434c88cada3e72816ecea8fc4803f15b9c050fb5e1c7e8a96f709265521fd6813ab1890dbf5634032f7ee0d50675
This commit is contained in:
commit
75142ece6b
3 changed files with 7 additions and 25 deletions
|
@ -34,7 +34,6 @@
|
|||
#include <QScrollBar>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QSignalMapper>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
|
@ -614,19 +613,10 @@ void RPCConsole::setClientModel(ClientModel *model)
|
|||
peersTableContextMenu->addAction(banAction7d);
|
||||
peersTableContextMenu->addAction(banAction365d);
|
||||
|
||||
// Add a signal mapping to allow dynamic context menu arguments.
|
||||
// We need to use int (instead of int64_t), because signal mapper only supports
|
||||
// int or objects, which is okay because max bantime (1 year) is < int_max.
|
||||
QSignalMapper* signalMapper = new QSignalMapper(this);
|
||||
signalMapper->setMapping(banAction1h, 60*60);
|
||||
signalMapper->setMapping(banAction24h, 60*60*24);
|
||||
signalMapper->setMapping(banAction7d, 60*60*24*7);
|
||||
signalMapper->setMapping(banAction365d, 60*60*24*365);
|
||||
connect(banAction1h, &QAction::triggered, signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
connect(banAction24h, &QAction::triggered, signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
connect(banAction7d, &QAction::triggered, signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
connect(banAction365d, &QAction::triggered, signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
connect(signalMapper, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped), this, &RPCConsole::banSelectedNode);
|
||||
connect(banAction1h, &QAction::triggered, [this] { banSelectedNode(60 * 60); });
|
||||
connect(banAction24h, &QAction::triggered, [this] { banSelectedNode(60 * 60 * 24); });
|
||||
connect(banAction7d, &QAction::triggered, [this] { banSelectedNode(60 * 60 * 24 * 7); });
|
||||
connect(banAction365d, &QAction::triggered, [this] { banSelectedNode(60 * 60 * 24 * 365); });
|
||||
|
||||
// peer table context menu signals
|
||||
connect(ui->peerWidget, &QTableView::customContextMenuRequested, this, &RPCConsole::showPeersTableContextMenu);
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
#include <QSignalMapper>
|
||||
#include <QTableView>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
|
@ -176,11 +175,6 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
|||
contextMenu->addAction(abandonAction);
|
||||
contextMenu->addAction(editLabelAction);
|
||||
|
||||
mapperThirdPartyTxUrls = new QSignalMapper(this);
|
||||
|
||||
// Connect actions
|
||||
connect(mapperThirdPartyTxUrls, static_cast<void (QSignalMapper::*)(const QString&)>(&QSignalMapper::mapped), this, &TransactionView::openThirdPartyTxUrl);
|
||||
|
||||
connect(dateWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseDate);
|
||||
connect(typeWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseType);
|
||||
connect(watchOnlyWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseWatchonly);
|
||||
|
@ -246,15 +240,15 @@ void TransactionView::setModel(WalletModel *_model)
|
|||
QStringList listUrls = _model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts);
|
||||
for (int i = 0; i < listUrls.size(); ++i)
|
||||
{
|
||||
QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
|
||||
QString url = listUrls[i].trimmed();
|
||||
QString host = QUrl(url, QUrl::StrictMode).host();
|
||||
if (!host.isEmpty())
|
||||
{
|
||||
QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
|
||||
if (i == 0)
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(thirdPartyTxUrlAction);
|
||||
connect(thirdPartyTxUrlAction, &QAction::triggered, mapperThirdPartyTxUrls, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed());
|
||||
connect(thirdPartyTxUrlAction, &QAction::triggered, [this, url] { openThirdPartyTxUrl(url); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ class QFrame;
|
|||
class QLineEdit;
|
||||
class QMenu;
|
||||
class QModelIndex;
|
||||
class QSignalMapper;
|
||||
class QTableView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -72,7 +71,6 @@ private:
|
|||
QLineEdit *amountWidget;
|
||||
|
||||
QMenu *contextMenu;
|
||||
QSignalMapper *mapperThirdPartyTxUrls;
|
||||
|
||||
QFrame *dateRangeWidget;
|
||||
QDateTimeEdit *dateFrom;
|
||||
|
|
Loading…
Reference in a new issue