mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
cc2369c5f9
commit
8ca4437624
5 changed files with 83 additions and 1 deletions
12
dive.c
12
dive.c
|
@ -2176,3 +2176,15 @@ void shift_times(const timestamp_t amount)
|
||||||
dive->when += 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;
|
||||||
|
}
|
||||||
|
|
1
dive.h
1
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 int subsurface_zip_close(struct zip *zip);
|
||||||
|
|
||||||
extern void shift_times(const timestamp_t amount);
|
extern void shift_times(const timestamp_t amount);
|
||||||
|
extern timestamp_t get_times();
|
||||||
|
|
||||||
extern xsltStylesheetPtr get_stylesheet(const char *name);
|
extern xsltStylesheetPtr get_stylesheet(const char *name);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>343</width>
|
<width>343</width>
|
||||||
<height>177</height>
|
<height>224</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -64,6 +64,38 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="shiftedTimeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Shifted time:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="currentTimeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Current time:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="currentTime">
|
||||||
|
<property name="text">
|
||||||
|
<string>0:0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="shiftedTime">
|
||||||
|
<property name="text">
|
||||||
|
<string>0:0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTimeEdit" name="timeEdit">
|
<widget class="QTimeEdit" name="timeEdit">
|
||||||
<property name="date">
|
<property name="date">
|
||||||
|
@ -166,5 +198,17 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>timeEdit</sender>
|
||||||
|
<signal>timeChanged(const QTime)</signal>
|
||||||
|
<receiver>ShiftTimesDialog</receiver>
|
||||||
|
<slot>changeTime()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>backwards</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>ShiftTimesDialog</receiver>
|
||||||
|
<slot>changeTime()</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
#include "../file.h"
|
#include "../file.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
class MinMaxAvgWidgetPrivate {
|
class MinMaxAvgWidgetPrivate {
|
||||||
public:
|
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)
|
ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
|
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)
|
void ShiftImageTimesDialog::buttonClicked(QAbstractButton *button)
|
||||||
|
|
|
@ -52,12 +52,15 @@ class ShiftTimesDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static ShiftTimesDialog *instance();
|
static ShiftTimesDialog *instance();
|
||||||
|
void showEvent ( QShowEvent * event );
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void buttonClicked(QAbstractButton *button);
|
void buttonClicked(QAbstractButton *button);
|
||||||
|
void changeTime ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ShiftTimesDialog(QWidget *parent);
|
explicit ShiftTimesDialog(QWidget *parent);
|
||||||
|
int64_t when;
|
||||||
Ui::ShiftTimesDialog ui;
|
Ui::ShiftTimesDialog ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue