From 627de38c01f6bcba56221ed3703bd08d1d215168 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 10 May 2015 12:44:35 -0300 Subject: Get the location information in a separate thread This makes Subsurface usable faster for those without a good internet connection when they are opening an older data file. While parsing, we are only feeding an vector of locations, after the parsing is done, we traverse the vector searching for the information on the web. I need to also add a way to stop if there`s no internet connection - but this will be another patch. Also, fixed two small memory leaks from the old imp. [Dirk Hohndel: cleaned up the whitespace mess] Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 970c0f739..f8ab75a75 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -32,6 +32,7 @@ #include "divelogimportdialog.h" #include "divelogexportdialog.h" #include "usersurvey.h" +#include "divesitehelpers.h" #ifndef NO_USERMANUAL #include "usermanual.h" #endif @@ -199,6 +200,10 @@ MainWindow::MainWindow() : QMainWindow(), undoRedoActions.append(undoAction); undoRedoActions.append(redoAction); ui.menu_Edit->addActions(undoRedoActions); + + ReverseGeoLoockupThread *geoLoockup = ReverseGeoLoockupThread::instance(); + connect(geoLoockup, SIGNAL(start()),information(), SLOT(setDisabled())); + connect(geoLoockup, SIGNAL(finished()), information(), SLOT(setEnabled())); } MainWindow::~MainWindow() @@ -1292,7 +1297,7 @@ int MainWindow::file_save_as(void) QString filename; const char *default_filename = existing_filename; QFileDialog selection_dialog(this, tr("Save file as"), default_filename, - tr("Subsurface XML files (*.ssrf *.xml *.XML)")); + tr("Subsurface XML files (*.ssrf *.xml *.XML)")); /* if the exit/cancel button is pressed return */ if (!selection_dialog.exec()) @@ -1448,6 +1453,10 @@ void MainWindow::loadFiles(const QStringList fileNames) addRecentFile(fileNames); removeRecentFile(failedParses); + // searches for geo lookup information in a thread so it doesn`t + // freezes the ui. + ReverseGeoLoockupThread::instance()->start(); + refreshDisplay(); ui.actionAutoGroup->setChecked(autogroup); } -- cgit v1.2.3-70-g09d2