@@ -72,6 +72,7 @@ void QgsBrowserModel::updateProjectHome()
7272 mProjectHome = home.isNull () ? nullptr : new QgsDirectoryItem ( nullptr , tr ( " Project home" ), home, " project:" + home );
7373 if ( mProjectHome )
7474 {
75+ mProjectHome ->setSortKey ( QStringLiteral ( " 1" ) );
7576 connectItem ( mProjectHome );
7677
7778 beginInsertRows ( QModelIndex (), 0 , 0 );
@@ -84,8 +85,9 @@ void QgsBrowserModel::addRootItems()
8485{
8586 updateProjectHome ();
8687
87- // give the home directory a prominent second place
88+ // give the home directory a prominent third place
8889 QgsDirectoryItem *item = new QgsDirectoryItem ( nullptr , tr ( " Home" ), QDir::homePath (), " home:" + QDir::homePath () );
90+ item->setSortKey ( QStringLiteral ( " 2" ) );
8991 QStyle *style = QApplication::style ();
9092 QIcon homeIcon ( style->standardPixmap ( QStyle::SP_DirHomeIcon ) );
9193 item->setIcon ( homeIcon );
@@ -109,6 +111,7 @@ void QgsBrowserModel::addRootItems()
109111 continue ;
110112
111113 QgsDirectoryItem *item = new QgsDirectoryItem ( nullptr , path, path );
114+ item->setSortKey ( QStringLiteral ( " 3 %1" ).arg ( path ) );
112115
113116 connectItem ( item );
114117 mRootItems << item;
@@ -212,6 +215,10 @@ QVariant QgsBrowserModel::data( const QModelIndex &index, int role ) const
212215 {
213216 return item->name ();
214217 }
218+ else if ( role == QgsBrowserModel::SortRole )
219+ {
220+ return item->sortKey ();
221+ }
215222 else if ( role == Qt::ToolTipRole )
216223 {
217224 return item->toolTip ();
0 commit comments