From 7d0cc6b337f242be2d15744465cc6adec5937193 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 18 Nov 2013 10:00:39 -0800 Subject: Improve shift time functionality In commit 85fab31c71fc ("Shift times of selected dives") we added a dialog that didn't align its content very well. This change improves the layout (I hope) and makes the labels in the layout clearer (earlier and later seem easier to correlate with the direction of the shift). The original commit also forgets to deal with the consequences of shifting the dives. The dive list needs to be re-sorted (as the relative order of dives could have changed) and be marked as changed. And we should try to maintain the selection across these operations. Signed-off-by: Dirk Hohndel --- qt-ui/shifttimes.ui | 25 ++++++++++++------------- qt-ui/simplewidgets.cpp | 12 +++++++++--- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/qt-ui/shifttimes.ui b/qt-ui/shifttimes.ui index 39b3250a1..b3c8c958f 100644 --- a/qt-ui/shifttimes.ui +++ b/qt-ui/shifttimes.ui @@ -6,8 +6,8 @@ 0 0 - 229 - 134 + 343 + 226 @@ -18,7 +18,7 @@ 0 - 0 + 14 0 @@ -35,11 +35,14 @@ Shift times of selected dives by + + 0 + 0 - 0 + 23 0 @@ -73,29 +76,25 @@ 1 + + h:mm + Qt::LocalTime - - - - backwards + earlier - forward + later true diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index bbe7b1b37..692cda1a1 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -134,9 +134,15 @@ void ShiftTimesDialog::buttonClicked(QAbstractButton* button) amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60; if (ui.backwards->isChecked()) amount *= -1; - - shift_times(amount); - mainWindow()->refreshDisplay(); + if (amount != 0) { + // DANGER, DANGER - this could get our dive_table unsorted... + shift_times(amount); + sort_table(&dive_table); + mark_divelist_changed(TRUE); + mainWindow()->dive_list()->rememberSelection(); + mainWindow()->refreshDisplay(); + mainWindow()->dive_list()->restoreSelection(); + } } } -- cgit v1.2.3-70-g09d2