summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-04 21:00:21 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-06 10:38:45 -0700
commit8af40025b02152586aeaeeba166ff9e597a2702d (patch)
tree4c5c703b2bde54db4d03d016e772b2300985fabc /core
parenta3e990dfd5a17ab541e3ab89a21b80d8bc48bb6e (diff)
downloadsubsurface-8af40025b02152586aeaeeba166ff9e597a2702d.tar.gz
cleanup: use pointer-to-function connect() in ConfigureDiveComputer
This version is compile-time checked and therefore less risky with respect to refactoring. Since the same three signals were connect()ed for three different threads-objects, do this in a new function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/configuredivecomputer.cpp30
-rw-r--r--core/configuredivecomputer.h1
2 files changed, 13 insertions, 18 deletions
diff --git a/core/configuredivecomputer.cpp b/core/configuredivecomputer.cpp
index 7574ceb6b..ad82fe1b8 100644
--- a/core/configuredivecomputer.cpp
+++ b/core/configuredivecomputer.cpp
@@ -20,6 +20,13 @@ ConfigureDiveComputer::ConfigureDiveComputer() : readThread(0),
setState(INITIAL);
}
+void ConfigureDiveComputer::connectThreadSignals(DeviceThread *thread)
+{
+ connect(thread, &DeviceThread::finished, this, &ConfigureDiveComputer::readThreadFinished, Qt::QueuedConnection);
+ connect(thread, &DeviceThread::error, this, &ConfigureDiveComputer::setError);
+ connect(thread, &DeviceThread::progress, this, &ConfigureDiveComputer::progressEvent, Qt::QueuedConnection);
+}
+
void ConfigureDiveComputer::readSettings(device_data_t *data)
{
setState(READING);
@@ -28,12 +35,8 @@ void ConfigureDiveComputer::readSettings(device_data_t *data)
readThread->deleteLater();
readThread = new ReadSettingsThread(this, data);
- connect(readThread, SIGNAL(finished()),
- this, SLOT(readThreadFinished()), Qt::QueuedConnection);
- connect(readThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
- connect(readThread, SIGNAL(devicedetails(DeviceDetails *)), this,
- SIGNAL(deviceDetailsChanged(DeviceDetails *)));
- connect(readThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
+ connectThreadSignals(readThread);
+ connect(readThread, &ReadSettingsThread::devicedetails, this, &ConfigureDiveComputer::deviceDetailsChanged);
readThread->start();
}
@@ -46,10 +49,7 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat
writeThread->deleteLater();
writeThread = new WriteSettingsThread(this, data);
- connect(writeThread, SIGNAL(finished()),
- this, SLOT(writeThreadFinished()), Qt::QueuedConnection);
- connect(writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
- connect(writeThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
+ connectThreadSignals(writeThread);
writeThread->setDeviceDetails(details);
writeThread->start();
@@ -498,10 +498,7 @@ void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t
firmwareThread->deleteLater();
firmwareThread = new FirmwareUpdateThread(this, data, fileName);
- connect(firmwareThread, SIGNAL(finished()),
- this, SLOT(firmwareThreadFinished()), Qt::QueuedConnection);
- connect(firmwareThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
- connect(firmwareThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
+ connectThreadSignals(firmwareThread);
firmwareThread->start();
}
@@ -514,10 +511,7 @@ void ConfigureDiveComputer::resetSettings(device_data_t *data)
resetThread->deleteLater();
resetThread = new ResetSettingsThread(this, data);
- connect(resetThread, SIGNAL(finished()),
- this, SLOT(resetThreadFinished()), Qt::QueuedConnection);
- connect(resetThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
- connect(resetThread, SIGNAL(progress(int)), this, SLOT(progressEvent(int)), Qt::QueuedConnection);
+ connectThreadSignals(resetThread);
resetThread->start();
}
diff --git a/core/configuredivecomputer.h b/core/configuredivecomputer.h
index 72661f00a..1bdc03549 100644
--- a/core/configuredivecomputer.h
+++ b/core/configuredivecomputer.h
@@ -55,6 +55,7 @@ private:
WriteSettingsThread *writeThread;
ResetSettingsThread *resetThread;
FirmwareUpdateThread *firmwareThread;
+ void connectThreadSignals(DeviceThread *thread);
void setState(states newState);
private
slots: