mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:43:25 +00:00
Allow editing of dive sites
And hook things up when double clicking the globe. The user experience isn't consistent with what we do on the main tab (i.e., no coloring of fields that are changed), but it seems to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
06e578424e
commit
32ad046f56
6 changed files with 44 additions and 13 deletions
1
dive.c
1
dive.c
|
@ -13,6 +13,7 @@
|
||||||
* it's used in the UI, but it seems to make the most sense to have it
|
* it's used in the UI, but it seems to make the most sense to have it
|
||||||
* here */
|
* here */
|
||||||
struct dive displayed_dive;
|
struct dive displayed_dive;
|
||||||
|
struct dive_site displayed_dive_site;
|
||||||
|
|
||||||
struct tag_entry *g_tag_list = NULL;
|
struct tag_entry *g_tag_list = NULL;
|
||||||
|
|
||||||
|
|
1
dive.h
1
dive.h
|
@ -474,6 +474,7 @@ struct dive_table {
|
||||||
|
|
||||||
extern struct dive_table dive_table;
|
extern struct dive_table dive_table;
|
||||||
extern struct dive displayed_dive;
|
extern struct dive displayed_dive;
|
||||||
|
extern struct dive_site displayed_dive_site;
|
||||||
extern int selected_dive;
|
extern int selected_dive;
|
||||||
extern unsigned int dc_number;
|
extern unsigned int dc_number;
|
||||||
#define current_dive (get_dive(selected_dive))
|
#define current_dive (get_dive(selected_dive))
|
||||||
|
|
|
@ -206,7 +206,10 @@ void GlobeGPS::repopulateLabels()
|
||||||
// don't show that flag, it's either already shown as displayed_dive
|
// don't show that flag, it's either already shown as displayed_dive
|
||||||
// or it's the one that we are moving right now...
|
// or it's the one that we are moving right now...
|
||||||
continue;
|
continue;
|
||||||
ds = get_dive_site_for_dive(dive);
|
if (idx == -1)
|
||||||
|
ds = &displayed_dive_site;
|
||||||
|
else
|
||||||
|
ds = get_dive_site_for_dive(dive);
|
||||||
if (dive_site_has_gps_location(ds)) {
|
if (dive_site_has_gps_location(ds)) {
|
||||||
GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
|
GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
|
||||||
place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
||||||
|
@ -329,9 +332,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
|
||||||
centerOn(lon, lat, true);
|
centerOn(lon, lat, true);
|
||||||
|
|
||||||
// change the location of the displayed_dive and put the UI in edit mode
|
// change the location of the displayed_dive and put the UI in edit mode
|
||||||
ds = get_dive_site_for_dive(&displayed_dive);
|
displayed_dive_site.latitude.udeg = lrint(lat * 1000000.0);
|
||||||
ds->latitude.udeg = lrint(lat * 1000000.0);
|
displayed_dive_site.longitude.udeg = lrint(lon * 1000000.0);
|
||||||
ds->longitude.udeg = lrint(lon * 1000000.0);
|
|
||||||
emit(coordinatesChanged());
|
emit(coordinatesChanged());
|
||||||
repopulateLabels();
|
repopulateLabels();
|
||||||
editingDiveLocation = false;
|
editingDiveLocation = false;
|
||||||
|
|
|
@ -113,6 +113,8 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
|
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
|
||||||
connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t)));
|
connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t)));
|
||||||
connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState()));
|
connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState()));
|
||||||
|
connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(refreshDisplay()));
|
||||||
|
|
||||||
#ifdef NO_PRINTING
|
#ifdef NO_PRINTING
|
||||||
ui.printPlan->hide();
|
ui.printPlan->hide();
|
||||||
ui.menuFile->removeAction(ui.actionPrint);
|
ui.menuFile->removeAction(ui.actionPrint);
|
||||||
|
@ -133,10 +135,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
#ifdef NO_MARBLE
|
#ifdef NO_MARBLE
|
||||||
ui.menuView->removeAction(ui.actionViewGlobe);
|
ui.menuView->removeAction(ui.actionViewGlobe);
|
||||||
#else
|
#else
|
||||||
// FIXME
|
connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates()));
|
||||||
// TODO
|
|
||||||
// we need this on the dive sites
|
|
||||||
//connect(globe(), SIGNAL(coordinatesChanged()), information(), SLOT(updateGpsCoordinates()));
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_USERMANUAL
|
#ifdef NO_USERMANUAL
|
||||||
ui.menuHelp->removeAction(ui.actionUserManual);
|
ui.menuHelp->removeAction(ui.actionUserManual);
|
||||||
|
@ -218,7 +217,6 @@ LocationInformationWidget *MainWindow::locationInformationWidget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::enableDiveSiteEdit(uint32_t id) {
|
void MainWindow::enableDiveSiteEdit(uint32_t id) {
|
||||||
locationInformationWidget()->setLocationId(id);
|
|
||||||
setApplicationState("EditDiveSite");
|
setApplicationState("EditDiveSite");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +274,7 @@ void MainWindow::current_dive_changed(int divenr)
|
||||||
}
|
}
|
||||||
graphics()->plotDive();
|
graphics()->plotDive();
|
||||||
information()->updateDiveInfo();
|
information()->updateDiveInfo();
|
||||||
|
locationInformationWidget()->setLocationId(displayed_dive.dive_site_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
|
|
|
@ -666,19 +666,46 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
|
||||||
void LocationInformationWidget::setLocationId(uint32_t uuid)
|
void LocationInformationWidget::setLocationId(uint32_t uuid)
|
||||||
{
|
{
|
||||||
currentDs = get_dive_site_by_uuid(uuid);
|
currentDs = get_dive_site_by_uuid(uuid);
|
||||||
ui.diveSiteName->setText(currentDs->name);
|
displayed_dive_site = *currentDs;
|
||||||
ui.diveSiteDescription->setText(currentDs->description);
|
ui.diveSiteName->setText(displayed_dive_site.name);
|
||||||
ui.diveSiteNotes->setPlainText(currentDs->notes);
|
ui.diveSiteDescription->setText(displayed_dive_site.description);
|
||||||
ui.diveSiteCoordinates->setText(printGPSCoords(currentDs->latitude.udeg, currentDs->longitude.udeg));
|
ui.diveSiteNotes->setPlainText(displayed_dive_site.notes);
|
||||||
|
ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocationInformationWidget::updateGpsCoordinates()
|
||||||
|
{
|
||||||
|
ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
|
||||||
|
MainWindow::instance()->setApplicationState("EditDiveSite");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationInformationWidget::acceptChanges()
|
void LocationInformationWidget::acceptChanges()
|
||||||
{
|
{
|
||||||
|
char *uiString;
|
||||||
|
currentDs->latitude = displayed_dive_site.latitude;
|
||||||
|
currentDs->longitude = displayed_dive_site.longitude;
|
||||||
|
uiString = ui.diveSiteName->text().toUtf8().data();
|
||||||
|
if (!same_string(uiString, currentDs->name)) {
|
||||||
|
free(currentDs->name);
|
||||||
|
currentDs->name = copy_string(uiString);
|
||||||
|
}
|
||||||
|
uiString = ui.diveSiteDescription->text().toUtf8().data();
|
||||||
|
if (!same_string(uiString, currentDs->description)) {
|
||||||
|
free(currentDs->description);
|
||||||
|
currentDs->description = copy_string(uiString);
|
||||||
|
}
|
||||||
|
uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data();
|
||||||
|
if (!same_string(uiString, currentDs->notes)) {
|
||||||
|
free(currentDs->notes);
|
||||||
|
currentDs->notes = copy_string(uiString);
|
||||||
|
}
|
||||||
|
mark_divelist_changed(true);
|
||||||
emit informationManagementEnded();
|
emit informationManagementEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationInformationWidget::rejectChanges()
|
void LocationInformationWidget::rejectChanges()
|
||||||
{
|
{
|
||||||
|
setLocationId(currentDs->uuid);
|
||||||
emit informationManagementEnded();
|
emit informationManagementEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,7 @@ public slots:
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
void setLocationId(uint32_t uuid);
|
void setLocationId(uint32_t uuid);
|
||||||
|
void updateGpsCoordinates(void);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void informationManagementEnded();
|
void informationManagementEnded();
|
||||||
|
|
Loading…
Add table
Reference in a new issue