Skip to content
Permalink
Browse files

remove Passthru option and change storage of options scanZipInBrowser…

… and scanItemsInBrowser
  • Loading branch information
etiennesky authored and jef-n committed Jun 16, 2012
1 parent abf3280 commit 4aab209400341b2c263f0e1a07b89fce303af656
@@ -202,17 +202,21 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

// Scan for valid items in the browser dock
cmbScanItemsInBrowser->clear();
cmbScanItemsInBrowser->addItem( tr( "Check file contents" ) ); // 0
cmbScanItemsInBrowser->addItem( tr( "Check extension" ) ); // 1
cmbScanItemsInBrowser->setCurrentIndex( settings.value( "/qgis/scanItemsInBrowser", 1 ).toInt() );
cmbScanItemsInBrowser->addItem( tr( "Check file contents" ), "contents" ); // 0
cmbScanItemsInBrowser->addItem( tr( "Check extension" ), "extension" ); // 1
int index = cmbScanItemsInBrowser->findData( settings.value( "/qgis/scanItemsInBrowser", "" ) );
if ( index == -1 ) index = 1;
cmbScanItemsInBrowser->setCurrentIndex( index );

// Scan for contents of compressed files (.zip) in browser dock
cmbScanZipInBrowser->clear();
cmbScanZipInBrowser->addItem( tr( "No" ) ); // 0
cmbScanZipInBrowser->addItem( tr( "Passthru" ) ); // 1
cmbScanZipInBrowser->addItem( tr( "Basic scan" ) ); // 2
cmbScanZipInBrowser->addItem( tr( "Full scan" ) ); // 3
cmbScanZipInBrowser->setCurrentIndex( settings.value( "/qgis/scanZipInBrowser", 2 ).toInt() );
cmbScanZipInBrowser->addItem( tr( "No" ), QVariant( "no" ) );
// cmbScanZipInBrowser->addItem( tr( "Passthru" ) ); // 1 - removed
cmbScanZipInBrowser->addItem( tr( "Basic scan" ), QVariant( "basic" ) );
cmbScanZipInBrowser->addItem( tr( "Full scan" ), QVariant( "full" ) );
index = cmbScanZipInBrowser->findData( settings.value( "/qgis/scanZipInBrowser", "" ) );
if ( index == -1 ) index = 1;
cmbScanZipInBrowser->setCurrentIndex( index );

// set the display update threshold
spinBoxUpdateThreshold->setValue( settings.value( "/Map/updateThreshold" ).toInt() );
@@ -442,7 +446,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mDefaultSnapModeComboBox->setCurrentIndex( mDefaultSnapModeComboBox->findData( defaultSnapString ) );
mDefaultSnappingToleranceSpinBox->setValue( settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble() );
mSearchRadiusVertexEditSpinBox->setValue( settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble() );
int index;
if ( settings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt() == QgsTolerance::MapUnits )
{
index = mDefaultSnappingToleranceComboBox->findText( tr( "map units" ) );
@@ -697,8 +700,10 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() );
settings.setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
settings.setValue( "/qgis/promptForRasterSublayers", cmbPromptRasterSublayers->currentIndex() );
settings.setValue( "/qgis/scanItemsInBrowser", cmbScanItemsInBrowser->currentIndex() );
settings.setValue( "/qgis/scanZipInBrowser", cmbScanZipInBrowser->currentIndex() );
settings.setValue( "/qgis/scanItemsInBrowser",
cmbScanItemsInBrowser->itemData( cmbScanItemsInBrowser->currentIndex() ).toString() );
settings.setValue( "/qgis/scanZipInBrowser",
cmbScanZipInBrowser->itemData( cmbScanZipInBrowser->currentIndex() ).toString() );
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
@@ -477,7 +477,7 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
QVector<QgsDataItem*> children;
QDir dir( mPath );
QSettings settings;
bool scanZip = ( settings.value( "/qgis/scanZipInBrowser", 2 ).toInt() != 0 );
bool scanZip = ( settings.value( "/qgis/scanZipInBrowser", QVariant( "basic" ) ).toString() != "no" );

QStringList entries = dir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
foreach( QString subdir, entries )
@@ -881,25 +881,25 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
QString childPath;

QSettings settings;
int scanZipSetting = settings.value( "/qgis/scanZipInBrowser", 2 ).toInt();
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString();

mZipFileList.clear();

QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3" ).arg( path() ).arg( name() ).arg( scanZipSetting ) );

// if scanZipBrowser == 0 (No): skip to the next file
if ( scanZipSetting == 0 )
// if scanZipBrowser == no: skip to the next file
if ( scanZipSetting == "no" )
{
return children;
}

// if scanZipBrowser == 1 (Passthru): do not scan zip and allow to open directly with /vsizip/
if ( scanZipSetting == 1 )
{
mPath = "/vsizip/" + path(); // should check for extension
QgsDebugMsg( "set path to " + path() );
return children;
}
// if scanZipBrowser == passthru: do not scan zip and allow to open directly with /vsizip/
// if ( scanZipSetting == 1 )
// {
// mPath = "/vsizip/" + path(); // should check for extension
// QgsDebugMsg( "set path to " + path() );
// return children;
// }

// get list of files inside zip file
QgsDebugMsg( QString( "Open file %1 with gdal vsi" ).arg( path() ) );
@@ -981,25 +981,25 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QString name )
{
QSettings settings;
int scanZipSetting = settings.value( "/qgis/scanZipInBrowser", 2 ).toInt();
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString();
QString vsizipPath = path;
int zipFileCount = 0;
QFileInfo fileInfo( path );
QgsZipItem * zipItem = 0;

QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3" ).arg( path ).arg( name ).arg( scanZipSetting ) );

// if scanZipBrowser == 0 (No): skip to the next file
if ( scanZipSetting == 0 )
// if scanZipBrowser == no: skip to the next file
if ( scanZipSetting == "no" )
{
return 0;
}
// if scanZipBrowser == 1 (Passthru): do not scan zip and allow to open directly with /vsizip/
else if ( scanZipSetting == 1 )
{
vsizipPath = "/vsizip/" + path;
zipItem = 0;
}
// if scanZipBrowser == passthru: do not scan zip and allow to open directly with /vsizip/
// else if ( scanZipSetting == 1 )
// {
// vsizipPath = "/vsizip/" + path;
// zipItem = 0;
// }
else
{
zipItem = new QgsZipItem( parent, name, path );
@@ -1041,8 +1041,8 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
// try first with normal path (Passthru)
// this is to simplify .qml handling, and without this some tests will fail
// (e.g. testZipItemVectorTransparency(), second test)
if (( scanZipSetting == 1 ) ||
( mProviderNames[i] == "ogr" ) ||
// if (( scanZipSetting == 1 ) ||
if (( mProviderNames[i] == "ogr" ) ||
( mProviderNames[i] == "gdal" && zipFileCount == 1 ) )
item = dataItem( path, parent );
// try with /vsizip/
@@ -398,8 +398,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )

// zip settings + info
QSettings settings;
int scanItemsSetting = settings.value( "/qgis/scanItemsInBrowser", 0 ).toInt();
int scanZipSetting = settings.value( "/qgis/scanZipInBrowser", 2 ).toInt();
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString();
bool is_vsizip = ( thePath.startsWith( "/vsizip/" ) ||
thePath.endsWith( ".zip", Qt::CaseInsensitive ) );
bool is_vsigzip = ( thePath.startsWith( "/vsigzip/" ) ||
@@ -415,7 +414,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
info.setFile( thePath );
QString name = info.fileName();

QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath );
QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name + " suffix= " + suffix );

// allow only normal files or VSIFILE items to continue
if ( !info.isFile() && !is_vsizip && !is_vsigzip )
@@ -477,8 +476,9 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
// return a /vsizip/ item without testing if:
// zipfile and scan zip == "Basic scan"
// not zipfile and scan items == "Check extension"
if (( is_vsizip && scanZipSetting == 2 ) ||
( !is_vsizip && scanItemsSetting == 1 ) )
if (( is_vsizip && scanZipSetting == "basic" ) ||
( !is_vsizip && ( settings.value( "/qgis/scanItemsInBrowser",
"extension" ).toString() == "extension" ) ) )
{
// if this is a VRT file make sure it is raster VRT to avoid duplicates
if ( suffix == "vrt" )
@@ -1916,7 +1916,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString
// VSIFileHandler (see qgsogrprovider.cpp)
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1600
QSettings settings;
if ( settings.value( "/qgis/scanZipInBrowser", 2 ).toInt() != 0 )
if ( settings.value( "/qgis/scanZipInBrowser", "basic" ).toString() != "no" )
{
QString glob = "*.zip";
glob += " *.gz";
@@ -239,8 +239,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )

// zip settings + info
QSettings settings;
int scanItemsSetting = settings.value( "/qgis/scanItemsInBrowser", 0 ).toInt();
int scanZipSetting = settings.value( "/qgis/scanZipInBrowser", 2 ).toInt();
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString();
bool is_vsizip = ( thePath.startsWith( "/vsizip/" ) ||
thePath.endsWith( ".zip", Qt::CaseInsensitive ) );
bool is_vsigzip = ( thePath.startsWith( "/vsigzip/" ) ||
@@ -256,6 +255,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
info.setFile( thePath );
QString name = info.fileName();

QgsDebugMsg( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name + " suffix= " + suffix );

// allow only normal files or VSIFILE items to continue
if ( !info.isFile() && !is_vsizip && !is_vsigzip )
return 0;
@@ -322,8 +323,9 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
// return a /vsizip/ item without testing if:
// zipfile and scan zip == "Basic scan"
// not zipfile and scan items == "Check extension"
if (( is_vsizip && scanZipSetting == 2 ) ||
( !is_vsizip && scanItemsSetting == 1 ) )
if (( is_vsizip && scanZipSetting == "basic" ) ||
( !is_vsizip && ( settings.value( "/qgis/scanItemsInBrowser",
"extension" ).toString() == "extension" ) ) )
{
// if this is a VRT file make sure it is vector VRT to avoid duplicates
if ( suffix == "vrt" )
@@ -1798,7 +1798,7 @@ QString createFilters( QString type )
// Ideally we should also add support for /vsitar/ (requires cpl_vsil_tar.cpp).
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1600
QSettings settings;
if ( settings.value( "/qgis/scanZipInBrowser", 2 ).toInt() != 0 )
if ( settings.value( "/qgis/scanZipInBrowser", "basic" ).toString() != "no" )
{
myFileFilters += createFileFilter_( QObject::tr( "GDAL/OGR VSIFileHandler" ), "*.zip *.gz" );
myExtensions << "zip" << "gz";

0 comments on commit 4aab209

Please sign in to comment.
You can’t perform that action at this time.