aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--qt-ui/divelistview.cpp7
-rw-r--r--qt-ui/divelistview.h1
-rw-r--r--qt-ui/mainwindow.cpp1
-rw-r--r--qt-ui/simplewidgets.cpp18
-rw-r--r--qt-ui/simplewidgets.h2
-rw-r--r--subsurfacestartup.c11
7 files changed, 32 insertions, 10 deletions
diff --git a/dive.h b/dive.h
index 98238970f..a4bc7f08b 100644
--- a/dive.h
+++ b/dive.h
@@ -554,7 +554,7 @@ extern unsigned int dc_airtemp(struct divecomputer *dc);
extern unsigned int dc_watertemp(struct divecomputer *dc);
extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded);
extern struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded);
-extern void renumber_dives(int nr);
+extern void renumber_dives(int start_nr, bool selected_only);
extern void copy_events(struct dive *s, struct dive *d);
extern void copy_cylinders(struct dive *s, struct dive *d);
extern void copy_samples(struct dive *s, struct dive *d);
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index e6eff5fc4..e6d82d5bc 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -529,6 +529,12 @@ void DiveListView::mergeDives()
MainWindow::instance()->refreshDisplay();
}
+void DiveListView::renumberDives()
+{
+ RenumberDialog::instance()->renumberOnlySelected();
+ RenumberDialog::instance()->show();
+}
+
void DiveListView::merge_trip(const QModelIndex &a, int offset)
{
int i = a.row() + offset;
@@ -768,6 +774,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event)
if (amount_selected > 1 && consecutive_selected())
popup.addAction(tr("merge selected dives"), this, SLOT(mergeDives()));
if (amount_selected >= 1) {
+ popup.addAction(tr("renumber dive(s)"), this, SLOT(renumberDives()));
popup.addAction(tr("save As"), this, SLOT(saveSelectedDivesAs()));
popup.addAction(tr("export As UDDF"), this, SLOT(exportSelectedDivesAsUDDF()));
popup.addAction(tr("export As CSV"), this, SLOT(exportSelectedDivesAsCSV()));
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index d946b1854..132d92f1f 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -48,6 +48,7 @@ slots:
void addToTripAbove();
void addToTripBelow();
void mergeDives();
+ void renumberDives();
void saveSelectedDivesAs();
void exportSelectedDivesAsUDDF();
void exportSelectedDivesAsCSV();
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index efa50bc0c..6ff0a68a4 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -444,6 +444,7 @@ void MainWindow::on_actionAddDive_triggered()
void MainWindow::on_actionRenumber_triggered()
{
+ RenumberDialog::instance()->renumberOnlySelected(false);
RenumberDialog::instance()->show();
}
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 8932baf15..b34f74c50 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -16,8 +16,9 @@
#include <QDateTime>
#include <QShortcut>
#include "exif.h"
-#include "../dive.h"
-#include "../file.h"
+#include "dive.h"
+#include "file.h"
+#include "display.h"
#include "mainwindow.h"
#include "helpers.h"
@@ -117,15 +118,24 @@ RenumberDialog *RenumberDialog::instance()
return self;
}
+void RenumberDialog::renumberOnlySelected(bool selected)
+{
+ if (selected && amount_selected == 1)
+ ui.groupBox->setTitle(tr("New number"));
+ else
+ ui.groupBox->setTitle(tr("New starting number"));
+ selectedOnly = selected;
+}
+
void RenumberDialog::buttonClicked(QAbstractButton *button)
{
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
qDebug() << "Renumbering.";
- renumber_dives(ui.spinBox->value());
+ renumber_dives(ui.spinBox->value(), selectedOnly);
}
}
-RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent)
+RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(false)
{
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index d43d2bbcc..aa82e4a29 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -40,6 +40,7 @@ class RenumberDialog : public QDialog {
Q_OBJECT
public:
static RenumberDialog *instance();
+ void renumberOnlySelected(bool selected = true);
private
slots:
void buttonClicked(QAbstractButton *button);
@@ -47,6 +48,7 @@ slots:
private:
explicit RenumberDialog(QWidget *parent);
Ui::RenumberDialog ui;
+ bool selectedOnly;
};
class ShiftTimesDialog : public QDialog {
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 471fea64e..4ae426d1c 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -149,13 +149,14 @@ void parse_argument(const char *arg)
} while (*++p);
}
-void renumber_dives(int nr)
+void renumber_dives(int start_nr, bool selected_only)
{
- int i;
+ int i, nr = start_nr;
+ struct dive *dive;
- for (i = 0; i < dive_table.nr; i++) {
- struct dive *dive = dive_table.dives[i];
- dive->number = nr + i;
+ for_each_dive (i, dive) {
+ if (dive->selected)
+ dive->number = nr++;
}
mark_divelist_changed(true);
}