summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-04-26 09:39:33 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-29 12:58:49 -0700
commit88fbcefd4fa0e4d699240d96f48f8e9ab97b5e87 (patch)
tree5eb14228b90571a3aeca906c5b1ac6851ad344da
parent9bb7bbef8490c360bc084802ea11d75004d08ee8 (diff)
downloadsubsurface-88fbcefd4fa0e4d699240d96f48f8e9ab97b5e87.tar.gz
Desktop: set dive fields only when not in trip mode
On the main-tab, when looking at a trip, the fields were filled out with dive-data and then either hidden or overwritten with trip data. Move the update of the fields into the corresponding if-branch that is only active if on dive-mode. This means removing the UPDATE_* macros, which updated or cleared dive-fields depending on whether a current dive was set. These operations are now performed explicitly in the corresponding if-branches. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp37
1 files changed, 15 insertions, 22 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 0e0398733..17ff289e8 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -361,18 +361,6 @@ void MainTab::nextInputField(QKeyEvent *event)
keyPressEvent(event);
}
-#define UPDATE_TEXT(field) \
- if (!current_dive || !current_dive->field) \
- ui.field->setText(QString()); \
- else \
- ui.field->setText(current_dive->field)
-
-#define UPDATE_TEMP(field) \
- if (!current_dive || current_dive->field.mkelvin == 0) \
- ui.field->setText(""); \
- else \
- ui.field->setText(get_temperature_string(current_dive->field, true))
-
bool MainTab::isEditing()
{
return editMode != NONE;
@@ -442,17 +430,7 @@ void MainTab::updateDiveInfo()
for (TabBase *widget: extraWidgets)
widget->updateData();
- UPDATE_TEXT(suit);
- UPDATE_TEXT(divemaster);
- UPDATE_TEXT(buddy);
- UPDATE_TEMP(airtemp);
- UPDATE_TEMP(watertemp);
-
if (current_dive) {
- updateNotes(current_dive);
- updateMode(current_dive);
- updateDiveSite(current_dive);
- updateDateTime(current_dive);
if (MainWindow::instance() && MainWindow::instance()->diveList->selectedTrips().count() == 1) {
// Remember the tab selected for last dive
if (lastSelectedDive)
@@ -555,6 +533,16 @@ void MainTab::updateDiveInfo()
ui.depthLabel->setVisible(isManual);
ui.duration->setVisible(isManual);
ui.durationLabel->setVisible(isManual);
+
+ updateNotes(current_dive);
+ updateMode(current_dive);
+ updateDiveSite(current_dive);
+ updateDateTime(current_dive);
+ ui.suit->setText(current_dive->suit);
+ ui.divemaster->setText(current_dive->divemaster);
+ ui.buddy->setText(current_dive->buddy);
+ ui.airtemp->setText(get_temperature_string(current_dive->airtemp, true));
+ ui.watertemp->setText(get_temperature_string(current_dive->watertemp, true));
}
ui.duration->setText(render_seconds_to_string(current_dive->duration.seconds));
ui.depth->setText(get_depth_string(current_dive->maxdepth, true));
@@ -581,6 +569,11 @@ void MainTab::updateDiveInfo()
ui.rating->setCurrentStars(0);
ui.visibility->setCurrentStars(0);
ui.location->clear();
+ ui.suit->clear();
+ ui.divemaster->clear();
+ ui.buddy->clear();
+ ui.airtemp->clear();
+ ui.watertemp->clear();
/* set date and time to minimums which triggers showing the special value text */
ui.dateEdit->setSpecialValueText(QString("-"));
ui.dateEdit->setMinimumDate(QDate(1, 1, 1));