#2813 Origin summary dialog. 'Ok to all' button

This commit is contained in:
Bjørn Erik Jensen 2018-04-27 08:26:44 +02:00
parent 478955d0f6
commit 0fcdfadddc
2 changed files with 21 additions and 30 deletions

View File

@ -107,13 +107,11 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
m_summaryNotReadBtn = new QRadioButton(this); m_summaryNotReadBtn = new QRadioButton(this);
m_gridSeparateCasesBtn = new QRadioButton(this); m_gridSeparateCasesBtn = new QRadioButton(this);
m_gridNotReadBtn = new QRadioButton(this); m_gridNotReadBtn = new QRadioButton(this);
m_applyToAllCheckBox = new QCheckBox(this);
m_warnings = new QListWidget(this); m_warnings = new QListWidget(this);
m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
// Connect to signals // Connect to signals
connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); connect(m_buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotDialogButtonClicked(QAbstractButton*)));
connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked()));
// Set widget properties // Set widget properties
m_summaryReadAllBtn->setText("Unified"); m_summaryReadAllBtn->setText("Unified");
@ -121,8 +119,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
m_summaryNotReadBtn->setText("Skip"); m_summaryNotReadBtn->setText("Skip");
m_gridSeparateCasesBtn->setText("Separate Cases"); m_gridSeparateCasesBtn->setText("Separate Cases");
m_gridNotReadBtn->setText("Skip"); m_gridNotReadBtn->setText("Skip");
m_applyToAllCheckBox->setText("OK to All"); m_buttons->button(QDialogButtonBox::Apply)->setText("OK to All");
m_applyToAllCheckBox->setLayoutDirection(Qt::RightToLeft);
// Define layout // Define layout
QVBoxLayout* dialogLayout = new QVBoxLayout(); QVBoxLayout* dialogLayout = new QVBoxLayout();
@ -171,7 +168,6 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
// Apply to all checkbox and buttons // Apply to all checkbox and buttons
QHBoxLayout* buttonsLayout = new QHBoxLayout(); QHBoxLayout* buttonsLayout = new QHBoxLayout();
buttonsLayout->addStretch(1); buttonsLayout->addStretch(1);
buttonsLayout->addWidget(m_applyToAllCheckBox);
buttonsLayout->addWidget(m_buttons); buttonsLayout->addWidget(m_buttons);
dialogLayout->addWidget(m_currentFilesGroup); dialogLayout->addWidget(m_currentFilesGroup);
@ -181,6 +177,8 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
dialogLayout->addLayout(buttonsLayout); dialogLayout->addLayout(buttonsLayout);
setLayout(dialogLayout); setLayout(dialogLayout);
m_okToAllPressed = false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -331,7 +329,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const
// Set properties and show dialog // Set properties and show dialog
dialog.setWindowTitle("Restart Files"); dialog.setWindowTitle("Restart Files");
dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); dialog.m_buttons->button(QDialogButtonBox::Apply)->setVisible(showApplyToAllWidget);
dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT);
dialog.exec(); dialog.exec();
@ -347,7 +345,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const
dialog.selectedGridImportOption(), dialog.selectedGridImportOption(),
{}, {},
{}, {},
dialog.applyToAllSelected()); dialog.okToAllSelected());
} }
if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK) if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK)
@ -403,9 +401,9 @@ RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selected
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicSummaryCaseRestartDialog::applyToAllSelected() const bool RicSummaryCaseRestartDialog::okToAllSelected() const
{ {
return m_applyToAllCheckBox->isChecked(); return m_okToAllPressed;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -476,20 +474,13 @@ void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnin
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicSummaryCaseRestartDialog::slotDialogOkClicked() void RicSummaryCaseRestartDialog::slotDialogButtonClicked(QAbstractButton* button)
{ {
accept(); bool okButtonClicked = m_buttons->button(QDialogButtonBox::Ok) == button;
bool cancelButtonClicked = m_buttons->button(QDialogButtonBox::Cancel) == button;
bool okToAllButtonClicked = m_buttons->button(QDialogButtonBox::Apply) == button;
m_okToAllPressed = okToAllButtonClicked;
if (cancelButtonClicked) reject();
else accept();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCaseRestartDialog::slotDialogCancelClicked()
{
reject();
}
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------

View File

@ -38,6 +38,7 @@ class QGridLayout;
class QCheckBox; class QCheckBox;
class QGroupBox; class QGroupBox;
class RicSummaryCaseRestartDialogResult; class RicSummaryCaseRestartDialogResult;
class QAbstractButton;
//================================================================================================== //==================================================================================================
/// ///
@ -63,7 +64,7 @@ public:
ImportOptions selectedSummaryImportOption() const; ImportOptions selectedSummaryImportOption() const;
ImportOptions selectedGridImportOption() const; ImportOptions selectedGridImportOption() const;
bool applyToAllSelected() const; bool okToAllSelected() const;
private: private:
void populateFileList(QGridLayout* gridLayout, const std::vector<RifRestartFileInfo>& fileInfos); void populateFileList(QGridLayout* gridLayout, const std::vector<RifRestartFileInfo>& fileInfos);
@ -72,8 +73,7 @@ private:
void displayWarningsIfAny(const QStringList& warnings); void displayWarningsIfAny(const QStringList& warnings);
private slots: private slots:
void slotDialogOkClicked(); void slotDialogButtonClicked(QAbstractButton* button);
void slotDialogCancelClicked();
private: private:
QGroupBox* m_currentFilesGroup; QGroupBox* m_currentFilesGroup;
@ -91,9 +91,9 @@ private:
QRadioButton* m_gridNotReadBtn; QRadioButton* m_gridNotReadBtn;
QRadioButton* m_gridSeparateCasesBtn; QRadioButton* m_gridSeparateCasesBtn;
QCheckBox* m_applyToAllCheckBox;
QDialogButtonBox* m_buttons; QDialogButtonBox* m_buttons;
bool m_okToAllPressed;
QListWidget* m_warnings; QListWidget* m_warnings;
}; };