Skip to content
Permalink
Browse files

Fix #10473 (raster preview icons in layer tree view)

  • Loading branch information
wonder-sk committed Jun 9, 2014
1 parent 6a17538 commit 7c0da6d4a528be52a40395259d69a64700b07c59
Showing with 24 additions and 1 deletion.
  1. +11 −0 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgisapp.h
  3. +9 −1 src/gui/layertree/qgslayertreemodel.cpp
  4. +1 −0 src/gui/layertree/qgslayertreemodel.h
@@ -2305,6 +2305,8 @@ void QgisApp::initLayerTreeView()
mLayerTreeView->setModel( model );
mLayerTreeView->setMenuProvider( new QgsAppLayerTreeViewMenuProvider( mLayerTreeView, mMapCanvas ) );

setupLayerTreeViewFromSettings();

connect( mLayerTreeView, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( layerTreeViewDoubleClicked( QModelIndex ) ) );
connect( mLayerTreeView, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( activeLayerChanged( QgsMapLayer* ) ) );
connect( mLayerTreeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( updateNewLayerInsertionPoint() ) );
@@ -2329,6 +2331,13 @@ void QgisApp::initLayerTreeView()
mLayerOrderDock->hide();
}

void QgisApp::setupLayerTreeViewFromSettings()
{
QSettings s;

mLayerTreeView->layerTreeModel()->setFlag( QgsLayerTreeModel::ShowRasterPreviewIcon, s.value( "/qgis/createRasterLegendIcons", false ).toBool() );
}


void QgisApp::updateNewLayerInsertionPoint()
{
@@ -7239,6 +7248,8 @@ void QgisApp::showOptionsDialog( QWidget *parent, QString currentPage )

QgsProject::instance()->layerTreeRegistryBridge()->setNewLayersVisible( mySettings.value( "/qgis/new_layers_visible", true ).toBool() );

setupLayerTreeViewFromSettings();

mMapCanvas->enableAntiAliasing( mySettings.value( "/qgis/enable_anti_aliasing" ).toBool() );

int action = mySettings.value( "/qgis/wheel_action", 2 ).toInt();
@@ -1338,6 +1338,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
/**Removes annotation items in the canvas*/
void removeAnnotationItems();

//! Configure layer tree view according to the user options from QSettings
void setupLayerTreeViewFromSettings();

/// QgisApp aren't copyable
QgisApp( QgisApp const & );
/// QgisApp aren't copyable
@@ -189,7 +189,15 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
if ( !layer )
return QVariant();
if ( layer->type() == QgsMapLayer::RasterLayer )
return QgsLayerItem::iconRaster();
{
if ( testFlag( ShowRasterPreviewIcon ) )
{
QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( layer );
return QIcon( rlayer->previewAsPixmap( QSize( 32, 32 ) ) );
}
else
return QgsLayerItem::iconRaster();
}
else if ( layer->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* vlayer = static_cast<QgsVectorLayer*>( layer );
@@ -89,6 +89,7 @@ class GUI_EXPORT QgsLayerTreeModel : public QAbstractItemModel
{
// display flags
ShowSymbology = 0x0001, //!< Add symbology items for layer nodes
ShowRasterPreviewIcon = 0x0002, //!< Will use real preview of raster layer as icon (may be slow)

// behavioral flags
AllowNodeReorder = 0x1000, //!< Allow reordering with drag'n'drop

0 comments on commit 7c0da6d

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