Skip to content
Permalink
Browse files

Plugin layers: added support for legend symbology items

  • Loading branch information
wonder-sk committed Oct 29, 2013
1 parent 1ef7553 commit a7409b74058d2823493511ecbd3930198c4ca8ff
Showing with 28 additions and 0 deletions.
  1. +5 −0 python/core/qgspluginlayer.sip
  2. +10 −0 src/app/legend/qgslegendlayer.cpp
  3. +6 −0 src/core/qgspluginlayer.cpp
  4. +7 −0 src/core/qgspluginlayer.h
@@ -12,4 +12,9 @@ class QgsPluginLayer : QgsMapLayer
QString pluginLayerType();

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 );
};
@@ -22,6 +22,7 @@
#include "qgsfield.h"
#include "qgsmapcanvasmap.h"
#include "qgsmaplayerregistry.h"
#include "qgspluginlayer.h"
#include "qgsrasterlayer.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
@@ -142,6 +143,15 @@ void QgsLegendLayer::refreshSymbology( const QString& key )
QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( theMapLayer );
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();
}
@@ -28,3 +28,9 @@ void QgsPluginLayer::setExtent( const QgsRectangle &extent )
{
mExtent = extent;
}

QgsLegendSymbologyList QgsPluginLayer::legendSymbologyItems( const QSize& iconSize )
{
Q_UNUSED( iconSize );
return QgsLegendSymbologyList();
}
@@ -17,6 +17,8 @@

#include "qgsmaplayer.h"

typedef QList< QPair<QString, QPixmap> > QgsLegendSymbologyList;

/** \ingroup core
Base class for plugin layers. These can be implemented by plugins
and registered in QgsPluginLayerRegistry.
@@ -39,6 +41,11 @@ class CORE_EXPORT QgsPluginLayer : public QgsMapLayer

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:
QString mPluginLayerType;
};

0 comments on commit a7409b7

Please sign in to comment.
You can’t perform that action at this time.