void QgsLegendLayerFile::setIconAppearance( bool isInOverview, bool editable ) { QPixmap newIcon( getOriginalPixmap() ); if ( isInOverview ) { // Overlay the overview icon on the default icon QPixmap myPixmap = QgisApp::getThemePixmap( "mIconOverview.png" ); QPainter p( &newIcon ); p.drawPixmap( 0, 0, myPixmap ); p.end(); } if ( editable ) { // Overlay the editable icon on the default icon QPixmap myPixmap = QgisApp::getThemePixmap( "mIconEditable.png" ); QPainter p( &newIcon ); p.drawPixmap( 0, 0, myPixmap ); p.end(); } QIcon theIcon( newIcon ); setIcon( 0, theIcon ); //also update the icon of the legend layer (( QgsLegendLayer* )( parent()->parent() ) )->updateIcon(); }
void QgsLegendLayer::updateIcon() { QPixmap newIcon( getOriginalPixmap() ); QgsMapLayer* theLayer = layer(); //overview // FIXME: overview icon is missing /* if ( theFile->isInOverview() ) { // Overlay the overview icon on the default icon QPixmap myPixmap = QgsApplication::getThemePixmap( "/mIconOverview.png" ); QPainter p( &newIcon ); p.drawPixmap( 0, 0, myPixmap ); p.end(); }*/ //editable if ( theLayer->isEditable() ) { QPixmap myPixmap; QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( theLayer ); if ( vlayer->isModified() ) { myPixmap = QgsApplication::getThemePixmap( "/mIconEditableEdits.png" ); } else { myPixmap = QgsApplication::getThemePixmap( "/mIconEditable.png" ); } // use editable icon instead of the layer's type icon newIcon = myPixmap; // Overlay the editable icon on the default icon /*QPainter p( &newIcon ); p.drawPixmap( 0, 0, myPixmap ); p.end();*/ } // TODO: projection error icon? QIcon theIcon( newIcon ); QgsLegend* l = legend(); if ( l ) { l->blockSignals( true ); //prevent unnecessary canvas redraw } setIcon( 0, theIcon ); if ( l ) { l->blockSignals( false ); } }