summaryrefslogtreecommitdiffstats
path: root/qt-ui/configuredivecomputerdialog.cpp
diff options
context:
space:
mode:
authorGravatar Joseph W. Joshua <joejoshw@gmail.com>2014-06-11 09:37:27 +0300
committerGravatar Thiago Macieira <thiago@macieira.org>2014-08-13 10:48:14 -0700
commitaad60ef6da3308960767a47cb750c2ba9aab54bd (patch)
tree3160041761184cdb3d871eec35ef54c8305c2efe /qt-ui/configuredivecomputerdialog.cpp
parente54d7d9178fc159f068587a59244340bec068efb (diff)
downloadsubsurface-aad60ef6da3308960767a47cb750c2ba9aab54bd.tar.gz
Working XML Backup and Restore
The ConfigureDiveComputer class now has functions for complete XML backup and restore. These dump the loaded settings on a dive computer to an XML file, and there is an option to restore them. Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
Diffstat (limited to 'qt-ui/configuredivecomputerdialog.cpp')
-rw-r--r--qt-ui/configuredivecomputerdialog.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index 71960b6f2..2f8771ed7 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -244,7 +244,7 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked()
QString errorText = "";
if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data, errorText)) {
QMessageBox::critical(this, tr("XML Backup Error"),
- tr("An eror occurred while saving the backup file.\n%1")
+ tr("An error occurred while saving the backup file.\n%1")
.arg(errorText)
);
} else {
@@ -255,3 +255,29 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked()
}
}
}
+
+void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked()
+{
+ QString filename = existing_filename ?: prefs.default_filename;
+ QFileInfo fi(filename);
+ filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml");
+ QString restorePath = QFileDialog::getOpenFileName(this, tr("Restore Dive Computer Settings"),
+ filename, tr("Backup files (*.xml)")
+ );
+ if (!restorePath.isEmpty()) {
+ QString errorText = "";
+ if (!config->restoreXMLBackup(restorePath, deviceDetails, errorText)) {
+ QMessageBox::critical(this, tr("XML Restore Error"),
+ tr("An error occurred while restoring the backup file.\n%1")
+ .arg(errorText)
+ );
+ } else {
+ reloadValues();
+ //getDeviceData();
+ //config->saveDeviceDetails(deviceDetails, &device_data);
+ QMessageBox::information(this, tr("Restore succeeded"),
+ tr("Your settings have been restored successfully.")
+ );
+ }
+ }
+}