diff --git a/dive.c b/dive.c
index 6deee8b08..9a836038d 100644
--- a/dive.c
+++ b/dive.c
@@ -2176,3 +2176,15 @@ void shift_times(const timestamp_t amount)
dive->when += amount;
}
}
+
+timestamp_t get_times()
+{
+ int i;
+ struct dive *dive;
+
+ for_each_dive(i, dive) {
+ if (dive->selected)
+ break;
+ }
+ return dive->when;
+}
diff --git a/dive.h b/dive.h
index 6c9a5b566..dd321a7b9 100644
--- a/dive.h
+++ b/dive.h
@@ -722,6 +722,7 @@ extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int
extern int subsurface_zip_close(struct zip *zip);
extern void shift_times(const timestamp_t amount);
+extern timestamp_t get_times();
extern xsltStylesheetPtr get_stylesheet(const char *name);
diff --git a/qt-ui/shifttimes.ui b/qt-ui/shifttimes.ui
index 55932a2d3..8aaa247ce 100644
--- a/qt-ui/shifttimes.ui
+++ b/qt-ui/shifttimes.ui
@@ -10,7 +10,7 @@
0
0
343
- 177
+ 224
@@ -64,6 +64,38 @@
9
+ -
+
+
-
+
+
+ Shifted time:
+
+
+
+ -
+
+
+ Current time:
+
+
+
+ -
+
+
+ 0:0
+
+
+
+ -
+
+
+ 0:0
+
+
+
+
+
-
@@ -166,5 +198,17 @@
+
+ timeEdit
+ timeChanged(const QTime)
+ ShiftTimesDialog
+ changeTime()
+
+
+ backwards
+ toggled(bool)
+ ShiftTimesDialog
+ changeTime()
+
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)
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index 6e4166f35..178dfece8 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -52,12 +52,15 @@ class ShiftTimesDialog : public QDialog {
Q_OBJECT
public:
static ShiftTimesDialog *instance();
+ void showEvent ( QShowEvent * event );
private
slots:
void buttonClicked(QAbstractButton *button);
+ void changeTime ();
private:
explicit ShiftTimesDialog(QWidget *parent);
+ int64_t when;
Ui::ShiftTimesDialog ui;
};