QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
25 #include <cpl_string.h>
46 const QString &filePath,
const QString &path,
47 const QString &providerKey )
49 , mFilePath( filePath )
54 void QgsZipItem::init()
57 mIconName = QStringLiteral(
"/mIconZip.svg" );
62 static std::once_flag initialized;
63 std::call_once( initialized, [ = ]
77 u.
layerType = QStringLiteral(
"collection" );
88 const QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
95 if ( scanZipSetting == QLatin1String(
"no" ) )
107 for (
const QString &fileName : constMZipFileList )
109 const QFileInfo info( fileName );
119 if ( provider->name() == QLatin1String(
"OGR" ) )
121 if ( info.suffix().compare( QLatin1String(
"dbf" ), Qt::CaseInsensitive ) == 0 )
123 if (
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) +
".shp" ) != -1 )
126 if ( info.completeSuffix().compare( QLatin1String(
"shp.xml" ), Qt::CaseInsensitive ) == 0 )
132 QgsDebugMsgLevel( QStringLiteral(
"trying to load item %1 with %2" ).arg( tmpPath, provider->name() ), 3 );
133 QgsDataItem *item = provider->createDataItem( tmpPath,
this );
158 const QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
159 QStringList zipFileList;
162 bool populated =
false;
167 if ( scanZipSetting == QLatin1String(
"no" ) )
171 if ( (
vsiPrefix != QLatin1String(
"/vsizip/" ) &&
vsiPrefix != QLatin1String(
"/vsitar/" ) ) )
184 if (
path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) ||
185 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) )
190 if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
194 QgsDebugMsgLevel( QStringLiteral(
"Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->
rowCount() ).arg( zipItem->
path(), zipItem->
name() ), 3 );
198 QgsDebugMsgLevel( QStringLiteral(
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
203 if ( zipItem && ( !populated || zipItem->
rowCount() > 0 ) )
219 const QString scanZipSetting = settings.
value( QStringLiteral(
"qgis/scanZipInBrowser2" ),
"basic" ).toString();
224 if ( scanZipSetting == QLatin1String(
"no" ) )
231 char **papszSiblingFiles = VSIReadDirRecursive( QString(
mVsiPrefix +
mFilePath ).toLocal8Bit().constData() );
232 if ( papszSiblingFiles )
234 for (
int i = 0; papszSiblingFiles[i]; i++ )
236 tmpPath = papszSiblingFiles[i];
239 if ( tmpPath.right( 1 ) != QLatin1String(
"/" ) )
242 CSLDestroy( papszSiblingFiles );
@ Collection
A collection of items.
QString uri
Identifier of the data source recognized by its providerKey.
A Collection: logical collection of layers or subcollections, e.g. GRASS location/mapset,...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
#define QgsDebugMsgLevel(str, level)
A zip file: contains layers, using GDAL/OGR VSIFILE mechanism.
QString layerType
Type of URI.
QStringList getZipFileList()
static QgsDataItem * itemFromPath(QgsDataItem *parent, const QString &path, const QString &name)
Creates a new data item from the specified path.
QString name() const
Returns the name of the item (the displayed text for the item).
This class is a composition of two QSettings instances:
QList< QgsMimeDataUtils::Uri > UriList
QVector< QgsDataItem * > createChildren() override
Create children.
Qgis::BrowserItemType mType
@ ItemRepresentsFile
Item's path() directly represents a file on disk (since QGIS 3.22)
QgsMimeDataUtils::UriList mimeUris() const override
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
QgsDataItem * parent() const
Gets item parent.
QList< QgsDataItemProvider * > providers() const
Returns the list of available providers.
This is the interface for those who want to add custom data items to the browser tree.
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
QString filePath
Path to file, if uri is associated with a file.
static QString vsiPrefix(const QString &uri)
void setName(const QString &name)
Sets the name of the item (the displayed text for the item).
QgsZipItem(QgsDataItem *parent, const QString &name, const QString &path)
Constructor.
virtual void setCapabilities(Qgis::BrowserItemCapabilities capabilities)
Sets the capabilities for the data item.
virtual void populate(const QVector< QgsDataItem * > &children)
QVector< QgsDataItem * > children() const
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QStringList sProviderNames
bool hasDragEnabled() const override
Returns true if the item may be dragged.
Base class for all items in the model.