18 #include <QApplication> 19 #include <QtConcurrentMap> 20 #include <QtConcurrentRun> 22 #include <QElapsedTimer> 26 #include <QMouseEvent> 27 #include <QTreeWidget> 28 #include <QTreeWidgetItem> 41 #include "qgsconfig.h" 48 #define CPL_SUPRESS_CPLUSPLUS //#spellok 50 #include "cpl_string.h" 115 return QStringLiteral(
" 0" );
134 , mDeferredDelete( false )
135 , mFutureWatcher( nullptr )
147 child->deleteLater();
151 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
154 QgsDebugMsg( QStringLiteral(
"mFutureWatcher not finished (should not happen) -> waitForFinished()" ) );
155 mDeferredDelete =
true;
156 mFutureWatcher->waitForFinished();
159 delete mFutureWatcher;
164 return QString(
string ).replace( QRegExp(
"[\\\\/]" ), QStringLiteral(
"|" ) );
186 child->deleteLater();
190 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
192 QgsDebugMsg( QStringLiteral(
"mFutureWatcher not finished -> schedule to delete later" ) );
193 mDeferredDelete =
true;
197 QObject::deleteLater();
203 const auto constItems = items;
222 child->QObject::setParent(
nullptr );
223 child->moveToThread( targetThread );
225 QObject::moveToThread( targetThread );
231 return sPopulatingIcon->
icon();
233 if ( !
mIcon.isNull() )
252 return QVector<QgsDataItem *>();
270 if ( !mFutureWatcher )
272 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
276 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
281 QVector<QgsDataItem *> QgsDataItem::runCreateChildren(
QgsDataItem *item )
287 QgsDebugMsgLevel( QStringLiteral(
"%1 children created in %2 ms" ).arg( children.size() ).arg( time.elapsed() ), 3 );
289 const auto constChildren =
children;
296 child->moveToThread( qApp->thread() );
298 QgsDebugMsgLevel( QStringLiteral(
"finished path %1: %2 children" ).arg( item->
path() ).arg( children.size() ), 3 );
304 QgsDebugMsgLevel( QStringLiteral(
"path = %1 children.size() = %2" ).arg(
path() ).arg( mFutureWatcher->result().size() ), 3 );
308 QgsDebugMsg( QStringLiteral(
"Item was scheduled to be deleted later" ) );
309 QObject::deleteLater();
315 populate( mFutureWatcher->result() );
319 refresh( mFutureWatcher->result() );
334 const auto constChildren =
children;
373 if ( !mFutureWatcher )
375 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
378 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
401 QVector<QgsDataItem *>
remove;
407 if (
findItem( children, child ) >= 0 )
409 remove.append( child );
411 const auto constRemove =
remove;
419 const auto constChildren =
children;
432 mChildren.value( index )->refresh( child->children() );
435 child->deleteLater();
466 disconnect(
this,
nullptr,
mParent,
nullptr );
501 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
546 for (
int i = 0; i < items.size(); i++ )
548 Q_ASSERT_X( items[i],
"findItem", QStringLiteral(
"item %1 is nullptr" ).arg( i ).toLatin1() );
550 if ( items[i]->
equal( item ) )
558 return ( metaObject()->className() == other->metaObject()->className() &&
565 return QList<QAction *>();
593 if ( !sPopulatingIcon )
617 return QList<QMenu *>();
626 , mLayerType( layerType )
660 switch ( layer->
type() )
664 switch ( qobject_cast< QgsVectorLayer * >( layer )->geometryType() )
697 static int enumIdx = staticMetaObject.indexOfEnumerator(
"LayerType" );
698 return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
706 return QStringLiteral(
"/mIconPointLayer.svg" );
708 return QStringLiteral(
"/mIconLineLayer.svg" );
710 return QStringLiteral(
"/mIconPolygonLayer.svg" );
713 return QStringLiteral(
"/mIconVector.svg" );
716 return QStringLiteral(
"/mIconTableLayer.svg" );
718 return QStringLiteral(
"/mIconRaster.svg" );
720 return QStringLiteral(
"/mIconMeshLayer.svg" );
722 return QStringLiteral(
"/mIconLayer.png" );
753 u.
layerType = QStringLiteral(
"vector" );
780 u.
layerType = QStringLiteral(
"raster" );
786 u.
layerType = QStringLiteral(
"plugin" );
806 mIconName = QStringLiteral(
"/mIconDbSchema.svg" );
818 QgsDebugMsgLevel( QStringLiteral(
"delete child = 0x%0" ).arg( static_cast<qlonglong>( i ), 8, 16, QLatin1Char(
'0' ) ), 2 );
829 , mRefreshLater( false )
840 , mRefreshLater( false )
862 if ( fi.isDir() && fi.isSymLink() )
883 QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
884 const auto constEntries = entries;
885 for (
const QString &subdir : constEntries )
893 QString subdirPath = dir.absoluteFilePath( subdir );
895 QgsDebugMsgLevel( QStringLiteral(
"creating subdir: %1" ).arg( subdirPath ), 2 );
901 bool handledByProvider =
false;
904 if ( provider->handlesDirectoryPath( path ) )
906 handledByProvider =
true;
910 if ( handledByProvider )
916 item->
setSortKey( QStringLiteral(
" %1" ).arg( subdir ) );
920 children.append( item );
923 QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
924 const auto constFileEntries = fileEntries;
925 for (
const QString &
name : constFileEntries )
933 QString
path = dir.absoluteFilePath(
name );
934 QFileInfo fileInfo( path );
936 if ( fileInfo.suffix().compare( QLatin1String(
"zip" ), Qt::CaseInsensitive ) == 0 ||
937 fileInfo.suffix().compare( QLatin1String(
"tar" ), Qt::CaseInsensitive ) == 0 )
942 children.append( item );
947 bool createdItem =
false;
950 int capabilities = provider->capabilities();
958 QgsDataItem *item = provider->createDataItem( path,
this );
961 children.append( item );
970 if ( fileInfo.suffix().compare( QLatin1String(
"qgs" ), Qt::CaseInsensitive ) == 0 ||
971 fileInfo.suffix().compare( QLatin1String(
"qgz" ), Qt::CaseInsensitive ) == 0 )
974 children.append( item );
989 if ( !mFileSystemWatcher )
991 mFileSystemWatcher =
new QFileSystemWatcher(
this );
992 mFileSystemWatcher->addPath(
mDirPath );
995 mLastScan = QDateTime::currentDateTime();
999 if ( mFileSystemWatcher )
1001 delete mFileSystemWatcher;
1002 mFileSystemWatcher =
nullptr;
1010 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) <
QgsSettings().
value( QStringLiteral(
"browser/minscaninterval" ), 10000 ).toInt() )
1017 mRefreshLater =
true;
1031 QTimer::singleShot( 100,
this, [ = ] {
refresh(); } );
1038 QStringList hiddenItems = settings.
value( QStringLiteral(
"browser/hiddenPaths" ),
1039 QStringList() ).toStringList();
1040 int idx = hiddenItems.indexOf( path );
1041 return ( idx > -1 );
1046 QgsDebugMsgLevel( QStringLiteral(
"mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
1048 if ( mRefreshLater )
1050 QgsDebugMsgLevel( QStringLiteral(
"directory changed during createChidren() -> refresh() again" ), 3 );
1051 mRefreshLater =
false;
1070 return (
path() == other->
path() );
1081 u.
layerType = QStringLiteral(
"directory" );
1088 : QTreeWidget( parent )
1090 setRootIsDecorated(
false );
1093 setColumnCount( 7 );
1095 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1096 setHeaderLabels( labels );
1103 QList<QTreeWidgetItem *> items;
1106 QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
1107 const auto constEntries = entries;
1108 for (
const QString &name : constEntries )
1110 QFileInfo fi( dir.absoluteFilePath( name ) );
1114 if ( fi.size() > 1024 )
1116 size = size.sprintf(
"%.1f KiB", fi.size() / 1024.0 );
1118 else if ( fi.size() > 1.048576e6 )
1120 size = size.sprintf(
"%.1f MiB", fi.size() / 1.048576e6 );
1124 size = QStringLiteral(
"%1 B" ).arg( fi.size() );
1127 texts << fi.lastModified().toString( Qt::SystemLocaleShortDate );
1129 perm += fi.permission( QFile::ReadOwner ) ?
'r' :
'-';
1130 perm += fi.permission( QFile::WriteOwner ) ?
'w' :
'-';
1131 perm += fi.permission( QFile::ExeOwner ) ?
'x' :
'-';
1133 perm += fi.permission( QFile::ReadGroup ) ?
'r' :
'-';
1134 perm += fi.permission( QFile::WriteGroup ) ?
'w' :
'-';
1135 perm += fi.permission( QFile::ExeGroup ) ?
'x' :
'-';
1136 perm += fi.permission( QFile::ReadOther ) ?
'r' :
'-';
1137 perm += fi.permission( QFile::WriteOther ) ?
'w' :
'-';
1138 perm += fi.permission( QFile::ExeOther ) ?
'x' :
'-';
1141 texts << fi.owner();
1142 texts << fi.group();
1146 if ( fi.isDir() && fi.isSymLink() )
1148 type = tr(
"folder" );
1151 else if ( fi.isDir() )
1153 type = tr(
"folder" );
1154 icon = iconDirectory;
1156 else if ( fi.isFile() && fi.isSymLink() )
1158 type = tr(
"file" );
1159 icon = iconFileLink;
1161 else if ( fi.isFile() )
1163 type = tr(
"file" );
1169 QTreeWidgetItem *item =
new QTreeWidgetItem( texts );
1170 item->setIcon( 0, icon );
1174 addTopLevelItems( items );
1178 QList<QVariant> lst = settings.
value( QStringLiteral(
"dataitem/directoryHiddenColumns" ) ).toList();
1179 const auto constLst = lst;
1180 for (
const QVariant &colVariant : constLst )
1182 setColumnHidden( colVariant.toInt(), true );
1188 if ( event->button() == Qt::RightButton )
1194 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1195 for (
int i = 0; i < labels.count(); i++ )
1198 action->setObjectName( QString::number( i ) );
1199 action->setCheckable(
true );
1200 action->setChecked( !isColumnHidden( i ) );
1203 popupMenu.exec( event->globalPos() );
1209 QAction *action = qobject_cast<QAction *>( sender() );
1213 int columnIndex = action->objectName().toInt();
1214 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
1218 QList<QVariant> lst;
1219 for (
int i = 0; i < columnCount(); i++ )
1221 if ( isColumnHidden( i ) )
1222 lst.append( QVariant( i ) );
1224 settings.
setValue( QStringLiteral(
"dataitem/directoryHiddenColumns" ), lst );
1228 const QString &path,
const QString &providerKey )
1231 mIconName = QStringLiteral(
":/images/icons/qgis_icon.svg" );
1232 setToolTip( QDir::toNativeSeparators( path ) );
1239 u.
layerType = QStringLiteral(
"project" );
1248 mIconName = QStringLiteral(
"/mIconDelete.svg" );
1254 :
QgsDataCollectionItem( parent, name, QStringLiteral(
"favorites:" ), QStringLiteral(
"special:Favorites" ) )
1259 mIconName = QStringLiteral(
"/mIconFavourites.svg" );
1268 const QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ), QVariant() ).toStringList();
1270 for (
const QString &favDir : favDirs )
1272 QStringList parts = favDir.split( QStringLiteral(
"|||" ) );
1273 if ( parts.empty() )
1276 QString dir = parts.at( 0 );
1278 if ( parts.count() > 1 )
1279 name = parts.at( 1 );
1289 QString
name = n.isEmpty() ? favDir : n;
1292 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1293 favDirs.append( QStringLiteral(
"%1|||%2" ).arg( favDir, name ) );
1294 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1299 const auto constItems = items;
1313 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1314 for (
int i = favDirs.count() - 1; i >= 0; --i )
1316 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1317 if ( parts.empty() )
1320 QString dir = parts.at( 0 );
1322 favDirs.removeAt( i );
1324 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1329 QgsDebugMsg( QStringLiteral(
"favorites item %1 not found" ).arg( item->
path() ) );
1341 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1342 for (
int i = 0; i < favDirs.count(); ++i )
1344 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1345 if ( parts.empty() )
1348 QString dir = parts.at( 0 );
1351 favDirs[i] = QStringLiteral(
"%1|||%2" ).arg( path, name );
1355 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1358 const QVector<QgsDataItem *> ch =
children();
1361 if ( QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( child ) )
1363 if ( favorite->dirPath() ==
path )
1365 favorite->setName( name );
1379 int capabilities = provider->capabilities();
1383 QgsDataItem *item = provider->createDataItem( favDir,
this );
1387 children.append( item );
1391 if ( children.isEmpty() )
1393 QgsFavoriteItem *item =
new QgsFavoriteItem(
this, name, favDir,
mPath +
'/' + pathName );
1396 children.append( item );
1414 const QString &filePath,
const QString &
path,
1422 void QgsZipItem::init()
1425 mIconName = QStringLiteral(
"/mIconZip.svg" );
1428 static std::once_flag initialized;
1429 std::call_once( initialized, [ = ]
1431 sProviderNames << QStringLiteral(
"OGR" ) << QStringLiteral(
"GDAL" );
1440 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1447 if ( scanZipSetting == QLatin1String(
"no" ) )
1459 for (
const QString &fileName : constMZipFileList )
1461 QFileInfo info( fileName );
1471 if ( provider->name() == QStringLiteral(
"OGR" ) )
1473 if ( info.suffix().compare( QLatin1String(
"dbf" ), Qt::CaseInsensitive ) == 0 )
1475 if (
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) +
".shp" ) != -1 )
1478 if ( info.completeSuffix().compare( QLatin1String(
"shp.xml" ), Qt::CaseInsensitive ) == 0 )
1484 QgsDebugMsgLevel( QStringLiteral(
"trying to load item %1 with %2" ).arg( tmpPath, provider->name() ), 3 );
1485 QgsDataItem *item = provider->createDataItem( tmpPath,
this );
1490 children.append( item );
1510 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1511 QStringList zipFileList;
1514 bool populated =
false;
1516 QgsDebugMsgLevel( QStringLiteral(
"path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path, name, scanZipSetting, vsiPrefix ), 3 );
1519 if ( scanZipSetting == QLatin1String(
"no" ) )
1523 if ( ( vsiPrefix != QLatin1String(
"/vsizip/" ) && vsiPrefix != QLatin1String(
"/vsitar/" ) ) )
1526 zipItem =
new QgsZipItem( parent, name, filePath, path );
1536 if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) ||
1537 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) )
1542 if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
1546 QgsDebugMsgLevel( QStringLiteral(
"Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->
rowCount() ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1550 QgsDebugMsgLevel( QStringLiteral(
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1555 if ( zipItem && ( !populated || zipItem->
rowCount() > 0 ) )
1571 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1576 if ( scanZipSetting == QLatin1String(
"no" ) )
1583 char **papszSiblingFiles = VSIReadDirRecursive( QString(
mVsiPrefix +
mFilePath ).toLocal8Bit().constData() );
1584 if ( papszSiblingFiles )
1586 for (
int i = 0; papszSiblingFiles[i]; i++ )
1588 tmpPath = papszSiblingFiles[i];
1591 if ( tmpPath.right( 1 ) != QLatin1String(
"/" ) )
1594 CSLDestroy( papszSiblingFiles );
1606 QgsProjectHomeItem::QgsProjectHomeItem(
QgsDataItem *
parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1611 QIcon QgsProjectHomeItem::icon()
1618 QVariant QgsProjectHomeItem::sortKey()
const 1620 return QStringLiteral(
" 1" );
1624 QgsFavoriteItem::QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1626 , mFavorites( parent )
1631 bool QgsFavoriteItem::rename(
const QString &
name )
1633 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
QgsDataItem(QgsDataItem::Type type, QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
Constructor for QgsDataItem, with the specified parent item.
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.
QgsMapLayerType mapLayerType() const
Returns QgsMapLayerType.
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.
QgsProjectItem(QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
A data item holding a reference to a QGIS project file.
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.
void setProviderKey(const QString &value)
Sets the provider key that created this item (e.g.
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)
Constructor for QgsDirectoryItem, with the specified parent item.
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)
Constructor.
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.
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.
QString providerKey() const
Returns the provider key that created this item (e.g.
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.
QgsDataCollectionItem(QgsDataItem *parent, const QString &name, const QString &path=QString(), const QString &providerKey=QString())
Constructor for QgsDataCollectionItem, with the specified parent item.
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.
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.