Skip to content

Commit 2d1e918

Browse files
committed
[processing] Allow providers to return a different helpId() vs
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
1 parent fcb50a6 commit 2d1e918

File tree

10 files changed

+41
-2
lines changed

10 files changed

+41
-2
lines changed

python/analysis/processing/qgsnativealgorithms.sip.in

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Constructor for QgsNativeAlgorithms.
3333

3434
virtual QString id() const;
3535

36+
virtual QString helpId() const;
37+
3638
virtual QString name() const;
3739

3840
virtual bool supportsNonFileBasedOutput() const;

python/core/processing/qgsprocessingprovider.sip.in

+11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ should be a unique, short, character only string, eg "qgis" or "gdal". This
5353
string should not be localised.
5454

5555
.. seealso:: :py:func:`name`
56+
57+
.. seealso:: :py:func:`helpId`
58+
%End
59+
60+
virtual QString helpId() const;
61+
%Docstring
62+
Returns the provider help id string, used for creating QgsHelp urls for algorithms
63+
belong to this provider. By default, this returns the provider's id(). This string
64+
should not be localised.
65+
66+
.. seealso:: :py:func:`id`
5667
%End
5768

5869
virtual QString name() const = 0;

python/plugins/processing/modeler/ModelerParametersDialog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def openHelp(self):
367367
algHelp = self._alg.helpUrl()
368368
if not algHelp:
369369
algHelp = QgsHelp.helpUrl("processing_algs/{}/{}.html{}".format(
370-
self._alg.provider().id(), self._alg.groupId(), self._alg.name())).toString()
370+
self._alg.provider().helpId(), self._alg.groupId(), self._alg.name())).toString()
371371

372372
if algHelp not in [None, ""]:
373373
webbrowser.open(algHelp)

src/3d/processing/qgs3dalgorithms.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ QString Qgs3DAlgorithms::id() const
4040
return QStringLiteral( "3d" );
4141
}
4242

43+
QString Qgs3DAlgorithms::helpId() const
44+
{
45+
return QStringLiteral( "qgis" );
46+
}
47+
4348
QString Qgs3DAlgorithms::name() const
4449
{
4550
return tr( "QGIS (3D)" );

src/3d/processing/qgs3dalgorithms.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class _3D_EXPORT Qgs3DAlgorithms: public QgsProcessingProvider
4242
QIcon icon() const override;
4343
QString svgIconPath() const override;
4444
QString id() const override;
45+
QString helpId() const override;
4546
QString name() const override;
4647
bool supportsNonFileBasedOutput() const override;
4748

src/analysis/processing/qgsnativealgorithms.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ QString QgsNativeAlgorithms::id() const
8686
return QStringLiteral( "native" );
8787
}
8888

89+
QString QgsNativeAlgorithms::helpId() const
90+
{
91+
return QStringLiteral( "qgis" );
92+
}
93+
8994
QString QgsNativeAlgorithms::name() const
9095
{
9196
return tr( "QGIS (native c++)" );

src/analysis/processing/qgsnativealgorithms.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ANALYSIS_EXPORT QgsNativeAlgorithms: public QgsProcessingProvider
4242
QIcon icon() const override;
4343
QString svgIconPath() const override;
4444
QString id() const override;
45+
QString helpId() const override;
4546
QString name() const override;
4647
bool supportsNonFileBasedOutput() const override;
4748

src/core/processing/qgsprocessingprovider.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ QString QgsProcessingProvider::svgIconPath() const
4141
return QgsApplication::iconPath( QStringLiteral( "processingAlgorithm.svg" ) );
4242
}
4343

44+
QString QgsProcessingProvider::helpId() const
45+
{
46+
return id();
47+
}
48+
4449
QString QgsProcessingProvider::longName() const
4550
{
4651
return name();

src/core/processing/qgsprocessingprovider.h

+9
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,18 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
6666
* should be a unique, short, character only string, eg "qgis" or "gdal". This
6767
* string should not be localised.
6868
* \see name()
69+
* \see helpId()
6970
*/
7071
virtual QString id() const = 0;
7172

73+
/**
74+
* Returns the provider help id string, used for creating QgsHelp urls for algorithms
75+
* belong to this provider. By default, this returns the provider's id(). This string
76+
* should not be localised.
77+
* \see id()
78+
*/
79+
virtual QString helpId() const;
80+
7281
/**
7382
* Returns the provider name, which is used to describe the provider within the GUI.
7483
* This string should be short (e.g. "Lastools") and localised.

src/gui/processing/qgsprocessingalgorithmdialogbase.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void QgsProcessingAlgorithmDialogBase::openHelp()
233233
QUrl algHelp = mAlgorithm->helpUrl();
234234
if ( algHelp.isEmpty() )
235235
{
236-
algHelp = QgsHelp::helpUrl( QStringLiteral( "processing_algs/%1/%2.html#%3" ).arg( mAlgorithm->provider()->id(), mAlgorithm->groupId(), mAlgorithm->name() ) );
236+
algHelp = QgsHelp::helpUrl( QStringLiteral( "processing_algs/%1/%2.html#%3" ).arg( mAlgorithm->provider()->helpId(), mAlgorithm->groupId(), mAlgorithm->name() ) );
237237
}
238238

239239
if ( !algHelp.isEmpty() )

0 commit comments

Comments
 (0)