Skip to content
Permalink
Browse files
add option to bypass dataset scanning in browser dock
  • Loading branch information
etiennesky committed Apr 2, 2012
1 parent 90108d8 commit eca9640429f05adc133b81b993a352abbbfb919b
@@ -196,6 +196,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cmbPromptRasterSublayers->addItem( tr( "Load all" ) );
cmbPromptRasterSublayers->setCurrentIndex( settings.value( "/qgis/promptForRasterSublayers", 0 ).toInt() );

// 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() );

// Scan for contents of compressed files (.zip) in browser dock
cmbScanZipInBrowser->clear();
cmbScanZipInBrowser->addItem( tr( "No" ) ); // 0
@@ -636,6 +642,7 @@ 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/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
@@ -112,6 +112,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
QSettings settings;
//extract basename with extension
QString name = info.fileName();
int scanItemsSetting = settings.value( "/qgis/scanItemsInBrowser", 0 ).toInt();
int scanZipSetting = settings.value( "/qgis/scanZipInBrowser", 1 ).toInt();

// allow normal files or VSIFILE items to pass
@@ -176,6 +177,17 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
}
}

// if scan items == "Check extension", add item here without trying to open
if ( scanItemsSetting == 1 )
{
QStringList sublayers;
QgsDebugMsg( QString( "adding item name=%1 thePath=%2 uri=%3" ).arg( name ).arg( thePath ).arg( uri ) );
QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, thePath, &sublayers );
if ( item )
return item;
}


// try to open using VSIFileHandler
if ( thePath.right( 4 ) == ".zip" )
{
@@ -231,6 +231,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
QFileInfo info( thePath );
QString name = info.fileName();
QSettings settings;
int scanItemsSetting = settings.value( "/qgis/scanItemsInBrowser", 0 ).toInt();
int scanZipSetting = settings.value( "/qgis/scanZipInBrowser", 1 ).toInt();

// allow normal files or VSIFILE items to pass
@@ -291,6 +292,14 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
}
}

// if scan items == "Check extension", add item here without trying to open
if ( scanItemsSetting == 1 )
{
QgsLayerItem * item = new QgsOgrLayerItem( parentItem, name, thePath, thePath, QgsLayerItem::Vector );
if ( item )
return item;
}

// try to open using VSIFileHandler
if ( thePath.right( 4 ) == ".zip" )
{
@@ -602,6 +602,33 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>Scan for valid items in the browser dock</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="cmbScanItemsInBrowser"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>

0 comments on commit eca9640

Please sign in to comment.