Skip to content

Commit

Permalink
don't show legend checkbox for geometryless layers
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14408 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 18, 2010
1 parent 3265dfb commit 920305c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/app/legend/qgslegendlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@ QgsLegendLayer::QgsLegendLayer( QgsMapLayer* layer )
mLyr( layer )
{
mType = LEGEND_LAYER;
setFlags( Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );

Qt::ItemFlags flags = Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if( !vlayer || vlayer->geometryType() != QGis::NoGeometry )
{
flags |= Qt::ItemIsUserCheckable;
}

setFlags( flags );

setCheckState( 0, Qt::Checked );

setText( 0, layer->name() );
setupFont();

Expand Down Expand Up @@ -92,6 +103,14 @@ QgsLegendLayer::~QgsLegendLayer()
mType = LEGEND_LAYER;
}

void QgsLegendLayer::setCheckState( int column, Qt::CheckState state )
{
if( flags() & Qt::ItemIsUserCheckable )
{
QTreeWidgetItem::setCheckState( column, state );
}
}

void QgsLegendLayer::setupFont() //private method
{
QFont myFont = font( 0 );
Expand Down
3 changes: 3 additions & 0 deletions src/app/legend/qgslegendlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class QgsLegendLayer : public QgsLegendItem
the name can be passed to the constructor of QgsLegendLayer*/
static QString nameFromLayer( QgsMapLayer* layer );

/** set check state, but only if user checkable */
void setCheckState( int column, Qt::CheckState state );

public slots:

/**Toggle show in overview*/
Expand Down

0 comments on commit 920305c

Please sign in to comment.