diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 2d0f34b52407..34ee135c7438 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -138,7 +138,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mRemoveCustomVarBtn->setEnabled( false ); mCustomVariablesTable->setEnabled( false ); } - QStringList customVarsList = mSettings->value( QStringLiteral( "qgis/customEnvVars" ), "" ).toStringList(); + QStringList customVarsList = mSettings->value( QStringLiteral( "qgis/customEnvVars" ) ).toStringList(); Q_FOREACH ( const QString &varStr, customVarsList ) { int pos = varStr.indexOf( QLatin1Char( '|' ) ); @@ -221,25 +221,20 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mCurrentVariablesTable->resizeColumnToContents( 0 ); //local directories to search when loading c++ plugins - QString myPaths = mSettings->value( QStringLiteral( "plugins/searchPathsForPlugins" ), "" ).toString(); - if ( !myPaths.isEmpty() ) + QStringList pathList = mSettings->value( QStringLiteral( "plugins/searchPathsForPlugins" ) ).toStringList(); + Q_FOREACH ( const QString& path, pathList ) { - QStringList myPathList = myPaths.split( '|' ); - QStringList::const_iterator pathIt = myPathList.constBegin(); - for ( ; pathIt != myPathList.constEnd(); ++pathIt ) - { - QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths ); - newItem->setText( *pathIt ); - newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - mListPluginPaths->addItem( newItem ); - } + QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths ); + newItem->setText( path ); + newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); + mListPluginPaths->addItem( newItem ); } //local directories to search when looking for an SVG with a given basename - QStringList svgPaths = QgsApplication::svgPaths(); - if ( !svgPaths.isEmpty() ) + pathList = QgsApplication::svgPaths(); + if ( !pathList.isEmpty() ) { - Q_FOREACH ( const QString& path, svgPaths ) + Q_FOREACH ( const QString& path, pathList ) { QListWidgetItem* newItem = new QListWidgetItem( mListSVGPaths ); newItem->setText( path ); @@ -248,10 +243,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) } } - QStringList templatePaths = QgsApplication::composerTemplatePaths(); - if ( !templatePaths.isEmpty() ) + //local directories to search when looking for a composer templates + pathList = QgsApplication::composerTemplatePaths(); + if ( !pathList.isEmpty() ) { - Q_FOREACH ( const QString& path, templatePaths ) + Q_FOREACH ( const QString& path, pathList ) { QListWidgetItem* newItem = new QListWidgetItem( mListComposerTemplatePaths ); newItem->setText( path ); @@ -260,13 +256,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) } } - QStringList hiddenItems = mSettings->value( QStringLiteral( "/browser/hiddenPaths" ), - QStringList() ).toStringList(); - QStringList::const_iterator pathIt = hiddenItems.constBegin(); - for ( ; pathIt != hiddenItems.constEnd(); ++pathIt ) + //paths hidden from browser + pathList = mSettings->value( QStringLiteral( "/browser/hiddenPaths" ) ).toStringList(); + Q_FOREACH ( const QString& path, pathList ) { QListWidgetItem* newItem = new QListWidgetItem( mListHiddenBrowserPaths ); - newItem->setText( *pathIt ); + newItem->setText( path ); mListHiddenBrowserPaths->addItem( newItem ); } @@ -300,18 +295,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mProxyTypeComboBox->setCurrentIndex( mProxyTypeComboBox->findText( settingProxyType ) ); //URLs excluded not going through proxies - QString proxyExcludedURLs = mSettings->value( QStringLiteral( "proxy/proxyExcludedUrls" ), "" ).toString(); - if ( !proxyExcludedURLs.isEmpty() ) + pathList = mSettings->value( QStringLiteral( "proxy/proxyExcludedUrls" ) ).toStringList(); + Q_FOREACH ( const QString& path, pathList ) { - QStringList splitUrls = proxyExcludedURLs.split( '|' ); - QStringList::const_iterator urlIt = splitUrls.constBegin(); - for ( ; urlIt != splitUrls.constEnd(); ++urlIt ) - { - QListWidgetItem* newItem = new QListWidgetItem( mExcludeUrlListWidget ); - newItem->setText( *urlIt ); - newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - mExcludeUrlListWidget->addItem( newItem ); - } + QListWidgetItem* newItem = new QListWidgetItem( mExcludeUrlListWidget ); + newItem->setText( path ); + newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); + mExcludeUrlListWidget->addItem( newItem ); } // cache settings @@ -731,7 +721,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) spinZoomFactor->setValue( mSettings->value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble() ); // predefined scales for scale combobox - myPaths = mSettings->value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString(); + QString myPaths = mSettings->value( QStringLiteral( "Map/scales" ), PROJECT_SCALES ).toString(); if ( !myPaths.isEmpty() ) { QStringList myScalesList = myPaths.split( ',' ); @@ -933,8 +923,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) mVariableEditor->reloadContext(); mVariableEditor->setEditableScopeIndex( 0 ); - - mAdvancedSettingsEditor->setSettingsObject( mSettings ); // restore window and widget geometry/state @@ -1077,46 +1065,34 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "qgis/customEnvVars" ), QVariant( customVars ) ); //search directories for user plugins - QString myPaths; + QStringList pathsList; for ( int i = 0; i < mListPluginPaths->count(); ++i ) { - if ( i != 0 ) - { - myPaths += '|'; - } - myPaths += mListPluginPaths->item( i )->text(); + pathsList << mListPluginPaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "plugins/searchPathsForPlugins" ), myPaths ); + mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), pathsList ); //search directories for svgs - myPaths.clear(); + pathsList.clear(); for ( int i = 0; i < mListSVGPaths->count(); ++i ) { - if ( i != 0 ) - { - myPaths += '|'; - } - myPaths += mListSVGPaths->item( i )->text(); + pathsList << mListSVGPaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "svg/searchPathsForSVG" ), myPaths ); + mSettings->setValue( QStringLiteral( "svg/searchPathsForSVG" ), pathsList ); - myPaths.clear(); + pathsList.clear(); for ( int i = 0; i < mListComposerTemplatePaths->count(); ++i ) { - if ( i != 0 ) - { - myPaths += '|'; - } - myPaths += mListComposerTemplatePaths->item( i )->text(); + pathsList << mListComposerTemplatePaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "composer/searchPathsForTemplates" ), myPaths ); + mSettings->setValue( QStringLiteral( "composer/searchPathsForTemplates" ), pathsList ); - QStringList paths; + pathsList.clear(); for ( int i = 0; i < mListHiddenBrowserPaths->count(); ++i ) { - paths << mListHiddenBrowserPaths->item( i )->text(); + pathsList << mListHiddenBrowserPaths->item( i )->text(); } - mSettings->setValue( QStringLiteral( "/browser/hiddenPaths" ), paths ); + mSettings->setValue( QStringLiteral( "/browser/hiddenPaths" ), pathsList ); //Network timeout mSettings->setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), mNetworkTimeoutSpinBox->value() ); @@ -1398,7 +1374,7 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), mCurveOffsetMiterLimitComboBox->value() ); // default scale list - myPaths.clear(); + QString myPaths; for ( int i = 0; i < mListGlobalScales->count(); ++i ) { if ( i != 0 ) diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 0b84b4d7697d..3d7e69772386 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -729,16 +729,11 @@ QStringList QgsApplication::svgPaths() //local directories to search when looking for an SVG with a given basename //defined by user in options dialog QSettings settings; - QStringList myPathList; - QString myPaths = settings.value( QStringLiteral( "svg/searchPathsForSVG" ), QString() ).toString(); - if ( !myPaths.isEmpty() ) - { - myPathList = myPaths.split( '|' ); - } + QStringList pathList = settings.value( QStringLiteral( "svg/searchPathsForSVG" ) ).toStringList(); // maintain user set order while stripping duplicates QStringList paths; - Q_FOREACH ( const QString& path, myPathList ) + Q_FOREACH ( const QString& path, pathList ) { if ( !paths.contains( path ) ) paths.append( path ); @@ -760,14 +755,9 @@ QStringList QgsApplication::composerTemplatePaths() //local directories to search when looking for an SVG with a given basename //defined by user in options dialog QSettings settings; - QStringList myPathList; - QString myPaths = settings.value( QStringLiteral( "composer/searchPathsForTemplates" ), QString() ).toString(); - if ( !myPaths.isEmpty() ) - { - myPathList = myPaths.split( '|' ); - } + QStringList pathList = settings.value( QStringLiteral( "composer/searchPathsForTemplates" ) ).toStringList(); - return myPathList; + return pathList; } QString QgsApplication::userStylePath()