summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-12-07 14:33:43 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-12-09 15:51:17 +0200
commitbe16ade0383813949e82491de5a26f42752c3e0f (patch)
tree94ffb8788db246ab0814b0ed6ed40f4dbccf9981 /qt-ui
parent3a49ad6ba5e8634e8653a60b5be3a75f2bc79959 (diff)
downloadsubsurface-be16ade0383813949e82491de5a26f42752c3e0f.tar.gz
Divelogs.de: allow import of downloaded dives
This patch adds commands to the dialog buttons, to apply (and possibly show an error if 'parse_file' fails', reject, or show help - which is a link to the 'divelogs.de' website. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/subsurfacewebservices.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 193f7c41b..08976e52c 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -1,7 +1,6 @@
#include "subsurfacewebservices.h"
#include "../webservice.h"
#include "mainwindow.h"
-
#include <libxml/parser.h>
#include <zip.h>
#include <errno.h>
@@ -663,22 +662,39 @@ void DivelogsDeWebServices::uploadError(QNetworkReply::NetworkError error)
void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
{
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
-
switch(ui.buttonBox->buttonRole(button)){
case QDialogButtonBox::ApplyRole:{
- char *errorptr = NULL;
- parse_file(zipFile.fileName().toUtf8().constData(), &errorptr);
+ /* parse file and import dives */
+ char *error = NULL;
+ parse_file(zipFile.fileName().toLocal8Bit().data(), &error);
+ if (error != NULL) {
+ mainWindow()->showError(error);
+ free(error);
+ }
process_dives(TRUE, FALSE);
- // ### FIXME: do something useful with the error - but there shouldn't be one, right?
- if (errorptr)
- qDebug() << errorptr;
+ mainWindow()->refreshDisplay();
+ /* store last entered user/pass in config */
+ QSettings s;
+ s.setValue("divelogde_user", ui.userID->text());
+ s.setValue("divelogde_pass", ui.password->text());
+ s.sync();
hide();
close();
resetState();
- mark_divelist_changed(TRUE);
- mainWindow()->refreshDisplay();
}
+ break;
+ case QDialogButtonBox::RejectRole:
+ // these two seem to be causing a crash:
+ // reply->deleteLater();
+ // reply = NULL;
+ resetState();
+ break;
+ case QDialogButtonBox::HelpRole:
+ QDesktopServices::openUrl(QUrl("http://divelogs.de"));
+ break;
+ default:
+ break;
}
}