16
16
***************************************************************************/
17
17
18
18
#include " qgssnappingdialog.h"
19
+ #include " qgsavoidintersectionsdialog.h"
19
20
#include " qgsmapcanvas.h"
20
21
#include " qgsmaplayer.h"
21
22
#include " qgsvectorlayer.h"
22
23
#include " qgsmaplayerregistry.h"
23
24
#include " qgisapp.h"
24
25
#include " qgsproject.h"
26
+ #include " qgslogger.h"
25
27
#include < QCheckBox>
26
28
#include < QDoubleValidator>
27
29
#include < QComboBox>
@@ -36,7 +38,7 @@ class QgsSnappingDock : public QDockWidget
36
38
QgsSnappingDock ( const QString & title, QWidget * parent = 0 , Qt::WindowFlags flags = 0 )
37
39
: QDockWidget( title, parent, flags )
38
40
{
39
- setObjectName ( " Snapping Options" ); // set object name so the position can be saved
41
+ setObjectName ( " Snapping and Digitizing Options" ); // set object name so the position can be saved
40
42
}
41
43
42
44
virtual void closeEvent ( QCloseEvent * ev )
@@ -54,7 +56,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
54
56
bool myDockFlag = myQsettings.value ( " /qgis/dockSnapping" , false ).toBool ();
55
57
if ( myDockFlag )
56
58
{
57
- mDock = new QgsSnappingDock ( tr ( " Snapping Options" ), QgisApp::instance () );
59
+ mDock = new QgsSnappingDock ( tr ( " Snapping and Digitizing Options" ), QgisApp::instance () );
58
60
mDock ->setAllowedAreas ( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea );
59
61
mDock ->setWidget ( this );
60
62
connect ( this , SIGNAL ( destroyed () ), mDock , SLOT ( close () ) );
@@ -67,6 +69,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
67
69
connect ( mButtonBox ->button ( QDialogButtonBox::Apply ), SIGNAL ( clicked () ), this , SLOT ( apply () ) );
68
70
}
69
71
connect ( QgsMapLayerRegistry::instance (), SIGNAL ( layerWasAdded ( QgsMapLayer * ) ), this , SLOT ( connectUpdate ( QgsMapLayer * ) ) );
72
+ connect ( cbxEnableTopologicalEditingCheckBox, SIGNAL ( stateChanged ( int ) ), this , SLOT ( on_cbxEnableTopologicalEditingCheckBox_stateChanged ( int ) ) );
70
73
71
74
update ();
72
75
@@ -87,6 +90,29 @@ QgsSnappingDialog::~QgsSnappingDialog()
87
90
{
88
91
}
89
92
93
+ void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged ( int state )
94
+ {
95
+ int topologicalEditingEnabled = ( state == Qt::Checked ) ? 1 : 0 ;
96
+ QgsProject::instance ()->writeEntry ( " Digitizing" , " /TopologicalEditing" , topologicalEditingEnabled );
97
+ }
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
+
90
116
void QgsSnappingDialog::closeEvent ( QCloseEvent* event )
91
117
{
92
118
QDialog::closeEvent ( event );
@@ -201,6 +227,29 @@ void QgsSnappingDialog::update()
201
227
cbxUnits->setCurrentIndex ( toleranceUnitList[idx].toInt () );
202
228
}
203
229
230
+ // read the digitizing settings
231
+ int topologicalEditing = QgsProject::instance ()->readNumEntry ( " Digitizing" , " /TopologicalEditing" , 0 );
232
+ if ( topologicalEditing != 0 )
233
+ {
234
+ cbxEnableTopologicalEditingCheckBox->setCheckState ( Qt::Checked );
235
+ }
236
+ else
237
+ {
238
+ cbxEnableTopologicalEditingCheckBox->setCheckState ( Qt::Unchecked );
239
+ }
240
+
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
+
204
253
if ( myDockFlag )
205
254
{
206
255
for ( int i = 0 ; i < mLayerTreeWidget ->topLevelItemCount (); ++i )
0 commit comments