]> sigrok.org Git - pulseview.git/commitdiff
MainWindow: Remove QSignalMapper usage
authorSoeren Apel <redacted>
Sat, 11 Jan 2020 21:24:23 +0000 (22:24 +0100)
committerUwe Hermann <redacted>
Sun, 12 Jan 2020 15:46:45 +0000 (16:46 +0100)
pv/mainwindow.cpp
pv/mainwindow.hpp

index c5387beb0a21b0ed943324b926cb093b77b48a3f..d7f5c31a3e78e11857ee149473c3ff0f5f763d9b 100644 (file)
@@ -71,7 +71,6 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) :
        QMainWindow(parent),
        device_manager_(device_manager),
        session_selector_(this),
-       session_state_mapper_(this),
        icon_red_(":/icons/status-red.svg"),
        icon_green_(":/icons/status-green.svg"),
        icon_grey_(":/icons/status-grey.svg")
@@ -334,9 +333,8 @@ shared_ptr<Session> MainWindow::add_session()
                this, SLOT(on_session_name_changed()));
        connect(session.get(), SIGNAL(device_changed()),
                this, SLOT(on_session_device_changed()));
-       session_state_mapper_.setMapping(session.get(), session.get());
        connect(session.get(), SIGNAL(capture_state_changed(int)),
-               &session_state_mapper_, SLOT(map()));
+               this, SLOT(on_session_capture_state_changed(int)));
 
        sessions_.push_back(session);
 
@@ -552,8 +550,6 @@ void MainWindow::setup_ui()
                this, SLOT(on_new_session_clicked()));
        connect(run_stop_button_, SIGNAL(clicked(bool)),
                this, SLOT(on_run_stop_clicked()));
-       connect(&session_state_mapper_, SIGNAL(mapped(QObject*)),
-               this, SLOT(on_capture_state_changed(QObject*)));
        connect(settings_button_, SIGNAL(clicked(bool)),
                this, SLOT(on_settings_clicked()));
 
@@ -693,7 +689,7 @@ void MainWindow::on_focused_session_changed(shared_ptr<Session> session)
        setWindowTitle(session->name() + " - " + WindowTitle);
 
        // Update the state of the run/stop button, too
-       on_capture_state_changed(session.get());
+       update_acq_button(session.get());
 }
 
 void MainWindow::on_new_session_clicked()
@@ -767,16 +763,19 @@ void MainWindow::on_session_device_changed()
        update_acq_button(session);
 }
 
-void MainWindow::on_capture_state_changed(QObject *obj)
+void MainWindow::on_session_capture_state_changed(int state)
 {
-       Session *caller = qobject_cast<Session*>(obj);
+       (void)state;
+
+       Session *session = qobject_cast<Session*>(QObject::sender());
+       assert(session);
 
        // Ignore if caller is not the currently focused session
        // unless there is only one session
-       if ((sessions_.size() > 1) && (caller != last_focused_session_.get()))
+       if ((sessions_.size() > 1) && (session != last_focused_session_.get()))
                return;
 
-       update_acq_button(caller);
+       update_acq_button(session);
 }
 
 void MainWindow::on_new_view(Session *session, int view_type)
index bf23acfb1fabe76795d9b558b64d8c2bccd5b23c..522ab1c0478ea7d1def85a90ada942733735f182 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <QMainWindow>
 #include <QShortcut>
-#include <QSignalMapper>
 #include <QTabWidget>
 #include <QToolButton>
 
@@ -125,7 +124,7 @@ private Q_SLOTS:
 
        void on_session_name_changed();
        void on_session_device_changed();
-       void on_capture_state_changed(QObject *obj);
+       void on_session_capture_state_changed(int state);
 
        void on_new_view(Session *session, int view_type);
        void on_view_close_clicked();
@@ -157,7 +156,6 @@ private:
        QWidget *static_tab_widget_;
        QToolButton *new_session_button_, *run_stop_button_, *settings_button_;
        QTabWidget session_selector_;
-       QSignalMapper session_state_mapper_;
 
        QIcon icon_red_;
        QIcon icon_green_;