mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
3a49ad6ba5
commit
be16ade038
1 changed files with 25 additions and 9 deletions
|
@ -1,7 +1,6 @@
|
||||||
#include "subsurfacewebservices.h"
|
#include "subsurfacewebservices.h"
|
||||||
#include "../webservice.h"
|
#include "../webservice.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <zip.h>
|
#include <zip.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -663,22 +662,39 @@ void DivelogsDeWebServices::uploadError(QNetworkReply::NetworkError error)
|
||||||
void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
|
void DivelogsDeWebServices::buttonClicked(QAbstractButton* button)
|
||||||
{
|
{
|
||||||
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||||
|
|
||||||
switch(ui.buttonBox->buttonRole(button)){
|
switch(ui.buttonBox->buttonRole(button)){
|
||||||
case QDialogButtonBox::ApplyRole:{
|
case QDialogButtonBox::ApplyRole:{
|
||||||
char *errorptr = NULL;
|
/* parse file and import dives */
|
||||||
parse_file(zipFile.fileName().toUtf8().constData(), &errorptr);
|
char *error = NULL;
|
||||||
|
parse_file(zipFile.fileName().toLocal8Bit().data(), &error);
|
||||||
|
if (error != NULL) {
|
||||||
|
mainWindow()->showError(error);
|
||||||
|
free(error);
|
||||||
|
}
|
||||||
process_dives(TRUE, FALSE);
|
process_dives(TRUE, FALSE);
|
||||||
// ### FIXME: do something useful with the error - but there shouldn't be one, right?
|
mainWindow()->refreshDisplay();
|
||||||
if (errorptr)
|
|
||||||
qDebug() << errorptr;
|
|
||||||
|
|
||||||
|
/* 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();
|
hide();
|
||||||
close();
|
close();
|
||||||
resetState();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue