Skip to content
Permalink
Browse files

[browser] Fix some items which are marked as "Collapse" capability

are incorrectly expanded on startup
  • Loading branch information
nyalldawson committed Oct 30, 2018
1 parent a873289 commit 5ebb9745694de324f6506d83536f403f6b001b01
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/gui/qgsbrowsertreeview.cpp
@@ -62,15 +62,15 @@ void QgsBrowserTreeView::saveState()
QgsSettings settings;
QStringList expandedPaths = expandedPathsList( QModelIndex() );
settings.setValue( expandedPathsKey(), expandedPaths );
QgsDebugMsgLevel( "expandedPaths = " + expandedPaths.join( " " ), 4 );
QgsDebugMsgLevel( "expandedPaths = " + expandedPaths.join( ' ' ), 4 );
}

void QgsBrowserTreeView::restoreState()
{
QgsSettings settings;
mExpandPaths = settings.value( expandedPathsKey(), QVariant() ).toStringList();

QgsDebugMsgLevel( "mExpandPaths = " + mExpandPaths.join( " " ), 4 );
QgsDebugMsgLevel( "mExpandPaths = " + mExpandPaths.join( ' ' ), 4 );
if ( !mExpandPaths.isEmpty() )
{
QSet<QModelIndex> expandIndexSet;
@@ -167,7 +167,7 @@ void QgsBrowserTreeView::rowsInserted( const QModelIndex &parentIndex, int start
if ( mExpandPaths.isEmpty() )
return;

QgsDebugMsgLevel( "mExpandPaths = " + mExpandPaths.join( "," ), 2 );
QgsDebugMsgLevel( "mExpandPaths = " + mExpandPaths.join( ',' ), 2 );

QString parentPath = model()->data( parentIndex, QgsBrowserModel::PathRole ).toString();
QgsDebugMsgLevel( "parentPath = " + parentPath, 2 );
@@ -197,7 +197,15 @@ void QgsBrowserTreeView::rowsInserted( const QModelIndex &parentIndex, int start
if ( mExpandPaths.contains( childPath ) || mExpandPaths.indexOf( QRegExp( "^" + escapedChildPath + "/.*" ) ) != -1 )
{
QgsDebugMsgLevel( QStringLiteral( "-> expand" ), 2 );
expand( childIndex );
QModelIndex modelIndex = browserModel()->findPath( childPath, Qt::MatchExactly );
if ( modelIndex.isValid() )
{
QgsDataItem *ptr = browserModel()->dataItem( modelIndex );
if ( !ptr || !( ptr->capabilities2() & QgsDataItem::Capability::Collapse ) )
{
expand( childIndex );
}
}
}
}
}

0 comments on commit 5ebb974

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