summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joseph W. Joshua <joejoshw@gmail.com>2014-07-31 18:51:38 +0300
committerGravatar Thiago Macieira <thiago@macieira.org>2014-08-13 10:48:15 -0700
commit4e99382c96c71e5427a7f1ef011b04f0e560a1f6 (patch)
tree980b96d4133481a5d719d89f3bdc7c9ff56820fb
parent24cb0b0496e8f593f22f3e1cd25b286ad8c7031f (diff)
downloadsubsurface-4e99382c96c71e5427a7f1ef011b04f0e560a1f6.tar.gz
Improve on error reporting in the ConfigureDiveComputer class
This patch improves on the error reporting for the dive computer configuration dialog to use config->lastError. The previous code was using a different argument in each function, which lacked uniformity. Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
-rw-r--r--configuredivecomputer.cpp10
-rw-r--r--configuredivecomputer.h6
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp13
3 files changed, 13 insertions, 16 deletions
diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp
index fac603f84..5fe5a4a91 100644
--- a/configuredivecomputer.cpp
+++ b/configuredivecomputer.cpp
@@ -50,7 +50,7 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat
writeThread->start();
}
-bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText)
+bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data)
{
QString xml = "";
QString vendor = data->vendor;
@@ -187,7 +187,7 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai
writer.writeEndDocument();
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) {
- errorText = tr("Could not save the backup file %1. Error Message: %2")
+ lastError = tr("Could not save the backup file %1. Error Message: %2")
.arg(fileName, file.errorString());
return false;
}
@@ -199,11 +199,11 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai
return true;
}
-bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText)
+bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details)
{
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
- errorText = tr("Could not open backup file: %1").arg(file.errorString());
+ lastError = tr("Could not open backup file: %1").arg(file.errorString());
return false;
}
@@ -401,7 +401,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de
return true;
}
-void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data, QString errorText)
+void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data)
{
}
diff --git a/configuredivecomputer.h b/configuredivecomputer.h
index 0cd16d311..4522e9fbe 100644
--- a/configuredivecomputer.h
+++ b/configuredivecomputer.h
@@ -32,9 +32,9 @@ public:
device_data_t *m_data;
void saveDeviceDetails(DeviceDetails *details, device_data_t *data);
void fetchDeviceDetails();
- bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText);
- bool restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText);
- void startFirmwareUpdate(QString fileName, device_data_t *data, QString errorText);
+ bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data);
+ bool restoreXMLBackup(QString fileName, DeviceDetails *details);
+ void startFirmwareUpdate(QString fileName, device_data_t *data);
signals:
void message(QString msg);
void error(QString err);
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index 293dd244b..e40522529 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -396,11 +396,10 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked()
if (!backupPath.isEmpty()) {
populateDeviceDetails();
getDeviceData();
- QString errorText = "";
- if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data, errorText)) {
+ if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data)) {
QMessageBox::critical(this, tr("XML Backup Error"),
tr("An error occurred while saving the backup file.\n%1")
- .arg(errorText)
+ .arg(config->lastError)
);
} else {
QMessageBox::information(this, tr("Backup succeeded"),
@@ -420,11 +419,10 @@ void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked()
filename, tr("Backup files (*.xml)")
);
if (!restorePath.isEmpty()) {
- QString errorText = "";
- if (!config->restoreXMLBackup(restorePath, deviceDetails, errorText)) {
+ if (!config->restoreXMLBackup(restorePath, deviceDetails)) {
QMessageBox::critical(this, tr("XML Restore Error"),
tr("An error occurred while restoring the backup file.\n%1")
- .arg(errorText)
+ .arg(config->lastError)
);
} else {
reloadValues();
@@ -447,8 +445,7 @@ void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked()
);
if (!firmwarePath.isEmpty()) {
getDeviceData();
- QString errText;
- config->startFirmwareUpdate(firmwarePath, &device_data, errText);
+ config->startFirmwareUpdate(firmwarePath, &device_data);
}
}