Skip to content
Permalink
Browse files

fix #7353

  • Loading branch information
jef-n committed Jun 2, 2013
1 parent 1c2c079 commit b87ccac52051050afcc05a1a1be74ba346c02598
Showing with 226 additions and 248 deletions.
  1. +2 −1 src/app/qgsoptions.cpp
  2. +12 −11 src/app/qgssnappingdialog.cpp
  3. +1 −1 src/gui/qgsdatadefinedbutton.h
  4. +211 −235 src/gui/qgsmapcanvassnapper.cpp
@@ -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() );
@@ -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();
@@ -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
@@ -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;
}
@@ -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() );
@@ -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 );

0 comments on commit b87ccac

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