mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Plugin layers: added support for legend symbology items
This commit is contained in:
parent
1ef7553d8d
commit
a7409b7405
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user