Skip to content

Commit

Permalink
fix #7353
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 2, 2013
1 parent 1c2c079 commit b87ccac
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 248 deletions.
3 changes: 2 additions & 1 deletion src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
mDefaultSnapModeComboBox->insertItem( 0, tr( "To vertex" ), "to vertex" );
mDefaultSnapModeComboBox->insertItem( 1, tr( "To segment" ), "to segment" );
mDefaultSnapModeComboBox->insertItem( 2, tr( "To vertex and segment" ), "to vertex and segment" );
QString defaultSnapString = settings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString();
mDefaultSnapModeComboBox->insertItem( 3, tr( "Off" ), "off" );
QString defaultSnapString = settings.value( "/qgis/digitizing/default_snap_mode", "off" ).toString();
mDefaultSnapModeComboBox->setCurrentIndex( mDefaultSnapModeComboBox->findData( defaultSnapString ) );
mDefaultSnappingToleranceSpinBox->setValue( settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble() );
mSearchRadiusVertexEditSpinBox->setValue( settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble() );
Expand Down
23 changes: 12 additions & 11 deletions src/app/qgssnappingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,14 @@ void QgsSnappingDialog::addLayers( QList<QgsMapLayer *> layers )
}
}

void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
{
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( theMapLayer );
if ( !currentVectorLayer || currentVectorLayer->geometryType() == QGis::NoGeometry )
return;

QSettings myQsettings;
bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool();

double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString();
Expand All @@ -232,27 +231,26 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
{
defaultSnappingStringIdx = 1;
}
else //to vertex and segment
else
{
// to vertex and segment
defaultSnappingStringIdx = 2;
}

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

//snap to layer yes/no
QTreeWidgetItem *item = new QTreeWidgetItem( mLayerTreeWidget );

QCheckBox *cbxEnable = new QCheckBox( mLayerTreeWidget );
mLayerTreeWidget->setItemWidget( item, 0, cbxEnable );
item->setData( 0, Qt::UserRole, currentVectorLayer->id() );

item->setText( 1, currentVectorLayer->name() );

//snap to vertex/ snap to segment
Expand Down Expand Up @@ -299,9 +297,11 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
{
connect( cbxAvoidIntersection, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
}
cbxEnable->setChecked( defaultSnappingString != "off" );
setTopologicalEditingState();
setIntersectionSnappingState();
}

// no settings for this layer yet
return;
}
Expand All @@ -321,6 +321,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
{
snappingStringIdx = 2;
}

cbxSnapTo->setCurrentIndex( snappingStringIdx );
leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) );
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsdatadefinedbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton

/**
* Emitted when active state changed
* @param set Whether the definition is set
* @param active Whether the definition is active
*/
void dataDefinedActivated( bool active );

Expand Down
Loading

0 comments on commit b87ccac

Please sign in to comment.