Skip to content

Commit 7d0d5d3

Browse files
committed
scanItemsInBrowser2/scanZipInBrowser2 : remove QgsApplication::upgradeConfig() and fix tests
1 parent 565d2eb commit 7d0d5d3

File tree

4 files changed

+11
-98
lines changed

4 files changed

+11
-98
lines changed

src/core/qgsapplication.cpp

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,6 @@ void QgsApplication::initQgis()
583583

584584
// create map layer registry if doesn't exist
585585
QgsMapLayerRegistry::instance();
586-
587-
// upgrade config options from older version
588-
upgradeConfig();
589586
}
590587

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

865-
void QgsApplication::upgradeConfig()
866-
{
867-
QSettings settings;
868-
869-
/* Due to changes in settings storage types for "scan items" and "scan zip" settings,
870-
qgis-1.8 and qgis-1.9 have conficting values, so the keys have been renamed
871-
Here we do a 1-time check to copy old setting to new setting
872-
*/
873-
874-
// use a special settings key so we only check once
875-
if ( ! settings.value( "/qgis/scanInBrowserUpgradeChecked", false ).toBool() )
876-
{
877-
QVariant v;
878-
int i;
879-
QString s;
880-
bool ok;
881-
882-
// check if new setting is empty
883-
if ( settings.value( "/qgis/scanItemsInBrowser2" ).isNull() )
884-
{
885-
v = settings.value( "/qgis/scanItemsInBrowser" );
886-
i = v.toInt( &ok );
887-
// check if value was defined in qgis-1.8 (as int)
888-
if ( ! v.isNull() && ok )
889-
{
890-
// convert old setting to new setting
891-
switch ( i )
892-
{
893-
case 0:
894-
s = "contents";
895-
break;
896-
case 1:
897-
s = "extension";
898-
break;
899-
default:
900-
s = "";
901-
break;
902-
}
903-
settings.setValue( "/qgis/scanItemsInBrowser2", s );
904-
}
905-
// check if value was defined in qgis-1.9 (as QString)
906-
else if ( ! v.isNull() && !v.toString().isEmpty() )
907-
{
908-
s = v.toString();
909-
settings.setValue( "/qgis/scanItemsInBrowser2", s );
910-
}
911-
}
912-
913-
if ( settings.value( "/qgis/scanZipInBrowser2" ).isNull() )
914-
{
915-
v = settings.value( "/qgis/scanZipInBrowser" );
916-
i = v.toInt( & ok );
917-
if ( ! v.isNull() && ok )
918-
{
919-
switch ( i )
920-
{
921-
case 0:
922-
s = "No";
923-
break;
924-
case 1: // passthru removed, use basic instead
925-
case 2:
926-
s = "basic";
927-
break;
928-
case 3:
929-
s = "full";
930-
break;
931-
default:
932-
s = "";
933-
break;
934-
}
935-
settings.setValue( "/qgis/scanZipInBrowser2", s );
936-
}
937-
else if ( ! v.isNull() && !v.toString().isEmpty() )
938-
{
939-
s = v.toString();
940-
settings.setValue( "/qgis/scanZipInBrowser2", s );
941-
}
942-
}
943-
944-
settings.setValue( "/qgis/scanInBrowserUpgradeChecked", true );
945-
}
946-
}
947862

src/core/qgsapplication.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ class CORE_EXPORT QgsApplication: public QApplication
270270
* @note added in 2.0 */
271271
static void applyGdalSkippedDrivers();
272272

273-
/** upgrades config options from older version, called by initQGis
274-
* @note added in 2.0 */
275-
static void upgradeConfig();
276-
277273
signals:
278274
//! @note not available in python bindings
279275
void preNotify( QObject * receiver, QEvent * event, bool * done );

tests/src/core/testqgsdataitem.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class TestQgsDataItem: public QObject
4242

4343
private:
4444
QgsDirectoryItem* mDirItem;
45-
int mScanItemsSetting;
45+
QString mScanItemsSetting;
4646
bool isValidDirItem( QgsDirectoryItem *item );
4747
};
4848

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

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

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

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

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

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

144146
if ( lFile == "landsat.tif" )
145147
{

tests/src/core/testziplayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ void TestZipLayer::initTestCase()
274274
// save current zipSetting value
275275
QSettings settings;
276276
mSettingsKey = "/qgis/scanZipInBrowser2";
277-
mScanZipSetting = settings.value( mSettingsKey, "basic" ).toString();
278-
mScanZipSettings << "basic" << "full";
277+
mScanZipSetting = settings.value( mSettingsKey, "" ).toString();
278+
mScanZipSettings << "" << "basic" << "full";
279279
}
280280

281281
void TestZipLayer::cleanupTestCase()

0 commit comments

Comments
 (0)