18 #include <QApplication> 19 #include <QtConcurrentMap> 20 #include <QtConcurrentRun> 25 #include <QMouseEvent> 26 #include <QTreeWidget> 27 #include <QTreeWidgetItem> 30 #include <QDesktopServices> 40 #include "qgsconfig.h" 45 #define CPL_SUPRESS_CPLUSPLUS //#spellok 47 #include "cpl_string.h" 92 QStyle *style = QApplication::style();
93 sIcon = QIcon( style->standardPixmap( QStyle::SP_DirClosedIcon ) );
94 sIcon.addPixmap( style->standardPixmap( QStyle::SP_DirOpenIcon ),
95 QIcon::Normal, QIcon::On );
108 return QStringLiteral(
" 0" );
127 , mDeferredDelete( false )
128 , mFutureWatcher( nullptr )
143 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
146 QgsDebugMsg(
"mFutureWatcher not finished (should not happen) -> waitForFinished()" );
147 mDeferredDelete =
true;
148 mFutureWatcher->waitForFinished();
151 delete mFutureWatcher;
156 return QString(
string ).replace( QRegExp(
"[\\\\/]" ), QStringLiteral(
"|" ) );
181 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
183 QgsDebugMsg(
"mFutureWatcher not finished -> schedule to delete later" );
184 mDeferredDelete =
true;
188 QObject::deleteLater();
211 child->QObject::setParent(
nullptr );
214 QObject::moveToThread( targetThread );
220 return sPopulatingIcon->
icon();
222 if ( !
mIcon.isNull() )
241 return QVector<QgsDataItem *>();
259 if ( !mFutureWatcher )
261 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
265 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
270 QVector<QgsDataItem *> QgsDataItem::runCreateChildren(
QgsDataItem *item )
276 QgsDebugMsgLevel( QString(
"%1 children created in %2 ms" ).arg( children.size() ).arg( time.elapsed() ), 3 );
286 QgsDebugMsgLevel( QString(
"finished path %1: %2 children" ).arg( item->
path() ).arg( children.size() ), 3 );
292 QgsDebugMsgLevel( QString(
"path = %1 children.size() = %2" ).arg(
path() ).arg( mFutureWatcher->result().size() ), 3 );
296 QgsDebugMsg(
"Item was scheduled to be deleted later" );
297 QObject::deleteLater();
303 populate( mFutureWatcher->result() );
307 refresh( mFutureWatcher->result() );
359 if ( !mFutureWatcher )
361 mFutureWatcher =
new QFutureWatcher< QVector <QgsDataItem *> >( this );
364 mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren,
this ) );
387 QVector<QgsDataItem *>
remove;
392 if (
findItem( children, child ) >= 0 )
394 remove.append( child );
439 disconnect(
this,
nullptr,
mParent,
nullptr );
474 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
519 for (
int i = 0; i < items.size(); i++ )
521 Q_ASSERT_X( items[i],
"findItem", QString(
"item %1 is nullptr" ).arg( i ).toLatin1() );
523 if ( items[i]->
equal( item ) )
531 return ( metaObject()->className() == other->metaObject()->className() &&
538 return QList<QAction *>();
561 if ( !sPopulatingIcon )
585 return QList<QMenu *>();
592 , mProviderKey( providerKey )
594 , mLayerType( layerType )
610 static int enumIdx = staticMetaObject.indexOfEnumerator(
"LayerType" );
611 return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
619 return QStringLiteral(
"/mIconPointLayer.svg" );
622 return QStringLiteral(
"/mIconLineLayer.svg" );
625 return QStringLiteral(
"/mIconPolygonLayer.svg" );
629 return QStringLiteral(
"/mIconPolygonLayer.svg" );
633 return QStringLiteral(
"/mIconTableLayer.svg" );
636 return QStringLiteral(
"/mIconRaster.svg" );
639 return QStringLiteral(
"/mIconLayer.png" );
666 u.
layerType = QStringLiteral(
"vector" );
669 u.
layerType = QStringLiteral(
"raster" );
672 u.
layerType = QStringLiteral(
"plugin" );
691 mIconName = QStringLiteral(
"/mIconDbSchema.svg" );
702 QgsDebugMsgLevel( QString(
"delete child = 0x%0" ).arg( ( qlonglong )i, 8, 16, QLatin1Char(
'0' ) ), 2 );
713 , mRefreshLater( false )
722 , mRefreshLater( false )
748 QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
749 Q_FOREACH (
const QString &subdir, entries )
757 QString subdirPath = dir.absoluteFilePath( subdir );
765 bool handledByProvider =
false;
768 if ( provider->handlesDirectoryPath( path ) )
770 handledByProvider =
true;
774 if ( handledByProvider )
780 item->
setSortKey( QStringLiteral(
" %1" ).arg( subdir ) );
784 children.append( item );
787 QStringList fileEntries = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files, QDir::Name );
788 Q_FOREACH (
const QString &
name, fileEntries )
796 QString
path = dir.absoluteFilePath( name );
797 QFileInfo fileInfo( path );
799 if ( fileInfo.suffix() == QLatin1String(
"qgs" ) || fileInfo.suffix() == QLatin1String(
"qgz" ) )
802 children.append( item );
812 children.append( item );
819 int capabilities = provider->capabilities();
827 QgsDataItem *item = provider->createDataItem( path,
this );
830 children.append( item );
844 if ( !mFileSystemWatcher )
846 mFileSystemWatcher =
new QFileSystemWatcher(
this );
847 mFileSystemWatcher->addPath(
mDirPath );
850 mLastScan = QDateTime::currentDateTime();
854 if ( mFileSystemWatcher )
856 delete mFileSystemWatcher;
857 mFileSystemWatcher =
nullptr;
865 if ( mLastScan.msecsTo( QDateTime::currentDateTime() ) <
QgsSettings().
value( QStringLiteral(
"browser/minscaninterval" ), 10000 ).toInt() )
872 mRefreshLater =
true;
886 QTimer::singleShot( 100,
this, SLOT(
refresh() ) );
893 QStringList hiddenItems = settings.
value( QStringLiteral(
"browser/hiddenPaths" ),
894 QStringList() ).toStringList();
895 int idx = hiddenItems.indexOf( path );
901 QList<QAction *> result;
902 QAction *openFolder =
new QAction( tr(
"Open Directory…" ), parent );
903 connect( openFolder, &QAction::triggered,
this, [ = ]
905 QDesktopServices::openUrl( QUrl::fromLocalFile(
mDirPath ) );
907 result << openFolder;
914 QgsDebugMsgLevel( QString(
"mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
918 QgsDebugMsgLevel(
"directory changed during createChidren() -> refresh() again", 3 );
919 mRefreshLater =
false;
947 : QTreeWidget( parent )
949 setRootIsDecorated(
false );
954 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
955 setHeaderLabels( labels );
957 QStyle *style = QApplication::style();
958 QIcon iconDirectory = QIcon( style->standardPixmap( QStyle::SP_DirClosedIcon ) );
959 QIcon iconFile = QIcon( style->standardPixmap( QStyle::SP_FileIcon ) );
960 QIcon iconDirLink = QIcon( style->standardPixmap( QStyle::SP_DirLinkIcon ) );
961 QIcon iconFileLink = QIcon( style->standardPixmap( QStyle::SP_FileLinkIcon ) );
963 QList<QTreeWidgetItem *> items;
966 QStringList entries = dir.entryList( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
967 Q_FOREACH (
const QString &name, entries )
969 QFileInfo fi( dir.absoluteFilePath( name ) );
973 if ( fi.size() > 1024 )
975 size = size.sprintf(
"%.1f KiB", fi.size() / 1024.0 );
977 else if ( fi.size() > 1.048576e6 )
979 size = size.sprintf(
"%.1f MiB", fi.size() / 1.048576e6 );
983 size = QStringLiteral(
"%1 B" ).arg( fi.size() );
986 texts << fi.lastModified().toString( Qt::SystemLocaleShortDate );
988 perm += fi.permission( QFile::ReadOwner ) ?
'r' :
'-';
989 perm += fi.permission( QFile::WriteOwner ) ?
'w' :
'-';
990 perm += fi.permission( QFile::ExeOwner ) ?
'x' :
'-';
992 perm += fi.permission( QFile::ReadGroup ) ?
'r' :
'-';
993 perm += fi.permission( QFile::WriteGroup ) ?
'w' :
'-';
994 perm += fi.permission( QFile::ExeGroup ) ?
'x' :
'-';
995 perm += fi.permission( QFile::ReadOther ) ?
'r' :
'-';
996 perm += fi.permission( QFile::WriteOther ) ?
'w' :
'-';
997 perm += fi.permission( QFile::ExeOther ) ?
'x' :
'-';
1000 texts << fi.owner();
1001 texts << fi.group();
1005 if ( fi.isDir() && fi.isSymLink() )
1007 type = tr(
"folder" );
1010 else if ( fi.isDir() )
1012 type = tr(
"folder" );
1013 icon = iconDirectory;
1015 else if ( fi.isFile() && fi.isSymLink() )
1017 type = tr(
"file" );
1018 icon = iconFileLink;
1020 else if ( fi.isFile() )
1022 type = tr(
"file" );
1028 QTreeWidgetItem *item =
new QTreeWidgetItem( texts );
1029 item->setIcon( 0, icon );
1033 addTopLevelItems( items );
1037 QList<QVariant> lst = settings.
value( QStringLiteral(
"dataitem/directoryHiddenColumns" ) ).toList();
1038 Q_FOREACH (
const QVariant &colVariant, lst )
1040 setColumnHidden( colVariant.toInt(), true );
1046 if ( event->button() == Qt::RightButton )
1052 labels << tr(
"Name" ) << tr(
"Size" ) << tr(
"Date" ) << tr(
"Permissions" ) << tr(
"Owner" ) << tr(
"Group" ) << tr(
"Type" );
1053 for (
int i = 0; i < labels.count(); i++ )
1055 QAction *action = popupMenu.addAction( labels[i],
this, SLOT(
showHideColumn() ) );
1056 action->setObjectName( QString::number( i ) );
1057 action->setCheckable(
true );
1058 action->setChecked( !isColumnHidden( i ) );
1061 popupMenu.exec( event->globalPos() );
1067 QAction *action = qobject_cast<QAction *>( sender() );
1071 int columnIndex = action->objectName().toInt();
1072 setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
1076 QList<QVariant> lst;
1077 for (
int i = 0; i < columnCount(); i++ )
1079 if ( isColumnHidden( i ) )
1080 lst.append( QVariant( i ) );
1082 settings.
setValue( QStringLiteral(
"dataitem/directoryHiddenColumns" ), lst );
1088 mIconName = QStringLiteral(
":/images/icons/qgis-icon-16x16.png" );
1089 setToolTip( QDir::toNativeSeparators( path ) );
1096 mIconName = QStringLiteral(
"/mIconDelete.svg" );
1107 mIconName = QStringLiteral(
"/mIconFavourites.svg" );
1116 const QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ), QVariant() ).toStringList();
1118 for (
const QString &favDir : favDirs )
1120 QStringList parts = favDir.split( QStringLiteral(
"|||" ) );
1121 if ( parts.empty() )
1124 QString dir = parts.at( 0 );
1126 if ( parts.count() > 1 )
1127 name = parts.at( 1 );
1137 QString
name = n.isEmpty() ? favDir : n;
1140 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1141 favDirs.append( QStringLiteral(
"%1|||%2" ).arg( favDir, name ) );
1142 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1160 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1161 for (
int i = favDirs.count() - 1; i >= 0; --i )
1163 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1164 if ( parts.empty() )
1167 QString dir = parts.at( 0 );
1169 favDirs.removeAt( i );
1171 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1176 QgsDebugMsg( QString(
"favorites item %1 not found" ).arg( item->
path() ) );
1188 QStringList favDirs = settings.
value( QStringLiteral(
"browser/favourites" ) ).toStringList();
1189 for (
int i = 0; i < favDirs.count(); ++i )
1191 QStringList parts = favDirs.at( i ).split( QStringLiteral(
"|||" ) );
1192 if ( parts.empty() )
1195 QString dir = parts.at( 0 );
1198 favDirs[i] = QStringLiteral(
"%1|||%2" ).arg( path, name );
1202 settings.
setValue( QStringLiteral(
"browser/favourites" ), favDirs );
1205 const QVector<QgsDataItem *> ch =
children();
1208 if ( QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( child ) )
1210 if ( favorite->dirPath() ==
path )
1212 favorite->setName( name );
1233 children.append( item );
1237 if ( children.isEmpty() )
1239 QgsFavoriteItem *item =
new QgsFavoriteItem(
this, name, favDir,
mPath +
'/' + pathName );
1242 children.append( item );
1267 void QgsZipItem::init()
1270 mIconName = QStringLiteral(
"/mIconZip.png" );
1279 keys << QStringLiteral(
"gdal" ) << QStringLiteral(
"ogr" );
1281 for (
const auto &k : qgis::as_const( keys ) )
1290 if ( !dataCapabilities )
1292 QgsDebugMsg( library->fileName() +
" does not have dataCapabilities" );
1297 QgsDebugMsg( library->fileName() +
" has NoDataCapabilities" );
1300 QgsDebugMsg( QString(
"%1 dataCapabilities : %2" ).arg( library->fileName() ).arg( dataCapabilities() ) );
1305 QgsDebugMsg( library->fileName() +
" does not have dataItem" );
1329 char **papszOFiles =
nullptr;
1330 char **papszFiles1 =
nullptr;
1331 char **papszFiles2 =
nullptr;
1332 VSIStatBufL psStatBuf;
1333 QString temp1, temp2;
1335 int nCount1, nCount2;
1338 papszFiles1 = VSIReadDir( pszPath );
1339 if ( ! papszFiles1 )
1343 nCount1 = CSLCount( papszFiles1 );
1344 for ( i = 0; i < nCount1; i++ )
1347 temp1 = QString(
"%1/%2" ).arg( pszPath, papszFiles1[i] );
1350 if ( VSIStatL( temp1.toUtf8(), &psStatBuf ) == 0 &&
1351 VSI_ISREG( psStatBuf.st_mode ) )
1354 papszOFiles = CSLAddString( papszOFiles, papszFiles1[i] );
1356 else if ( VSIStatL( temp1.toUtf8(), &psStatBuf ) == 0 &&
1357 VSI_ISDIR( psStatBuf.st_mode ) )
1360 temp2 = QString(
"%1/" ).arg( papszFiles1[i] );
1363 papszOFiles = CSLAddString( papszOFiles, temp2.toUtf8() );
1369 nCount2 = CSLCount( papszFiles2 );
1370 for ( j = 0; j < nCount2; j++ )
1372 temp2 = QString(
"%1/%2" ).arg( papszFiles1[i], papszFiles2[j] );
1375 papszOFiles = CSLAddString( papszOFiles, temp2.toUtf8() );
1377 CSLDestroy( papszFiles2 );
1381 CSLDestroy( papszFiles1 );
1392 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1399 if ( scanZipSetting == QLatin1String(
"no" ) )
1410 QFileInfo info( fileName );
1420 if ( info.suffix().toLower() == QLatin1String(
"dbf" ) )
1422 if (
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) +
".shp" ) != -1 )
1425 if ( info.completeSuffix().toLower() == QLatin1String(
"shp.xml" ) )
1442 children.append( item );
1464 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1465 int zipFileCount = 0;
1466 QStringList zipFileList;
1469 bool populated =
false;
1471 QgsDebugMsgLevel( QString(
"path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path, name, scanZipSetting, vsiPrefix ), 3 );
1474 if ( scanZipSetting == QLatin1String(
"no" ) )
1478 if ( ( vsiPrefix != QLatin1String(
"/vsizip/" ) && vsiPrefix != QLatin1String(
"/vsitar/" ) ) )
1481 zipItem =
new QgsZipItem( parent, name, filePath, path );
1491 if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) ||
1492 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) )
1497 if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
1505 QgsDebugMsgLevel( QString(
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
1510 if ( zipItem && ( !populated || zipItem->
rowCount() > 1 ) )
1518 QString vsiPath = vsiPrefix + filePath;
1522 if ( children.size() == 1 )
1527 vsiPath = layerItem->
uri();
1529 zipFileCount = zipFileList.count();
1533 QgsDebugMsgLevel( QString(
"will try to create a normal dataItem from filePath= %2 or vsiPath = %3" ).arg( filePath, vsiPath ), 3 );
1546 (
sProviderNames.at( i ) == QLatin1String(
"gdal" ) && zipFileCount == 1 ) )
1547 item = dataItem( filePath, parent );
1550 item = dataItem( vsiPath, parent );
1567 QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
1572 if ( scanZipSetting == QLatin1String(
"no" ) )
1580 if ( papszSiblingFiles )
1582 for (
int i = 0; i < CSLCount( papszSiblingFiles ); i++ )
1584 tmpPath = papszSiblingFiles[i];
1587 if ( tmpPath.right( 1 ) != QLatin1String(
"/" ) )
1590 CSLDestroy( papszSiblingFiles );
1602 QgsProjectHomeItem::QgsProjectHomeItem(
QgsDataItem *
parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1607 QIcon QgsProjectHomeItem::icon()
1612 QVariant QgsProjectHomeItem::sortKey()
const 1614 return QStringLiteral(
" 1" );
1617 QgsFavoriteItem::QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &
name,
const QString &dirPath,
const QString &
path )
1619 , mFavorites( parent )
1624 void QgsFavoriteItem::rename(
const QString &
name )
1626 mFavorites->renameFavorite( dirPath(), name );
A Collection: logical collection of layers or subcollections, e.g.
QString layerType
Type of URI. Recognized types: "vector" / "raster" / "plugin" / "custom".
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...
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)
char ** VSIReadDirRecursive1(const char *pszPath)
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).
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static void deleteLater(QVector< QgsDataItem *> &items)
QgsDataItem * parent() const
Get 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
Return 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
Get 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.
static QVector< dataItem_t * > sDataItemPtr
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
Return mime URI for the data item.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
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.
QIcon icon() const
Get 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).
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.