Browse Source

Replace deprecated QSignalMapper class

adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
3dd969df64
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 8
      src/gui/properties/speedwidget.cpp
  2. 2
      src/gui/properties/speedwidget.h
  3. 9
      src/gui/search/searchwidget.cpp
  4. 2
      src/gui/search/searchwidget.h

8
src/gui/properties/speedwidget.cpp

@ -32,7 +32,6 @@ @@ -32,7 +32,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QSignalMapper>
#include <QTimer>
#include <libtorrent/session_status.hpp>
@ -89,18 +88,13 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) @@ -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"));

2
src/gui/properties/speedwidget.h

@ -38,7 +38,6 @@ class QVBoxLayout; @@ -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: @@ -80,7 +79,6 @@ private:
ComboBoxMenuButton *m_graphsButton;
QMenu *m_graphsMenu;
QList<QAction *> m_graphsMenuActions;
QSignalMapper *m_graphsSignalMapper;
};
#endif // SPEEDWIDGET_H

9
src/gui/search/searchwidget.cpp

@ -42,7 +42,6 @@ @@ -42,7 +42,6 @@
#include <QProcess>
#include <QRegularExpression>
#include <QShortcut>
#include <QSignalMapper>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTextStream>
@ -91,7 +90,6 @@ namespace @@ -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) @@ -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]()
{
@ -342,9 +337,7 @@ void SearchWidget::on_searchButton_clicked() @@ -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;

2
src/gui/search/searchwidget.h

@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
#include <QWidget>
class QShortcut;
class QSignalMapper;
class QTabWidget;
class MainWindow;
@ -81,7 +80,6 @@ private: @@ -81,7 +80,6 @@ private:
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

Loading…
Cancel
Save