diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-06 21:02:10 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-06 13:19:57 -0700 |
commit | c50e58d761c0c6e54219a3114a26bc033ddeee70 (patch) | |
tree | e5f03ddabada01985c98554fff4b7b28483a917e | |
parent | 9298466037dd7ac80e65407eac93bfe62705f1ac (diff) | |
download | subsurface-c50e58d761c0c6e54219a3114a26bc033ddeee70.tar.gz |
desktop: avoid spurious undo commands for date/time editing
The date and time fields of the main tab posted undo events
for every date/timeChanged signal. Thus, when changing the
day of the month to e.g. 21, this would result in two date
change events: one to the 2nd and one to the 21st. This is
very irritating.
Instead listen to editingFinished() events, which thankfully
exist for these widgets.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.h | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 7204cd7b0..d63f59692 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -607,23 +607,23 @@ static void shiftTime(QDateTime &dateTime) } } -void MainTab::on_dateEdit_dateChanged(const QDate &date) +void MainTab::on_dateEdit_editingFinished() { if (ignoreInput || !current_dive) return; QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC); dateTime.setTimeSpec(Qt::UTC); - dateTime.setDate(date); + dateTime.setDate(ui.dateEdit->date()); shiftTime(dateTime); } -void MainTab::on_timeEdit_timeChanged(const QTime &time) +void MainTab::on_timeEdit_editingFinished() { if (ignoreInput || !current_dive) return; QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(1000*current_dive->when, Qt::UTC); dateTime.setTimeSpec(Qt::UTC); - dateTime.setTime(time); + dateTime.setTime(ui.timeEdit->time()); shiftTime(dateTime); } diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index 49003be4e..9e4290371 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -57,8 +57,8 @@ slots: void on_notes_editingFinished(); void on_duration_editingFinished(); void on_depth_editingFinished(); - void on_dateEdit_dateChanged(const QDate &date); - void on_timeEdit_timeChanged(const QTime & time); + void on_dateEdit_editingFinished(); + void on_timeEdit_editingFinished(); void on_rating_valueChanged(int value); void on_tagWidget_editingFinished(); void hideMessage(); |