Skip to content
Permalink
Browse files

Don't mark project dirty when legend nodes are expanded/collapsed

  • Loading branch information
nyalldawson committed Mar 10, 2018
1 parent 773ec22 commit 40ceb7bdcefbaae68ebdc7b97d36f59914582c08
@@ -148,6 +148,8 @@ Returns list of indicators associated with a particular layer tree node.
.. versionadded:: 3.2
%End



public slots:
void refreshLayerSymbology( const QString &layerId );
%Docstring
@@ -3238,7 +3238,12 @@ void QgisApp::setupConnections()
connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::visibilityChanged,
this, &QgisApp::markDirty );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::customPropertyChanged,
this, &QgisApp::markDirty );
this, [ = ]( QgsLayerTreeNode *, const QString & key )
{
// only mark dirty for non-view only changes
if ( !QgsLayerTreeView::viewOnlyCustomProperties().contains( key ) )
QgisApp::markDirty();
} );

// connect map layer registry
connect( QgsProject::instance(), &QgsProject::layersAdded,
@@ -355,6 +355,12 @@ QList<QgsLayerTreeViewIndicator *> QgsLayerTreeView::indicators( QgsLayerTreeNod
return mIndicators.value( node );
}

///@cond PRIVATE
QStringList QgsLayerTreeView::viewOnlyCustomProperties()
{
return QStringList() << QStringLiteral( "expandedLegendNodes" );
}
///@endcond

void QgsLayerTreeView::refreshLayerSymbology( const QString &layerId )
{
@@ -135,6 +135,20 @@ class GUI_EXPORT QgsLayerTreeView : public QTreeView
*/
QList<QgsLayerTreeViewIndicator *> indicators( QgsLayerTreeNode *node ) const;

///@cond PRIVATE

/**
* Returns a list of custom property keys which are considered as related to view operations
* only. E.g. node expanded state.
*
* Changes to these keys will not mark a project as "dirty" and trigger unsaved changes
* warnings.
*
* \since QGIS 3.2
*/
static QStringList viewOnlyCustomProperties() SIP_SKIP;
///@endcond

public slots:
//! Force refresh of layer symbology. Normally not needed as the changes of layer's renderer are monitored by the model
void refreshLayerSymbology( const QString &layerId );

0 comments on commit 40ceb7b

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