Skip to content

Commit

Permalink
Moved QgsLayerTreeModelLegendNode (+derived classes) to a new file
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 1, 2014
1 parent 6891aae commit 89941f6
Show file tree
Hide file tree
Showing 12 changed files with 701 additions and 650 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -168,6 +168,7 @@
%Include layertree/qgslayertreegroup.sip
%Include layertree/qgslayertreelayer.sip
%Include layertree/qgslayertreemodel.sip
%Include layertree/qgslayertreemodellegendnode.sip
%Include layertree/qgslayertreenode.sip
%Include layertree/qgslayertreeregistrybridge.sip
%Include layertree/qgslayertreeutils.sip
Expand Down
74 changes: 74 additions & 0 deletions python/core/layertree/qgslayertreemodellegendnode.sip
@@ -0,0 +1,74 @@

/**
* The QgsLegendRendererItem class is abstract interface for legend items
* returned from QgsMapLayerLegend implementation.
*
* The objects are used in QgsLayerTreeModel. Custom implementations may offer additional interactivity
* and customized look.
*
* @note added in 2.6
*/
class QgsLayerTreeModelLegendNode : QObject
{
%TypeHeaderCode
#include <qgslayertreemodellegendnode.h>
%End

public:

/** Return pointer to the parent layer node */
QgsLayerTreeLayer* parent() const;

/** Return item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. */
virtual Qt::ItemFlags flags() const;

/** Return data associated with the item. Must be implemented in derived class. */
virtual QVariant data( int role ) const = 0;

/** Set some data associated with the item. Default implementation does nothing and returns false. */
virtual bool setData( const QVariant& value, int role );

protected:
/** Construct the node with pointer to its parent layer node */
explicit QgsLayerTreeModelLegendNode( QgsLayerTreeLayer* nodeL );
};



/**
* Implementation of legend node interface for displaying preview of vector symbols and their labels
* and allowing interaction with the symbol / renderer.
*
* @note added in 2.6
*/
/*
class QgsSymbolV2LegendNode : QgsLayerTreeModelLegendNode
{
%TypeHeaderCode
#include <qgslayertreemodellegendnode.h>
%End
public:
QgsSymbolV2LegendNode( QgsLayerTreeLayer* nodeLayer, const QgsLegendSymbolItemV2& item );

virtual Qt::ItemFlags flags() const;
virtual QVariant data( int role ) const;
virtual bool setData( const QVariant& value, int role );
};*/


/**
* Implementation of legend node interface for displaying arbitrary label with icon.
*
* @note added in 2.6
*/
class QgsSimpleLegendNode : QgsLayerTreeModelLegendNode
{
%TypeHeaderCode
#include <qgslayertreemodellegendnode.h>
%End
public:
QgsSimpleLegendNode( QgsLayerTreeLayer* nodeLayer, const QString& label, const QIcon& icon = QIcon() );

virtual QVariant data( int role ) const;
};

77 changes: 0 additions & 77 deletions python/core/qgsmaplayerlegend.sip
@@ -1,78 +1,4 @@

/**
* The QgsLegendRendererItem class is abstract interface for legend items
* returned from QgsMapLayerLegend implementation.
*
* The objects are used in QgsLayerTreeModel. Custom implementations may offer additional interactivity
* and customized look.
*
* @note added in 2.6
*/
class QgsLayerTreeModelLegendNode : QObject
{
%TypeHeaderCode
#include <qgsmaplayerlegend.h>
%End

public:

/** Return pointer to the parent layer node */
QgsLayerTreeLayer* parent() const;

/** Return item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. */
virtual Qt::ItemFlags flags() const;

/** Return data associated with the item. Must be implemented in derived class. */
virtual QVariant data( int role ) const = 0;

/** Set some data associated with the item. Default implementation does nothing and returns false. */
virtual bool setData( const QVariant& value, int role );

protected:
/** Construct the node with pointer to its parent layer node */
explicit QgsLayerTreeModelLegendNode( QgsLayerTreeLayer* nodeL );
};



/**
* Implementation of legend node interface for displaying preview of vector symbols and their labels
* and allowing interaction with the symbol / renderer.
*
* @note added in 2.6
*/
/*
class QgsSymbolV2LegendNode : QgsLayerTreeModelLegendNode
{
%TypeHeaderCode
#include <qgsmaplayerlegend.h>
%End
public:
QgsSymbolV2LegendNode( QgsLayerTreeLayer* nodeLayer, const QgsLegendSymbolItemV2& item );

virtual Qt::ItemFlags flags() const;
virtual QVariant data( int role ) const;
virtual bool setData( const QVariant& value, int role );
};*/


/**
* Implementation of legend node interface for displaying arbitrary label with icon.
*
* @note added in 2.6
*/
class QgsSimpleLegendNode : QgsLayerTreeModelLegendNode
{
%TypeHeaderCode
#include <qgsmaplayerlegend.h>
%End
public:
QgsSimpleLegendNode( QgsLayerTreeLayer* nodeLayer, const QString& label, const QIcon& icon = QIcon() );

virtual QVariant data( int role ) const;
};


/**
* The QgsMapLayerLegend class is abstract interface for implementations
* of legends for one map layer.
Expand All @@ -98,9 +24,6 @@ class QgsMapLayerLegend : QObject

// TODO: support for layer tree view delegates

// TODO: support for legend renderer


//! Create new legend implementation for vector layer
static QgsMapLayerLegend* defaultVectorLegend( QgsVectorLayer* vl ) /Factory/;

Expand Down
3 changes: 3 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -49,6 +49,7 @@ SET(QGIS_CORE_SRCS
layertree/qgslayertreegroup.cpp
layertree/qgslayertreelayer.cpp
layertree/qgslayertreemodel.cpp
layertree/qgslayertreemodellegendnode.cpp
layertree/qgslayertreenode.cpp
layertree/qgslayertreeregistrybridge.cpp
layertree/qgslayertreeutils.cpp
Expand Down Expand Up @@ -409,6 +410,7 @@ SET(QGIS_CORE_MOC_HDRS
layertree/qgslayertreegroup.h
layertree/qgslayertreelayer.h
layertree/qgslayertreemodel.h
layertree/qgslayertreemodellegendnode.h
layertree/qgslayertreenode.h
layertree/qgslayertreeregistrybridge.h
)
Expand Down Expand Up @@ -639,6 +641,7 @@ SET(QGIS_CORE_HDRS
layertree/qgslayertreegroup.h
layertree/qgslayertreelayer.h
layertree/qgslayertreemodel.h
layertree/qgslayertreemodellegendnode.h
layertree/qgslayertreenode.h
layertree/qgslayertreeregistrybridge.h
layertree/qgslayertreeutils.h
Expand Down
1 change: 1 addition & 0 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -16,6 +16,7 @@
#include "qgslayertreemodel.h"

#include "qgslayertree.h"
#include "qgslayertreemodellegendnode.h"

#include <QMimeData>
#include <QTextStream>
Expand Down

0 comments on commit 89941f6

Please sign in to comment.