Skip to content
Permalink
Browse files

scanItemsInBrowser2/scanZipInBrowser2 : remove QgsApplication::upgrad…

…eConfig() and fix tests
  • Loading branch information
etiennesky committed Nov 15, 2012
1 parent 565d2eb commit 7d0d5d3267a51f4bf96586441de2e042f281d640
Showing with 11 additions and 98 deletions.
  1. +0 −85 src/core/qgsapplication.cpp
  2. +0 −4 src/core/qgsapplication.h
  3. +9 −7 tests/src/core/testqgsdataitem.cpp
  4. +2 −2 tests/src/core/testziplayer.cpp
@@ -583,9 +583,6 @@ void QgsApplication::initQgis()

// create map layer registry if doesn't exist
QgsMapLayerRegistry::instance();

// upgrade config options from older version
upgradeConfig();
}

void QgsApplication::exitQgis()
@@ -862,86 +859,4 @@ void QgsApplication::applyGdalSkippedDrivers()
GDALAllRegister(); //to update driver list and skip missing ones
}

void QgsApplication::upgradeConfig()
{
QSettings settings;

/* Due to changes in settings storage types for "scan items" and "scan zip" settings,
qgis-1.8 and qgis-1.9 have conficting values, so the keys have been renamed
Here we do a 1-time check to copy old setting to new setting
*/

// use a special settings key so we only check once
if ( ! settings.value( "/qgis/scanInBrowserUpgradeChecked", false ).toBool() )
{
QVariant v;
int i;
QString s;
bool ok;

// check if new setting is empty
if ( settings.value( "/qgis/scanItemsInBrowser2" ).isNull() )
{
v = settings.value( "/qgis/scanItemsInBrowser" );
i = v.toInt( &ok );
// check if value was defined in qgis-1.8 (as int)
if ( ! v.isNull() && ok )
{
// convert old setting to new setting
switch ( i )
{
case 0:
s = "contents";
break;
case 1:
s = "extension";
break;
default:
s = "";
break;
}
settings.setValue( "/qgis/scanItemsInBrowser2", s );
}
// check if value was defined in qgis-1.9 (as QString)
else if ( ! v.isNull() && !v.toString().isEmpty() )
{
s = v.toString();
settings.setValue( "/qgis/scanItemsInBrowser2", s );
}
}

if ( settings.value( "/qgis/scanZipInBrowser2" ).isNull() )
{
v = settings.value( "/qgis/scanZipInBrowser" );
i = v.toInt( & ok );
if ( ! v.isNull() && ok )
{
switch ( i )
{
case 0:
s = "No";
break;
case 1: // passthru removed, use basic instead
case 2:
s = "basic";
break;
case 3:
s = "full";
break;
default:
s = "";
break;
}
settings.setValue( "/qgis/scanZipInBrowser2", s );
}
else if ( ! v.isNull() && !v.toString().isEmpty() )
{
s = v.toString();
settings.setValue( "/qgis/scanZipInBrowser2", s );
}
}

settings.setValue( "/qgis/scanInBrowserUpgradeChecked", true );
}
}

@@ -270,10 +270,6 @@ class CORE_EXPORT QgsApplication: public QApplication
* @note added in 2.0 */
static void applyGdalSkippedDrivers();

/** upgrades config options from older version, called by initQGis
* @note added in 2.0 */
static void upgradeConfig();

signals:
//! @note not available in python bindings
void preNotify( QObject * receiver, QEvent * event, bool * done );
@@ -42,7 +42,7 @@ class TestQgsDataItem: public QObject

private:
QgsDirectoryItem* mDirItem;
int mScanItemsSetting;
QString mScanItemsSetting;
bool isValidDirItem( QgsDirectoryItem *item );
};

@@ -62,7 +62,7 @@ void TestQgsDataItem::initTestCase()
QCoreApplication::setApplicationName( "QGIS-TEST" );
// save current scanItemsSetting value
QSettings settings;
mScanItemsSetting = settings.value( "/qgis/scanItemsInBrowser2", 0 ).toInt();
mScanItemsSetting = settings.value( "/qgis/scanItemsInBrowser2", QVariant( "" ) ).toString();

//create a directory item that will be used in all tests...
mDirItem = new QgsDirectoryItem( 0, "Test", TEST_DATA_DIR );
@@ -94,9 +94,11 @@ void TestQgsDataItem::testValid()
void TestQgsDataItem::testDirItemChildren()
{
QSettings settings;
for ( int iSetting = 0 ; iSetting <= 1 ; iSetting++ )
QStringList tmpSettings;
tmpSettings << "" << "contents" << "extension";
foreach ( QString tmpSetting, tmpSettings )
{
settings.setValue( "/qgis/scanItemsInBrowser2", iSetting );
settings.setValue( "/qgis/scanItemsInBrowser2", tmpSetting );
QgsDirectoryItem* dirItem = new QgsDirectoryItem( 0, "Test", TEST_DATA_DIR );
QVERIFY( isValidDirItem( dirItem ) );

@@ -112,9 +114,9 @@ void TestQgsDataItem::testDirItemChildren()
QFileInfo info( layerItem->path() );
QString lFile = info.fileName();
QString lProvider = layerItem->providerKey();
QString errStr = QString( "layer #%1 - %2 provider = %3 iSetting = %4" ).arg( i ).arg( lFile ).arg( lProvider ).arg( iSetting );
QString errStr = QString( "layer #%1 - %2 provider = %3 tmpSetting = %4" ).arg( i ).arg( lFile ).arg( lProvider ).arg( tmpSetting );

QgsDebugMsg( QString( "testing child name=%1 provider=%2 path=%3" ).arg( layerItem->name() ).arg( lProvider ).arg( lFile ) );
QgsDebugMsg( QString( "testing child name=%1 provider=%2 path=%3 tmpSetting = %4" ).arg( layerItem->name() ).arg( lProvider ).arg( lFile ).arg( tmpSetting ) );

if ( lFile == "landsat.tif" )
{
@@ -139,7 +141,7 @@ void TestQgsDataItem::testDirItemChildren()

// test layerName() does not include extension for gdal and ogr items (bug #5621)
QString lName = layerItem->layerName();
errStr = QString( "layer #%1 - %2 lName = %3 iSetting = %4" ).arg( i ).arg( lFile ).arg( lName ).arg( iSetting );
errStr = QString( "layer #%1 - %2 lName = %3 tmpSetting = %4" ).arg( i ).arg( lFile ).arg( lName ).arg( tmpSetting );

if ( lFile == "landsat.tif" )
{
@@ -274,8 +274,8 @@ void TestZipLayer::initTestCase()
// save current zipSetting value
QSettings settings;
mSettingsKey = "/qgis/scanZipInBrowser2";
mScanZipSetting = settings.value( mSettingsKey, "basic" ).toString();
mScanZipSettings << "basic" << "full";
mScanZipSetting = settings.value( mSettingsKey, "" ).toString();
mScanZipSettings << "" << "basic" << "full";
}

void TestZipLayer::cleanupTestCase()

0 comments on commit 7d0d5d3

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