Skip to content

Commit

Permalink
Replace deprecated QSignalMapper class
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed Feb 28, 2019
1 parent c6ae1aa commit 3dd969d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
8 changes: 1 addition & 7 deletions src/gui/properties/speedwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QSignalMapper>
#include <QTimer>

#include <libtorrent/session_status.hpp>
Expand Down Expand Up @@ -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<void (QSignalMapper::*)()>(&QSignalMapper::map));
m_graphsSignalMapper->setMapping(action, id);
connect(action, &QAction::changed, this, [this, id]() { onGraphChange(id); });
}
connect(m_graphsSignalMapper, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped)
, this, &SpeedWidget::onGraphChange);

m_graphsButton = new ComboBoxMenuButton(this, m_graphsMenu);
m_graphsButton->addItem(tr("Select Graphs"));
Expand Down
2 changes: 0 additions & 2 deletions src/gui/properties/speedwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QMenu;
class QSignalMapper;
class PropertiesWidget;

class ComboBoxMenuButton : public QComboBox
Expand Down Expand Up @@ -80,7 +79,6 @@ private slots:
ComboBoxMenuButton *m_graphsButton;
QMenu *m_graphsMenu;
QList<QAction *> m_graphsMenuActions;
QSignalMapper *m_graphsSignalMapper;
};

#endif // SPEEDWIDGET_H
9 changes: 1 addition & 8 deletions src/gui/search/searchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <QProcess>
#include <QRegularExpression>
#include <QShortcut>
#include <QSignalMapper>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTextStream>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<void (QSignalMapper::*)(QWidget *)>(&QSignalMapper::mapped)
, this, &SearchWidget::tabStatusChanged);

const auto *searchManager = SearchPluginManager::instance();
const auto onPluginChanged = [this]()
{
Expand Down Expand Up @@ -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<void (QSignalMapper::*)()>(&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;
Expand Down
2 changes: 0 additions & 2 deletions src/gui/search/searchwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <QWidget>

class QShortcut;
class QSignalMapper;
class QTabWidget;

class MainWindow;
Expand Down Expand Up @@ -81,7 +80,6 @@ private slots:
QString selectedPlugin() const;

Ui::SearchWidget *m_ui;
QSignalMapper *m_tabStatusChangedMapper;
QPointer<SearchJobWidget> m_currentSearchTab; // Selected tab
QPointer<SearchJobWidget> m_activeSearchTab; // Tab with running search
QList<SearchJobWidget *> m_allTabs; // To store all tabs
Expand Down

0 comments on commit 3dd969d

Please sign in to comment.