Skip to content

Commit

Permalink
improve QSettings handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jan 10, 2017
1 parent 6c3c533 commit 1882aea
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
}

//locations of the QGIS help
myPaths = mSettings->value( QStringLiteral( "help/helpSearchPath" ), "" ).toString();
if ( !myPaths.isEmpty() )
QStringList helpPathList = mSettings->value( QStringLiteral( "help/helpSearchPath" ) ).toStringList();
Q_FOREACH ( const QString& path, helpPathList )
{
QStringList myPathList = myPaths.split( '|' );
QStringList::const_iterator pathIt = myPathList.constBegin();
for ( ; pathIt != myPathList.constEnd(); ++pathIt )
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText( 0, *pathIt );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mHelpPathTreeWidget->addTopLevelItem( item );
}
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText( 0, path );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mHelpPathTreeWidget->addTopLevelItem( item );
}

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

//QGIS help locations
myPaths.clear();
QStringList helpPaths;
for ( int i = 0; i < mHelpPathTreeWidget->topLevelItemCount(); ++i )
{
QTreeWidgetItem* item = mHelpPathTreeWidget->topLevelItem( i );
if ( item )
if ( QTreeWidgetItem* item = mHelpPathTreeWidget->topLevelItem( i ) )
{
if ( i != 0 )
{
myPaths += '|';
}
myPaths += item->text( 0 );
helpPaths << item->text( 0 );
}
}
mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), myPaths );
mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), helpPaths );

//Network timeout
mSettings->setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), mNetworkTimeoutSpinBox->value() );
Expand Down Expand Up @@ -1747,7 +1737,7 @@ void QgsOptions::on_mBtnRemovePluginPath_clicked()
void QgsOptions::on_mBtnAddHelpPath_clicked()
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText( 0, QLatin1String( "" ) );
item->setText( 0, QString() );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mHelpPathTreeWidget->addTopLevelItem( item );
}
Expand Down

0 comments on commit 1882aea

Please sign in to comment.