Skip to content
Permalink
Browse files

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
  • Loading branch information
wonder
wonder committed Jun 9, 2009
1 parent b4549c7 commit e592fd5eeef4695afd0d1ccdf5d913f03803b109
Showing with 21 additions and 19 deletions.
  1. +6 −2 src/app/legend/qgslegend.cpp
  2. +10 −10 src/app/legend/qgslegendlayer.cpp
  3. +5 −7 src/app/legend/qgslegendlayer.h
@@ -506,7 +506,7 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
QgsLegendLayer * llayer = new QgsLegendLayer( layer->name() );//generate entry for mStateOfCheckBoxes below
QgsLegendLayerFileGroup * llfgroup = new QgsLegendLayerFileGroup( llayer, QString( "Files" ) );
QgsLegendLayerFile * llfile = new QgsLegendLayerFile( llfgroup, QgsLegendLayerFile::nameFromLayer( layer ), layer );
llayer->setLayerTypeIcon();
llayer->updateIcon();
llayer->setToolTip( 0, layer->publicSource() );

//set the correct check states
@@ -547,6 +547,10 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
setCurrentItem( llayer );
//make the QTreeWidget item up-to-date
doItemsLayout();

// setup connections that will update the layer icons
connect(layer, SIGNAL(editingStarted()), llayer, SLOT(updateIcon()));
connect(layer, SIGNAL(editingStopped()), llayer, SLOT(updateIcon()));
}

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

theLegendLayerFile->updateLegendItem();
@@ -84,11 +84,6 @@ void QgsLegendLayer::setupFont() //private method
myFont.setBold( true ); //visually differentiate layer labels from the rest
setFont( 0, myFont );
}
void QgsLegendLayer::setLayerTypeIcon()
{
QIcon myIcon( getOriginalPixmap() );
setIcon( 0, myIcon );
}

bool QgsLegendLayer::isLeafNode()
{
@@ -407,23 +402,28 @@ void QgsLegendLayer::updateIcon()
if ( mapLayers().size() == 1 )
{
//overview
// FIXME: overview icon is missing
/*
if ( theFile->isInOverview() )
{
// Overlay the overview icon on the default icon
QPixmap myPixmap = QgisApp::getThemePixmap( + "mIconOverview.png" );
QPixmap myPixmap = QgisApp::getThemePixmap( "/mIconOverview.png" );
QPainter p( &newIcon );
p.drawPixmap( 0, 0, myPixmap );
p.end();
}
}*/

//editable
if ( theLayer->isEditable() )
{
QPixmap myPixmap = QgisApp::getThemePixmap( "/mIconEditable.png" );
// use editable icon instead of the layer's type icon
newIcon = myPixmap;

// Overlay the editable icon on the default icon
QPixmap myPixmap = QgisApp::getThemePixmap( + "mIconEditable.png" );
QPainter p( &newIcon );
/*QPainter p( &newIcon );
p.drawPixmap( 0, 0, myPixmap );
p.end();
p.end();*/
}
}

@@ -49,9 +49,7 @@ class QgsLegendLayer : public QgsLegendItem
QgsLegendLayer( QTreeWidget*, QString );
QgsLegendLayer( QString name );
~QgsLegendLayer();
/**Sets an icon characterising the type of layer(s) it contains.
Note: cannot be in the constructor because layers are added after creation*/
void setLayerTypeIcon();

bool isLeafNode();
QgsLegendItem::DRAG_ACTION accept( LEGEND_ITEM_TYPE type );
QgsLegendItem::DRAG_ACTION accept( const QgsLegendItem* li ) const;
@@ -70,10 +68,6 @@ class QgsLegendLayer : public QgsLegendItem
/**Updates symbology of the layer and copies symbology to other layer files in the group*/
void refreshSymbology( const QString& key, double widthScale = 1.0 );

/**Goes through all the legendlayerfiles and adds editing/overview pixmaps to the icon. If not all layer files
have the same editing/overview state, a tristate is applied*/
void updateIcon();

/** called to add appropriate menu items to legend's popup menu */
void addToPopupMenu( QMenu& theMenu, QAction* toggleEditingAction );

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

/**Goes through all the legendlayerfiles and adds editing/overview pixmaps to the icon. If not all layer files
have the same editing/overview state, a tristate is applied*/
void updateIcon();

protected:

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

0 comments on commit e592fd5

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