Skip to content

Commit

Permalink
[processing] Allow providers to return a different helpId() vs
Browse files Browse the repository at this point in the history
their unique id()

This is used when generating the QgsHelp url for algorithms
attached to the providers.

Implement helpId overrides for the native and 3d providers so
that they return 'qgis' helpIds, meaning that all QGIS processing
algorithm documentation can be kept within the same url path
regardless of which QGIS provider library it sits within.

This also allows us to freely move algorithms from the Python
'qgis' provider to c++ 'native' provider in future releases
without breaking the help URLs.

Fixes #17231
  • Loading branch information
nyalldawson committed Feb 9, 2018
1 parent fcb50a6 commit 2d1e918
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/analysis/processing/qgsnativealgorithms.sip.in
Expand Up @@ -33,6 +33,8 @@ Constructor for QgsNativeAlgorithms.

virtual QString id() const;

virtual QString helpId() const;

virtual QString name() const;

virtual bool supportsNonFileBasedOutput() const;
Expand Down
11 changes: 11 additions & 0 deletions python/core/processing/qgsprocessingprovider.sip.in
Expand Up @@ -53,6 +53,17 @@ should be a unique, short, character only string, eg "qgis" or "gdal". This
string should not be localised.

.. seealso:: :py:func:`name`

.. seealso:: :py:func:`helpId`
%End

virtual QString helpId() const;
%Docstring
Returns the provider help id string, used for creating QgsHelp urls for algorithms
belong to this provider. By default, this returns the provider's id(). This string
should not be localised.

.. seealso:: :py:func:`id`
%End

virtual QString name() const = 0;
Expand Down
Expand Up @@ -367,7 +367,7 @@ def openHelp(self):
algHelp = self._alg.helpUrl()
if not algHelp:
algHelp = QgsHelp.helpUrl("processing_algs/{}/{}.html{}".format(
self._alg.provider().id(), self._alg.groupId(), self._alg.name())).toString()
self._alg.provider().helpId(), self._alg.groupId(), self._alg.name())).toString()

if algHelp not in [None, ""]:
webbrowser.open(algHelp)
5 changes: 5 additions & 0 deletions src/3d/processing/qgs3dalgorithms.cpp
Expand Up @@ -40,6 +40,11 @@ QString Qgs3DAlgorithms::id() const
return QStringLiteral( "3d" );
}

QString Qgs3DAlgorithms::helpId() const
{
return QStringLiteral( "qgis" );
}

QString Qgs3DAlgorithms::name() const
{
return tr( "QGIS (3D)" );
Expand Down
1 change: 1 addition & 0 deletions src/3d/processing/qgs3dalgorithms.h
Expand Up @@ -42,6 +42,7 @@ class _3D_EXPORT Qgs3DAlgorithms: public QgsProcessingProvider
QIcon icon() const override;
QString svgIconPath() const override;
QString id() const override;
QString helpId() const override;
QString name() const override;
bool supportsNonFileBasedOutput() const override;

Expand Down
5 changes: 5 additions & 0 deletions src/analysis/processing/qgsnativealgorithms.cpp
Expand Up @@ -86,6 +86,11 @@ QString QgsNativeAlgorithms::id() const
return QStringLiteral( "native" );
}

QString QgsNativeAlgorithms::helpId() const
{
return QStringLiteral( "qgis" );
}

QString QgsNativeAlgorithms::name() const
{
return tr( "QGIS (native c++)" );
Expand Down
1 change: 1 addition & 0 deletions src/analysis/processing/qgsnativealgorithms.h
Expand Up @@ -42,6 +42,7 @@ class ANALYSIS_EXPORT QgsNativeAlgorithms: public QgsProcessingProvider
QIcon icon() const override;
QString svgIconPath() const override;
QString id() const override;
QString helpId() const override;
QString name() const override;
bool supportsNonFileBasedOutput() const override;

Expand Down
5 changes: 5 additions & 0 deletions src/core/processing/qgsprocessingprovider.cpp
Expand Up @@ -41,6 +41,11 @@ QString QgsProcessingProvider::svgIconPath() const
return QgsApplication::iconPath( QStringLiteral( "processingAlgorithm.svg" ) );
}

QString QgsProcessingProvider::helpId() const
{
return id();
}

QString QgsProcessingProvider::longName() const
{
return name();
Expand Down
9 changes: 9 additions & 0 deletions src/core/processing/qgsprocessingprovider.h
Expand Up @@ -66,9 +66,18 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
* should be a unique, short, character only string, eg "qgis" or "gdal". This
* string should not be localised.
* \see name()
* \see helpId()
*/
virtual QString id() const = 0;

/**
* Returns the provider help id string, used for creating QgsHelp urls for algorithms
* belong to this provider. By default, this returns the provider's id(). This string
* should not be localised.
* \see id()
*/
virtual QString helpId() const;

/**
* Returns the provider name, which is used to describe the provider within the GUI.
* This string should be short (e.g. "Lastools") and localised.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/processing/qgsprocessingalgorithmdialogbase.cpp
Expand Up @@ -233,7 +233,7 @@ void QgsProcessingAlgorithmDialogBase::openHelp()
QUrl algHelp = mAlgorithm->helpUrl();
if ( algHelp.isEmpty() )
{
algHelp = QgsHelp::helpUrl( QStringLiteral( "processing_algs/%1/%2.html#%3" ).arg( mAlgorithm->provider()->id(), mAlgorithm->groupId(), mAlgorithm->name() ) );
algHelp = QgsHelp::helpUrl( QStringLiteral( "processing_algs/%1/%2.html#%3" ).arg( mAlgorithm->provider()->helpId(), mAlgorithm->groupId(), mAlgorithm->name() ) );
}

if ( !algHelp.isEmpty() )
Expand Down

0 comments on commit 2d1e918

Please sign in to comment.