From b303f217a9d66ef031c58534b3796ddefbe362c5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 20 May 2014 06:11:32 +0900 Subject: Dive list: add context menu function to renumber dive(s) No attempt is made to ensure that what the user does is sane. So this can result in duplicate numbers, non-consecutive numbers, non-monotonous numbers, whatever floats the users boat. You can renumber a single dive or all selected dives (with a starting number given that is applied to the oldest selected dive and then for each newer selected dive that number is incremented by one). Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'qt-ui/simplewidgets.cpp') 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 #include #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 *))); -- cgit v1.2.3-70-g09d2