mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
merge bitcoin#16706: Replace deprecated QSignalMapper by lambda expressions
This commit is contained in:
parent
1c77b0eb0a
commit
52b972a3a4
@ -40,7 +40,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QSettings>
|
||||
#include <QSignalMapper>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
@ -651,19 +650,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);
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <QPoint>
|
||||
#include <QScrollBar>
|
||||
#include <QSettings>
|
||||
#include <QSignalMapper>
|
||||
#include <QTableView>
|
||||
#include <QTextCharFormat>
|
||||
#include <QTimer>
|
||||
@ -173,11 +172,6 @@ transactionView(nullptr), abandonAction(nullptr), columnResizingFixer(nullptr)
|
||||
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);
|
||||
@ -244,15 +238,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 QItemSelectionModel;
|
||||
class QLineEdit;
|
||||
class QMenu;
|
||||
class QModelIndex;
|
||||
class QSignalMapper;
|
||||
class QTableView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@ -71,7 +70,6 @@ private:
|
||||
QLineEdit *amountWidget;
|
||||
|
||||
QMenu *contextMenu;
|
||||
QSignalMapper *mapperThirdPartyTxUrls;
|
||||
|
||||
QFrame *dateRangeWidget;
|
||||
QDateTimeEdit *dateFrom;
|
||||
|
Loading…
Reference in New Issue
Block a user