Skip to content

Commit e592fd5

Browse files
author
wonder
committed
Change layer's icon in legend to reflext that the layer is editable.
Removed duplicate function. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10895 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b4549c7 commit e592fd5

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/app/legend/qgslegend.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
506506
QgsLegendLayer * llayer = new QgsLegendLayer( layer->name() );//generate entry for mStateOfCheckBoxes below
507507
QgsLegendLayerFileGroup * llfgroup = new QgsLegendLayerFileGroup( llayer, QString( "Files" ) );
508508
QgsLegendLayerFile * llfile = new QgsLegendLayerFile( llfgroup, QgsLegendLayerFile::nameFromLayer( layer ), layer );
509-
llayer->setLayerTypeIcon();
509+
llayer->updateIcon();
510510
llayer->setToolTip( 0, layer->publicSource() );
511511

512512
//set the correct check states
@@ -547,6 +547,10 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
547547
setCurrentItem( llayer );
548548
//make the QTreeWidget item up-to-date
549549
doItemsLayout();
550+
551+
// setup connections that will update the layer icons
552+
connect(layer, SIGNAL(editingStarted()), llayer, SLOT(updateIcon()));
553+
connect(layer, SIGNAL(editingStopped()), llayer, SLOT(updateIcon()));
550554
}
551555

552556
QgsLegendLayerFile* QgsLegend::currentLayerFile()
@@ -1086,7 +1090,7 @@ bool QgsLegend::readXML( QDomNode& legendnode )
10861090
//set the layer type icon if this legendlayerfile is the last in the file group
10871091
if ( child.nextSibling().isNull() )
10881092
{
1089-
static_cast<QgsLegendLayer*>( theLegendLayerFile->parent()->parent() )->setLayerTypeIcon();
1093+
static_cast<QgsLegendLayer*>( theLegendLayerFile->parent()->parent() )->updateIcon();
10901094
}
10911095

10921096
theLegendLayerFile->updateLegendItem();

src/app/legend/qgslegendlayer.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ void QgsLegendLayer::setupFont() //private method
8484
myFont.setBold( true ); //visually differentiate layer labels from the rest
8585
setFont( 0, myFont );
8686
}
87-
void QgsLegendLayer::setLayerTypeIcon()
88-
{
89-
QIcon myIcon( getOriginalPixmap() );
90-
setIcon( 0, myIcon );
91-
}
9287

9388
bool QgsLegendLayer::isLeafNode()
9489
{
@@ -407,23 +402,28 @@ void QgsLegendLayer::updateIcon()
407402
if ( mapLayers().size() == 1 )
408403
{
409404
//overview
405+
// FIXME: overview icon is missing
406+
/*
410407
if ( theFile->isInOverview() )
411408
{
412409
// Overlay the overview icon on the default icon
413-
QPixmap myPixmap = QgisApp::getThemePixmap( + "mIconOverview.png" );
410+
QPixmap myPixmap = QgisApp::getThemePixmap( "/mIconOverview.png" );
414411
QPainter p( &newIcon );
415412
p.drawPixmap( 0, 0, myPixmap );
416413
p.end();
417-
}
414+
}*/
418415

419416
//editable
420417
if ( theLayer->isEditable() )
421418
{
419+
QPixmap myPixmap = QgisApp::getThemePixmap( "/mIconEditable.png" );
420+
// use editable icon instead of the layer's type icon
421+
newIcon = myPixmap;
422+
422423
// Overlay the editable icon on the default icon
423-
QPixmap myPixmap = QgisApp::getThemePixmap( + "mIconEditable.png" );
424-
QPainter p( &newIcon );
424+
/*QPainter p( &newIcon );
425425
p.drawPixmap( 0, 0, myPixmap );
426-
p.end();
426+
p.end();*/
427427
}
428428
}
429429

src/app/legend/qgslegendlayer.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class QgsLegendLayer : public QgsLegendItem
4949
QgsLegendLayer( QTreeWidget*, QString );
5050
QgsLegendLayer( QString name );
5151
~QgsLegendLayer();
52-
/**Sets an icon characterising the type of layer(s) it contains.
53-
Note: cannot be in the constructor because layers are added after creation*/
54-
void setLayerTypeIcon();
52+
5553
bool isLeafNode();
5654
QgsLegendItem::DRAG_ACTION accept( LEGEND_ITEM_TYPE type );
5755
QgsLegendItem::DRAG_ACTION accept( const QgsLegendItem* li ) const;
@@ -70,10 +68,6 @@ class QgsLegendLayer : public QgsLegendItem
7068
/**Updates symbology of the layer and copies symbology to other layer files in the group*/
7169
void refreshSymbology( const QString& key, double widthScale = 1.0 );
7270

73-
/**Goes through all the legendlayerfiles and adds editing/overview pixmaps to the icon. If not all layer files
74-
have the same editing/overview state, a tristate is applied*/
75-
void updateIcon();
76-
7771
/** called to add appropriate menu items to legend's popup menu */
7872
void addToPopupMenu( QMenu& theMenu, QAction* toggleEditingAction );
7973

@@ -91,6 +85,10 @@ class QgsLegendLayer : public QgsLegendItem
9185
void saveAsShapefile();
9286
void saveSelectionAsShapefile();
9387

88+
/**Goes through all the legendlayerfiles and adds editing/overview pixmaps to the icon. If not all layer files
89+
have the same editing/overview state, a tristate is applied*/
90+
void updateIcon();
91+
9492
protected:
9593

9694
/** Prepare and change symbology for vector layer */

0 commit comments

Comments
 (0)