Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More robust parsing of project snapping options
git-svn-id: http://svn.osgeo.org/qgis/trunk@10883 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 5, 2009
1 parent bc83daf commit bfc3b6c
Showing 1 changed file with 47 additions and 19 deletions.
66 changes: 47 additions & 19 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -120,13 +120,12 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
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();
Expand All @@ -139,33 +138,62 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
//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();
}
Expand Down

0 comments on commit bfc3b6c

Please sign in to comment.