[QGIS Commit] r10883 - trunk/qgis/src/app
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Jun 5 05:24:00 EDT 2009
Author: mhugent
Date: 2009-06-05 05:24:00 -0400 (Fri, 05 Jun 2009)
New Revision: 10883
Modified:
trunk/qgis/src/app/qgsprojectproperties.cpp
Log:
More robust parsing of project snapping options
Modified: trunk/qgis/src/app/qgsprojectproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsprojectproperties.cpp 2009-06-05 08:11:40 UTC (rev 10882)
+++ trunk/qgis/src/app/qgsprojectproperties.cpp 2009-06-05 09:24:00 UTC (rev 10883)
@@ -120,13 +120,12 @@
mAvoidIntersectionsCheckBox->setCheckState( Qt::Unchecked );
}
- bool ok;
- bool toleranceUnitOk; //1.0 project files may not have a unit entry
- QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &ok );
- QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &ok );
- QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", &ok );
- QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", &toleranceUnitOk );
- QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &ok );
+ bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk;
+ 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::const_iterator idIter = layerIdList.constBegin();
QStringList::const_iterator enabledIter = enabledList.constBegin();
@@ -139,33 +138,62 @@
//create the new layer entries
for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++tolUnitIter, ++snapToIter )
{
- currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter );
+ if(layerIdListOk)
+ {
+ currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter );
+ }
+ else
+ {
+ break;
+ }
+
if ( currentLayer )
{
LayerEntry newEntry;
newEntry.layerName = currentLayer->name();
- if (( *enabledIter ) == "enabled" )
+
+ newEntry.checked = false;
+ if(enabledListOk && enabledIter != enabledList.constEnd())
{
- newEntry.checked = true;
+ if (( *enabledIter ) == "enabled" )
+ {
+ newEntry.checked = true;
+ }
}
- else
+
+ //snap to vertex / segment / vertex and segment
+ if(snapToListOk &&snapToIter != snapToList.constEnd())
{
- newEntry.checked = false;
+ if (( *snapToIter ) == "to_vertex" )
+ {
+ newEntry.snapTo = 0;
+ }
+ else if (( *snapToIter ) == "to_segment" )
+ {
+ newEntry.snapTo = 1;
+ }
+ else //to vertex and segment
+ {
+ newEntry.snapTo = 2;
+ }
}
- if (( *snapToIter ) == "to_vertex" )
+ else
{
newEntry.snapTo = 0;
}
- else if (( *snapToIter ) == "to_segment" )
+
+ //snap tolerance
+ if(toleranceListOk && tolIter != toleranceList.constEnd())
{
- newEntry.snapTo = 1;
+ newEntry.tolerance = tolIter->toDouble();
}
- else //to vertex and segment
+ else
{
- newEntry.snapTo = 2;
+ newEntry.tolerance = 0;
}
- newEntry.tolerance = tolIter->toDouble();
- if ( toleranceUnitOk )
+
+ //snap tolerance unit
+ if (toleranceUnitListOk && tolUnitIter != toleranceUnitList.constEnd())
{
newEntry.toleranceUnit = tolUnitIter->toInt();
}
More information about the QGIS-commit
mailing list