Skip to content
Permalink
Browse files

More Python wrapper updates + fixes

  • Loading branch information
wonder-sk committed Aug 22, 2014
1 parent b04199a commit 216ecab1fc3011a12aa17b2be41a069cdd907f77
@@ -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
*/
@@ -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 );
@@ -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 );
@@ -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; }
@@ -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() )
@@ -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;
}
}
@@ -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;

0 comments on commit 216ecab

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