mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Create a new DiveSite when user clicks on add
Also reorganized a bit of the code, and renamed a few misleading methods. [Dirk Hohndel: remove some C++11 code] Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
82d3f088a4
commit
b8092c07a4
7 changed files with 44 additions and 23 deletions
|
@ -49,3 +49,14 @@ void LocationInformationModel::update()
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int lat)
|
||||||
|
{
|
||||||
|
degrees_t latitude, longitude;
|
||||||
|
latitude.udeg = lat;
|
||||||
|
longitude.udeg = lon;
|
||||||
|
|
||||||
|
int32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude);
|
||||||
|
update();
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ public:
|
||||||
static LocationInformationModel *instance();
|
static LocationInformationModel *instance();
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
|
||||||
|
int32_t addDiveSite(const QString& name, int lat = 0, int lon = 0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void update();
|
void update();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -34,16 +34,16 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
|
||||||
connect(this, SIGNAL(stopFilterDiveSite()), MultiFilterSortModel::instance(), SLOT(stopFilterDiveSite()));
|
connect(this, SIGNAL(stopFilterDiveSite()), MultiFilterSortModel::instance(), SLOT(stopFilterDiveSite()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationInformationWidget::setCurrentDiveSite(int dive_nr)
|
void LocationInformationWidget::setCurrentDiveSiteByIndex(int dive_nr)
|
||||||
{
|
{
|
||||||
currentDs = get_dive_site(dive_nr);
|
currentDs = get_dive_site(dive_nr);
|
||||||
if (currentDs)
|
if (currentDs)
|
||||||
setLocationId(currentDs->uuid);
|
setCurrentDiveSiteByUuid(currentDs->uuid);
|
||||||
else
|
else
|
||||||
setLocationId(displayed_dive.dive_site_uuid);
|
setCurrentDiveSiteByUuid(displayed_dive.dive_site_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationInformationWidget::setLocationId(uint32_t uuid)
|
void LocationInformationWidget::setCurrentDiveSiteByUuid(uint32_t uuid)
|
||||||
{
|
{
|
||||||
currentDs = get_dive_site_by_uuid(uuid);
|
currentDs = get_dive_site_by_uuid(uuid);
|
||||||
if(!currentDs)
|
if(!currentDs)
|
||||||
|
|
|
@ -15,13 +15,13 @@ protected:
|
||||||
public slots:
|
public slots:
|
||||||
void acceptChanges();
|
void acceptChanges();
|
||||||
void rejectChanges();
|
void rejectChanges();
|
||||||
void setLocationId(uint32_t uuid);
|
void setCurrentDiveSiteByUuid(uint32_t uuid);
|
||||||
void updateGpsCoordinates(void);
|
void updateGpsCoordinates(void);
|
||||||
void markChangedWidget(QWidget *w);
|
void markChangedWidget(QWidget *w);
|
||||||
void enableEdition();
|
void enableEdition();
|
||||||
void resetState();
|
void resetState();
|
||||||
void resetPallete();
|
void resetPallete();
|
||||||
void setCurrentDiveSite(int dive_nr);
|
void setCurrentDiveSiteByIndex(int dive_nr);
|
||||||
void on_diveSiteCoordinates_textChanged(const QString& text);
|
void on_diveSiteCoordinates_textChanged(const QString& text);
|
||||||
void on_diveSiteDescription_textChanged(const QString& text);
|
void on_diveSiteDescription_textChanged(const QString& text);
|
||||||
void on_diveSiteName_textChanged(const QString& text);
|
void on_diveSiteName_textChanged(const QString& text);
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "divepicturemodel.h"
|
#include "divepicturemodel.h"
|
||||||
#include "divecomputerextradatamodel.h"
|
#include "divecomputerextradatamodel.h"
|
||||||
#include "divelocationmodel.h"
|
#include "divelocationmodel.h"
|
||||||
|
#include "divesite.h"
|
||||||
|
|
||||||
#if defined(FBSUPPORT)
|
#if defined(FBSUPPORT)
|
||||||
#include "socialnetworks.h"
|
#include "socialnetworks.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,7 +57,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
ui.extraData->setModel(extraDataModel);
|
ui.extraData->setModel(extraDataModel);
|
||||||
closeMessage();
|
closeMessage();
|
||||||
|
|
||||||
connect(ui.manageDiveSite, SIGNAL(clicked()), this, SLOT(prepareDiveSiteEdit()));
|
connect(ui.addDiveSite, SIGNAL(clicked()), this, SLOT(prepareDiveSiteEdit()));
|
||||||
|
|
||||||
QAction *action = new QAction(tr("Apply changes"), this);
|
QAction *action = new QAction(tr("Apply changes"), this);
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
|
||||||
|
@ -231,17 +233,19 @@ void MainTab::setCurrentLocationIndex()
|
||||||
void MainTab::enableGeoLookupEdition()
|
void MainTab::enableGeoLookupEdition()
|
||||||
{
|
{
|
||||||
ui.waitingSpinner->stop();
|
ui.waitingSpinner->stop();
|
||||||
ui.manageDiveSite->show();
|
ui.addDiveSite->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::disableGeoLookupEdition()
|
void MainTab::disableGeoLookupEdition()
|
||||||
{
|
{
|
||||||
ui.waitingSpinner->start();
|
ui.waitingSpinner->start();
|
||||||
ui.manageDiveSite->hide();
|
ui.addDiveSite->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::prepareDiveSiteEdit() {
|
void MainTab::prepareDiveSiteEdit() {
|
||||||
emit requestDiveSiteEdit(displayed_dive.dive_site_uuid);
|
uint32_t dive_site_uuid = LocationInformationModel::instance()->addDiveSite(tr("Unnamed"));
|
||||||
|
displayed_dive.dive_site_uuid = dive_site_uuid;
|
||||||
|
emit requestDiveSiteEdit(dive_site_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::toggleTriggeredColumn()
|
void MainTab::toggleTriggeredColumn()
|
||||||
|
|
|
@ -55,8 +55,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>447</width>
|
<width>445</width>
|
||||||
<height>766</height>
|
<height>760</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
@ -196,9 +196,13 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="manageDiveSite">
|
<widget class="QToolButton" name="addDiveSite">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>manage</string>
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../subsurface.qrc">
|
||||||
|
<normaloff>:/plus</normaloff>:/plus</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -535,8 +539,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>447</width>
|
<width>445</width>
|
||||||
<height>756</height>
|
<height>754</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="equipmentTabScrollAreaLayout">
|
<layout class="QGridLayout" name="equipmentTabScrollAreaLayout">
|
||||||
|
@ -630,8 +634,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>447</width>
|
<width>445</width>
|
||||||
<height>756</height>
|
<height>754</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="diveInfoScrollAreaLayout">
|
<layout class="QGridLayout" name="diveInfoScrollAreaLayout">
|
||||||
|
@ -971,8 +975,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>447</width>
|
<width>445</width>
|
||||||
<height>756</height>
|
<height>754</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
|
|
@ -216,7 +216,7 @@ void MainWindow::on_actionManage_dive_sites_triggered() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::enableDiveSiteEdit(uint32_t id) {
|
void MainWindow::enableDiveSiteEdit(uint32_t id) {
|
||||||
locationInformationWidget()->setLocationId(displayed_dive.dive_site_uuid);
|
locationInformationWidget()->setCurrentDiveSiteByUuid(id);
|
||||||
setApplicationState("EditDiveSite");
|
setApplicationState("EditDiveSite");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ void MainWindow::cleanUpEmpty()
|
||||||
information()->updateDiveInfo(true);
|
information()->updateDiveInfo(true);
|
||||||
graphics()->setEmptyState();
|
graphics()->setEmptyState();
|
||||||
dive_list()->reload(DiveTripModel::TREE);
|
dive_list()->reload(DiveTripModel::TREE);
|
||||||
locationInformationWidget()->setLocationId(0);
|
locationInformationWidget()->setCurrentDiveSiteByUuid(0);
|
||||||
globe()->reload();
|
globe()->reload();
|
||||||
if (!existing_filename)
|
if (!existing_filename)
|
||||||
setTitle(MWTF_DEFAULT);
|
setTitle(MWTF_DEFAULT);
|
||||||
|
@ -632,7 +632,7 @@ void MainWindow::setupForAddAndPlan(const char *model)
|
||||||
// setup the dive cylinders
|
// setup the dive cylinders
|
||||||
DivePlannerPointsModel::instance()->clear();
|
DivePlannerPointsModel::instance()->clear();
|
||||||
DivePlannerPointsModel::instance()->setupCylinders();
|
DivePlannerPointsModel::instance()->setupCylinders();
|
||||||
locationInformationWidget()->setLocationId(0);
|
locationInformationWidget()->setCurrentDiveSiteByUuid(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionReplanDive_triggered()
|
void MainWindow::on_actionReplanDive_triggered()
|
||||||
|
|
Loading…
Add table
Reference in a new issue