18 #include <QApplication> 19 #include <QtConcurrentMap> 20 #include <QtConcurrentRun> 25 #include <QMouseEvent> 26 #include <QTreeWidget> 27 #include <QTreeWidgetItem> 40 #include "qgsconfig.h" 47 #define CPL_SUPRESS_CPLUSPLUS //#spellok 49 #include "cpl_string.h" 114 return QStringLiteral(
" 0" );
132 , mDeferredDelete( false )
133 , mFutureWatcher( nullptr )
148 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
151 QgsDebugMsg( QStringLiteral(
"mFutureWatcher not finished (should not happen) -> waitForFinished()" ) );
152 mDeferredDelete =
true;
153 mFutureWatcher->waitForFinished();
156 delete mFutureWatcher;
161 return QString(
string ).replace( QRegExp(
"[\\\\/]" ), QStringLiteral(
"|" ) );
186 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
188 QgsDebugMsg( QStringLiteral(
"mFutureWatcher not finished -> schedule to delete later" ) );
189 mDeferredDelete =
true;
193 QObject::deleteLater();
216 child->QObject::setParent(
nullptr );
219 QObject::moveToThread( targetThread );
225 return sPopulatingIcon->
icon();
227 if ( !
mIcon.isNull() )
246 return QVector<QgsDataItem *>();
264 if ( !mFutureWatcher )
266 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
270 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
275 QVector<QgsDataItem *> QgsDataItem::runCreateChildren(
QgsDataItem *item )
281 QgsDebugMsgLevel( QStringLiteral(
"%1 children created in %2 ms" ).arg( children.size() ).arg( time.elapsed() ), 3 );
291 QgsDebugMsgLevel( QStringLiteral(
"finished path %1: %2 children" ).arg( item->
path() ).arg( children.size() ), 3 );
297 QgsDebugMsgLevel( QStringLiteral(
"path = %1 children.size() = %2" ).arg(
path() ).arg( mFutureWatcher->result().size() ), 3 );
301 QgsDebugMsg( QStringLiteral(
"Item was scheduled to be deleted later" ) );
302 QObject::deleteLater();
308 populate( mFutureWatcher->result() );
312 refresh( mFutureWatcher->result() );
364 if ( !mFutureWatcher )
366 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
369 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
392 QVector<QgsDataItem *>
remove;
397 if (
findItem( children, child ) >= 0 )
399 remove.append( child );
444 disconnect(
this,
nullptr,
mParent,
nullptr );
479 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
524 for (
int i = 0; i < items.size(); i++ )
526 Q_ASSERT_X( items[i],
"findItem", QStringLiteral(
"item %1 is nullptr" ).arg( i ).toLatin1() );
528 if ( items[i]->
equal( item ) )
536 return ( metaObject()->className() == other->metaObject()->className() &&
543 return QList<QAction *>();
571 if ( !sPopulatingIcon )
595 return QList<QMenu *>();
602 , mProviderKey( providerKey )
604 , mLayerType( layerType )
638 switch ( layer->
type() )
642 switch ( qobject_cast< QgsVectorLayer * >( layer )->geometryType() )
675 static int enumIdx = staticMetaObject.indexOfEnumerator(
"LayerType" );
676 return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
684 return QStringLiteral(
"/mIconPointLayer.svg" );
686 return QStringLiteral(
"/mIconLineLayer.svg" );
688 return QStringLiteral(
"/mIconPolygonLayer.svg" );
691 return QStringLiteral(
"/mIconVector.svg" );
694 return QStringLiteral(
"/mIconTableLayer.svg" );
696 return QStringLiteral(
"/mIconRaster.svg" );
698 return QStringLiteral(
"/mIconMeshLayer.svg" );
700 return QStringLiteral(
"/mIconLayer.png" );
731 u.
layerType = QStringLiteral(
"vector" );
734 u.
layerType = QStringLiteral(
"raster" );
740 u.
layerType = QStringLiteral(
"plugin" );
757 mIconName = QStringLiteral(
"/mIconDbSchema.svg" );
768 QgsDebugMsgLevel( QStringLiteral(
"delete child = 0x%0" ).arg( static_cast<qlonglong>( i ), 8, 16, QLatin1Char(
'0' ) ), 2 );
779 , mRefreshLater( false )
788 , mRefreshLater( false )
810 if ( fi.isDir() && fi.isSymLink() )
831 QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
832 Q_FOREACH (
const QString &subdir, entries )
840 QString subdirPath = dir.absoluteFilePath( subdir );
842 QgsDebugMsgLevel( QStringLiteral(
"creating subdir: %1" ).arg( subdirPath ), 2 );
848 bool handledByProvider =
false;
851 if ( provider->handlesDirectoryPath( path ) )
853 handledByProvider =
true;
857 if ( handledByProvider )
863 item->
setSortKey( QStringLiteral(
" %1" ).arg( subdir ) );
867 children.append( item );
870 QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
871 Q_FOREACH (
const QString &
name, fileEntries )
879 QString
path = dir.absoluteFilePath( name );
880 QFileInfo fileInfo( path );
882 if ( fileInfo.suffix().compare( QLatin1String(
"zip" ), Qt::CaseInsensitive ) == 0 ||
883 fileInfo.suffix().compare( QLatin1String(
"tar" ), Qt::CaseInsensitive ) == 0 )
888 children.append( item );
893 bool createdItem =
false;
896 int capabilities = provider->capabilities();
904 QgsDataItem *item = provider->createDataItem( path,
this );
907 children.append( item );
916 if ( fileInfo.suffix().compare( QLatin1String(
"qgs" ), Qt::CaseInsensitive ) == 0 ||
917 fileInfo.suffix().compare( QLatin1String(
"qgz" ), Qt::CaseInsensitive ) == 0 )
920 children.append( item );
935 if ( !mFileSystemWatcher )
937 mFileSystemWatcher =
new QFileSystemWatcher(
this );
938 mFileSystemWatcher->addPath(
mDirPath );
941 mLastScan = QDateTime::currentDateTime();
945 if ( mFileSystemWatcher )
947 delete mFileSystemWatcher;
948 mFileSystemWatcher =
nullptr;
956 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) <
QgsSettings().
value( QStringLiteral(
"browser/minscaninterval" ), 10000 ).toInt() )
963 mRefreshLater =
true;
977 QTimer::singleShot( 100,
this, [ = ] {
refresh(); } );
984 QStringList hiddenItems = settings.
value( QStringLiteral(
"browser/hiddenPaths" ),
985 QStringList() ).toStringList();
986 int idx = hiddenItems.indexOf( path );
992 QgsDebugMsgLevel( QStringLiteral(
"mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
996 QgsDebugMsgLevel( QStringLiteral(
"directory changed during createChidren() -> refresh() again" ), 3 );
997 mRefreshLater =
false;
1016 return (
path() == other->
path() );
1027 u.
layerType = QStringLiteral(
"directory" );
1034 : QTreeWidget( parent )
1036 setRootIsDecorated(
false );
1039 setColumnCount( 7 );
1041 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1042 setHeaderLabels( labels );
1049 QList<QTreeWidgetItem *> items;
1052 QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
1053 Q_FOREACH (
const QString &name, entries )
1055 QFileInfo fi( dir.absoluteFilePath( name ) );
1059 if ( fi.size() > 1024 )
1061 size = size.sprintf(
"%.1f KiB", fi.size() / 1024.0 );
1063 else if ( fi.size() > 1.048576e6 )
1065 size = size.sprintf(
"%.1f MiB", fi.size() / 1.048576e6 );
1069 size = QStringLiteral(
"%1 B" ).arg( fi.size() );
1072 texts << fi.lastModified().toString( Qt::SystemLocaleShortDate );
1074 perm += fi.permission( QFile::ReadOwner ) ?
'r' :
'-';
1075 perm += fi.permission( QFile::WriteOwner ) ?
'w' :
'-';
1076 perm += fi.permission( QFile::ExeOwner ) ?
'x' :
'-';
1078 perm += fi.permission( QFile::ReadGroup ) ?
'r' :
'-';
1079 perm += fi.permission( QFile::WriteGroup ) ?
'w' :
'-';
1080 perm += fi.permission( QFile::ExeGroup ) ?
'x' :
'-';
1081 perm += fi.permission( QFile::ReadOther ) ?
'r' :
'-';
1082 perm += fi.permission( QFile::WriteOther ) ?
'w' :
'-';
1083 perm += fi.permission( QFile::ExeOther ) ?
'x' :
'-';
1086 texts << fi.owner();
1087 texts << fi.group();
1091 if ( fi.isDir() && fi.isSymLink() )
1093 type = tr(
"folder" );
1096 else if ( fi.isDir() )
1098 type = tr(
"folder" );
1099 icon = iconDirectory;
1101 else if ( fi.isFile() && fi.isSymLink() )
1103 type = tr(
"file" );
1104 icon = iconFileLink;
1106 else if ( fi.isFile() )
1108 type = tr(
"file" );
1114 QTreeWidgetItem *item =
new QTreeWidgetItem( texts );
1115 item->setIcon( 0, icon );
1119 addTopLevelItems( items );
1123 QList<QVariant> lst = settings.
value( QStringLiteral(
"dataitem/directoryHiddenColumns" ) ).toList();
1124 Q_FOREACH (
const QVariant &colVariant, lst )
1126 setColumnHidden( colVariant.toInt(), true );
1132 if ( event->button() == Qt::RightButton )
1138 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1139 for (
int i = 0; i < labels.count(); i++ )
1142 action->setObjectName( QString::number( i ) );
1143 action->setCheckable(
true );
1144 action->setChecked( !isColumnHidden( i ) );
1147 popupMenu.exec( event->globalPos() );
1153 QAction *action = qobject_cast<QAction *>( sender() );
1157 int columnIndex = action->objectName().toInt();
1158 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
1162 QList<QVariant> lst;
1163 for (
int i = 0; i < columnCount(); i++ )
1165 if ( isColumnHidden( i ) )
1166 lst.append( QVariant( i ) );
1168 settings.
setValue( QStringLiteral(
"dataitem/directoryHiddenColumns" ), lst );
1174 mIconName = QStringLiteral(
":/images/icons/qgis_icon.svg" );
1175 setToolTip( QDir::toNativeSeparators( path ) );
1182 u.
layerType = QStringLiteral(
"project" );
1191 mIconName = QStringLiteral(
"/mIconDelete.svg" );
1202 mIconName = QStringLiteral(
"/mIconFavourites.svg" );
1211 const QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ), QVariant() ).toStringList();
1213 for (
const QString &favDir : favDirs )
1215 QStringList parts = favDir.split( QStringLiteral(
"|||" ) );
1216 if ( parts.empty() )
1219 QString dir = parts.at( 0 );
1221 if ( parts.count() > 1 )
1222 name = parts.at( 1 );
1232 QString
name = n.isEmpty() ? favDir : n;
1235 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1236 favDirs.append( QStringLiteral(
"%1|||%2" ).arg( favDir, name ) );
1237 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1255 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1256 for (
int i = favDirs.count() - 1; i >= 0; --i )
1258 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1259 if ( parts.empty() )
1262 QString dir = parts.at( 0 );
1264 favDirs.removeAt( i );
1266 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1271 QgsDebugMsg( QStringLiteral(
"favorites item %1 not found" ).arg( item->
path() ) );
1283 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1284 for (
int i = 0; i < favDirs.count(); ++i )
1286 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1287 if ( parts.empty() )
1290 QString dir = parts.at( 0 );
1293 favDirs[i] = QStringLiteral(
"%1|||%2" ).arg( path, name );
1297 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1300 const QVector<QgsDataItem *> ch =
children();
1303 if ( QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( child ) )
1305 if ( favorite->dirPath() ==
path )
1307 favorite->setName( name );
1328 children.append( item );
1332 if ( children.isEmpty() )
1334 QgsFavoriteItem *item =
new QgsFavoriteItem(
this, name, favDir,
mPath +
'/' + pathName );
1337 children.append( item );
1361 void QgsZipItem::init()
1364 mIconName = QStringLiteral(
"/mIconZip.svg" );
1367 static std::once_flag initialized;
1368 std::call_once( initialized, [ = ]
1370 sProviderNames << QStringLiteral(
"OGR" ) << QStringLiteral(
"GDAL" );
1379 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1386 if ( scanZipSetting == QLatin1String(
"no" ) )
1399 QFileInfo info( fileName );
1409 if ( provider->name() == QStringLiteral(
"OGR" ) )
1411 if ( info.suffix().compare( QLatin1String(
"dbf" ), Qt::CaseInsensitive ) == 0 )
1413 if (
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) +
".shp" ) != -1 )
1416 if ( info.completeSuffix().compare( QLatin1String(
"shp.xml" ), Qt::CaseInsensitive ) == 0 )
1422 QgsDebugMsgLevel( QStringLiteral(
"trying to load item %1 with %2" ).arg( tmpPath, provider->name() ), 3 );
1423 QgsDataItem *item = provider->createDataItem( tmpPath,
this );
1428 children.append( item );
1448 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1449 QStringList zipFileList;
1452 bool populated =
false;
1454 QgsDebugMsgLevel( QStringLiteral(
"path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path, name, scanZipSetting, vsiPrefix ), 3 );
1457 if ( scanZipSetting == QLatin1String(
"no" ) )
1461 if ( ( vsiPrefix != QLatin1String(
"/vsizip/" ) && vsiPrefix != QLatin1String(
"/vsitar/" ) ) )
1464 zipItem =
new QgsZipItem( parent, name, filePath, path );
1474 if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) ||
1475 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) )
1480 if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
1484 QgsDebugMsgLevel( QStringLiteral(
"Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->
rowCount() ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1488 QgsDebugMsgLevel( QStringLiteral(
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1493 if ( zipItem && ( !populated || zipItem->
rowCount() > 0 ) )
1509 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1514 if ( scanZipSetting == QLatin1String(
"no" ) )
1521 char **papszSiblingFiles = VSIReadDirRecursive( QString(
mVsiPrefix +
mFilePath ).toLocal8Bit().constData() );
1522 if ( papszSiblingFiles )
1524 for (
int i = 0; papszSiblingFiles[i]; i++ )
1526 tmpPath = papszSiblingFiles[i];
1529 if ( tmpPath.right( 1 ) != QLatin1String(
"/" ) )
1532 CSLDestroy( papszSiblingFiles );
1544 QgsProjectHomeItem::QgsProjectHomeItem(
QgsDataItem *
parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1549 QIcon QgsProjectHomeItem::icon()
1556 QVariant QgsProjectHomeItem::sortKey()
const 1558 return QStringLiteral(
" 1" );
1562 QgsFavoriteItem::QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1564 , mFavorites( parent )
1569 bool QgsFavoriteItem::rename(
const QString &
name )
1571 mFavorites->renameFavorite( dirPath(), name );
A Collection: logical collection of layers or subcollections, e.g.
QString layerType
Type of URI.
virtual QList< QMenu * > menus(QWidget *parent)
Returns the list of menus available for this item.
~QgsDataCollectionItem() override
virtual QVariant sortKey() const
Returns the sorting key for the item.
static QIcon iconRaster()
void beginInsertItems(QgsDataItem *parent, int first, int last)
bool disconnectFrameChanged(const typename QtPrivate::FunctionPointer< Func1 >::Object *receiver, Func1 slot)
Convenience function to disconnect the same style that the frame change connection was established...
Base class for all map layer types.
QgsFavoritesItem(QgsDataItem *parent, const QString &name, const QString &path=QString())
Constructor for QgsFavoritesItem.
virtual void childrenCreated()
virtual QString layerName() const
void childrenCreated() override
void setSortKey(const QVariant &key)
Sets a custom sorting key for the item.
QString providerKey() const
Returns provider key.
QgsErrorItem(QgsDataItem *parent, const QString &error, const QString &path)
QString name() const
Returns the name of the item (the displayed text for the item).
void dataChanged(QgsDataItem *item)
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
QVariant mSortKey
Custom sort key. If invalid, name() will be used for sorting instead.
This class is a composition of two QSettings instances:
virtual QgsDataItem * createDataItem(const QString &path, QgsDataItem *parentItem)=0
Create a new instance of QgsDataItem (or null) for given path and parent item.
QgsMapLayer::LayerType mapLayerType() const
Returns QgsMapLayer::LayerType.
void connectionsChanged()
Emitted when the provider's connections of the child items have changed This signal is normally forwa...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QString mProviderKey
The provider key.
QgsDataCollectionItem(QgsDataItem *parent, const QString &name, const QString &path=QString())
QString name
Human readable name to be used e.g. in layer tree.
static QString pathComponent(const QString &component)
Create path component replacing path separators.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
void setState(State state) override
Set item state.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QStringList supportedFormats
virtual bool rename(const QString &name)
Sets a new name for the item, and returns true if the item was successfully renamed.
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items...
QVariant sortKey() const override
Returns the sorting key for the item.
void setToolTip(const QString &msg)
static QIcon iconDefault()
QgsMapLayer::LayerType type() const
Returns the type of the layer.
QgsDirectoryItem(QgsDataItem *parent, const QString &name, const QString &path)
A zip file: contains layers, using GDAL/OGR VSIFILE mechanism.
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
QgsMimeDataUtils::Uri mimeUri() const override
Returns mime URI for the data item.
static void deleteLater(QVector< QgsDataItem *> &items)
QgsDataItem * parent() const
Gets item parent.
static QIcon iconPolygon()
void beginRemoveItems(QgsDataItem *parent, int first, int last)
QgsMimeDataUtils::Uri mimeUri() const override
Returns mime URI for the data item.
#define QgsDebugMsgLevel(str, level)
LayerType
Types of layers that can be added to a map.
static QIcon iconDir()
Returns the standard browser directory icon.
virtual bool deleteLayer()
Delete this layer item.
QgsZipItem(QgsDataItem *parent, const QString &name, const QString &path)
virtual bool handleDoubleClick()
Called when a user double clicks on the item.
static QgsDataItem * itemFromPath(QgsDataItem *parent, const QString &path, const QString &name)
Creates a new data item from the specified path.
Children not yet created.
Creating children in separate thread (populating or refreshing)
void updateIcon()
Will request a repaint of this icon.
virtual void refreshConnections()
Refresh connections: update GUI and emit signal.
virtual int capabilities()=0
Returns combination of flags from QgsDataProvider::DataCapabilities.
static LayerType typeFromMapLayer(QgsMapLayer *layer)
Returns the layer item type corresponding to a QgsMapLayer layer.
static bool hiddenPath(const QString &path)
Check if the given path is hidden from the browser model.
bool equal(const QgsDataItem *other) override
Returns true if this item is equal to another item (by testing item type and path).
static QIcon openDirIcon()
Shared open directory icon.
QList< QgsDataItemProvider * > providers() const
Returns the list of available providers.
QgsDataItem(QgsDataItem::Type type, QgsDataItem *parent, const QString &name, const QString &path)
Create new data item.
A directory: contains subdirectories and layers.
static QStringList sProviderNames
Base class for all items in the model.
Capabilities mCapabilities
virtual void setState(State state)
Set item state.
virtual void addChildItem(QgsDataItem *child, bool refresh=false)
Inserts a new child item.
void setName(const QString &name)
Sets the name of the item (the displayed text for the item).
Can create children. Even items without this capability may have children, but cannot create them...
QVector< QgsDataItem * > children() const
QVector< QgsDataItem * > createChildren() override
Create children.
void moveToThread(QThread *targetThread)
Move object and all its descendants to thread.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Contains various Favorites directories.
QVector< QgsDataItem * > createChildren() override
Create children.
void removeDirectory(QgsDirectoryItem *item)
Removes an existing directory from the favorites group.
QgsMimeDataUtils::Uri mimeUri() const override
Returns mime URI for the data item.
QStringList supportedFormats() const
Returns the supported formats.
static QString layerTypeAsString(LayerType layerType)
Returns the string representation of the given layerType.
void addDirectory(const QString &directory, const QString &name=QString())
Adds a new directory to the favorites group.
void setParent(QgsDataItem *parent)
Set item parent and connect / disconnect parent to / from item signals.
void renameFavorite(const QString &path, const QString &name)
Renames the stored favorite with corresponding path a new name.
Animated icon is keeping an animation running if there are listeners connected to frameChanged...
QString uri() const
Returns layer uri or empty string if layer cannot be created.
virtual QList< QAction * > actions(QWidget *parent)
Returns the list of actions available for this item.
bool deferredDelete()
The item is scheduled to be deleted.
static QIcon homeDirIcon()
Shared home directory icon.
QString dirPath() const
Returns the full path to the directory the item represents.
QIcon icon() const
Gets the icons representation in the current frame.
static QIcon iconFavorites()
Icon for favorites group.
QString providerKey
For "vector" / "raster" type: provider id.
QString uri
Identifier of the data source recognized by its providerKey.
virtual QVector< QgsDataItem * > createChildren()
Create children.
static QIcon iconDataCollection()
Returns the standard browser data collection icon.
QVector< QgsDataItem * > createChildren() override
Create children.
Item that represents a layer that can be opened with one of the providers.
QgsProjectItem(QgsDataItem *parent, const QString &name, const QString &path)
A data item holding a reference to a QGIS project file.
static int findItem(QVector< QgsDataItem *> items, QgsDataItem *item)
virtual QgsDataItem * removeChildItem(QgsDataItem *child)
Removes a child item and returns it without deleting it.
virtual void deleteChildItem(QgsDataItem *child)
Removes and deletes a child item, emitting relevant signals to the model.
virtual void populate(const QVector< QgsDataItem *> &children)
QgsLayerItem(QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType, const QString &providerKey)
Data item that can be used to represent QGIS projects.
LayerType mLayerType
The layer type.
bool equal(const QgsDataItem *other) override
Returns true if this item is equal to another item (by testing item type and path).
static QIcon iconMesh()
Returns icon for mesh layer type.
QVector< QgsDataItem * > mChildren
QStringList getZipFileList()
virtual void deleteLater()
Safely delete the item:
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
QWidget * paramWidget() override
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms...
bool connectFrameChanged(const typename QtPrivate::FunctionPointer< Func1 >::Object *receiver, Func1 slot)
Connect a slot that will be notified repeatedly whenever a frame changes and which should request the...
Represents a favorite item.
This is the interface for those who want to add custom data items to the browser tree.
QStringList supportedCrs() const
Returns the supported CRS.
void stateChanged(QgsDataItem *item, QgsDataItem::State oldState)
static QString vsiPrefix(const QString &uri)
QMap< QString, QIcon > mIconMap
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.
static QString iconName(LayerType layerType)
Returns the icon name of the given layerType.