mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add new plugin metadata string to indicate whether a plugin
implements Processing providers Plugins which implement providers should include the hasProcessingProvider=yes line within their metadata.txt file. This allows for rapid identification of all plugins which implement Processing functionality.
This commit is contained in:
parent
2f82bab1d9
commit
558d5365b5
@ -14,3 +14,5 @@ icon=:/images/themes/default/processingAlgorithm.svg
|
||||
homepage=http://qgis.org
|
||||
tracker=https://issues.qgis.org/projects/qgis/issues
|
||||
repository=https://github.com/qgis/QGIS
|
||||
|
||||
hasProcessingProvider=yes
|
@ -167,6 +167,7 @@ class PYTHON_EXPORT QgsPythonUtils
|
||||
* This command adds a plugin to active plugins and calls initProcessing(),
|
||||
* initializing only Processing related components of that plugin.
|
||||
*
|
||||
* \see pluginHasProcessingProvider()
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
virtual bool startProcessingPlugin( const QString &packageName ) = 0;
|
||||
@ -174,10 +175,20 @@ class PYTHON_EXPORT QgsPythonUtils
|
||||
/**
|
||||
* Helper function to return some information about a plugin.
|
||||
*
|
||||
* \param function metadata component to return. Must match one of the strings: name, type, version, or description.
|
||||
* \param function metadata component to return. Must match one of the strings: name, type, version, description, hasProcessingProvider.
|
||||
*/
|
||||
virtual QString getPluginMetadata( const QString &pluginName, const QString &function ) = 0;
|
||||
|
||||
/**
|
||||
* Returns TRUE if a plugin implements a Processing provider.
|
||||
*
|
||||
* This is determined by checking the plugin metadata for the "hasProcessingProvider=yes" line.
|
||||
*
|
||||
* \see startProcessingPlugin()
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
virtual bool pluginHasProcessingProvider( const QString &pluginName ) = 0;
|
||||
|
||||
/**
|
||||
* Confirms that the plugin can be uninstalled.
|
||||
*/
|
||||
|
@ -609,6 +609,11 @@ QString QgsPythonUtilsImpl::getPluginMetadata( const QString &pluginName, const
|
||||
return res;
|
||||
}
|
||||
|
||||
bool QgsPythonUtilsImpl::pluginHasProcessingProvider( const QString &pluginName )
|
||||
{
|
||||
return getPluginMetadata( pluginName, QStringLiteral( "hasProcessingProvider" ) ).compare( QLatin1String( "yes" ), Qt::CaseInsensitive ) == 0;
|
||||
}
|
||||
|
||||
bool QgsPythonUtilsImpl::loadPlugin( const QString &packageName )
|
||||
{
|
||||
QString output;
|
||||
|
@ -87,6 +87,7 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
|
||||
bool startPlugin( const QString &packageName ) override;
|
||||
bool startProcessingPlugin( const QString &packageName ) override;
|
||||
QString getPluginMetadata( const QString &pluginName, const QString &function ) override;
|
||||
bool pluginHasProcessingProvider( const QString &pluginName ) override;
|
||||
bool canUninstallPlugin( const QString &packageName ) override;
|
||||
bool unloadPlugin( const QString &packageName ) override;
|
||||
bool isPluginEnabled( const QString &packageName ) const override;
|
||||
|
@ -43,6 +43,7 @@ class TestQgisAppPython : public QObject
|
||||
void hasPython();
|
||||
void plugins();
|
||||
void pythonPlugin();
|
||||
void pluginMetadata();
|
||||
void runString();
|
||||
void evalString();
|
||||
|
||||
@ -105,6 +106,25 @@ void TestQgisAppPython::pythonPlugin()
|
||||
QVERIFY( !mQgisApp->mPythonUtils->startProcessingPlugin( QStringLiteral( "PluginPathTest" ) ) );
|
||||
}
|
||||
|
||||
void TestQgisAppPython::pluginMetadata()
|
||||
{
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "not a plugin" ), QStringLiteral( "name" ) ), QStringLiteral( "__error__" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "invalid" ) ), QStringLiteral( "__error__" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "name" ) ), QStringLiteral( "plugin path test" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "qgisMinimumVersion" ) ), QStringLiteral( "2.0" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "description" ) ), QStringLiteral( "desc" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "version" ) ), QStringLiteral( "0.1" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "author" ) ), QStringLiteral( "HM/Oslandia" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "email" ) ), QStringLiteral( "hugo.mercier@oslandia.com" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "PluginPathTest" ), QStringLiteral( "hasProcessingProvider" ) ), QStringLiteral( "__error__" ) );
|
||||
QVERIFY( !mQgisApp->mPythonUtils->pluginHasProcessingProvider( QStringLiteral( "x" ) ) );
|
||||
QVERIFY( !mQgisApp->mPythonUtils->pluginHasProcessingProvider( QStringLiteral( "PluginPathTest" ) ) );
|
||||
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "ProcessingPluginTest" ), QStringLiteral( "name" ) ), QStringLiteral( "processing plugin test" ) );
|
||||
QCOMPARE( mQgisApp->mPythonUtils->getPluginMetadata( QStringLiteral( "ProcessingPluginTest" ), QStringLiteral( "hasProcessingProvider" ) ), QStringLiteral( "yes" ) );
|
||||
QVERIFY( mQgisApp->mPythonUtils->pluginHasProcessingProvider( QStringLiteral( "ProcessingPluginTest" ) ) );
|
||||
}
|
||||
|
||||
void TestQgisAppPython::runString()
|
||||
{
|
||||
QVERIFY( mQgisApp->mPythonUtils->runString( "a=1+1" ) );
|
||||
|
@ -1,7 +1,7 @@
|
||||
[general]
|
||||
name=plugin path test
|
||||
qgisMinimumVersion=2.0
|
||||
name=processing plugin test
|
||||
qgisMinimumVersion=3.8
|
||||
description=desc
|
||||
version=0.1
|
||||
author=HM/Oslandia
|
||||
email=hugo.mercier@oslandia.com
|
||||
author=matt cauthin
|
||||
hasProcessingProvider=yes
|
||||
|
Loading…
x
Reference in New Issue
Block a user