@@ -71,6 +71,12 @@ QgsSnappingDialog::QgsSnappingDialog( QgsMapCanvas* canvas, const QMap<QString,
71
71
snappingToleranceEdit->setValidator ( validator );
72
72
mLayerTreeWidget ->setItemWidget ( newItem, 2 , snappingToleranceEdit );
73
73
74
+ // snap to vertex/ snap to segment
75
+ QComboBox* toleranceUnitsComboBox = new QComboBox ( mLayerTreeWidget );
76
+ toleranceUnitsComboBox->insertItem ( 0 , tr ( " map units" ) );
77
+ toleranceUnitsComboBox->insertItem ( 1 , tr ( " pixels" ) );
78
+ mLayerTreeWidget ->setItemWidget ( newItem, 3 , toleranceUnitsComboBox );
79
+
74
80
settingIt = settings.find ( currentVectorLayer->getLayerID () );
75
81
if ( settingIt != settings.constEnd () )
76
82
{
@@ -89,6 +95,15 @@ QgsSnappingDialog::QgsSnappingDialog( QgsMapCanvas* canvas, const QMap<QString,
89
95
index = snapToComboBox->findText ( tr ( " to vertex and segment" ) );
90
96
}
91
97
snapToComboBox->setCurrentIndex ( index );
98
+ if ( settingIt.value ().toleranceUnit == 0 )// map units
99
+ {
100
+ index = toleranceUnitsComboBox->findText ( tr ( " map units" ) );
101
+ }
102
+ else
103
+ {
104
+ index = toleranceUnitsComboBox->findText ( tr ( " pixels" ) );
105
+ }
106
+ toleranceUnitsComboBox->setCurrentIndex ( index );
92
107
if ( settingIt.value ().checked )
93
108
{
94
109
newItem->setCheckState ( 0 , Qt::Checked );
@@ -103,8 +118,9 @@ QgsSnappingDialog::QgsSnappingDialog( QgsMapCanvas* canvas, const QMap<QString,
103
118
}
104
119
}
105
120
mLayerTreeWidget ->resizeColumnToContents ( 0 );
106
- mLayerTreeWidget ->setColumnWidth ( 1 , 300 ); // hardcoded for now
121
+ mLayerTreeWidget ->setColumnWidth ( 1 , 200 ); // hardcoded for now
107
122
mLayerTreeWidget ->resizeColumnToContents ( 2 );
123
+ mLayerTreeWidget ->resizeColumnToContents ( 3 );
108
124
}
109
125
}
110
126
@@ -127,7 +143,9 @@ void QgsSnappingDialog::layerSettings( QMap<QString, LayerEntry>& settings ) con
127
143
QString layerId;
128
144
QString layerName;
129
145
QString snapToItemText;
146
+ QString toleranceItemText;
130
147
int snapTo;
148
+ int toleranceUnit;
131
149
double tolerance;
132
150
bool checked = false ;
133
151
@@ -144,6 +162,7 @@ void QgsSnappingDialog::layerSettings( QMap<QString, LayerEntry>& settings ) con
144
162
layerId = mLayerIds .at ( i );
145
163
checked = ( currentItem->checkState ( 0 ) == Qt::Checked );
146
164
snapToItemText = (( QComboBox* )( mLayerTreeWidget ->itemWidget ( currentItem, 1 ) ) )->currentText ();
165
+ toleranceItemText = (( QComboBox* )( mLayerTreeWidget ->itemWidget ( currentItem, 3 ) ) )->currentText ();
147
166
if ( snapToItemText == tr ( " to vertex" ) )
148
167
{
149
168
snapTo = 0 ;
@@ -156,10 +175,18 @@ void QgsSnappingDialog::layerSettings( QMap<QString, LayerEntry>& settings ) con
156
175
{
157
176
snapTo = 2 ;
158
177
}
178
+ if ( toleranceItemText == tr ( " map units" ) )
179
+ {
180
+ toleranceUnit = 0 ;
181
+ }
182
+ else // to vertex and segment
183
+ {
184
+ toleranceUnit = 1 ;
185
+ }
159
186
tolerance = (( QLineEdit* )( mLayerTreeWidget ->itemWidget ( currentItem, 2 ) ) )->text ().toDouble ();
160
187
LayerEntry newEntry;
161
188
newEntry.checked = checked; newEntry.snapTo = snapTo; newEntry.layerName = layerName;
162
- newEntry.tolerance = tolerance;
189
+ newEntry.tolerance = tolerance; newEntry. toleranceUnit = toleranceUnit;
163
190
settings.insert ( layerId, newEntry );
164
191
}
165
192
}
0 commit comments