diff --git a/dive.c b/dive.c
index 558cdee30..97637e4dd 100644
--- a/dive.c
+++ b/dive.c
@@ -2072,3 +2072,15 @@ struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset)
}
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;
+ }
+}
diff --git a/dive.h b/dive.h
index 0014a3ae7..03b783480 100644
--- a/dive.h
+++ b/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 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 char *xslt_path;
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 95f85d604..ca0ea5713 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -614,6 +614,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
if (amount_selected >= 1) {
popup.addAction(tr("save As"), this, SLOT(saveSelectedDivesAs()));
popup.addAction(tr("export As UDDF"), this, SLOT(exportSelectedDivesAsUDDF()));
+ popup.addAction(tr("shift times"), this, SLOT(shiftTimes()));
}
// "collapse all" really closes all trips,
// "collapse" keeps the trip with the selected dive open
@@ -664,3 +665,9 @@ void DiveListView::exportSelectedDivesAsUDDF()
if (!filename.isNull() && !filename.isEmpty())
export_dives_uddf(filename.toUtf8(), true);
}
+
+
+void DiveListView::shiftTimes()
+{
+ ShiftTimesDialog::instance()->show();
+}
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index 3d486d1bd..b4a0d3b35 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -47,6 +47,7 @@ public slots:
void mergeDives();
void saveSelectedDivesAs();
void exportSelectedDivesAsUDDF();
+ void shiftTimes();
signals:
void currentDiveChanged(int divenr);
diff --git a/qt-ui/shifttimes.ui b/qt-ui/shifttimes.ui
new file mode 100644
index 000000000..39b3250a1
--- /dev/null
+++ b/qt-ui/shifttimes.ui
@@ -0,0 +1,155 @@
+
+
+ ShiftTimesDialog
+
+
+
+ 0
+ 0
+ 229
+ 134
+
+
+
+ Shift selected times
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Shift times of selected dives by
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+ 2000
+ 1
+ 1
+
+
+
+
+ 0
+ 0
+ 0
+ 2000
+ 1
+ 1
+
+
+
+
+ 2000
+ 1
+ 1
+
+
+
+ Qt::LocalTime
+
+
+
+
+
+
+ -
+
+
+ backwards
+
+
+
+ -
+
+
+ forward
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ ShiftTimesDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ ShiftTimesDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index f1cf8906d..bbe7b1b37 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -13,6 +13,7 @@
#include
#include "../dive.h"
+#include "mainwindow.h"
class MinMaxAvgWidgetPrivate{
public:
@@ -119,6 +120,32 @@ RenumberDialog::RenumberDialog(): QDialog()
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()
{
#if defined(QT_OS_WIW) || defined(QT_OS_MAC)
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index 057a97251..70d61ca59 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -8,6 +8,7 @@ class QAbstractButton;
#include
#include "ui_renumber.h"
+#include "ui_shifttimes.h"
class MinMaxAvgWidget : public QWidget{
Q_OBJECT
@@ -41,6 +42,17 @@ private:
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();
#endif
diff --git a/subsurface.pro b/subsurface.pro
index 23fc43af1..8754f1da7 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -123,6 +123,7 @@ FORMS = \
qt-ui/preferences.ui \
qt-ui/printoptions.ui \
qt-ui/renumber.ui \
+ qt-ui/shifttimes.ui \
qt-ui/webservices.ui \
qt-ui/tableview.ui \
qt-ui/csvimportdialog.ui