diff options
-rw-r--r-- | desktop-widgets/divelistview.cpp | 4 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 4 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 33 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.h | 4 |
4 files changed, 16 insertions, 29 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index a47c05b67..6d41c7ff1 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -647,8 +647,8 @@ void DiveListView::splitDives() void DiveListView::renumberDives() { - RenumberDialog::instance()->renumberOnlySelected(); - RenumberDialog::instance()->show(); + RenumberDialog dialog(true, MainWindow::instance()); + dialog.exec(); } void DiveListView::merge_trip(const QModelIndex &a, int offset) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 94c51279f..87a7e1d06 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -921,8 +921,8 @@ void MainWindow::on_actionAddDive_triggered() void MainWindow::on_actionRenumber_triggered() { - RenumberDialog::instance()->renumberOnlySelected(false); - RenumberDialog::instance()->show(); + RenumberDialog dialog(false, this); + dialog.exec(); } void MainWindow::on_actionAutoGroup_triggered() diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index ba3dc67ee..ef7ca71d0 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -124,27 +124,6 @@ void MinMaxAvgWidget::setAvgVisibility(bool visible) avgValue->setVisible(visible); } -RenumberDialog *RenumberDialog::instance() -{ - static RenumberDialog *self = new RenumberDialog(MainWindow::instance()); - return self; -} - -void RenumberDialog::renumberOnlySelected(bool selected) -{ - if (selected && amount_selected == 1) - ui.renumberText->setText(tr("New number")); - else - ui.renumberText->setText(tr("New starting number")); - - if (selected) - ui.groupBox->setTitle(tr("Renumber selected dives")); - else - ui.groupBox->setTitle(tr("Renumber all dives")); - - selectedOnly = selected; -} - void RenumberDialog::buttonClicked(QAbstractButton *button) { if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { @@ -163,7 +142,7 @@ void RenumberDialog::buttonClicked(QAbstractButton *button) } } -RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(false) +RenumberDialog::RenumberDialog(bool selectedOnlyIn, QWidget *parent) : QDialog(parent), selectedOnly(selectedOnlyIn) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); @@ -171,6 +150,16 @@ RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly( connect(close, SIGNAL(activated()), this, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quit, SIGNAL(activated()), parent, SLOT(close())); + + if (selectedOnly && amount_selected == 1) + ui.renumberText->setText(tr("New number")); + else + ui.renumberText->setText(tr("New starting number")); + + if (selectedOnly) + ui.groupBox->setTitle(tr("Renumber selected dives")); + else + ui.groupBox->setTitle(tr("Renumber all dives")); } void SetpointDialog::buttonClicked(QAbstractButton *button) diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index 421695815..ce8c636f7 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -50,14 +50,12 @@ public: class RenumberDialog : public QDialog { Q_OBJECT public: - static RenumberDialog *instance(); - void renumberOnlySelected(bool selected = true); + explicit RenumberDialog(bool selectedOnly, QWidget *parent); private slots: void buttonClicked(QAbstractButton *button); private: - explicit RenumberDialog(QWidget *parent); Ui::RenumberDialog ui; bool selectedOnly; }; |