aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-models/divelocationmodel.cpp6
-rw-r--r--qt-models/divelocationmodel.h4
-rw-r--r--qt-ui/locationinformation.cpp2
-rw-r--r--qt-ui/maintab.cpp15
-rw-r--r--qt-ui/maintab.h2
5 files changed, 25 insertions, 4 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index a5303da49..973452b16 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -1,6 +1,12 @@
#include "divelocationmodel.h"
#include "dive.h"
+LocationInformationModel *LocationInformationModel::instance()
+{
+ static LocationInformationModel *self = new LocationInformationModel();
+ return self;
+}
+
LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractListModel(obj), internalRowCount(0)
{
}
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index 1bf7cedfd..ee5f3c362 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -6,11 +6,13 @@
class LocationInformationModel : public QAbstractListModel {
Q_OBJECT
public:
- LocationInformationModel(QObject *obj = 0);
+ static LocationInformationModel *instance();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
+public slots:
void update();
private:
+ LocationInformationModel(QObject *obj = 0);
int internalRowCount;
};
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index 1ba7fd402..657a6f3f5 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -28,7 +28,7 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
ui.diveSiteMessage->setText(tr("Dive site management"));
ui.diveSiteMessage->addAction(closeAction);
- ui.currentLocation->setModel(new LocationInformationModel());
+ ui.currentLocation->setModel(LocationInformationModel::instance());
connect(ui.currentLocation, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentDiveSite(int)));
connect(this, SIGNAL(startFilterDiveSite(uint32_t)), MultiFilterSortModel::instance(), SLOT(startFilterDiveSite(uint32_t)));
connect(this, SIGNAL(stopFilterDiveSite()), MultiFilterSortModel::instance(), SLOT(stopFilterDiveSite()));
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();
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 23be96efa..466733b8b 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -97,7 +97,7 @@ slots:
void showLocation();
void enableGeoLookupEdition();
void disableGeoLookupEdition();
-
+ void setCurrentLocationIndex();
private:
Ui::MainTab ui;
WeightModel *weightModel;