void QgsBrowserModel::addRootItems() { updateProjectHome(); // give the home directory a prominent second place QgsDirectoryItem *item = new QgsDirectoryItem( NULL, tr( "Home" ), QDir::homePath(), "home:" + QDir::homePath() ); QStyle *style = QApplication::style(); QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) ); item->setIcon( homeIcon ); connectItem( item ); mRootItems << item; // add favourite directories mFavourites = new QgsFavouritesItem( NULL, tr( "Favourites" ) ); if ( mFavourites ) { connectItem( mFavourites ); mRootItems << mFavourites; } // add drives foreach ( QFileInfo drive, QDir::drives() ) { QString path = drive.absolutePath(); QgsDirectoryItem *item = new QgsDirectoryItem( NULL, path, path ); connectItem( item ); mRootItems << item; }
void QgsBrowserModel::addRootItems() { updateProjectHome(); // give the home directory a prominent third place QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, tr( "Home" ), QDir::homePath(), QStringLiteral( HOME_PREFIX ) + QDir::homePath() ); item->setSortKey( QStringLiteral( " 2" ) ); QStyle *style = QApplication::style(); QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) ); item->setIcon( homeIcon ); connectItem( item ); mRootItems << item; // add favorite directories mFavorites = new QgsFavoritesItem( nullptr, tr( "Favorites" ) ); if ( mFavorites ) { connectItem( mFavorites ); mRootItems << mFavorites; } // add drives Q_FOREACH ( const QFileInfo &drive, QDir::drives() ) { QString path = drive.absolutePath(); if ( QgsDirectoryItem::hiddenPath( path ) ) continue; QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, path, path ); item->setSortKey( QStringLiteral( " 3 %1" ).arg( path ) ); connectItem( item ); mRootItems << item; }
void QgsBrowserModel::addRootItems() { // give the home directory a prominent first place QgsDirectoryItem *item = new QgsDirectoryItem( NULL, tr( "Home" ), QDir::homePath() ); QStyle *style = QApplication::style(); QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) ); item->setIcon( homeIcon ); connectItem( item ); mRootItems << item; // add favourite directories QSettings settings; QStringList favDirs = settings.value( "/browser/favourites", QVariant() ).toStringList(); foreach( QString favDir, favDirs ) { QgsDirectoryItem *item = new QgsDirectoryItem( NULL, favDir, favDir ); connectItem( item ); mRootItems << item; }