From 4fc16b16749a73b8c06d41cb7cb22b78c77ab29e Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 15:03:26 +0300 Subject: Move divecomputer configuration code to different files This splits the code in configuredivecomputer.cpp into multiple files. The read and write threads are moved to configuredivecomputerthreads.h/cpp, and the device details class is moved to devicedetails.h/.cpp Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 36 +++++++++++------------------------ 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 1d5b1d7f8..8ae250468 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -33,14 +33,16 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : ui(new Ui::ConfigureDiveComputerDialog), config(0), vendorModel(0), - productModel(0) + productModel(0), + deviceDetails(0) { ui->setupUi(this); + deviceDetails = new DeviceDetails(this); config = new ConfigureDiveComputer(this); connect (config, SIGNAL(error(QString)), this, SLOT(configError(QString))); connect (config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); - connect (config, SIGNAL(deviceSettings(QString)), ui->availableDetails, SLOT(setText(QString))); + connect (config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished())); fill_computer_list(); @@ -157,7 +159,7 @@ void ConfigureDiveComputerDialog::readSettings() ui->errorLabel->clear(); getDeviceData(); - config->readSettings(&device_data); + config->readSettings(deviceDetails, &device_data); } void ConfigureDiveComputerDialog::configMessage(QString msg) @@ -181,6 +183,8 @@ void ConfigureDiveComputerDialog::getDeviceData() set_default_dive_computer(device_data.vendor, device_data.product); set_default_dive_computer_device(device_data.devname); + + //deviceDetails->setData(&device_data); } void ConfigureDiveComputerDialog::on_cancel_clicked() @@ -188,31 +192,13 @@ void ConfigureDiveComputerDialog::on_cancel_clicked() this->close(); } -void ConfigureDiveComputerDialog::on_setDeviceName_clicked() +void ConfigureDiveComputerDialog::deviceReadFinished() { - ui->statusLabel->clear(); - ui->errorLabel->clear(); - ui->availableDetails->clear(); - - QString newDeviceName = QInputDialog::getText(this, tr("Set device name"), tr("Enter the new name for this device:")); - if (newDeviceName.length() > 0) { - getDeviceData(); - config->setDeviceName(&device_data, newDeviceName); - } + ui->brightnessComboBox->setCurrentIndex(config->m_deviceDetails->brightness()); } -void ConfigureDiveComputerDialog::on_setDateAndTime_clicked() +void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() { - ui->statusLabel->clear(); - ui->errorLabel->clear(); - ui->availableDetails->clear(); - - getDeviceData(); - config->setDeviceDateAndTime(&device_data, QDateTime::currentDateTime()); + config->saveDeviceDetails(); } -void ConfigureDiveComputerDialog::on_setBrightnessButton_clicked() -{ - getDeviceData(); - config->setDeviceBrightness(&device_data, ui->brightnessComboBox->currentIndex()); -} -- cgit v1.2.3-70-g09d2