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" );
 
   60   static std::once_flag initialized;
 
   61   std::call_once( initialized, [ = ]
 
   63     sProviderNames << QStringLiteral( 
"OGR" ) << QStringLiteral( 
"GDAL" );
 
   72   QString scanZipSetting = settings.value( QStringLiteral( 
"qgis/scanZipInBrowser2" ), 
"basic" ).toString();
 
   79   if ( scanZipSetting == QLatin1String( 
"no" ) )
 
   91   for ( 
const QString &fileName : constMZipFileList )
 
   93     QFileInfo info( fileName );
 
  103       if ( provider->name() == QLatin1String( 
"OGR" ) )
 
  105         if ( info.suffix().compare( QLatin1String( 
"dbf" ), Qt::CaseInsensitive ) == 0 )
 
  107           if ( 
mZipFileList.indexOf( fileName.left( fileName.count() - 4 ) + 
".shp" ) != -1 )
 
  110         if ( info.completeSuffix().compare( QLatin1String( 
"shp.xml" ), Qt::CaseInsensitive ) == 0 )
 
  116       QgsDebugMsgLevel( QStringLiteral( 
"trying to load item %1 with %2" ).arg( tmpPath, provider->name() ), 3 );
 
  117       QgsDataItem *item = provider->createDataItem( tmpPath, 
this );
 
  141   QgsSettings settings;
 
  142   QString scanZipSetting = settings.value( QStringLiteral( 
"qgis/scanZipInBrowser2" ), 
"basic" ).toString();
 
  143   QStringList zipFileList;
 
  146   bool populated = 
false;
 
  151   if ( scanZipSetting == QLatin1String( 
"no" ) )
 
  155   if ( ( 
vsiPrefix != QLatin1String( 
"/vsizip/" ) && 
vsiPrefix != QLatin1String( 
"/vsitar/" ) ) )
 
  168     if ( 
path.endsWith( QLatin1String( 
".zip" ), Qt::CaseInsensitive ) ||
 
  169          path.endsWith( QLatin1String( 
".tar" ), Qt::CaseInsensitive ) )
 
  174     if ( !zipFileList.isEmpty() && zipFileList.count() <= 10 )
 
  178       QgsDebugMsgLevel( QStringLiteral( 
"Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->
rowCount() ).arg( zipItem->
path(), zipItem->
name() ), 3 );
 
  182       QgsDebugMsgLevel( QStringLiteral( 
"Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->
path(), zipItem->
name() ), 3 );
 
  187   if ( zipItem && ( !populated || zipItem->
rowCount() > 0 ) )
 
  202   QgsSettings settings;
 
  203   QString scanZipSetting = settings.value( QStringLiteral( 
"qgis/scanZipInBrowser2" ), 
"basic" ).toString();
 
  208   if ( scanZipSetting == QLatin1String( 
"no" ) )
 
  215   char **papszSiblingFiles = VSIReadDirRecursive( QString( 
mVsiPrefix + 
mFilePath ).toLocal8Bit().constData() );
 
  216   if ( papszSiblingFiles )
 
  218     for ( 
int i = 0; papszSiblingFiles[i]; i++ )
 
  220       tmpPath = papszSiblingFiles[i];
 
  223       if ( tmpPath.right( 1 ) != QLatin1String( 
"/" ) )
 
  226     CSLDestroy( papszSiblingFiles );
 
@ Collection
A collection of items.
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A Collection: logical collection of layers or subcollections, e.g.
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.
Base class for all items in the model.
Qgis::BrowserItemType mType
QVector< QgsDataItem * > children() const
QgsDataItem * parent() const
Gets item parent.
QString name() const
Returns the name of the item (the displayed text for the item).
void setName(const QString &name)
Sets the name of the item (the displayed text for the item).
virtual void populate(const QVector< QgsDataItem * > &children)
A zip file: contains layers, using GDAL/OGR VSIFILE mechanism.
QgsZipItem(QgsDataItem *parent, const QString &name, const QString &path)
Constructor.
QStringList getZipFileList()
static QgsDataItem * itemFromPath(QgsDataItem *parent, const QString &path, const QString &name)
Creates a new data item from the specified path.
static QString vsiPrefix(const QString &uri)
QVector< QgsDataItem * > createChildren() override
Create children.
static QStringList sProviderNames
#define QgsDebugMsgLevel(str, level)