diff options
Diffstat (limited to 'qt-ui/configuredivecomputer.cpp')
-rw-r--r-- | qt-ui/configuredivecomputer.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index ad431eefe..0d602c8e8 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -1,6 +1,8 @@ #include "configuredivecomputer.h" #include "libdivecomputer/hw.h" #include <QDebug> +#include <QFile> + ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), readThread(0), @@ -42,6 +44,36 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat writeThread->start(); } +bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText) +{ + QString xml = ""; + QString vendor = data->vendor; + QString product = data->product; + xml += "<backup>"; + xml += "\n<divecomputer vendor='" + vendor + + "' model = '" + product + "'" + + " />"; + xml += "\n<settings>"; + xml += "\n<setting name='CustomText' value = '" + details->customText() + "' />"; + xml += "\n<setting name='Brightness' value = '" + QString::number(details->brightness()) + "' />"; + xml += "\n<setting name='Language' value = '" + QString::number(details->language()) + "' />"; + xml += "\n<setting name='DateFormat' value = '" + QString::number(details->dateFormat()) + "' />"; + xml += "\n</settings>"; + xml += "\n</backup>"; + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly)) { + errorText = tr("Could not save the backup file %1. Error Message: %2") + .arg(fileName, file.errorString()); + return false; + } + //file open successful. write data and save. + QTextStream out(&file); + out << xml; + + file.close(); + return true; +} + void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) { currentState = newState; |