From 5eb2cc4594ab2181ccc3b09a2540af3fb615468e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 22:30:21 -0200 Subject: Created a 'WebService' dialog that will handle download and upload. Created a WebService dialog that will handle download and upload from all child based webservices. Also, ported the currently - only - one webservice to use the new dialog. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.cpp | 2 +- qt-ui/subsurfacewebservices.cpp | 33 +++++++---- qt-ui/subsurfacewebservices.h | 32 +++++++--- qt-ui/subsurfacewebservices.ui | 106 --------------------------------- qt-ui/webservices.ui | 127 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 174 insertions(+), 126 deletions(-) delete mode 100644 qt-ui/subsurfacewebservices.ui create mode 100644 qt-ui/webservices.ui (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 69cf363c3..bb21e6625 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -252,7 +252,7 @@ void MainWindow::on_actionDownloadDC_triggered() void MainWindow::on_actionDownloadWeb_triggered() { - SubsurfaceWebServices::instance()->runDialog(); + SubsurfaceWebServices::instance()->exec(); } void MainWindow::on_actionEditDeviceNames_triggered() diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index f2b1b88cc..d9da69287 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -15,6 +15,26 @@ struct dive_table gps_location_table; static bool merge_locations_into_dives(void); +WebServices::WebServices(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f) +{ + ui.setupUi(this); + connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); + connect(ui.download, SIGNAL(clicked(bool)), this, SLOT(startDownload())); + ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + +} + +void WebServices::hidePassword() +{ + ui.password->hide(); + ui.passLabel->hide(); +} + +void WebServices::hideUpload() +{ + ui.upload->hide(); +} + SubsurfaceWebServices* SubsurfaceWebServices::instance() { static SubsurfaceWebServices *self = new SubsurfaceWebServices(); @@ -24,12 +44,10 @@ SubsurfaceWebServices* SubsurfaceWebServices::instance() SubsurfaceWebServices::SubsurfaceWebServices(QWidget* parent, Qt::WindowFlags f) { - ui.setupUi(this); - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); - connect(ui.download, SIGNAL(clicked(bool)), this, SLOT(startDownload())); - ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); QSettings s; ui.userID->setText(s.value("webservice_uid").toString()); + hidePassword(); + hideUpload(); } static void clear_table(struct dive_table *table) @@ -56,7 +74,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button) /* store last entered uid in config */ QSettings s; - s.setValue("webservice_uid", ui.userID->text()); + s.setValue("subsurface_webservice_uid", ui.userID->text()); s.sync(); hide(); close(); @@ -135,11 +153,6 @@ void SubsurfaceWebServices::setStatusText(int status) ui.status->setText(text); } -void SubsurfaceWebServices::runDialog() -{ - exec(); -} - /* requires that there is a or tag under the tag */ void SubsurfaceWebServices::download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status) { diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 0719a8f15..19c3f56c7 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -5,16 +5,35 @@ #include #include -#include "ui_subsurfacewebservices.h" +#include "ui_webservices.h" class QAbstractButton; class QNetworkReply; -class SubsurfaceWebServices : public QDialog { +class WebServices : public QDialog{ + Q_OBJECT +public: + explicit WebServices(QWidget* parent = 0, Qt::WindowFlags f = 0); + void hidePassword(); + void hideUpload(); + +private slots: + virtual void startDownload() = 0; + virtual void buttonClicked(QAbstractButton* button) = 0; + virtual void downloadFinished() = 0; + virtual void downloadError(QNetworkReply::NetworkError error) = 0; + +protected: + Ui::WebServices ui; + QNetworkReply *reply; + QNetworkAccessManager *manager; + QByteArray downloadedData; +}; + +class SubsurfaceWebServices : public WebServices { Q_OBJECT public: static SubsurfaceWebServices* instance(); - void runDialog(); private slots: void startDownload(); @@ -23,15 +42,10 @@ private slots: void downloadError(QNetworkReply::NetworkError error); private: + explicit SubsurfaceWebServices(QWidget* parent = 0, Qt::WindowFlags f = 0); void setStatusText(int status); void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status); unsigned int download_dialog_parse_response(const QByteArray& length); - - explicit SubsurfaceWebServices(QWidget* parent = 0, Qt::WindowFlags f = 0); - Ui::SubsurfaceWebServices ui; - QNetworkReply *reply; - QNetworkAccessManager *manager; - QByteArray downloadedData; }; #endif diff --git a/qt-ui/subsurfacewebservices.ui b/qt-ui/subsurfacewebservices.ui deleted file mode 100644 index 899eea909..000000000 --- a/qt-ui/subsurfacewebservices.ui +++ /dev/null @@ -1,106 +0,0 @@ - - - SubsurfaceWebServices - - - - 0 - 0 - 399 - 104 - - - - Download Location Data - - - - - - 0 - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help - - - - - - - Download - - - - - - - Enter your ID here - - - - - - - User ID - - - - - - - Status: - - - - - - - - - - - - - - - - buttonBox - accepted() - SubsurfaceWebServices - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - SubsurfaceWebServices - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/qt-ui/webservices.ui b/qt-ui/webservices.ui new file mode 100644 index 000000000..b190a7980 --- /dev/null +++ b/qt-ui/webservices.ui @@ -0,0 +1,127 @@ + + + WebServices + + + + 0 + 0 + 425 + 141 + + + + Download Location Data + + + + + + Status: + + + + + + + Enter your ID here + + + + + + + Download + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help + + + + + + + 0 + + + + + + + User ID + + + + + + + + + + + + + + Password + + + + + + + QLineEdit::Password + + + + + + + Upload + + + + + + + + + buttonBox + accepted() + WebServices + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + WebServices + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- cgit v1.2.3-70-g09d2 From d2b87e0eb5f5d5e85a9e65c4370f3c6fe42c9357 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 22:38:41 -0200 Subject: Fixed a crash when the user canceled the download from webservice dialog. Null references, ah, love them. Signed-off-by: Tomaz Canabrava --- qt-ui/subsurfacewebservices.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'qt-ui') diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index d9da69287..344815c21 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -16,6 +16,7 @@ struct dive_table gps_location_table; static bool merge_locations_into_dives(void); WebServices::WebServices(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f) +, reply(0) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); -- cgit v1.2.3-70-g09d2 From 06ba04ab785e142ead9f95b3335e0d6237f03ad1 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 22:39:21 -0200 Subject: fix the string of the subsurfice webservice on the settings. The setting was 'webservice', but this is too wide, since we are supporting more than one. changed it to 'subsurface_webservice_uid' Signed-off-by: Tomaz Canabrava --- qt-ui/subsurfacewebservices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 344815c21..7475ff1c7 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -46,7 +46,7 @@ SubsurfaceWebServices* SubsurfaceWebServices::instance() SubsurfaceWebServices::SubsurfaceWebServices(QWidget* parent, Qt::WindowFlags f) { QSettings s; - ui.userID->setText(s.value("webservice_uid").toString()); + ui.userID->setText(s.value("subsurface_webservice_uid").toString()); hidePassword(); hideUpload(); } -- cgit v1.2.3-70-g09d2 From 216f9212b953aecddea1cfbce6a10740d3db2cd4 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 22:52:11 -0200 Subject: Added the skeleton for the Download / Upload from Divelogs.de Added the skeleton code for the Download / Upload from Divelogs. de webservice. Now I need to hoopup things from the .ui side and do the actual implementation of the code. Signed-off-by: Tomaz Canabrava --- qt-ui/subsurfacewebservices.cpp | 52 +++++++++++++++++++++++++++++++++++++++++ qt-ui/subsurfacewebservices.h | 25 ++++++++++++++++---- 2 files changed, 73 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 7475ff1c7..edca1ee74 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -36,6 +36,12 @@ void WebServices::hideUpload() ui.upload->hide(); } +// # +// # +// # Subsurface Web Service Implementation. +// # +// # + SubsurfaceWebServices* SubsurfaceWebServices::instance() { static SubsurfaceWebServices *self = new SubsurfaceWebServices(); @@ -254,3 +260,49 @@ static bool merge_locations_into_dives(void) } return changed > 0; } + +// # +// # +// # Divelogs DE Web Service Implementation. +// # +// # + +DivelogsDeWebServices* DivelogsDeWebServices::instance() +{ + +} + +DivelogsDeWebServices::DivelogsDeWebServices(QWidget* parent, Qt::WindowFlags f): WebServices(parent, f) +{ + +} + +void DivelogsDeWebServices::startUpload() +{ + +} + +void DivelogsDeWebServices::startDownload() +{ + +} + +void DivelogsDeWebServices::downloadFinished() +{ + +} + +void DivelogsDeWebServices::setStatusText(int status) +{ + +} + +void DivelogsDeWebServices::downloadError(QNetworkReply::NetworkError error) +{ + +} + +void DivelogsDeWebServices::buttonClicked(QAbstractButton* button) +{ + +} diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 19c3f56c7..515e3fe9c 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -19,9 +19,8 @@ public: private slots: virtual void startDownload() = 0; + virtual void startUpload() = 0; virtual void buttonClicked(QAbstractButton* button) = 0; - virtual void downloadFinished() = 0; - virtual void downloadError(QNetworkReply::NetworkError error) = 0; protected: Ui::WebServices ui; @@ -34,13 +33,13 @@ class SubsurfaceWebServices : public WebServices { Q_OBJECT public: static SubsurfaceWebServices* instance(); - + private slots: void startDownload(); void buttonClicked(QAbstractButton* button); void downloadFinished(); void downloadError(QNetworkReply::NetworkError error); - + void startUpload(){} /*no op*/ private: explicit SubsurfaceWebServices(QWidget* parent = 0, Qt::WindowFlags f = 0); void setStatusText(int status); @@ -48,4 +47,22 @@ private: unsigned int download_dialog_parse_response(const QByteArray& length); }; +class DivelogsDeWebServices : public WebServices { + Q_OBJECT +public: + static DivelogsDeWebServices * instance(); + +private slots: + void startDownload(); + void buttonClicked(QAbstractButton* button); + void downloadFinished(); + void downloadError(QNetworkReply::NetworkError error); + void startUpload(); +private: + explicit DivelogsDeWebServices (QWidget* parent = 0, Qt::WindowFlags f = 0); + void setStatusText(int status); + void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status); + unsigned int download_dialog_parse_response(const QByteArray& length); +}; + #endif -- cgit v1.2.3-70-g09d2 From 6cf875ed92d1d526fa91f3712109a19bd754c6d2 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 22:57:43 -0200 Subject: Reorganized the downlads menu for the inclusion of more webservices. This patch moves around a few items on the menu to a new submenu downloads/uploads. I think it's not the best way, but it already fives a bit more of 'unverbosity', because the old menu had 'Download from Dive Computer', 'Download from Webservices', and now we would introduce a new 'Download from Divelogs.de' I tougth it was better to have a 'parent' named 'Download' and put all children inside. this can grow quite big as soon as I implement the plugin system for that. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.ui | 78 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 10 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index ffe55c1f9..2ea6df354 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -18,7 +18,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -39,7 +48,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -52,7 +70,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -70,7 +97,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -83,7 +119,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -169,7 +214,7 @@ 0 0 763 - 32 + 18 @@ -196,8 +241,15 @@ Log - - + + + Downloads/Uploads + + + + + + @@ -206,6 +258,7 @@ + @@ -317,7 +370,7 @@ - Download from Dive computer + Dive computer Ctrl+D @@ -325,7 +378,7 @@ - Download from Web Service + Subsurface Service @@ -453,6 +506,11 @@ Import CSV + + + Divelogs.de + + -- cgit v1.2.3-70-g09d2 From 7bea2e1be062cd6ac4aa79f62bcd5cd42aa44d4a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 23:02:59 -0200 Subject: Minimum hooking-up done, divelogs.de shows on menu-activation. This patch does the hooking up to show the dialog of the divelogs.de window when the user selects it on the menu.: Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.cpp | 5 +++++ qt-ui/mainwindow.h | 1 + qt-ui/subsurfacewebservices.cpp | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index bb21e6625..5a2f872b4 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -255,6 +255,11 @@ void MainWindow::on_actionDownloadWeb_triggered() SubsurfaceWebServices::instance()->exec(); } +void MainWindow::on_actionDivelogs_de_triggered() +{ + DivelogsDeWebServices::instance()->exec(); +} + void MainWindow::on_actionEditDeviceNames_triggered() { DiveComputerManagementDialog::instance()->init(); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 5dfae3e98..45f9fd37a 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -69,6 +69,7 @@ private slots: /* log menu actions */ void on_actionDownloadDC_triggered(); void on_actionDownloadWeb_triggered(); + void on_actionDivelogs_de_triggered(); void on_actionEditDeviceNames_triggered(); void on_actionAddDive_triggered(); void on_actionRenumber_triggered(); diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index edca1ee74..7ece0a640 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -269,7 +269,9 @@ static bool merge_locations_into_dives(void) DivelogsDeWebServices* DivelogsDeWebServices::instance() { - + static DivelogsDeWebServices *self = new DivelogsDeWebServices(); + self->setAttribute(Qt::WA_QuitOnClose, false); + return self; } DivelogsDeWebServices::DivelogsDeWebServices(QWidget* parent, Qt::WindowFlags f): WebServices(parent, f) -- cgit v1.2.3-70-g09d2 From a4da3004da2f5179e2e7cac46047eec39c7b6949 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 24 Oct 2013 23:04:34 -0200 Subject: code cleanup: removed unused function from mainwindow.h The setupSplitters method was created quite a while ago to deal with the splitters when I didn't used a more sane approach. I forgot to delete it back them, removing now. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.h | 1 - 1 file changed, 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 45f9fd37a..1c68fc4f7 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -121,7 +121,6 @@ private: void redrawProfile(); void file_save(); void file_save_as(); - void setupSplitters(); }; MainWindow *mainWindow(); -- cgit v1.2.3-70-g09d2