Skip to content

Commit 40ceb7b

Browse files
committedMar 12, 2018
Don't mark project dirty when legend nodes are expanded/collapsed
1 parent 773ec22 commit 40ceb7b

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed
 

‎python/gui/layertree/qgslayertreeview.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ Returns list of indicators associated with a particular layer tree node.
148148
.. versionadded:: 3.2
149149
%End
150150

151+
152+
151153
public slots:
152154
void refreshLayerSymbology( const QString &layerId );
153155
%Docstring

‎src/app/qgisapp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3238,7 +3238,12 @@ void QgisApp::setupConnections()
32383238
connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::visibilityChanged,
32393239
this, &QgisApp::markDirty );
32403240
connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::customPropertyChanged,
3241-
this, &QgisApp::markDirty );
3241+
this, [ = ]( QgsLayerTreeNode *, const QString & key )
3242+
{
3243+
// only mark dirty for non-view only changes
3244+
if ( !QgsLayerTreeView::viewOnlyCustomProperties().contains( key ) )
3245+
QgisApp::markDirty();
3246+
} );
32423247

32433248
// connect map layer registry
32443249
connect( QgsProject::instance(), &QgsProject::layersAdded,

‎src/gui/layertree/qgslayertreeview.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ QList<QgsLayerTreeViewIndicator *> QgsLayerTreeView::indicators( QgsLayerTreeNod
355355
return mIndicators.value( node );
356356
}
357357

358+
///@cond PRIVATE
359+
QStringList QgsLayerTreeView::viewOnlyCustomProperties()
360+
{
361+
return QStringList() << QStringLiteral( "expandedLegendNodes" );
362+
}
363+
///@endcond
358364

359365
void QgsLayerTreeView::refreshLayerSymbology( const QString &layerId )
360366
{

‎src/gui/layertree/qgslayertreeview.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ class GUI_EXPORT QgsLayerTreeView : public QTreeView
135135
*/
136136
QList<QgsLayerTreeViewIndicator *> indicators( QgsLayerTreeNode *node ) const;
137137

138+
///@cond PRIVATE
139+
140+
/**
141+
* Returns a list of custom property keys which are considered as related to view operations
142+
* only. E.g. node expanded state.
143+
*
144+
* Changes to these keys will not mark a project as "dirty" and trigger unsaved changes
145+
* warnings.
146+
*
147+
* \since QGIS 3.2
148+
*/
149+
static QStringList viewOnlyCustomProperties() SIP_SKIP;
150+
///@endcond
151+
138152
public slots:
139153
//! Force refresh of layer symbology. Normally not needed as the changes of layer's renderer are monitored by the model
140154
void refreshLayerSymbology( const QString &layerId );

0 commit comments

Comments
 (0)
Please sign in to comment.