mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +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();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) 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:
|
||||
void update();
|
||||
private:
|
||||
|
|
|
@ -34,16 +34,16 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
|
|||
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);
|
||||
if (currentDs)
|
||||
setLocationId(currentDs->uuid);
|
||||
setCurrentDiveSiteByUuid(currentDs->uuid);
|
||||
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);
|
||||
if(!currentDs)
|
||||
|
|
|
@ -15,13 +15,13 @@ protected:
|
|||
public slots:
|
||||
void acceptChanges();
|
||||
void rejectChanges();
|
||||
void setLocationId(uint32_t uuid);
|
||||
void setCurrentDiveSiteByUuid(uint32_t uuid);
|
||||
void updateGpsCoordinates(void);
|
||||
void markChangedWidget(QWidget *w);
|
||||
void enableEdition();
|
||||
void resetState();
|
||||
void resetPallete();
|
||||
void setCurrentDiveSite(int dive_nr);
|
||||
void setCurrentDiveSiteByIndex(int dive_nr);
|
||||
void on_diveSiteCoordinates_textChanged(const QString& text);
|
||||
void on_diveSiteDescription_textChanged(const QString& text);
|
||||
void on_diveSiteName_textChanged(const QString& text);
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "divepicturemodel.h"
|
||||
#include "divecomputerextradatamodel.h"
|
||||
#include "divelocationmodel.h"
|
||||
#include "divesite.h"
|
||||
|
||||
#if defined(FBSUPPORT)
|
||||
#include "socialnetworks.h"
|
||||
#endif
|
||||
|
@ -55,7 +57,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
ui.extraData->setModel(extraDataModel);
|
||||
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);
|
||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
|
||||
|
@ -231,17 +233,19 @@ void MainTab::setCurrentLocationIndex()
|
|||
void MainTab::enableGeoLookupEdition()
|
||||
{
|
||||
ui.waitingSpinner->stop();
|
||||
ui.manageDiveSite->show();
|
||||
ui.addDiveSite->show();
|
||||
}
|
||||
|
||||
void MainTab::disableGeoLookupEdition()
|
||||
{
|
||||
ui.waitingSpinner->start();
|
||||
ui.manageDiveSite->hide();
|
||||
ui.addDiveSite->hide();
|
||||
}
|
||||
|
||||
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()
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>447</width>
|
||||
<height>766</height>
|
||||
<width>445</width>
|
||||
<height>760</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
|
@ -196,9 +196,13 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="manageDiveSite">
|
||||
<widget class="QToolButton" name="addDiveSite">
|
||||
<property name="text">
|
||||
<string>manage</string>
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../subsurface.qrc">
|
||||
<normaloff>:/plus</normaloff>:/plus</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -535,8 +539,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>447</width>
|
||||
<height>756</height>
|
||||
<width>445</width>
|
||||
<height>754</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="equipmentTabScrollAreaLayout">
|
||||
|
@ -630,8 +634,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>447</width>
|
||||
<height>756</height>
|
||||
<width>445</width>
|
||||
<height>754</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="diveInfoScrollAreaLayout">
|
||||
|
@ -971,8 +975,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>447</width>
|
||||
<height>756</height>
|
||||
<width>445</width>
|
||||
<height>754</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
|
|
|
@ -216,7 +216,7 @@ void MainWindow::on_actionManage_dive_sites_triggered() {
|
|||
}
|
||||
|
||||
void MainWindow::enableDiveSiteEdit(uint32_t id) {
|
||||
locationInformationWidget()->setLocationId(displayed_dive.dive_site_uuid);
|
||||
locationInformationWidget()->setCurrentDiveSiteByUuid(id);
|
||||
setApplicationState("EditDiveSite");
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ void MainWindow::cleanUpEmpty()
|
|||
information()->updateDiveInfo(true);
|
||||
graphics()->setEmptyState();
|
||||
dive_list()->reload(DiveTripModel::TREE);
|
||||
locationInformationWidget()->setLocationId(0);
|
||||
locationInformationWidget()->setCurrentDiveSiteByUuid(0);
|
||||
globe()->reload();
|
||||
if (!existing_filename)
|
||||
setTitle(MWTF_DEFAULT);
|
||||
|
@ -632,7 +632,7 @@ void MainWindow::setupForAddAndPlan(const char *model)
|
|||
// setup the dive cylinders
|
||||
DivePlannerPointsModel::instance()->clear();
|
||||
DivePlannerPointsModel::instance()->setupCylinders();
|
||||
locationInformationWidget()->setLocationId(0);
|
||||
locationInformationWidget()->setCurrentDiveSiteByUuid(0);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionReplanDive_triggered()
|
||||
|
|
Loading…
Reference in a new issue