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 QgsLegendLayerFile::updateLegendItem()
{
  QPixmap pix = legend()->pixmaps().mOriginalPixmap;

  if ( mLyr.isInOverview() )
  {
    //add overview glasses to the pixmap
    QPainter p( &pix );
    p.drawPixmap( 0, 0, legend()->pixmaps().mInOverviewPixmap );
  }
  if ( mLyr.layer()->isEditable() )
  {
    //add editing icon to the pixmap
    QPainter p( &pix );
    p.drawPixmap( 30, 0, legend()->pixmaps().mEditablePixmap );
  }

  /*
  // TODO:
  if(mLyr.layer()->hasProjectionError())
  {
    //add overview glasses to the pixmap
    QPainter p(&pix);
    p.drawPixmap(60,0, legend()->pixmaps().mProjectionErrorPixmap);
  }
  */

  QIcon theIcon( pix );
  setIcon( 0, theIcon );

}
Example #3
0
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 );
  }
}