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>
This commit is contained in:
Joseph W. Joshua 2014-06-11 09:37:27 +03:00 committed by Thiago Macieira
parent e54d7d9178
commit aad60ef6da
4 changed files with 115 additions and 13 deletions

View file

@ -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.")
);
}
}
}