Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Allow help url to be set for models within help edit dialog
Refs #18767
  • Loading branch information
nyalldawson committed Sep 25, 2018
1 parent 95d68e9 commit 844a3fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions python/plugins/processing/gui/HelpEditionDialog.py
Expand Up @@ -53,6 +53,7 @@ class HelpEditionDialog(BASE, WIDGET):
ALG_HELP_CREATOR = 'ALG_HELP_CREATOR'
ALG_VERSION = 'ALG_VERSION'
SHORT_DESCRIPTION = 'SHORT_DESCRIPTION'
HELP_URL = 'HELP_URL'

def __init__(self, alg):
super(HelpEditionDialog, self).__init__(None)
Expand Down Expand Up @@ -127,6 +128,9 @@ def fillTree(self):
item = TreeDescriptionItem(self.tr('Algorithm version'),
self.ALG_VERSION)
self.tree.addTopLevelItem(item)
item = TreeDescriptionItem(self.tr('Documentation help URL'),
self.HELP_URL)
self.tree.addTopLevelItem(item)

def changeItem(self):
item = self.tree.currentItem()
Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/models/qgsprocessingmodelalgorithm.cpp
Expand Up @@ -83,7 +83,7 @@ QString QgsProcessingModelAlgorithm::shortDescription() const

QString QgsProcessingModelAlgorithm::helpUrl() const
{
return QString();
return mHelpContent.value( QStringLiteral( "HELP_URL" ) ).toString();
}

QgsProcessingAlgorithm::Flags QgsProcessingModelAlgorithm::flags() const
Expand Down
12 changes: 12 additions & 0 deletions tests/src/analysis/testqgsprocessing.cpp
Expand Up @@ -5661,6 +5661,18 @@ void TestQgsProcessing::modelerAlgorithm()
alg.setGroup( QStringLiteral( "group2" ) );
QCOMPARE( alg.group(), QStringLiteral( "group2" ) );

QVariantMap help;
alg.setHelpContent( help );
QVERIFY( alg.helpContent().isEmpty() );
QVERIFY( alg.helpUrl().isEmpty() );
QVERIFY( alg.shortDescription().isEmpty() );
help.insert( QStringLiteral( "SHORT_DESCRIPTION" ), QStringLiteral( "short" ) );
help.insert( QStringLiteral( "HELP_URL" ), QStringLiteral( "url" ) );
alg.setHelpContent( help );
QCOMPARE( alg.helpContent(), help );
QCOMPARE( alg.shortDescription(), QStringLiteral( "short" ) );
QCOMPARE( alg.helpUrl(), QStringLiteral( "url" ) );

// child algorithms
QMap<QString, QgsProcessingModelChildAlgorithm> algs;
QgsProcessingModelChildAlgorithm a1;
Expand Down

0 comments on commit 844a3fb

Please sign in to comment.