Skip to content
Permalink
Browse files

Merge pull request #460 from 3nids/readListEntryDefault

Added default value argument for readEntryList
  • Loading branch information
mhugent committed Apr 12, 2013
2 parents 61b3e4c + 706ac99 commit 71c45c03fdb1868a8e893357fd805ebe1be1f525
@@ -197,7 +197,7 @@ class QgsProject : QObject
@note The key string <em>must</em> include '/'s. E.g., "/foo" not "foo".
*/
//@{
QStringList readListEntry( const QString & scope, const QString & key, bool * ok = 0 ) const;
QStringList readListEntry( const QString & scope, const QString & key, QStringList def = QStringList(), bool * ok = 0 ) const;

QString readEntry( const QString & scope, const QString & key, const QString & def = QString::null, bool * ok = 0 ) const;
int readNumEntry( const QString & scope, const QString & key, int def = 0, bool * ok = 0 ) const;
@@ -280,7 +280,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
mWMSExtMaxX->setValidator( new QDoubleValidator( mWMSExtMaxX ) );
mWMSExtMaxY->setValidator( new QDoubleValidator( mWMSExtMaxY ) );

values = QgsProject::instance()->readListEntry( "WMSExtent", "/", &ok );
values = QgsProject::instance()->readListEntry( "WMSExtent", "/", QStringList(), &ok );
grpWMSExt->setChecked( ok && values.size() == 4 );
if ( grpWMSExt->isChecked() )
{
@@ -290,15 +290,15 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
mWMSExtMaxY->setText( values[3] );
}

values = QgsProject::instance()->readListEntry( "WMSCrsList", "/", &ok );
values = QgsProject::instance()->readListEntry( "WMSCrsList", "/", QStringList(), &ok );
grpWMSList->setChecked( ok && values.size() > 0 );
if ( grpWMSList->isChecked() )
{
mWMSList->addItems( values );
}
else
{
values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok );
values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", QStringList(), &ok );
grpWMSList->setChecked( ok && values.size() > 0 );
if ( grpWMSList->isChecked() )
{
@@ -315,15 +315,15 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
grpWMSList->setChecked( mWMSList->count() > 0 );

//composer restriction for WMS
values = QgsProject::instance()->readListEntry( "WMSComposerList", "/", &ok );
values = QgsProject::instance()->readListEntry( "WMSComposerList", "/", QStringList(), &ok );
mWMSComposerGroupBox->setChecked( ok );
if ( ok )
{
mComposerListWidget->addItems( values );
}

//layer restriction for WMS
values = QgsProject::instance()->readListEntry( "WMSRestrictedLayers", "/", &ok );
values = QgsProject::instance()->readListEntry( "WMSRestrictedLayers", "/", QStringList(), &ok );
mLayerRestrictionsGroupBox->setChecked( ok );
if ( ok )
{
@@ -238,12 +238,13 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
}

bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk );
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );
QStringList defList;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", defList, &layerIdListOk );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", defList, &enabledListOk );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", defList, & toleranceListOk );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", defList, &toleranceUnitListOk );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", defList, &snapToListOk );
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", defList, &avoidIntersectionListOk );

//snap to layer yes/no
QTreeWidgetItem *item = new QTreeWidgetItem( mLayerTreeWidget );
@@ -6785,7 +6785,7 @@ int QgsGeometry::avoidIntersections( QMap<QgsVectorLayer*, QSet< QgsFeatureId >

//read avoid intersections list from project properties
bool listReadOk;
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &listReadOk );
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", QStringList(), &listReadOk );
if ( !listReadOk )
{
return true; //no intersections stored in project does not mean error
@@ -1130,7 +1130,8 @@ QgsProject::writeEntry( QString const &scope, const QString & key,
QStringList
QgsProject::readListEntry( QString const & scope,
const QString & key,
bool * ok ) const
QStringList def,
bool * ok) const
{
QgsProperty * property = findKey_( scope, key, imp_->properties_ );

@@ -1153,7 +1154,7 @@ QgsProject::readListEntry( QString const & scope,
return value.toStringList();
}

return QStringList();
return def;
} // QgsProject::readListEntry


@@ -231,7 +231,7 @@ class CORE_EXPORT QgsProject : public QObject
@note The key string <em>must</em> include '/'s. E.g., "/foo" not "foo".
*/
//@{
QStringList readListEntry( const QString & scope, const QString & key, bool * ok = 0 ) const;
QStringList readListEntry( const QString & scope, const QString & key, QStringList def = QStringList(), bool *ok = 0 ) const;

QString readEntry( const QString & scope, const QString & key, const QString & def = QString::null, bool * ok = 0 ) const;
int readNumEntry( const QString & scope, const QString & key, int def = 0, bool * ok = 0 ) const;
@@ -165,15 +165,16 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QPoint& p, QList<QgsSnapp
//read snapping settings from project
bool ok; //todo: take the default snapping tolerance for all vector layers if snapping not defined in project
bool snappingDefinedInProject = true;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &ok );
QStringList defList;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", defList, &ok );
if ( !ok )
{
snappingDefinedInProject = false;
}
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &ok );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", &ok );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", &ok );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &ok );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", defList, &ok );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", defList, &ok );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", defList, &ok );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", defList, &ok );

if ( !( layerIdList.size() == enabledList.size() && layerIdList.size() == toleranceList.size() && layerIdList.size() == toleranceUnitList.size() && layerIdList.size() == snapToList.size() ) )
{

0 comments on commit 71c45c0

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