mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
cleanup: un-singletonize RenumberDialog
There is no reason that this dialog is a singleton. Since it is modal, it can be created on demand. This simplifies code, because the mode (selected-only or all-dives) can be set in the constructor. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
79f90effe9
commit
25f1bc488f
4 changed files with 16 additions and 29 deletions
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue