Skip to content

Commit 270ac21

Browse files
committed
Fix project home folder in browser always closes all subfolders
when saving a project (cherry-picked from c7421c7)
1 parent f5da529 commit 270ac21

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/core/qgsbrowsermodel.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include "qgsproject.h"
3131
#include "qgssettings.h"
3232

33+
#define PROJECT_HOME_PREFIX "project:"
34+
#define HOME_PREFIX "home:"
35+
3336
QgsBrowserWatcher::QgsBrowserWatcher( QgsDataItem *item )
3437
: QFutureWatcher( nullptr )
3538
, mItem( item )
@@ -56,7 +59,7 @@ QgsBrowserModel::~QgsBrowserModel()
5659
void QgsBrowserModel::updateProjectHome()
5760
{
5861
QString home = QgsProject::instance()->homePath();
59-
if ( mProjectHome && mProjectHome->path() == home )
62+
if ( mProjectHome && mProjectHome->path().mid( QStringLiteral( PROJECT_HOME_PREFIX ).length() ) == home )
6063
return;
6164

6265
int idx = mRootItems.indexOf( mProjectHome );
@@ -69,7 +72,7 @@ void QgsBrowserModel::updateProjectHome()
6972
endRemoveRows();
7073
}
7174
delete mProjectHome;
72-
mProjectHome = home.isNull() ? nullptr : new QgsProjectHomeItem( nullptr, tr( "Project Home" ), home, "project:" + home );
75+
mProjectHome = home.isNull() ? nullptr : new QgsProjectHomeItem( nullptr, tr( "Project Home" ), home, QStringLiteral( PROJECT_HOME_PREFIX ) + home );
7376
if ( mProjectHome )
7477
{
7578
connectItem( mProjectHome );
@@ -85,7 +88,7 @@ void QgsBrowserModel::addRootItems()
8588
updateProjectHome();
8689

8790
// give the home directory a prominent third place
88-
QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, tr( "Home" ), QDir::homePath(), "home:" + QDir::homePath() );
91+
QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, tr( "Home" ), QDir::homePath(), QStringLiteral( HOME_PREFIX ) + QDir::homePath() );
8992
item->setSortKey( QStringLiteral( " 2" ) );
9093
QStyle *style = QApplication::style();
9194
QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) );

0 commit comments

Comments
 (0)