mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
a3e990dfd5
commit
8af40025b0
2 changed files with 13 additions and 18 deletions
|
@ -20,6 +20,13 @@ ConfigureDiveComputer::ConfigureDiveComputer() : readThread(0),
|
||||||
setState(INITIAL);
|
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)
|
void ConfigureDiveComputer::readSettings(device_data_t *data)
|
||||||
{
|
{
|
||||||
setState(READING);
|
setState(READING);
|
||||||
|
@ -28,12 +35,8 @@ void ConfigureDiveComputer::readSettings(device_data_t *data)
|
||||||
readThread->deleteLater();
|
readThread->deleteLater();
|
||||||
|
|
||||||
readThread = new ReadSettingsThread(this, data);
|
readThread = new ReadSettingsThread(this, data);
|
||||||
connect(readThread, SIGNAL(finished()),
|
connectThreadSignals(readThread);
|
||||||
this, SLOT(readThreadFinished()), Qt::QueuedConnection);
|
connect(readThread, &ReadSettingsThread::devicedetails, this, &ConfigureDiveComputer::deviceDetailsChanged);
|
||||||
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);
|
|
||||||
|
|
||||||
readThread->start();
|
readThread->start();
|
||||||
}
|
}
|
||||||
|
@ -46,10 +49,7 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat
|
||||||
writeThread->deleteLater();
|
writeThread->deleteLater();
|
||||||
|
|
||||||
writeThread = new WriteSettingsThread(this, data);
|
writeThread = new WriteSettingsThread(this, data);
|
||||||
connect(writeThread, SIGNAL(finished()),
|
connectThreadSignals(writeThread);
|
||||||
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);
|
|
||||||
|
|
||||||
writeThread->setDeviceDetails(details);
|
writeThread->setDeviceDetails(details);
|
||||||
writeThread->start();
|
writeThread->start();
|
||||||
|
@ -498,10 +498,7 @@ void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t
|
||||||
firmwareThread->deleteLater();
|
firmwareThread->deleteLater();
|
||||||
|
|
||||||
firmwareThread = new FirmwareUpdateThread(this, data, fileName);
|
firmwareThread = new FirmwareUpdateThread(this, data, fileName);
|
||||||
connect(firmwareThread, SIGNAL(finished()),
|
connectThreadSignals(firmwareThread);
|
||||||
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);
|
|
||||||
|
|
||||||
firmwareThread->start();
|
firmwareThread->start();
|
||||||
}
|
}
|
||||||
|
@ -514,10 +511,7 @@ void ConfigureDiveComputer::resetSettings(device_data_t *data)
|
||||||
resetThread->deleteLater();
|
resetThread->deleteLater();
|
||||||
|
|
||||||
resetThread = new ResetSettingsThread(this, data);
|
resetThread = new ResetSettingsThread(this, data);
|
||||||
connect(resetThread, SIGNAL(finished()),
|
connectThreadSignals(resetThread);
|
||||||
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);
|
|
||||||
|
|
||||||
resetThread->start();
|
resetThread->start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ private:
|
||||||
WriteSettingsThread *writeThread;
|
WriteSettingsThread *writeThread;
|
||||||
ResetSettingsThread *resetThread;
|
ResetSettingsThread *resetThread;
|
||||||
FirmwareUpdateThread *firmwareThread;
|
FirmwareUpdateThread *firmwareThread;
|
||||||
|
void connectThreadSignals(DeviceThread *thread);
|
||||||
void setState(states newState);
|
void setState(states newState);
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue