mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d6e61b74fc
commit
ac6a7ab24e
5 changed files with 25 additions and 4 deletions
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -97,7 +97,7 @@ slots:
|
|||
void showLocation();
|
||||
void enableGeoLookupEdition();
|
||||
void disableGeoLookupEdition();
|
||||
|
||||
void setCurrentLocationIndex();
|
||||
private:
|
||||
Ui::MainTab ui;
|
||||
WeightModel *weightModel;
|
||||
|
|
Loading…
Add table
Reference in a new issue