aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Gehad <gehadelrobey@gmail.com>2014-03-20 22:57:49 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-21 21:26:09 -0700
commit8ca4437624ad84b9bec934436cc42182e96f359a (patch)
treeff84eba5c3adc66307509904fb47071f5b828707 /qt-ui/simplewidgets.cpp
parentcc2369c5f9dbaebb8fae2e652e27f189d0454fc1 (diff)
downloadsubsurface-8ca4437624ad84b9bec934436cc42182e96f359a.tar.gz
Add current time and adjusted time to gui when adjusting dive's timestamp
This patch adds the current dive time and the adjusted time to the time shift window. I added a function to dive.c to get the timestamp of the first selected dive. This will view the time of the first selected dive only even when multi dives are selected but it does change the times for multiple dives properly. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r--qt-ui/simplewidgets.cpp22
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)