From 3dd969df643f68b465e10f29a4c8611607ca9968 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 27 Feb 2019 16:16:02 +0800 Subject: [PATCH] Replace deprecated QSignalMapper class --- src/gui/properties/speedwidget.cpp | 8 +------- src/gui/properties/speedwidget.h | 2 -- src/gui/search/searchwidget.cpp | 9 +-------- src/gui/search/searchwidget.h | 2 -- 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 754211569..56012f7b6 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -89,18 +88,13 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) m_graphsMenu->addAction(tr("Tracker Download")); m_graphsMenuActions = m_graphsMenu->actions(); - m_graphsSignalMapper = new QSignalMapper(this); for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) { QAction *action = m_graphsMenuActions.at(id); action->setCheckable(true); action->setChecked(true); - connect(action, &QAction::changed, m_graphsSignalMapper - , static_cast(&QSignalMapper::map)); - m_graphsSignalMapper->setMapping(action, id); + connect(action, &QAction::changed, this, [this, id]() { onGraphChange(id); }); } - connect(m_graphsSignalMapper, static_cast(&QSignalMapper::mapped) - , this, &SpeedWidget::onGraphChange); m_graphsButton = new ComboBoxMenuButton(this, m_graphsMenu); m_graphsButton->addItem(tr("Select Graphs")); diff --git a/src/gui/properties/speedwidget.h b/src/gui/properties/speedwidget.h index bcfa68f9b..148e40f55 100644 --- a/src/gui/properties/speedwidget.h +++ b/src/gui/properties/speedwidget.h @@ -38,7 +38,6 @@ class QVBoxLayout; class QHBoxLayout; class QLabel; class QMenu; -class QSignalMapper; class PropertiesWidget; class ComboBoxMenuButton : public QComboBox @@ -80,7 +79,6 @@ private: ComboBoxMenuButton *m_graphsButton; QMenu *m_graphsMenu; QList m_graphsMenuActions; - QSignalMapper *m_graphsSignalMapper; }; #endif // SPEEDWIDGET_H diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 748a501fe..fec6cd1c1 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,6 @@ namespace SearchWidget::SearchWidget(MainWindow *mainWindow) : QWidget(mainWindow) , m_ui(new Ui::SearchWidget()) - , m_tabStatusChangedMapper(new QSignalMapper(this)) , m_mainWindow(mainWindow) , m_isNewQueryString(false) { @@ -131,9 +129,6 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) connect(m_ui->tabWidget, &QTabWidget::tabCloseRequested, this, &SearchWidget::closeTab); connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, &SearchWidget::tabChanged); - connect(m_tabStatusChangedMapper, static_cast(&QSignalMapper::mapped) - , this, &SearchWidget::tabStatusChanged); - const auto *searchManager = SearchPluginManager::instance(); const auto onPluginChanged = [this]() { @@ -342,9 +337,7 @@ void SearchWidget::on_searchButton_clicked() m_ui->tabWidget->setCurrentWidget(newTab); connect(newTab, &SearchJobWidget::resultsCountUpdated, this, &SearchWidget::resultsCountUpdated); - connect(newTab, &SearchJobWidget::statusChanged - , m_tabStatusChangedMapper, static_cast(&QSignalMapper::map)); - m_tabStatusChangedMapper->setMapping(newTab, newTab); + connect(newTab, &SearchJobWidget::statusChanged, this, [this, &newTab]() { tabStatusChanged(newTab); }); m_ui->searchButton->setText(tr("Stop")); m_activeSearchTab = newTab; diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index e303b569d..46a8315a7 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -34,7 +34,6 @@ #include class QShortcut; -class QSignalMapper; class QTabWidget; class MainWindow; @@ -81,7 +80,6 @@ private: QString selectedPlugin() const; Ui::SearchWidget *m_ui; - QSignalMapper *m_tabStatusChangedMapper; QPointer m_currentSearchTab; // Selected tab QPointer m_activeSearchTab; // Tab with running search QList m_allTabs; // To store all tabs