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 )
145 child->deleteLater();
149 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
152 QgsDebugMsg( QStringLiteral(
"mFutureWatcher not finished (should not happen) -> waitForFinished()" ) );
153 mDeferredDelete =
true;
154 mFutureWatcher->waitForFinished();
157 delete mFutureWatcher;
162 return QString(
string ).replace( QRegExp(
"[\\\\/]" ), QStringLiteral(
"|" ) );
184 child->deleteLater();
188 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
190 QgsDebugMsg( QStringLiteral(
"mFutureWatcher not finished -> schedule to delete later" ) );
191 mDeferredDelete =
true;
195 QObject::deleteLater();
201 const auto constItems = items;
220 child->QObject::setParent(
nullptr );
221 child->moveToThread( targetThread );
223 QObject::moveToThread( targetThread );
229 return sPopulatingIcon->
icon();
231 if ( !
mIcon.isNull() )
250 return QVector<QgsDataItem *>();
268 if ( !mFutureWatcher )
270 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
274 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
279 QVector<QgsDataItem *> QgsDataItem::runCreateChildren(
QgsDataItem *item )
285 QgsDebugMsgLevel( QStringLiteral(
"%1 children created in %2 ms" ).arg( children.size() ).arg( time.elapsed() ), 3 );
287 const auto constChildren =
children;
294 child->moveToThread( qApp->thread() );
296 QgsDebugMsgLevel( QStringLiteral(
"finished path %1: %2 children" ).arg( item->
path() ).arg( children.size() ), 3 );
302 QgsDebugMsgLevel( QStringLiteral(
"path = %1 children.size() = %2" ).arg(
path() ).arg( mFutureWatcher->result().size() ), 3 );
306 QgsDebugMsg( QStringLiteral(
"Item was scheduled to be deleted later" ) );
307 QObject::deleteLater();
313 populate( mFutureWatcher->result() );
317 refresh( mFutureWatcher->result() );
332 const auto constChildren =
children;
371 if ( !mFutureWatcher )
373 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
376 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
399 QVector<QgsDataItem *>
remove;
405 if (
findItem( children, child ) >= 0 )
407 remove.append( child );
409 const auto constRemove =
remove;
417 const auto constChildren =
children;
430 mChildren.value( index )->refresh( child->children() );
433 child->deleteLater();
454 disconnect(
this,
nullptr,
mParent,
nullptr );
489 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
534 for (
int i = 0; i < items.size(); i++ )
536 Q_ASSERT_X( items[i],
"findItem", QStringLiteral(
"item %1 is nullptr" ).arg( i ).toLatin1() );
538 if ( items[i]->
equal( item ) )
546 return ( metaObject()->className() == other->metaObject()->className() &&
553 return QList<QAction *>();
581 if ( !sPopulatingIcon )
605 return QList<QMenu *>();
612 , mProviderKey( providerKey )
614 , mLayerType( layerType )
648 switch ( layer->
type() )
652 switch ( qobject_cast< QgsVectorLayer * >( layer )->geometryType() )
685 static int enumIdx = staticMetaObject.indexOfEnumerator(
"LayerType" );
686 return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
694 return QStringLiteral(
"/mIconPointLayer.svg" );
696 return QStringLiteral(
"/mIconLineLayer.svg" );
698 return QStringLiteral(
"/mIconPolygonLayer.svg" );
701 return QStringLiteral(
"/mIconVector.svg" );
704 return QStringLiteral(
"/mIconTableLayer.svg" );
706 return QStringLiteral(
"/mIconRaster.svg" );
708 return QStringLiteral(
"/mIconMeshLayer.svg" );
710 return QStringLiteral(
"/mIconLayer.png" );
741 u.
layerType = QStringLiteral(
"vector" );
768 u.
layerType = QStringLiteral(
"raster" );
774 u.
layerType = QStringLiteral(
"plugin" );
791 mIconName = QStringLiteral(
"/mIconDbSchema.svg" );
803 QgsDebugMsgLevel( QStringLiteral(
"delete child = 0x%0" ).arg( static_cast<qlonglong>( i ), 8, 16, QLatin1Char(
'0' ) ), 2 );
814 , mRefreshLater( false )
823 , mRefreshLater( false )
845 if ( fi.isDir() && fi.isSymLink() )
866 QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
867 const auto constEntries = entries;
868 for (
const QString &subdir : constEntries )
876 QString subdirPath = dir.absoluteFilePath( subdir );
878 QgsDebugMsgLevel( QStringLiteral(
"creating subdir: %1" ).arg( subdirPath ), 2 );
884 bool handledByProvider =
false;
887 if ( provider->handlesDirectoryPath( path ) )
889 handledByProvider =
true;
893 if ( handledByProvider )
899 item->
setSortKey( QStringLiteral(
" %1" ).arg( subdir ) );
903 children.append( item );
906 QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
907 const auto constFileEntries = fileEntries;
908 for (
const QString &
name : constFileEntries )
916 QString
path = dir.absoluteFilePath(
name );
917 QFileInfo fileInfo( path );
919 if ( fileInfo.suffix().compare( QLatin1String(
"zip" ), Qt::CaseInsensitive ) == 0 ||
920 fileInfo.suffix().compare( QLatin1String(
"tar" ), Qt::CaseInsensitive ) == 0 )
925 children.append( item );
930 bool createdItem =
false;
933 int capabilities = provider->capabilities();
941 QgsDataItem *item = provider->createDataItem( path,
this );
944 children.append( item );
953 if ( fileInfo.suffix().compare( QLatin1String(
"qgs" ), Qt::CaseInsensitive ) == 0 ||
954 fileInfo.suffix().compare( QLatin1String(
"qgz" ), Qt::CaseInsensitive ) == 0 )
957 children.append( item );
972 if ( !mFileSystemWatcher )
974 mFileSystemWatcher =
new QFileSystemWatcher(
this );
975 mFileSystemWatcher->addPath(
mDirPath );
978 mLastScan = QDateTime::currentDateTime();
982 if ( mFileSystemWatcher )
984 delete mFileSystemWatcher;
985 mFileSystemWatcher =
nullptr;
993 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) <
QgsSettings().
value( QStringLiteral(
"browser/minscaninterval" ), 10000 ).toInt() )
1000 mRefreshLater =
true;
1014 QTimer::singleShot( 100,
this, [ = ] {
refresh(); } );
1021 QStringList hiddenItems = settings.
value( QStringLiteral(
"browser/hiddenPaths" ),
1022 QStringList() ).toStringList();
1023 int idx = hiddenItems.indexOf( path );
1024 return ( idx > -1 );
1029 QgsDebugMsgLevel( QStringLiteral(
"mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
1031 if ( mRefreshLater )
1033 QgsDebugMsgLevel( QStringLiteral(
"directory changed during createChidren() -> refresh() again" ), 3 );
1034 mRefreshLater =
false;
1053 return (
path() == other->
path() );
1064 u.
layerType = QStringLiteral(
"directory" );
1071 : QTreeWidget( parent )
1073 setRootIsDecorated(
false );
1076 setColumnCount( 7 );
1078 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1079 setHeaderLabels( labels );
1086 QList<QTreeWidgetItem *> items;
1089 QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
1090 const auto constEntries = entries;
1091 for (
const QString &name : constEntries )
1093 QFileInfo fi( dir.absoluteFilePath( name ) );
1097 if ( fi.size() > 1024 )
1099 size = size.sprintf(
"%.1f KiB", fi.size() / 1024.0 );
1101 else if ( fi.size() > 1.048576e6 )
1103 size = size.sprintf(
"%.1f MiB", fi.size() / 1.048576e6 );
1107 size = QStringLiteral(
"%1 B" ).arg( fi.size() );
1110 texts << fi.lastModified().toString( Qt::SystemLocaleShortDate );
1112 perm += fi.permission( QFile::ReadOwner ) ?
'r' :
'-';
1113 perm += fi.permission( QFile::WriteOwner ) ?
'w' :
'-';
1114 perm += fi.permission( QFile::ExeOwner ) ?
'x' :
'-';
1116 perm += fi.permission( QFile::ReadGroup ) ?
'r' :
'-';
1117 perm += fi.permission( QFile::WriteGroup ) ?
'w' :
'-';
1118 perm += fi.permission( QFile::ExeGroup ) ?
'x' :
'-';
1119 perm += fi.permission( QFile::ReadOther ) ?
'r' :
'-';
1120 perm += fi.permission( QFile::WriteOther ) ?
'w' :
'-';
1121 perm += fi.permission( QFile::ExeOther ) ?
'x' :
'-';
1124 texts << fi.owner();
1125 texts << fi.group();
1129 if ( fi.isDir() && fi.isSymLink() )
1131 type = tr(
"folder" );
1134 else if ( fi.isDir() )
1136 type = tr(
"folder" );
1137 icon = iconDirectory;
1139 else if ( fi.isFile() && fi.isSymLink() )
1141 type = tr(
"file" );
1142 icon = iconFileLink;
1144 else if ( fi.isFile() )
1146 type = tr(
"file" );
1152 QTreeWidgetItem *item =
new QTreeWidgetItem( texts );
1153 item->setIcon( 0, icon );
1157 addTopLevelItems( items );
1161 QList<QVariant> lst = settings.
value( QStringLiteral(
"dataitem/directoryHiddenColumns" ) ).toList();
1162 const auto constLst = lst;
1163 for (
const QVariant &colVariant : constLst )
1165 setColumnHidden( colVariant.toInt(), true );
1171 if ( event->button() == Qt::RightButton )
1177 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1178 for (
int i = 0; i < labels.count(); i++ )
1181 action->setObjectName( QString::number( i ) );
1182 action->setCheckable(
true );
1183 action->setChecked( !isColumnHidden( i ) );
1186 popupMenu.exec( event->globalPos() );
1192 QAction *action = qobject_cast<QAction *>( sender() );
1196 int columnIndex = action->objectName().toInt();
1197 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
1201 QList<QVariant> lst;
1202 for (
int i = 0; i < columnCount(); i++ )
1204 if ( isColumnHidden( i ) )
1205 lst.append( QVariant( i ) );
1207 settings.
setValue( QStringLiteral(
"dataitem/directoryHiddenColumns" ), lst );
1213 mIconName = QStringLiteral(
":/images/icons/qgis_icon.svg" );
1214 setToolTip( QDir::toNativeSeparators( path ) );
1221 u.
layerType = QStringLiteral(
"project" );
1230 mIconName = QStringLiteral(
"/mIconDelete.svg" );
1241 mIconName = QStringLiteral(
"/mIconFavourites.svg" );
1250 const QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ), QVariant() ).toStringList();
1252 for (
const QString &favDir : favDirs )
1254 QStringList parts = favDir.split( QStringLiteral(
"|||" ) );
1255 if ( parts.empty() )
1258 QString dir = parts.at( 0 );
1260 if ( parts.count() > 1 )
1261 name = parts.at( 1 );
1271 QString
name = n.isEmpty() ? favDir : n;
1274 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1275 favDirs.append( QStringLiteral(
"%1|||%2" ).arg( favDir, name ) );
1276 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1281 const auto constItems = items;
1295 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1296 for (
int i = favDirs.count() - 1; i >= 0; --i )
1298 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1299 if ( parts.empty() )
1302 QString dir = parts.at( 0 );
1304 favDirs.removeAt( i );
1306 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1311 QgsDebugMsg( QStringLiteral(
"favorites item %1 not found" ).arg( item->
path() ) );
1323 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1324 for (
int i = 0; i < favDirs.count(); ++i )
1326 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1327 if ( parts.empty() )
1330 QString dir = parts.at( 0 );
1333 favDirs[i] = QStringLiteral(
"%1|||%2" ).arg( path, name );
1337 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1340 const QVector<QgsDataItem *> ch =
children();
1343 if ( QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( child ) )
1345 if ( favorite->dirPath() ==
path )
1347 favorite->setName( name );
1361 int capabilities = provider->capabilities();
1365 QgsDataItem *item = provider->createDataItem( favDir,
this );
1369 children.append( item );
1373 if ( children.isEmpty() )
1375 QgsFavoriteItem *item =
new QgsFavoriteItem(
this, name, favDir,
mPath +
'/' + pathName );
1378 children.append( item );
1402 void QgsZipItem::init()
1405 mIconName = QStringLiteral(
"/mIconZip.svg" );
1408 static std::once_flag initialized;
1409 std::call_once( initialized, [ = ]
1411 sProviderNames << QStringLiteral(
"OGR" ) << QStringLiteral(
"GDAL" );
1420 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1427 if ( scanZipSetting == QLatin1String(
"no" ) )
1439 for (
const QString &fileName : constMZipFileList )
1441 QFileInfo info( fileName );
1451 if ( provider->name() == QStringLiteral(
"OGR" ) )
1453 if ( info.suffix().compare( QLatin1String(
"dbf" ), Qt::CaseInsensitive ) == 0 )
1455 if (
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) +
".shp" ) != -1 )
1458 if ( info.completeSuffix().compare( QLatin1String(
"shp.xml" ), Qt::CaseInsensitive ) == 0 )
1464 QgsDebugMsgLevel( QStringLiteral(
"trying to load item %1 with %2" ).arg( tmpPath, provider->name() ), 3 );
1465 QgsDataItem *item = provider->createDataItem( tmpPath,
this );
1470 children.append( item );
1490 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1491 QStringList zipFileList;
1494 bool populated =
false;
1496 QgsDebugMsgLevel( QStringLiteral(
"path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path, name, scanZipSetting, vsiPrefix ), 3 );
1499 if ( scanZipSetting == QLatin1String(
"no" ) )
1503 if ( ( vsiPrefix != QLatin1String(
"/vsizip/" ) && vsiPrefix != QLatin1String(
"/vsitar/" ) ) )
1506 zipItem =
new QgsZipItem( parent, name, filePath, path );
1516 if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) ||
1517 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) )
1522 if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
1526 QgsDebugMsgLevel( QStringLiteral(
"Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->
rowCount() ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1530 QgsDebugMsgLevel( QStringLiteral(
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1535 if ( zipItem && ( !populated || zipItem->
rowCount() > 0 ) )
1551 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1556 if ( scanZipSetting == QLatin1String(
"no" ) )
1563 char **papszSiblingFiles = VSIReadDirRecursive( QString(
mVsiPrefix +
mFilePath ).toLocal8Bit().constData() );
1564 if ( papszSiblingFiles )
1566 for (
int i = 0; papszSiblingFiles[i]; i++ )
1568 tmpPath = papszSiblingFiles[i];
1571 if ( tmpPath.right( 1 ) != QLatin1String(
"/" ) )
1574 CSLDestroy( papszSiblingFiles );
1586 QgsProjectHomeItem::QgsProjectHomeItem(
QgsDataItem *
parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1591 QIcon QgsProjectHomeItem::icon()
1598 QVariant QgsProjectHomeItem::sortKey()
const 1600 return QStringLiteral(
" 1" );
1604 QgsFavoriteItem::QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1606 , mFavorites( parent )
1611 bool QgsFavoriteItem::rename(
const QString &
name )
1613 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)
QgsMapLayerType type() const
Returns the type of the layer.
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:
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.
QgsMapLayerType mapLayerType() const
Returns QgsMapLayerType.
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 Q_DECL_DEPRECATED 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()
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)
QList< QgsDataItemProvider * > providers() const
Returns the list of available providers.
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)
static QIcon iconDir()
Returns the standard browser directory icon.
virtual Q_DECL_DEPRECATED bool deleteLayer()
Delete this layer item Use QgsDataItemGuiProvider::deleteLayer instead.
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.
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.
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.
QgsMapLayerType
Types of layers that can be added to a map.
virtual void deleteChildItem(QgsDataItem *child)
Removes and deletes a child item, emitting relevant signals to the model.
QgsWkbTypes::Type wkbType
WKB type, if associated with a vector layer, or QgsWkbTypes::Unknown if not yet known.
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...
Q_DECL_DEPRECATED QWidget * paramWidget() override
Returns source widget from data item for QgsBrowserPropertiesWidget.
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.