Skip to content
Permalink
Browse files

don't show legend checkbox for geometryless layers

git-svn-id: http://svn.osgeo.org/qgis/trunk@14408 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Oct 18, 2010
1 parent 3265dfb commit 920305cbbd90162430fb25358a63eca92b55cf95
Showing with 23 additions and 1 deletion.
  1. +20 −1 src/app/legend/qgslegendlayer.cpp
  2. +3 −0 src/app/legend/qgslegendlayer.h
@@ -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();

@@ -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 );
@@ -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*/

0 comments on commit 920305c

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