Skip to content

Commit 15cff4f

Browse files
committedOct 30, 2018
[browser] Fix some items which are marked as "Collapse" capability
are incorrectly expanded on startup (cherry picked from commit 5ebb974)
1 parent c3ddce1 commit 15cff4f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
 

‎src/gui/qgsbrowsertreeview.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ void QgsBrowserTreeView::saveState()
6262
QgsSettings settings;
6363
QStringList expandedPaths = expandedPathsList( QModelIndex() );
6464
settings.setValue( expandedPathsKey(), expandedPaths );
65-
QgsDebugMsgLevel( "expandedPaths = " + expandedPaths.join( " " ), 4 );
65+
QgsDebugMsgLevel( "expandedPaths = " + expandedPaths.join( ' ' ), 4 );
6666
}
6767

6868
void QgsBrowserTreeView::restoreState()
6969
{
7070
QgsSettings settings;
7171
mExpandPaths = settings.value( expandedPathsKey(), QVariant() ).toStringList();
7272

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

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

172172
QString parentPath = model()->data( parentIndex, QgsBrowserModel::PathRole ).toString();
173173
QgsDebugMsgLevel( "parentPath = " + parentPath, 2 );
@@ -197,7 +197,15 @@ void QgsBrowserTreeView::rowsInserted( const QModelIndex &parentIndex, int start
197197
if ( mExpandPaths.contains( childPath ) || mExpandPaths.indexOf( QRegExp( "^" + escapedChildPath + "/.*" ) ) != -1 )
198198
{
199199
QgsDebugMsgLevel( QStringLiteral( "-> expand" ), 2 );
200-
expand( childIndex );
200+
QModelIndex modelIndex = browserModel()->findPath( childPath, Qt::MatchExactly );
201+
if ( modelIndex.isValid() )
202+
{
203+
QgsDataItem *ptr = browserModel()->dataItem( modelIndex );
204+
if ( !ptr || !( ptr->capabilities2() & QgsDataItem::Capability::Collapse ) )
205+
{
206+
expand( childIndex );
207+
}
208+
}
201209
}
202210
}
203211
}

0 commit comments

Comments
 (0)
Please sign in to comment.