diff options
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r-- | qt-ui/simplewidgets.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 2ec984b7a..be3add815 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -18,6 +18,7 @@ #include "../dive.h" #include "../file.h" #include "mainwindow.h" +#include "helpers.h" class MinMaxAvgWidgetPrivate { public: @@ -155,10 +156,31 @@ void ShiftTimesDialog::buttonClicked(QAbstractButton *button) } } +void ShiftTimesDialog::showEvent(QShowEvent * event) +{ + ui.timeEdit->setTime(QTime(0, 0, 0, 0)); + when = get_times();//get time of first selected dive + ui.currentTime->setText(get_dive_date_string(when)); + ui.shiftedTime->setText(get_dive_date_string(when)); +} + +void ShiftTimesDialog::changeTime() +{ + int amount; + + amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60; + if (ui.backwards->isChecked()) + amount *= -1; + + ui.shiftedTime->setText (get_dive_date_string(amount+when)); +} + ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) : QDialog(parent) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); + connect(ui.timeEdit, SIGNAL(timeChanged(const QTime)), this, SLOT(changeTime())); + connect(ui.backwards, SIGNAL(toggled(bool)), this, SLOT(changeTime())); } void ShiftImageTimesDialog::buttonClicked(QAbstractButton *button) |