Skip to content

Commit

Permalink
Fix confusing override of accept method for non-dialog acceptance
Browse files Browse the repository at this point in the history
(cherry picked from commit 3ce1662)
  • Loading branch information
nyalldawson committed Nov 23, 2018
1 parent d1cec84 commit 84dc8fa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Expand Up @@ -116,9 +116,6 @@ the given ``format``.

public slots:

virtual void accept();


void reportError( const QString &error, bool fatalError );
%Docstring
Reports an ``error`` string to the dialog's log.
Expand Down Expand Up @@ -271,6 +268,11 @@ Formats an input ``string`` for display in the log tab.
virtual void finished( bool successful, const QVariantMap &result, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
%Docstring
Called when the algorithm has finished executing.
%End

virtual void runAlgorithm();
%Docstring
Called when the dialog's algorithm should be run. Must be overridden by subclasses.
%End

};
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -159,7 +159,7 @@ def getParameterValues(self):

return self.algorithm().preprocessParameters(parameters)

def accept(self):
def runAlgorithm(self):
feedback = self.createFeedback()
context = dataobjects.createContext(feedback)

Expand Down
11 changes: 6 additions & 5 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.cpp
Expand Up @@ -95,7 +95,7 @@ QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *par
splitterChanged( 0, 0 );

connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsProcessingAlgorithmDialogBase::closeClicked );
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsProcessingAlgorithmDialogBase::accept );
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsProcessingAlgorithmDialogBase::runAlgorithm );

// Rename OK button to Run
mButtonRun = mButtonBox->button( QDialogButtonBox::Ok );
Expand Down Expand Up @@ -262,10 +262,6 @@ void QgsProcessingAlgorithmDialogBase::finished( bool, const QVariantMap &, QgsP

}

void QgsProcessingAlgorithmDialogBase::accept()
{
}

void QgsProcessingAlgorithmDialogBase::openHelp()
{
QUrl algHelp = mAlgorithm->helpUrl();
Expand Down Expand Up @@ -464,6 +460,11 @@ void QgsProcessingAlgorithmDialogBase::closeEvent( QCloseEvent *e )
}
}

void QgsProcessingAlgorithmDialogBase::runAlgorithm()
{

}

void QgsProcessingAlgorithmDialogBase::setPercentage( double percent )
{
// delay setting maximum progress value until we know algorithm reports progress
Expand Down
7 changes: 5 additions & 2 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.h
Expand Up @@ -168,8 +168,6 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::

public slots:

void accept() override;

/**
* Reports an \a error string to the dialog's log.
*
Expand Down Expand Up @@ -315,6 +313,11 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
*/
virtual void finished( bool successful, const QVariantMap &result, QgsProcessingContext &context, QgsProcessingFeedback *feedback );

/**
* Called when the dialog's algorithm should be run. Must be overridden by subclasses.
*/
virtual void runAlgorithm();

private slots:

void openHelp();
Expand Down

0 comments on commit 84dc8fa

Please sign in to comment.