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 QgsBrowserDirectoryProperties::setItem( QgsDataItem* item ) { QgsDirectoryItem* directoryItem = qobject_cast<QgsDirectoryItem*>( item ); if ( !item ) return; mPathLabel->setText( directoryItem->dirPath() ); mDirectoryWidget = new QgsDirectoryParamWidget( directoryItem->dirPath(), this ); mLayout->addWidget( mDirectoryWidget ); }
void QgsBrowserDockWidget::addFavorite() { QModelIndex index = mProxyModel->mapToSource( mBrowserView->currentIndex() ); QgsDataItem *item = mModel->dataItem( index ); if ( !item ) return; QgsDirectoryItem *dirItem = dynamic_cast<QgsDirectoryItem *>( item ); if ( !dirItem ) return; addFavoriteDirectory( dirItem->dirPath() ); }
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; }
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" ) ); setupItemConnections( item ); mRootItems << item; // add favorite directories mFavorites = new QgsFavoritesItem( nullptr, tr( "Favorites" ) ); if ( mFavorites ) { setupItemConnections( mFavorites ); mRootItems << mFavorites; } // add drives Q_FOREACH ( const QFileInfo &drive, QDir::drives() ) { const QString path = drive.absolutePath(); if ( QgsDirectoryItem::hiddenPath( path ) ) continue; QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, path, path ); item->setSortKey( QStringLiteral( " 3 %1" ).arg( path ) ); mDriveItems.insert( path, item ); setupItemConnections( item ); mRootItems << item; } #ifdef Q_OS_MAC QString path = QString( "/Volumes" ); QgsDirectoryItem *vols = new QgsDirectoryItem( nullptr, path, path ); mRootItems << vols; #endif // container for displaying providers as sorted groups (by QgsDataProvider::DataCapability enum) QMap<int, QgsDataItem *> providerMap; Q_FOREACH ( QgsDataItemProvider *pr, QgsApplication::dataItemProviderRegistry()->providers() ) { int capabilities = pr->capabilities(); if ( capabilities == QgsDataProvider::NoDataCapabilities ) { QgsDebugMsgLevel( pr->name() + " does not have any dataCapabilities", 4 ); continue; } QgsDataItem *item = pr->createDataItem( QString(), nullptr ); // empty path -> top level if ( item ) { // Forward the signal from the root items to the model (and then to the app) connect( item, &QgsDataItem::connectionsChanged, this, &QgsBrowserModel::connectionsChanged ); QgsDebugMsgLevel( "Add new top level item : " + item->name(), 4 ); setupItemConnections( item ); providerMap.insertMulti( capabilities, item ); } }