Skip to content

Commit

Permalink
[browser] Fix some items which are marked as "Collapse" capability
Browse files Browse the repository at this point in the history
are incorrectly expanded on startup
  • Loading branch information
nyalldawson committed Oct 30, 2018
1 parent a873289 commit 5ebb974
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/gui/qgsbrowsertreeview.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
}
}
}
}
Expand Down

0 comments on commit 5ebb974

Please sign in to comment.