From ac6a7ab24e087cc150a7eff0ff6e7e4f8c52ce9a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 29 May 2015 22:22:24 -0300 Subject: Update DiveLocationModel when thread finishes This patch updates the DiveLocationModel when the GeoLoockupInformationThread finishes, and also selects the correct index for the displayed dive. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'qt-ui/maintab.cpp') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e6cf8bc13..5b5c10115 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -20,7 +20,7 @@ #include "weightmodel.h" #include "divepicturemodel.h" #include "divecomputerextradatamodel.h" - +#include "divelocationmodel.h" #if defined(FBSUPPORT) #include "socialnetworks.h" #endif @@ -97,6 +97,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex))); connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex))); + ui.location->setModel(LocationInformationModel::instance()); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this)); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this)); ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); @@ -199,6 +200,12 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.waitingSpinner->setInnerRadius(5); ui.waitingSpinner->setRevolutionsPerSecond(1); + connect(ReverseGeoLookupThread::instance(), SIGNAL(finished()), + LocationInformationModel::instance(), SLOT(update())); + + connect(ReverseGeoLookupThread::instance(), &QThread::finished, + this, &MainTab::setCurrentLocationIndex); + acceptingEdit = false; } @@ -213,6 +220,12 @@ MainTab::~MainTab() } } +void MainTab::setCurrentLocationIndex() +{ + if (current_dive) + ui.location->setCurrentText(get_dive_site_by_uuid(current_dive->dive_site_uuid)->name); +} + void MainTab::enableGeoLookupEdition() { ui.waitingSpinner->stop(); -- cgit v1.2.3-70-g09d2