From 3c530c0c4ba8371c02cc5099ed33c1211471b4f7 Mon Sep 17 00:00:00 2001 From: Dmitry Krivoruchko <144147209+UmbrellaLeaf5@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:08:58 +0300 Subject: [PATCH] simplify connections --- main/mainwindow.cpp | 4 +- .../interaction_buttons.cpp | 56 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/main/mainwindow.cpp b/main/mainwindow.cpp index 2158439..5c60380 100644 --- a/main/mainwindow.cpp +++ b/main/mainwindow.cpp @@ -12,8 +12,8 @@ MainWindow::MainWindow(QWidget* parent) ui->plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables | QCP::iSelectItems); - connect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressObjectsButton(QMouseEvent*))); + connect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressObjectsButton); area_->Setup(manager_.get()); t_connection_->Setup(manager_.get(), area_.get()); diff --git a/main/mainwindow_connections/interaction_buttons.cpp b/main/mainwindow_connections/interaction_buttons.cpp index 4c736ce..c7eedcf 100644 --- a/main/mainwindow_connections/interaction_buttons.cpp +++ b/main/mainwindow_connections/interaction_buttons.cpp @@ -5,32 +5,32 @@ void MainWindow::DisconnectObject(gui::ObjectType obj_type) { switch (obj_type) { case gui::ObjectType::TrappyCircles: { - disconnect(ui->plot, SIGNAL(mouseMove(QMouseEvent*)), this, - SLOT(mouseMoveSetRadiusFromPlot(QMouseEvent*))); - disconnect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressSetRadiusFromPlot(QMouseEvent*))); + disconnect(ui->plot, &QCustomPlot::mouseMove, this, + &MainWindow::mouseMoveSetRadiusFromPlot); + disconnect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressSetRadiusFromPlot); break; } case gui::ObjectType::TrappyLines: { - disconnect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressSelectSecondTarget(QMouseEvent*))); + disconnect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressSelectSecondTarget); break; } case gui::ObjectType::Hills: { - disconnect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressAddVertice(QMouseEvent*))); - disconnect(ui->plot, SIGNAL(mousePress(QMouseEvent*)), this, - SLOT(mousePressDeleteLastVertice(QMouseEvent*))); + disconnect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressAddVertice); + disconnect(ui->plot, &QCustomPlot::mousePress, this, + &MainWindow::mousePressDeleteLastVertice); } default: break; } - connect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressObjectsButton(QMouseEvent*))); + connect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressObjectsButton); ui->plot->setCursor(Qt::CrossCursor); cursor_ = CursorType::DefaultCursor; @@ -94,13 +94,13 @@ void MainWindow::mousePressObjectsButton(QMouseEvent* mouse_event) { case CursorType::TrCircleCursor: { manager_->Add(new gui::TrappyCircle({x, y}, 0)); - disconnect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressObjectsButton(QMouseEvent*))); + disconnect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressObjectsButton); - connect(ui->plot, SIGNAL(mouseMove(QMouseEvent*)), this, - SLOT(mouseMoveSetRadiusFromPlot(QMouseEvent*))); - connect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressSetRadiusFromPlot(QMouseEvent*))); + connect(ui->plot, &QCustomPlot::mouseMove, this, + &MainWindow::mouseMoveSetRadiusFromPlot); + connect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressSetRadiusFromPlot); ui->plot->setCursor(Qt::ClosedHandCursor); what_obj_addition_ = WhatObjectAddition::TrCircle; @@ -113,11 +113,11 @@ void MainWindow::mousePressObjectsButton(QMouseEvent* mouse_event) { for (const auto& t_ptr : manager_->GetTargetsPtrs()) { if (t_ptr->GetGraphPtr() == ui->plot->selectedGraphs()[0]) { manager_->Add(new gui::TrappyLine(t_ptr, t_ptr)); - disconnect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressObjectsButton(QMouseEvent*))); + disconnect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressObjectsButton); - connect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressSelectSecondTarget(QMouseEvent*))); + connect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressSelectSecondTarget); what_obj_addition_ = WhatObjectAddition::TrLine; break; @@ -129,13 +129,13 @@ void MainWindow::mousePressObjectsButton(QMouseEvent* mouse_event) { case CursorType::HillCursor: { manager_->Add(new gui::Hill{{x, y}, {x, y}}); - disconnect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressObjectsButton(QMouseEvent*))); + disconnect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressObjectsButton); - connect(ui->plot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, - SLOT(mousePressAddVertice(QMouseEvent*))); - connect(ui->plot, SIGNAL(mousePress(QMouseEvent*)), this, - SLOT(mousePressDeleteLastVertice(QMouseEvent*))); + connect(ui->plot, &QCustomPlot::mouseDoubleClick, this, + &MainWindow::mousePressAddVertice); + connect(ui->plot, &QCustomPlot::mousePress, this, + &MainWindow::mousePressDeleteLastVertice); what_obj_addition_ = WhatObjectAddition::Hill; break;