summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-06 13:56:46 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-06 13:59:06 -0700
commit024420a60ddf7d18a6bd2ce4aad30344be0edbac (patch)
tree9aba239292353bc4a9ca16891a2c111ff258aa62 /qt-ui/maintab.cpp
parent20595ac0d7c9cb9c588162075b1704c1a9648a32 (diff)
downloadsubsurface-024420a60ddf7d18a6bd2ce4aad30344be0edbac.tar.gz
More multi-edit fixes
This time for values that aren't simply text. For normal integers this is rather straight forward. For the 'when' timestamp we simply assume that this is a shift in time. What is still missing is consistent handling of the three fields that are implemented as tags: tags, buddy and divemaster. We have special code for tags that makes no sense in a multi-edit scenario. And we treat divemaster and buddy as a single string - which kinda works but treats "Bill, Joe" and "Joe, Bill" as different. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index b5e2ea887..ec4065d85 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -864,6 +864,11 @@ void MainTab::rejectChanges()
mydive->what = strdup(textByteArray.data()); \
}
+#define EDIT_VALUE(what, value) \
+ if (mydive->what == current_dive->what) { \
+ mydive->what = value; \
+ }
+
#define EDIT_TRIP_TEXT(what, text) \
QByteArray textByteArray = text.toUtf8(); \
free(what); \
@@ -900,14 +905,14 @@ void MainTab::on_divemaster_textChanged()
void MainTab::on_airtemp_textChanged(const QString &text)
{
- EDIT_SELECTED_DIVES(mydive->airtemp.mkelvin = parseTemperatureToMkelvin(text));
+ EDIT_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin, parseTemperatureToMkelvin(text)));
markChangedWidget(ui.airtemp);
validate_temp_field(ui.airtemp, text);
}
void MainTab::on_watertemp_textChanged(const QString &text)
{
- EDIT_SELECTED_DIVES(mydive->watertemp.mkelvin = parseTemperatureToMkelvin(text));
+ EDIT_SELECTED_DIVES(EDIT_VALUE(watertemp.mkelvin, parseTemperatureToMkelvin(text)));
markChangedWidget(ui.watertemp);
validate_temp_field(ui.watertemp, text);
}
@@ -939,14 +944,18 @@ void MainTab::validate_temp_field(QLineEdit *tempField,const QString &text)
missing_precision = false;
}
}
+
+// changing the time stamp on multiple dives really needs to be a relative shift
void MainTab::on_dateTimeEdit_dateTimeChanged(const QDateTime &datetime)
{
QDateTime dateTimeUtc(datetime);
dateTimeUtc.setTimeSpec(Qt::UTC);
- EDIT_SELECTED_DIVES(mydive->when = dateTimeUtc.toTime_t());
+ time_t offset = current_dive->when - dateTimeUtc.toTime_t();
+ EDIT_SELECTED_DIVES(mydive->when -= offset);
markChangedWidget(ui.dateTimeEdit);
}
+// changing the tags on multiple dives is semantically strange - what's the right thing to do?
void MainTab::saveTags()
{
EDIT_SELECTED_DIVES(
@@ -1017,9 +1026,6 @@ void MainTab::on_notes_textChanged()
markChangedWidget(ui.notes);
}
-#undef EDIT_TEXT
-#undef EDIT_TRIP_TEXT
-
void MainTab::on_coordinates_textChanged(const QString &text)
{
bool gpsChanged = false;
@@ -1036,14 +1042,19 @@ void MainTab::on_coordinates_textChanged(const QString &text)
void MainTab::on_rating_valueChanged(int value)
{
- EDIT_SELECTED_DIVES(mydive->rating = value);
+ EDIT_SELECTED_DIVES(EDIT_VALUE(rating, value));
}
void MainTab::on_visibility_valueChanged(int value)
{
- EDIT_SELECTED_DIVES(mydive->visibility = value);
+ EDIT_SELECTED_DIVES(EDIT_VALUE(visibility, value));
}
+#undef EDIT_SELECTED_DIVES
+#undef EDIT_TEXT
+#undef EDIT_TRIP_TEXT
+#undef EDIT_VALUE
+
void MainTab::editCylinderWidget(const QModelIndex &index)
{
if (cylindersModel->changed && editMode == NONE) {