18 #include <QApplication> 19 #include <QtConcurrentMap> 20 #include <QtConcurrentRun> 25 #include <QMouseEvent> 26 #include <QTreeWidget> 27 #include <QTreeWidgetItem> 30 #include <QDesktopServices> 31 #include <QFileDialog> 41 #include "qgsconfig.h" 47 #define CPL_SUPRESS_CPLUSPLUS //#spellok 49 #include "cpl_string.h" 99 QStyle *style = QApplication::style();
100 sIcon = QIcon( style->standardPixmap( QStyle::SP_DirClosedIcon ) );
101 sIcon.addPixmap( style->standardPixmap( QStyle::SP_DirOpenIcon ),
102 QIcon::Normal, QIcon::On );
115 return QStringLiteral(
" 0" );
134 , mDeferredDelete( false )
135 , mFutureWatcher( nullptr )
150 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
153 QgsDebugMsg(
"mFutureWatcher not finished (should not happen) -> waitForFinished()" );
154 mDeferredDelete =
true;
155 mFutureWatcher->waitForFinished();
158 delete mFutureWatcher;
163 return QString(
string ).replace( QRegExp(
"[\\\\/]" ), QStringLiteral(
"|" ) );
188 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
190 QgsDebugMsg(
"mFutureWatcher not finished -> schedule to delete later" );
191 mDeferredDelete =
true;
195 QObject::deleteLater();
218 child->QObject::setParent(
nullptr );
221 QObject::moveToThread( targetThread );
227 return sPopulatingIcon->
icon();
229 if ( !
mIcon.isNull() )
248 return QVector<QgsDataItem *>();
266 if ( !mFutureWatcher )
268 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
272 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
277 QVector<QgsDataItem *> QgsDataItem::runCreateChildren(
QgsDataItem *item )
283 QgsDebugMsgLevel( QString(
"%1 children created in %2 ms" ).arg( children.size() ).arg( time.elapsed() ), 3 );
293 QgsDebugMsgLevel( QString(
"finished path %1: %2 children" ).arg( item->
path() ).arg( children.size() ), 3 );
299 QgsDebugMsgLevel( QString(
"path = %1 children.size() = %2" ).arg(
path() ).arg( mFutureWatcher->result().size() ), 3 );
303 QgsDebugMsg(
"Item was scheduled to be deleted later" );
304 QObject::deleteLater();
310 populate( mFutureWatcher->result() );
314 refresh( mFutureWatcher->result() );
366 if ( !mFutureWatcher )
368 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
371 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
394 QVector<QgsDataItem *>
remove;
399 if (
findItem( children, child ) >= 0 )
401 remove.append( child );
446 disconnect(
this,
nullptr,
mParent,
nullptr );
481 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
526 for (
int i = 0; i < items.size(); i++ )
528 Q_ASSERT_X( items[i],
"findItem", QString(
"item %1 is nullptr" ).arg( i ).toLatin1() );
530 if ( items[i]->
equal( item ) )
538 return ( metaObject()->className() == other->metaObject()->className() &&
545 return QList<QAction *>();
568 if ( !sPopulatingIcon )
592 return QList<QMenu *>();
599 , mProviderKey( providerKey )
601 , mLayerType( layerType )
619 static int enumIdx = staticMetaObject.indexOfEnumerator(
"LayerType" );
620 return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
628 return QStringLiteral(
"/mIconPointLayer.svg" );
631 return QStringLiteral(
"/mIconLineLayer.svg" );
634 return QStringLiteral(
"/mIconPolygonLayer.svg" );
638 return QStringLiteral(
"/mIconPolygonLayer.svg" );
642 return QStringLiteral(
"/mIconTableLayer.svg" );
645 return QStringLiteral(
"/mIconRaster.svg" );
650 return QStringLiteral(
"/mIconLayer.png" );
677 u.
layerType = QStringLiteral(
"vector" );
680 u.
layerType = QStringLiteral(
"raster" );
686 u.
layerType = QStringLiteral(
"plugin" );
705 mIconName = QStringLiteral(
"/mIconDbSchema.svg" );
716 QgsDebugMsgLevel( QString(
"delete child = 0x%0" ).arg( ( qlonglong )i, 8, 16, QLatin1Char(
'0' ) ), 2 );
727 , mRefreshLater( false )
736 , mRefreshLater( false )
762 QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
763 Q_FOREACH (
const QString &subdir, entries )
771 QString subdirPath = dir.absoluteFilePath( subdir );
779 bool handledByProvider =
false;
782 if ( provider->handlesDirectoryPath( path ) )
784 handledByProvider =
true;
788 if ( handledByProvider )
794 item->
setSortKey( QStringLiteral(
" %1" ).arg( subdir ) );
798 children.append( item );
801 QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
802 Q_FOREACH (
const QString &
name, fileEntries )
810 QString
path = dir.absoluteFilePath( name );
811 QFileInfo fileInfo( path );
813 if ( fileInfo.suffix() == QLatin1String(
"qgs" ) || fileInfo.suffix() == QLatin1String(
"qgz" ) )
816 children.append( item );
826 children.append( item );
833 int capabilities = provider->capabilities();
841 QgsDataItem *item = provider->createDataItem( path,
this );
844 children.append( item );
858 if ( !mFileSystemWatcher )
860 mFileSystemWatcher =
new QFileSystemWatcher(
this );
861 mFileSystemWatcher->addPath(
mDirPath );
864 mLastScan = QDateTime::currentDateTime();
868 if ( mFileSystemWatcher )
870 delete mFileSystemWatcher;
871 mFileSystemWatcher =
nullptr;
879 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) <
QgsSettings().
value( QStringLiteral(
"browser/minscaninterval" ), 10000 ).toInt() )
886 mRefreshLater =
true;
900 QTimer::singleShot( 100,
this, SLOT(
refresh() ) );
907 QStringList hiddenItems = settings.
value( QStringLiteral(
"browser/hiddenPaths" ),
908 QStringList() ).toStringList();
909 int idx = hiddenItems.indexOf( path );
915 QList<QAction *> result;
916 QAction *openFolder =
new QAction( tr(
"Open Directory…" ), parent );
917 connect( openFolder, &QAction::triggered,
this, [ = ]
919 QDesktopServices::openUrl( QUrl::fromLocalFile(
mDirPath ) );
921 result << openFolder;
928 QgsDebugMsgLevel( QString(
"mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
932 QgsDebugMsgLevel(
"directory changed during createChidren() -> refresh() again", 3 );
933 mRefreshLater =
false;
961 : QTreeWidget( parent )
963 setRootIsDecorated(
false );
968 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
969 setHeaderLabels( labels );
971 QStyle *style = QApplication::style();
972 QIcon iconDirectory = QIcon( style->standardPixmap( QStyle::SP_DirClosedIcon ) );
973 QIcon iconFile = QIcon( style->standardPixmap( QStyle::SP_FileIcon ) );
974 QIcon iconDirLink = QIcon( style->standardPixmap( QStyle::SP_DirLinkIcon ) );
975 QIcon iconFileLink = QIcon( style->standardPixmap( QStyle::SP_FileLinkIcon ) );
977 QList<QTreeWidgetItem *> items;
980 QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
981 Q_FOREACH (
const QString &name, entries )
983 QFileInfo fi( dir.absoluteFilePath( name ) );
987 if ( fi.size() > 1024 )
989 size = size.sprintf(
"%.1f KiB", fi.size() / 1024.0 );
991 else if ( fi.size() > 1.048576e6 )
993 size = size.sprintf(
"%.1f MiB", fi.size() / 1.048576e6 );
997 size = QStringLiteral(
"%1 B" ).arg( fi.size() );
1000 texts << fi.lastModified().toString( Qt::SystemLocaleShortDate );
1002 perm += fi.permission( QFile::ReadOwner ) ?
'r' :
'-';
1003 perm += fi.permission( QFile::WriteOwner ) ?
'w' :
'-';
1004 perm += fi.permission( QFile::ExeOwner ) ?
'x' :
'-';
1006 perm += fi.permission( QFile::ReadGroup ) ?
'r' :
'-';
1007 perm += fi.permission( QFile::WriteGroup ) ?
'w' :
'-';
1008 perm += fi.permission( QFile::ExeGroup ) ?
'x' :
'-';
1009 perm += fi.permission( QFile::ReadOther ) ?
'r' :
'-';
1010 perm += fi.permission( QFile::WriteOther ) ?
'w' :
'-';
1011 perm += fi.permission( QFile::ExeOther ) ?
'x' :
'-';
1014 texts << fi.owner();
1015 texts << fi.group();
1019 if ( fi.isDir() && fi.isSymLink() )
1021 type = tr(
"folder" );
1024 else if ( fi.isDir() )
1026 type = tr(
"folder" );
1027 icon = iconDirectory;
1029 else if ( fi.isFile() && fi.isSymLink() )
1031 type = tr(
"file" );
1032 icon = iconFileLink;
1034 else if ( fi.isFile() )
1036 type = tr(
"file" );
1042 QTreeWidgetItem *item =
new QTreeWidgetItem( texts );
1043 item->setIcon( 0, icon );
1047 addTopLevelItems( items );
1051 QList<QVariant> lst = settings.
value( QStringLiteral(
"dataitem/directoryHiddenColumns" ) ).toList();
1052 Q_FOREACH (
const QVariant &colVariant, lst )
1054 setColumnHidden( colVariant.toInt(), true );
1060 if ( event->button() == Qt::RightButton )
1066 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1067 for (
int i = 0; i < labels.count(); i++ )
1069 QAction *action = popupMenu.addAction( labels[i],
this, SLOT(
showHideColumn() ) );
1070 action->setObjectName( QString::number( i ) );
1071 action->setCheckable(
true );
1072 action->setChecked( !isColumnHidden( i ) );
1075 popupMenu.exec( event->globalPos() );
1081 QAction *action = qobject_cast<QAction *>( sender() );
1085 int columnIndex = action->objectName().toInt();
1086 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
1090 QList<QVariant> lst;
1091 for (
int i = 0; i < columnCount(); i++ )
1093 if ( isColumnHidden( i ) )
1094 lst.append( QVariant( i ) );
1096 settings.
setValue( QStringLiteral(
"dataitem/directoryHiddenColumns" ), lst );
1102 mIconName = QStringLiteral(
":/images/icons/qgis-icon-16x16.png" );
1103 setToolTip( QDir::toNativeSeparators( path ) );
1110 u.
layerType = QStringLiteral(
"project" );
1119 mIconName = QStringLiteral(
"/mIconDelete.svg" );
1130 mIconName = QStringLiteral(
"/mIconFavourites.svg" );
1139 const QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ), QVariant() ).toStringList();
1141 for (
const QString &favDir : favDirs )
1143 QStringList parts = favDir.split( QStringLiteral(
"|||" ) );
1144 if ( parts.empty() )
1147 QString dir = parts.at( 0 );
1149 if ( parts.count() > 1 )
1150 name = parts.at( 1 );
1160 QString
name = n.isEmpty() ? favDir : n;
1163 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1164 favDirs.append( QStringLiteral(
"%1|||%2" ).arg( favDir, name ) );
1165 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1183 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1184 for (
int i = favDirs.count() - 1; i >= 0; --i )
1186 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1187 if ( parts.empty() )
1190 QString dir = parts.at( 0 );
1192 favDirs.removeAt( i );
1194 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1199 QgsDebugMsg( QString(
"favorites item %1 not found" ).arg( item->
path() ) );
1211 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1212 for (
int i = 0; i < favDirs.count(); ++i )
1214 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1215 if ( parts.empty() )
1218 QString dir = parts.at( 0 );
1221 favDirs[i] = QStringLiteral(
"%1|||%2" ).arg( path, name );
1225 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1228 const QVector<QgsDataItem *> ch =
children();
1231 if ( QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( child ) )
1233 if ( favorite->dirPath() ==
path )
1235 favorite->setName( name );
1256 children.append( item );
1260 if ( children.isEmpty() )
1262 QgsFavoriteItem *item =
new QgsFavoriteItem(
this, name, favDir,
mPath +
'/' + pathName );
1265 children.append( item );
1290 void QgsZipItem::init()
1293 mIconName = QStringLiteral(
"/mIconZip.png" );
1302 keys << QStringLiteral(
"gdal" ) << QStringLiteral(
"ogr" );
1304 for (
const auto &k : qgis::as_const( keys ) )
1313 if ( !dataCapabilities )
1315 QgsDebugMsg( library->fileName() +
" does not have dataCapabilities" );
1320 QgsDebugMsg( library->fileName() +
" has NoDataCapabilities" );
1323 QgsDebugMsg( QString(
"%1 dataCapabilities : %2" ).arg( library->fileName() ).arg( dataCapabilities() ) );
1328 QgsDebugMsg( library->fileName() +
" does not have dataItem" );
1350 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1357 if ( scanZipSetting == QLatin1String(
"no" ) )
1368 QFileInfo info( fileName );
1378 if ( info.suffix().toLower() == QLatin1String(
"dbf" ) )
1380 if (
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) +
".shp" ) != -1 )
1383 if ( info.completeSuffix().toLower() == QLatin1String(
"shp.xml" ) )
1400 children.append( item );
1422 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1423 int zipFileCount = 0;
1424 QStringList zipFileList;
1427 bool populated =
false;
1429 QgsDebugMsgLevel( QString(
"path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path, name, scanZipSetting, vsiPrefix ), 3 );
1432 if ( scanZipSetting == QLatin1String(
"no" ) )
1436 if ( ( vsiPrefix != QLatin1String(
"/vsizip/" ) && vsiPrefix != QLatin1String(
"/vsitar/" ) ) )
1439 zipItem =
new QgsZipItem( parent, name, filePath, path );
1449 if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) ||
1450 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) )
1455 if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
1463 QgsDebugMsgLevel( QString(
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1468 if ( zipItem && ( !populated || zipItem->
rowCount() > 1 ) )
1476 QString vsiPath = vsiPrefix + filePath;
1480 if ( children.size() == 1 )
1485 vsiPath = layerItem->
uri();
1487 zipFileCount = zipFileList.count();
1491 QgsDebugMsgLevel( QString(
"will try to create a normal dataItem from filePath= %2 or vsiPath = %3" ).arg( filePath, vsiPath ), 3 );
1504 (
sProviderNames.at( i ) == QLatin1String(
"gdal" ) && zipFileCount == 1 ) )
1505 item = dataItem( filePath, parent );
1508 item = dataItem( vsiPath, parent );
1525 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1530 if ( scanZipSetting == QLatin1String(
"no" ) )
1537 char **papszSiblingFiles = VSIReadDirRecursive( QString(
mVsiPrefix +
mFilePath ).toLocal8Bit().constData() );
1538 if ( papszSiblingFiles )
1540 for (
int i = 0; papszSiblingFiles[i]; i++ )
1542 tmpPath = papszSiblingFiles[i];
1545 if ( tmpPath.right( 1 ) != QLatin1String(
"/" ) )
1548 CSLDestroy( papszSiblingFiles );
1560 QgsProjectHomeItem::QgsProjectHomeItem(
QgsDataItem *
parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1565 QIcon QgsProjectHomeItem::icon()
1570 QVariant QgsProjectHomeItem::sortKey()
const 1572 return QStringLiteral(
" 1" );
1575 QList<QAction *> QgsProjectHomeItem::actions( QWidget *parent )
1578 QAction *separator =
new QAction( parent );
1579 separator->setSeparator(
true );
1580 lst.append( separator );
1582 QAction *setHome =
new QAction( tr(
"Set Project Home…" ), parent );
1583 connect( setHome, &QAction::triggered,
this, [ = ]
1586 QString newPath = QFileDialog::getExistingDirectory( parent, tr(
"Select Project Home Directory" ), oldHome );
1587 if ( !newPath.isEmpty() )
1597 QgsFavoriteItem::QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1599 , mFavorites( parent )
1604 void QgsFavoriteItem::rename(
const QString &
name )
1606 mFavorites->renameFavorite( dirPath(), name );
A Collection: logical collection of layers or subcollections, e.g.
QString layerType
Type of URI. Recognized types: "vector" / "raster" / "mesh" / "plugin" / "custom" / "project"...
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...
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 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 QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static void deleteLater(QVector< QgsDataItem *> &items)
QgsDataItem * parent() const
Gets item parent.
static QIcon iconPolygon()
void beginRemoveItems(QgsDataItem *parent, int first, int last)
#define QgsDebugMsgLevel(str, level)
LayerType
Types of layers that can be added to a map.
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 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).
QList< QgsDataItemProvider * > providers() const
Gets 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
void setPresetHomePath(const QString &path)
Sets the project's home path.
QVector< QgsDataItem * > createChildren() override
Create children.
void moveToThread(QThread *targetThread)
Move object and all its descendants to thread.
static QVector< dataItem_t * > sDataItemPtr
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.
static QgsProject * instance()
Returns the QgsProject singleton instance.
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.
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()
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)
QgsDataItem * dataItem_t(QString, QgsDataItem *)
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.
QList< QAction * > actions(QWidget *parent) override
Returns the list of actions available for this item.
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
static QString iconName(LayerType layerType)
Returns the icon name of the given layerType.