Skip to content

Commit

Permalink
More Python wrapper updates + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 1, 2014
1 parent b04199a commit 216ecab
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
33 changes: 32 additions & 1 deletion python/core/composer/qgscomposerlegend.sip
@@ -1,3 +1,25 @@

/** \ingroup MapComposer
* Item model implementation based on layer tree model for composer legend.
* Overrides some functionality of QgsLayerTreeModel to better fit the needs of composer legend.
*
* @note added in 2.6
*/
class QgsLegendModelV2 : QgsLayerTreeModel
{
%TypeHeaderCode
#include <qgscomposerlegend.h>
%End

public:
QgsLegendModelV2( QgsLayerTreeGroup* rootNode, QObject *parent /TransferThis/ = 0 );

QVariant data( const QModelIndex& index, int role ) const;

Qt::ItemFlags flags( const QModelIndex &index ) const;
};


/** \ingroup MapComposer
* A legend that can be placed onto a map composition
*/
Expand Down Expand Up @@ -25,7 +47,16 @@ class QgsComposerLegend : QgsComposerItem
void adjustBoxSize();

/**Returns pointer to the legend model*/
QgsLegendModel* model();
//! @note deprecated in 2.6 - use modelV2()
QgsLegendModel* model() /Deprecated/;

//! @note added in 2.6
QgsLegendModelV2* modelV2();

//! @note added in 2.6
void setAutoUpdateModel( bool autoUpdate );
//! @note added in 2.6
bool autoUpdateModel() const;

//setters and getters
void setTitle( const QString& t );
Expand Down
10 changes: 7 additions & 3 deletions src/core/composer/qgscomposerlegend.h
Expand Up @@ -34,9 +34,12 @@ class QgsLegendRenderer;


/** \ingroup MapComposer
* Item model implementation based on layer tree model for composer legend
* Item model implementation based on layer tree model for composer legend.
* Overrides some functionality of QgsLayerTreeModel to better fit the needs of composer legend.
*
* @note added in 2.6
*/
class QgsLegendModelV2 : public QgsLayerTreeModel
class CORE_EXPORT QgsLegendModelV2 : public QgsLayerTreeModel
{
public:
QgsLegendModelV2( QgsLayerTreeGroup* rootNode, QObject *parent = 0 );
Expand Down Expand Up @@ -71,7 +74,8 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
void adjustBoxSize();

/**Returns pointer to the legend model*/
QgsLegendModel* model() {return &mLegendModel;}
//! @note deprecated in 2.6 - use modelV2()
Q_DECL_DEPRECATED QgsLegendModel* model() {return &mLegendModel;}

//! @note added in 2.6
QgsLegendModelV2* modelV2() { return mLegendModel2; }
Expand Down
7 changes: 3 additions & 4 deletions src/core/qgsmaplayerlegend.cpp
Expand Up @@ -195,7 +195,7 @@ QList<QgsLayerTreeModelLegendNode*> QgsDefaultVectorLayerLegend::createLayerTree
QSettings settings;
if ( settings.value( "/qgis/showLegendClassifiers", false ).toBool() && !r->legendClassificationAttribute().isEmpty() )
{
nodes.append( new QgsSimpleLegendNode( nodeLayer, r->legendClassificationAttribute(), "_class_attribute_" ) );
nodes.append( new QgsSimpleLegendNode( nodeLayer, r->legendClassificationAttribute() ) );
}

foreach ( const QgsLegendSymbolItemV2& i, r->legendSymbolItemsV2() )
Expand Down Expand Up @@ -252,7 +252,7 @@ QList<QgsLayerTreeModelLegendNode*> QgsDefaultRasterLayerLegend::createLayerTree
if ( count == max_count )
{
QString label = tr( "following %1 items\nnot displayed" ).arg( rasterItemList.size() - max_count );
nodes << new QgsSimpleLegendNode( nodeLayer, label, "_more_items_" );
nodes << new QgsSimpleLegendNode( nodeLayer, label );
break;
}
}
Expand All @@ -279,11 +279,10 @@ QList<QgsLayerTreeModelLegendNode*> QgsDefaultPluginLayerLegend::createLayerTree
if ( symbologyList.count() == 0 )
return nodes;

int i = 0;
typedef QPair<QString, QPixmap> XY;
foreach ( XY item, symbologyList )
{
nodes << new QgsSimpleLegendNode( nodeLayer, item.first, QString::number( i++ ), QIcon( item.second ) );
nodes << new QgsSimpleLegendNode( nodeLayer, item.first, QIcon( item.second ) );
}

return nodes;
Expand Down

0 comments on commit 216ecab

Please sign in to comment.