Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[needs-docs] Remove option to show raster preview icons in layer tree
This option is not safe - see #16803, and generally undesirable
due to how slow generating the preview icons are
  • Loading branch information
nyalldawson committed Nov 14, 2017
1 parent d839840 commit de7b33a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 45 deletions.
2 changes: 2 additions & 0 deletions doc/api_break.dox
Expand Up @@ -1566,6 +1566,7 @@ QgsLayerTreeModel {#qgis_api_break_3_0_QgsLayerTreeMode}
-----------------

- The ShowSymbology flag was removed. Use ShowLegend instead.
- The ShowRasterPreviewIcon was removed. This is no longer supported.
- The AllowSymbologyChangeState flag was removed. Use AllowLegendChangeState instead.
- legendFilterByMap() was renamed to legendFilterMapSettings()
- isIndexSymbologyNode() was removed. Use index2legendNode() instead.
Expand All @@ -1575,6 +1576,7 @@ QgsLayerTreeModel {#qgis_api_break_3_0_QgsLayerTreeMode}
- autoCollapseSymbologyNodes() was removed. Use autoCollapseLegendNodes() instead.
- the constructor takes a `QgsLayerTree*` instead of a `QgsLayerTreeGroup*`


QgsLayerTreeModelLegendNode {#qgis_api_break_3_0_QgsLayerTreeModelLegendNode}
---------------------------

Expand Down
1 change: 0 additions & 1 deletion python/core/layertree/qgslayertreemodel.sip
Expand Up @@ -77,7 +77,6 @@ class QgsLayerTreeModel : QAbstractItemModel
{
// display
ShowLegend,
ShowRasterPreviewIcon,
ShowLegendAsTree,
DeferredLegendInvalidation,
UseEmbeddedWidgets,
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -3686,8 +3686,6 @@ void QgisApp::setupLayerTreeViewFromSettings()
QgsSettings s;

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

QFont fontLayer, fontGroup;
fontLayer.setBold( true );
fontGroup.setBold( false );
Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsoptions.cpp
Expand Up @@ -673,7 +673,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cbxAddPostgisDC->setChecked( mSettings->value( QStringLiteral( "/qgis/addPostgisDC" ), false ).toBool() );
cbxAddOracleDC->setChecked( mSettings->value( QStringLiteral( "/qgis/addOracleDC" ), false ).toBool() );
cbxCompileExpressions->setChecked( mSettings->value( QStringLiteral( "/qgis/compileExpressions" ), true ).toBool() );
cbxCreateRasterLegendIcons->setChecked( mSettings->value( QStringLiteral( "/qgis/createRasterLegendIcons" ), false ).toBool() );

mComboCopyFeatureFormat->addItem( tr( "Plain text, no geometry" ), QgsClipboard::AttributesOnly );
mComboCopyFeatureFormat->addItem( tr( "Plain text, WKT geometry" ), QgsClipboard::AttributesWithWKT );
Expand Down Expand Up @@ -1283,8 +1282,6 @@ void QgsOptions::saveOptions()
mSettings->setValue( QStringLiteral( "/qgis/addOracleDC" ), cbxAddOracleDC->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/compileExpressions" ), cbxCompileExpressions->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/defaultLegendGraphicResolution" ), mLegendGraphicResolutionSpinBox->value() );
bool createRasterLegendIcons = mSettings->value( QStringLiteral( "/qgis/createRasterLegendIcons" ), false ).toBool();
mSettings->setValue( QStringLiteral( "/qgis/createRasterLegendIcons" ), cbxCreateRasterLegendIcons->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/copyFeatureFormat" ), mComboCopyFeatureFormat->currentData().toInt() );

mSettings->setValue( QStringLiteral( "/qgis/new_layers_visible" ), chkAddedVisibility->isChecked() );
Expand Down Expand Up @@ -1549,8 +1546,7 @@ void QgsOptions::saveOptions()
saveGdalDriverList();

// refresh symbology for any legend items, only if needed
if ( showLegendClassifiers != cbxLegendClassifiers->isChecked()
|| createRasterLegendIcons != cbxCreateRasterLegendIcons->isChecked() )
if ( showLegendClassifiers != cbxLegendClassifiers->isChecked() )
{
// TODO[MD] QgisApp::instance()->legend()->updateLegendItemSymbologies();
}
Expand Down
10 changes: 1 addition & 9 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -195,15 +195,7 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
// icons possibly overriding default icon
if ( layer->type() == QgsMapLayer::RasterLayer )
{
if ( testFlag( ShowRasterPreviewIcon ) )
{
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
return QIcon( QPixmap::fromImage( rlayer->previewAsImage( QSize( 32, 32 ) ) ) );
}
else
{
return QgsLayerItem::iconRaster();
}
return QgsLayerItem::iconRaster();
}

QgsVectorLayer *vlayer = dynamic_cast<QgsVectorLayer *>( layer );
Expand Down
1 change: 0 additions & 1 deletion src/core/layertree/qgslayertreemodel.h
Expand Up @@ -96,7 +96,6 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
{
// display flags
ShowLegend = 0x0001, //!< Add legend nodes for layer nodes
ShowRasterPreviewIcon = 0x0002, //!< Will use real preview of raster layer as icon (may be slow)
ShowLegendAsTree = 0x0004, //!< For legends that support it, will show them in a tree instead of a list (needs also ShowLegend). Added in 2.8
DeferredLegendInvalidation = 0x0008, //!< Defer legend model invalidation
UseEmbeddedWidgets = 0x0010, //!< Layer nodes may optionally include extra embedded widgets (if used in QgsLayerTreeView). Added in 2.16
Expand Down
46 changes: 19 additions & 27 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -2681,8 +2681,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>741</width>
<height>779</height>
<width>269</width>
<height>424</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_46">
Expand Down Expand Up @@ -2991,27 +2991,7 @@
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3" columnminimumwidth="0,1,0">
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="cbxLegendClassifiers">
<property name="text">
<string>Display classification attribute names</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_53">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Legend item styles</string>
</property>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,1,0">
<item row="1" column="0">
<spacer name="horizontalSpacer_34">
<property name="orientation">
Expand All @@ -3028,10 +3008,23 @@
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="cbxCreateRasterLegendIcons">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_53">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Legend item styles</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="cbxLegendClassifiers">
<property name="text">
<string>Create raster icons (may be slow)</string>
<string>Display classification attribute names</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -5526,7 +5519,6 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<tabstop>mLegendGrpBx</tabstop>
<tabstop>cmbLegendDoubleClickAction</tabstop>
<tabstop>cbxLegendClassifiers</tabstop>
<tabstop>cbxCreateRasterLegendIcons</tabstop>
<tabstop>mLegendGraphicResolutionSpinBox</tabstop>
<tabstop>mOptionsScrollArea_05</tabstop>
<tabstop>mIdentifyGroupBox</tabstop>
Expand Down

0 comments on commit de7b33a

Please sign in to comment.