Skip to content

Commit 1882aea

Browse files
committedJan 10, 2017
improve QSettings handling
1 parent 6c3c533 commit 1882aea

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
266266
}
267267

268268
//locations of the QGIS help
269-
myPaths = mSettings->value( QStringLiteral( "help/helpSearchPath" ), "" ).toString();
270-
if ( !myPaths.isEmpty() )
269+
QStringList helpPathList = mSettings->value( QStringLiteral( "help/helpSearchPath" ) ).toStringList();
270+
Q_FOREACH ( const QString& path, helpPathList )
271271
{
272-
QStringList myPathList = myPaths.split( '|' );
273-
QStringList::const_iterator pathIt = myPathList.constBegin();
274-
for ( ; pathIt != myPathList.constEnd(); ++pathIt )
275-
{
276-
QTreeWidgetItem* item = new QTreeWidgetItem();
277-
item->setText( 0, *pathIt );
278-
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
279-
mHelpPathTreeWidget->addTopLevelItem( item );
280-
}
272+
QTreeWidgetItem* item = new QTreeWidgetItem();
273+
item->setText( 0, path );
274+
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
275+
mHelpPathTreeWidget->addTopLevelItem( item );
281276
}
282277

283278
//Network timeout
@@ -1112,20 +1107,15 @@ void QgsOptions::saveOptions()
11121107
mSettings->setValue( QStringLiteral( "/browser/hiddenPaths" ), pathsList );
11131108

11141109
//QGIS help locations
1115-
myPaths.clear();
1110+
QStringList helpPaths;
11161111
for ( int i = 0; i < mHelpPathTreeWidget->topLevelItemCount(); ++i )
11171112
{
1118-
QTreeWidgetItem* item = mHelpPathTreeWidget->topLevelItem( i );
1119-
if ( item )
1113+
if ( QTreeWidgetItem* item = mHelpPathTreeWidget->topLevelItem( i ) )
11201114
{
1121-
if ( i != 0 )
1122-
{
1123-
myPaths += '|';
1124-
}
1125-
myPaths += item->text( 0 );
1115+
helpPaths << item->text( 0 );
11261116
}
11271117
}
1128-
mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), myPaths );
1118+
mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), helpPaths );
11291119

11301120
//Network timeout
11311121
mSettings->setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), mNetworkTimeoutSpinBox->value() );
@@ -1747,7 +1737,7 @@ void QgsOptions::on_mBtnRemovePluginPath_clicked()
17471737
void QgsOptions::on_mBtnAddHelpPath_clicked()
17481738
{
17491739
QTreeWidgetItem* item = new QTreeWidgetItem();
1750-
item->setText( 0, QLatin1String( "" ) );
1740+
item->setText( 0, QString() );
17511741
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
17521742
mHelpPathTreeWidget->addTopLevelItem( item );
17531743
}

0 commit comments

Comments
 (0)
Please sign in to comment.