From 1e2349e7945b0f56fef503179dd0550db0137495 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 26 Jun 2014 14:54:16 -0300 Subject: Added code for TimeEdit This makes the TimeEdit work again. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 14 +++++++++++++- qt-ui/maintab.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index c64ef5b14..15759d7ec 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -75,6 +75,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.airtemp->installEventFilter(this); ui.watertemp->installEventFilter(this); ui.dateEdit->installEventFilter(this); + ui.timeEdit->installEventFilter(this); ui.tagWidget->installEventFilter(this); QList statisticsTabWidgets = ui.statisticsTab->children(); @@ -391,7 +392,7 @@ void MainTab::updateDiveInfo(int dive) if (d) { updateGpsCoordinates(d); ui.dateEdit->setDate(QDateTime::fromTime_t(d->when).date()); - //TODO: set also the time when the widget is ready. + ui.timeEdit->setTime(QDateTime::fromTime_t(d->when).time()); if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) { setTabText(0, tr("Trip Notes")); // only use trip relevant fields @@ -789,6 +790,7 @@ void MainTab::resetPallete() ui.airtemp->setPalette(p); ui.watertemp->setPalette(p); ui.dateEdit->setPalette(p); + ui.timeEdit->setPalette(p); ui.tagWidget->setPalette(p); } @@ -956,6 +958,16 @@ void MainTab::on_dateEdit_dateChanged(const QDateTime &datetime) markChangedWidget(ui.dateEdit); } +void MainTab::on_timeEdit_timeChanged(const QTime &time) +{ + if (editMode == NONE) + return; + QDateTime dateTime = QDateTime::fromTime_t(editedDive.when); + dateTime.setTime(time); + editedDive.when = dateTime.toTime_t(); + markChangedWidget(ui.timeEdit); +} + bool MainTab::tagsChanged(dive *a, dive *b) { char bufA[1024], bufB[1024]; diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index e296f1470..1e7b5d3a3 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -69,6 +69,7 @@ slots: void on_watertemp_textChanged(const QString &text); void validate_temp_field(QLineEdit *tempField, const QString &text); void on_dateEdit_dateChanged(const QDateTime &datetime); + void on_timeEdit_timeChanged(const QTime & time); void on_rating_valueChanged(int value); void on_visibility_valueChanged(int value); void on_tagWidget_textChanged(); -- cgit v1.2.3-70-g09d2