mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Shift times of selected dives
This patch adds the possibility to shift the times of all selected dives by a fixed amount to correct for time zone problems or mis-set dive computer clocks. Select the dives and right click in the dive list. [Dirk Hohndel: added .ui file to FORMS and fixed some whitespace damage] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e289881db9
commit
4966336e1d
8 changed files with 217 additions and 0 deletions
12
dive.c
12
dive.c
|
@ -2072,3 +2072,15 @@ struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shift_times(const timestamp_t amount)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct dive *dive;
|
||||||
|
|
||||||
|
for_each_dive (i, dive) {
|
||||||
|
if (!dive->selected)
|
||||||
|
continue;
|
||||||
|
dive->when += amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
2
dive.h
2
dive.h
|
@ -633,6 +633,8 @@ extern void save_dives_logic(const char *filename, bool select_only);
|
||||||
extern void save_dive(FILE *f, struct dive *dive);
|
extern void save_dive(FILE *f, struct dive *dive);
|
||||||
extern void export_dives_uddf(const char *filename, const bool selected);
|
extern void export_dives_uddf(const char *filename, const bool selected);
|
||||||
|
|
||||||
|
extern void shift_times(const timestamp_t amount);
|
||||||
|
|
||||||
extern xsltStylesheetPtr get_stylesheet(const char *name);
|
extern xsltStylesheetPtr get_stylesheet(const char *name);
|
||||||
|
|
||||||
extern char *xslt_path;
|
extern char *xslt_path;
|
||||||
|
|
|
@ -614,6 +614,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
if (amount_selected >= 1) {
|
if (amount_selected >= 1) {
|
||||||
popup.addAction(tr("save As"), this, SLOT(saveSelectedDivesAs()));
|
popup.addAction(tr("save As"), this, SLOT(saveSelectedDivesAs()));
|
||||||
popup.addAction(tr("export As UDDF"), this, SLOT(exportSelectedDivesAsUDDF()));
|
popup.addAction(tr("export As UDDF"), this, SLOT(exportSelectedDivesAsUDDF()));
|
||||||
|
popup.addAction(tr("shift times"), this, SLOT(shiftTimes()));
|
||||||
}
|
}
|
||||||
// "collapse all" really closes all trips,
|
// "collapse all" really closes all trips,
|
||||||
// "collapse" keeps the trip with the selected dive open
|
// "collapse" keeps the trip with the selected dive open
|
||||||
|
@ -664,3 +665,9 @@ void DiveListView::exportSelectedDivesAsUDDF()
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
export_dives_uddf(filename.toUtf8(), true);
|
export_dives_uddf(filename.toUtf8(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DiveListView::shiftTimes()
|
||||||
|
{
|
||||||
|
ShiftTimesDialog::instance()->show();
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public slots:
|
||||||
void mergeDives();
|
void mergeDives();
|
||||||
void saveSelectedDivesAs();
|
void saveSelectedDivesAs();
|
||||||
void exportSelectedDivesAsUDDF();
|
void exportSelectedDivesAsUDDF();
|
||||||
|
void shiftTimes();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentDiveChanged(int divenr);
|
void currentDiveChanged(int divenr);
|
||||||
|
|
155
qt-ui/shifttimes.ui
Normal file
155
qt-ui/shifttimes.ui
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ShiftTimesDialog</class>
|
||||||
|
<widget class="QDialog" name="ShiftTimesDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>229</width>
|
||||||
|
<height>134</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Shift selected times</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Shift times of selected dives by</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QTimeEdit" name="timeEdit">
|
||||||
|
<property name="date">
|
||||||
|
<date>
|
||||||
|
<year>2000</year>
|
||||||
|
<month>1</month>
|
||||||
|
<day>1</day>
|
||||||
|
</date>
|
||||||
|
</property>
|
||||||
|
<property name="minimumDateTime">
|
||||||
|
<datetime>
|
||||||
|
<hour>0</hour>
|
||||||
|
<minute>0</minute>
|
||||||
|
<second>0</second>
|
||||||
|
<year>2000</year>
|
||||||
|
<month>1</month>
|
||||||
|
<day>1</day>
|
||||||
|
</datetime>
|
||||||
|
</property>
|
||||||
|
<property name="maximumDate">
|
||||||
|
<date>
|
||||||
|
<year>2000</year>
|
||||||
|
<month>1</month>
|
||||||
|
<day>1</day>
|
||||||
|
</date>
|
||||||
|
</property>
|
||||||
|
<property name="timeSpec">
|
||||||
|
<enum>Qt::LocalTime</enum>
|
||||||
|
</property>
|
||||||
|
<property name="time">
|
||||||
|
<time>
|
||||||
|
<hour>0</hour>
|
||||||
|
<minute>0</minute>
|
||||||
|
<second>0</second>
|
||||||
|
</time>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="backwards">
|
||||||
|
<property name="text">
|
||||||
|
<string>backwards</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="forward">
|
||||||
|
<property name="text">
|
||||||
|
<string>forward</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>ShiftTimesDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>ShiftTimesDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
class MinMaxAvgWidgetPrivate{
|
class MinMaxAvgWidgetPrivate{
|
||||||
public:
|
public:
|
||||||
|
@ -119,6 +120,32 @@ RenumberDialog::RenumberDialog(): QDialog()
|
||||||
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShiftTimesDialog* ShiftTimesDialog::instance()
|
||||||
|
{
|
||||||
|
static ShiftTimesDialog* self = new ShiftTimesDialog();
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShiftTimesDialog::buttonClicked(QAbstractButton* button)
|
||||||
|
{
|
||||||
|
int amount;
|
||||||
|
|
||||||
|
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole){
|
||||||
|
amount = ui.timeEdit->time().hour() * 3600 + ui.timeEdit->time().minute() * 60;
|
||||||
|
if (ui.backwards->isChecked())
|
||||||
|
amount *= -1;
|
||||||
|
|
||||||
|
shift_times(amount);
|
||||||
|
mainWindow()->refreshDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShiftTimesDialog::ShiftTimesDialog(): QDialog()
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||||
|
}
|
||||||
|
|
||||||
bool isGnome3Session()
|
bool isGnome3Session()
|
||||||
{
|
{
|
||||||
#if defined(QT_OS_WIW) || defined(QT_OS_MAC)
|
#if defined(QT_OS_WIW) || defined(QT_OS_MAC)
|
||||||
|
|
|
@ -8,6 +8,7 @@ class QAbstractButton;
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "ui_renumber.h"
|
#include "ui_renumber.h"
|
||||||
|
#include "ui_shifttimes.h"
|
||||||
|
|
||||||
class MinMaxAvgWidget : public QWidget{
|
class MinMaxAvgWidget : public QWidget{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -41,6 +42,17 @@ private:
|
||||||
Ui::RenumberDialog ui;
|
Ui::RenumberDialog ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ShiftTimesDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static ShiftTimesDialog *instance();
|
||||||
|
private slots:
|
||||||
|
void buttonClicked(QAbstractButton *button);
|
||||||
|
private:
|
||||||
|
explicit ShiftTimesDialog();
|
||||||
|
Ui::ShiftTimesDialog ui;
|
||||||
|
};
|
||||||
|
|
||||||
bool isGnome3Session();
|
bool isGnome3Session();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -123,6 +123,7 @@ FORMS = \
|
||||||
qt-ui/preferences.ui \
|
qt-ui/preferences.ui \
|
||||||
qt-ui/printoptions.ui \
|
qt-ui/printoptions.ui \
|
||||||
qt-ui/renumber.ui \
|
qt-ui/renumber.ui \
|
||||||
|
qt-ui/shifttimes.ui \
|
||||||
qt-ui/webservices.ui \
|
qt-ui/webservices.ui \
|
||||||
qt-ui/tableview.ui \
|
qt-ui/tableview.ui \
|
||||||
qt-ui/csvimportdialog.ui
|
qt-ui/csvimportdialog.ui
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue