diff options
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e8087c7cc..6bb6f14f8 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -771,10 +771,7 @@ void MainTab::acceptChanges() } if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) { fixup_dive(current_dive); - if (dive_table.nr == 1) - current_dive->number = 1; - else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number) - current_dive->number = get_dive(dive_table.nr - 2)->number + 1; + set_dive_nr_for_current_dive(); MainWindow::instance()->showProfile(); mark_divelist_changed(true); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING); @@ -1026,9 +1023,12 @@ void MainTab::on_location_textChanged(const QString &text) // If we have GPS data for the location entered, add it. void MainTab::on_location_editingFinished() { + // if we have a location and no GPS data, look up the GPS data; + // but if the GPS data was intentionally cleared then don't if (!currentTrip && !same_string(displayed_dive.location, "") && - ui.coordinates->text().trimmed().isEmpty()) { + ui.coordinates->text().trimmed().isEmpty() && + !(editMode == DIVE && dive_has_gps_location(current_dive))) { struct dive *dive; int i = 0; for_each_dive (i, dive) { @@ -1170,3 +1170,43 @@ void MainTab::removeSelectedPhotos() QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString(); DivePictureModel::instance()->removePicture(fileUrl); } + +#define SHOW_SELECTIVE(_component) \ + if (what._component) \ + ui._component->setText(displayed_dive._component); + +void MainTab::showAndTriggerEditSelective(struct dive_components what) +{ + // take the data in our copyPasteDive and apply it to selected dives + enableEdition(); + SHOW_SELECTIVE(location); + SHOW_SELECTIVE(buddy); + SHOW_SELECTIVE(divemaster); + SHOW_SELECTIVE(suit); + if (what.notes) { + QString tmp(displayed_dive.notes); + if (tmp.contains("<table")) + ui.notes->setHtml(tmp); + else + ui.notes->setPlainText(tmp); + } + if (what.rating) + ui.rating->setCurrentStars(displayed_dive.rating); + if (what.visibility) + ui.visibility->setCurrentStars(displayed_dive.visibility); + if (what.gps) + updateGpsCoordinates(&displayed_dive); + if (what.tags) { + char buf[1024]; + taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); + ui.tagWidget->setText(QString(buf)); + } + if (what.cylinders) { + cylindersModel->updateDive(); + cylindersModel->changed = true; + } + if (what.weights) { + weightModel->updateDive(); + weightModel->changed = true; + } +} |