summaryrefslogtreecommitdiffstats
path: root/qt-ui/configuredivecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Joseph W. Joshua <joejoshw@gmail.com>2014-06-10 18:25:25 +0300
committerGravatar Thiago Macieira <thiago@macieira.org>2014-08-13 10:48:11 -0700
commit20eb62a98a70c1773ff99ece05f1c69e6ca8ce15 (patch)
tree0d7e18fd5405b0b259c9ae35b8315887dd4658b6 /qt-ui/configuredivecomputer.cpp
parent4fc16b16749a73b8c06d41cb7cb22b78c77ab29e (diff)
downloadsubsurface-20eb62a98a70c1773ff99ece05f1c69e6ca8ce15.tar.gz
Polish up on classes
This patch polishes up on all classes added for dive computer configuration to give a clean workflow. The classes can now write and read data from the OSTC 3. Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
Diffstat (limited to 'qt-ui/configuredivecomputer.cpp')
-rw-r--r--qt-ui/configuredivecomputer.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp
index d24c8905d..ad431eefe 100644
--- a/qt-ui/configuredivecomputer.cpp
+++ b/qt-ui/configuredivecomputer.cpp
@@ -4,31 +4,42 @@
ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) :
QObject(parent),
readThread(0),
- writeThread(0),
- m_deviceDetails(0)
+ writeThread(0)
{
setState(INITIAL);
}
-void ConfigureDiveComputer::readSettings(DeviceDetails *deviceDetails, device_data_t *data)
+void ConfigureDiveComputer::readSettings(device_data_t *data)
{
setState(READING);
- m_deviceDetails = deviceDetails;
if (readThread)
readThread->deleteLater();
- readThread = new ReadSettingsThread(this, deviceDetails, data);
+ 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*)));
readThread->start();
}
-void ConfigureDiveComputer::saveDeviceDetails()
+void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_data_t *data)
{
+ setState(WRITING);
+ if (writeThread)
+ 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)));
+
+ writeThread->setDeviceDetails(details);
+ writeThread->start();
}
void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState)