Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow processing providers to specify a long name, and show it in too…
…ltips

Add version number to gdal provider long name
  • Loading branch information
nyalldawson committed Oct 19, 2017
1 parent a33376f commit 4ce1662
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
16 changes: 15 additions & 1 deletion python/core/processing/qgsprocessingprovider.sip
Expand Up @@ -56,8 +56,22 @@ class QgsProcessingProvider : QObject

virtual QString name() const = 0;
%Docstring
Returns the full provider name, which is used to describe the provider within the GUI.
Returns the provider name, which is used to describe the provider within the GUI.
This string should be short (e.g. "Lastools") and localised.
.. seealso:: longName()
.. seealso:: id()
:rtype: str
%End

virtual QString longName() const;
%Docstring
Returns the a longer version of the provider name, which can include extra details
such as version numbers. E.g. "Lastools LIDAR tools (version 2.2.1)".
This string should be localised.

The default implementation returns the same string as name().

.. seealso:: name()
.. seealso:: id()
:rtype: str
%End
Expand Down
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py 100644 → 100755
Expand Up @@ -124,6 +124,10 @@ def setActive(self, active):
def name(self):
return 'GDAL'

def longName(self):
version = GdalUtils.readableVersion()
return 'GDAL ({})'.format(version)

def id(self):
return 'gdal'

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/ProcessingToolbox.py 100644 → 100755
Expand Up @@ -454,7 +454,6 @@ def activateProvider():
self.algorithmTree.setItemWidget(parent, 0, label)
else:
parent.setText(0, text)
parent.setToolTip(0, parent.text(0))

for groupItem in list(groups.values()):
parent.addChild(groupItem)
Expand Down Expand Up @@ -512,6 +511,7 @@ def __init__(self, provider, tree, toolbox):
self.provider = provider
self.setIcon(0, self.provider.icon())
self.setData(0, ProcessingToolbox.TYPE_ROLE, ProcessingToolbox.PROVIDER_ITEM)
self.setToolTip(0, self.provider.longName())
self.populate()

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

QString QgsProcessingProvider::longName() const
{
return name();
}

void QgsProcessingProvider::refreshAlgorithms()
{
qDeleteAll( mAlgorithms );
Expand Down
17 changes: 15 additions & 2 deletions src/core/processing/qgsprocessingprovider.h
Expand Up @@ -70,12 +70,25 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
virtual QString id() const = 0;

/**
* Returns the full provider name, which is used to describe the provider within the GUI.
* This string should be localised.
* Returns the provider name, which is used to describe the provider within the GUI.
* This string should be short (e.g. "Lastools") and localised.
* \see longName()
* \see id()
*/
virtual QString name() const = 0;

/**
* Returns the a longer version of the provider name, which can include extra details
* such as version numbers. E.g. "Lastools LIDAR tools (version 2.2.1)".
* This string should be localised.
*
* The default implementation returns the same string as name().
*
* \see name()
* \see id()
*/
virtual QString longName() const;

/**
* Returns true if the provider can be activated, or false if it cannot be activated (e.g. due to
* missing external dependencies).
Expand Down

0 comments on commit 4ce1662

Please sign in to comment.