Plugin layers: added support for legend symbology items

This commit is contained in:
Martin Dobias 2013-10-29 10:55:02 +07:00
parent 1ef7553d8d
commit a7409b7405
4 changed files with 28 additions and 0 deletions

View File

@ -12,4 +12,9 @@ class QgsPluginLayer : QgsMapLayer
QString pluginLayerType(); QString pluginLayerType();
void setExtent( const QgsRectangle &extent ); void setExtent( const QgsRectangle &extent );
//! return a list of symbology items for the legend
//! (defult implementation returns nothing)
//! @note Added in v2.1
virtual QgsLegendSymbologyList legendSymbologyItems( const QSize& iconSize );
}; };

View File

@ -22,6 +22,7 @@
#include "qgsfield.h" #include "qgsfield.h"
#include "qgsmapcanvasmap.h" #include "qgsmapcanvasmap.h"
#include "qgsmaplayerregistry.h" #include "qgsmaplayerregistry.h"
#include "qgspluginlayer.h"
#include "qgsrasterlayer.h" #include "qgsrasterlayer.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h" #include "qgsvectordataprovider.h"
@ -142,6 +143,15 @@ void QgsLegendLayer::refreshSymbology( const QString& key )
QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( theMapLayer ); QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( theMapLayer );
rasterLayerSymbology( rlayer ); // get and change symbology rasterLayerSymbology( rlayer ); // get and change symbology
} }
else if ( theMapLayer->type() == QgsMapLayer::PluginLayer )
{
QgsPluginLayer* player = qobject_cast<QgsPluginLayer *>( theMapLayer );
QSize iconSize( 16, 16 );
SymbologyList itemList = player->legendSymbologyItems( iconSize );
changeSymbologySettings( theMapLayer, itemList );
}
updateIcon(); updateIcon();
} }

View File

@ -28,3 +28,9 @@ void QgsPluginLayer::setExtent( const QgsRectangle &extent )
{ {
mExtent = extent; mExtent = extent;
} }
QgsLegendSymbologyList QgsPluginLayer::legendSymbologyItems( const QSize& iconSize )
{
Q_UNUSED( iconSize );
return QgsLegendSymbologyList();
}

View File

@ -17,6 +17,8 @@
#include "qgsmaplayer.h" #include "qgsmaplayer.h"
typedef QList< QPair<QString, QPixmap> > QgsLegendSymbologyList;
/** \ingroup core /** \ingroup core
Base class for plugin layers. These can be implemented by plugins Base class for plugin layers. These can be implemented by plugins
and registered in QgsPluginLayerRegistry. and registered in QgsPluginLayerRegistry.
@ -39,6 +41,11 @@ class CORE_EXPORT QgsPluginLayer : public QgsMapLayer
void setExtent( const QgsRectangle &extent ); void setExtent( const QgsRectangle &extent );
//! return a list of symbology items for the legend
//! (defult implementation returns nothing)
//! @note Added in v2.1
virtual QgsLegendSymbologyList legendSymbologyItems( const QSize& iconSize );
protected: protected:
QString mPluginLayerType; QString mPluginLayerType;
}; };