16
16
***************************************************************************/
17
17
18
18
#include " qgssnappingdialog.h"
19
- #include " qgsavoidintersectionsdialog.h"
20
19
#include " qgsmapcanvas.h"
21
20
#include " qgsmaplayer.h"
22
21
#include " qgsvectorlayer.h"
23
22
#include " qgsmaplayerregistry.h"
24
23
#include " qgisapp.h"
25
24
#include " qgsproject.h"
26
25
#include " qgslogger.h"
26
+
27
27
#include < QCheckBox>
28
28
#include < QDoubleValidator>
29
29
#include < QComboBox>
@@ -96,23 +96,6 @@ void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int
96
96
QgsProject::instance ()->writeEntry ( " Digitizing" , " /TopologicalEditing" , topologicalEditingEnabled );
97
97
}
98
98
99
- void QgsSnappingDialog::on_mAvoidIntersectionsPushButton_clicked ()
100
- {
101
- QgsAvoidIntersectionsDialog d ( mMapCanvas , mAvoidIntersectionsSettings );
102
- if ( d.exec () == QDialog::Accepted )
103
- {
104
- d.enabledLayers ( mAvoidIntersectionsSettings );
105
- // store avoid intersection layers
106
- QStringList avoidIntersectionList;
107
- QSet<QString>::const_iterator avoidIt = mAvoidIntersectionsSettings .constBegin ();
108
- for ( ; avoidIt != mAvoidIntersectionsSettings .constEnd (); ++avoidIt )
109
- {
110
- avoidIntersectionList.append ( *avoidIt );
111
- }
112
- QgsProject::instance ()->writeEntry ( " Digitizing" , " /AvoidIntersectionsList" , avoidIntersectionList );
113
- }
114
- }
115
-
116
99
void QgsSnappingDialog::closeEvent ( QCloseEvent* event )
117
100
{
118
101
QDialog::closeEvent ( event );
@@ -151,12 +134,13 @@ void QgsSnappingDialog::update()
151
134
defaultSnappingStringIdx = 2 ;
152
135
}
153
136
154
- bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk;
137
+ bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk ;
155
138
QStringList layerIdList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /LayerSnappingList" , &layerIdListOk );
156
139
QStringList enabledList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /LayerSnappingEnabledList" , &enabledListOk );
157
140
QStringList toleranceList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /LayerSnappingToleranceList" , & toleranceListOk );
158
141
QStringList toleranceUnitList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /LayerSnappingToleranceUnitList" , & toleranceUnitListOk );
159
142
QStringList snapToList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /LayerSnapToList" , &snapToListOk );
143
+ QStringList avoidIntersectionsList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /AvoidIntersectionsList" , &avoidIntersectionListOk );
160
144
161
145
mLayerTreeWidget ->clear ();
162
146
@@ -165,7 +149,7 @@ void QgsSnappingDialog::update()
165
149
for ( it = mapLayers.begin (); it != mapLayers.end () ; ++it )
166
150
{
167
151
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value () );
168
- if ( !currentVectorLayer )
152
+ if ( !currentVectorLayer || currentVectorLayer-> geometryType () == QGis::NoGeometry )
169
153
continue ;
170
154
171
155
// snap to layer yes/no
@@ -200,6 +184,13 @@ void QgsSnappingDialog::update()
200
184
cbxUnits->setCurrentIndex ( defaultSnappingUnit );
201
185
mLayerTreeWidget ->setItemWidget ( item, 4 , cbxUnits );
202
186
187
+ QCheckBox *cbxAvoidIntersection = 0 ;
188
+ if ( currentVectorLayer->geometryType () == QGis::Polygon )
189
+ {
190
+ cbxAvoidIntersection = new QCheckBox ( mLayerTreeWidget );
191
+ mLayerTreeWidget ->setItemWidget ( item, 5 , cbxAvoidIntersection );
192
+ }
193
+
203
194
int idx = layerIdList.indexOf ( currentVectorLayer->getLayerID () );
204
195
if ( idx < 0 )
205
196
{
@@ -225,6 +216,10 @@ void QgsSnappingDialog::update()
225
216
cbxSnapTo->setCurrentIndex ( snappingStringIdx );
226
217
leTolerance->setText ( QString::number ( toleranceList[idx].toDouble (), ' f' ) );
227
218
cbxUnits->setCurrentIndex ( toleranceUnitList[idx].toInt () );
219
+ if ( cbxAvoidIntersection )
220
+ {
221
+ cbxAvoidIntersection->setChecked ( avoidIntersectionsList.contains ( currentVectorLayer->getLayerID () ) );
222
+ }
228
223
}
229
224
230
225
// read the digitizing settings
@@ -238,18 +233,6 @@ void QgsSnappingDialog::update()
238
233
cbxEnableTopologicalEditingCheckBox->setCheckState ( Qt::Unchecked );
239
234
}
240
235
241
- bool avoidIntersectionListOk;
242
- mAvoidIntersectionsSettings .clear ();
243
- QStringList avoidIntersectionsList = QgsProject::instance ()->readListEntry ( " Digitizing" , " /AvoidIntersectionsList" , &avoidIntersectionListOk );
244
- if ( avoidIntersectionListOk )
245
- {
246
- QStringList::const_iterator avoidIt = avoidIntersectionsList.constBegin ();
247
- for ( ; avoidIt != avoidIntersectionsList.constEnd (); ++avoidIt )
248
- {
249
- mAvoidIntersectionsSettings .insert ( *avoidIt );
250
- }
251
- }
252
-
253
236
if ( myDockFlag )
254
237
{
255
238
for ( int i = 0 ; i < mLayerTreeWidget ->topLevelItemCount (); ++i )
@@ -259,6 +242,12 @@ void QgsSnappingDialog::update()
259
242
connect ( mLayerTreeWidget ->itemWidget ( item, 2 ), SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( apply () ) );
260
243
connect ( mLayerTreeWidget ->itemWidget ( item, 3 ), SIGNAL ( textEdited ( const QString ) ), this , SLOT ( apply () ) );
261
244
connect ( mLayerTreeWidget ->itemWidget ( item, 4 ), SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( apply () ) );
245
+
246
+ QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget ->itemWidget ( item, 5 ) );
247
+ if ( cbxAvoidIntersection )
248
+ {
249
+ connect ( cbxAvoidIntersection, SIGNAL ( stateChanged ( int ) ), this , SLOT ( apply () ) );
250
+ }
262
251
}
263
252
}
264
253
}
@@ -270,6 +259,7 @@ void QgsSnappingDialog::apply()
270
259
QStringList toleranceList;
271
260
QStringList enabledList;
272
261
QStringList toleranceUnitList;
262
+ QStringList avoidIntersectionList;
273
263
274
264
for ( int i = 0 ; i < mLayerTreeWidget ->topLevelItemCount (); ++i )
275
265
{
@@ -298,13 +288,20 @@ void QgsSnappingDialog::apply()
298
288
299
289
toleranceList << QString::number ( qobject_cast<QLineEdit*>( mLayerTreeWidget ->itemWidget ( currentItem, 3 ) )->text ().toDouble (), ' f' );
300
290
toleranceUnitList << QString::number ( qobject_cast<QComboBox*>( mLayerTreeWidget ->itemWidget ( currentItem, 4 ) )->currentIndex () );
291
+
292
+ QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget ->itemWidget ( currentItem, 5 ) );
293
+ if ( cbxAvoidIntersection && cbxAvoidIntersection->isChecked () )
294
+ {
295
+ avoidIntersectionList << currentItem->data ( 0 , Qt::UserRole ).toString ();
296
+ }
301
297
}
302
298
303
299
QgsProject::instance ()->writeEntry ( " Digitizing" , " /LayerSnappingList" , layerIdList );
304
300
QgsProject::instance ()->writeEntry ( " Digitizing" , " /LayerSnapToList" , snapToList );
305
301
QgsProject::instance ()->writeEntry ( " Digitizing" , " /LayerSnappingToleranceList" , toleranceList );
306
302
QgsProject::instance ()->writeEntry ( " Digitizing" , " /LayerSnappingToleranceUnitList" , toleranceUnitList );
307
303
QgsProject::instance ()->writeEntry ( " Digitizing" , " /LayerSnappingEnabledList" , enabledList );
304
+ QgsProject::instance ()->writeEntry ( " Digitizing" , " /AvoidIntersectionsList" , avoidIntersectionList );
308
305
}
309
306
310
307
void QgsSnappingDialog::show ()
0 commit comments