Skip to content

Commit 6188322

Browse files
committed
Convenient access functions also for topological editing
1 parent 1e60028 commit 6188322

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

python/core/qgsproject.sip

+5
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ public:
245245
bool snapSettingsForLayer( const QString& layerId, bool& enabled /Out/, QgsSnapper::SnappingType& type /Out/, QgsTolerance::UnitType& units /Out/, double& tolerance /Out/,
246246
bool& avoidIntersection /Out/ );
247247

248+
void setTopologicalEditing( bool enabled );
249+
bool topologicalEditing() const;
250+
248251
protected:
249252

250253
/** Set error message from read/write operation
@@ -263,6 +266,8 @@ public:
263266
//! emitted when project is being written
264267
void writeProject(QDomDocument &);
265268

269+
void snapSettingsChanged();
270+
266271
private:
267272

268273
QgsProject(); // private 'cause it's a singleton

src/app/qgssnappingdialog.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
7373
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) );
7474
connect( cbxEnableTopologicalEditingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ) ) );
7575

76-
reloadLayers();
76+
reload();
7777

7878
QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
7979
QMap< QString, QgsMapLayer *>::iterator it;
@@ -90,8 +90,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
9090
mLayerTreeWidget->resizeColumnToContents( 4 );
9191
mLayerTreeWidget->setSortingEnabled( true );
9292

93-
setTopologicalEditingState();
94-
connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), this, SLOT( reloadLayers() ) );
93+
connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), this, SLOT( reload() ) );
9594
}
9695

9796
QgsSnappingDialog::QgsSnappingDialog()
@@ -102,7 +101,7 @@ QgsSnappingDialog::~QgsSnappingDialog()
102101
{
103102
}
104103

105-
void QgsSnappingDialog::reloadLayers()
104+
void QgsSnappingDialog::reload()
106105
{
107106
mLayerTreeWidget->clear();
108107

@@ -113,6 +112,7 @@ void QgsSnappingDialog::reloadLayers()
113112
addLayer( it.value() );
114113
}
115114

115+
setTopologicalEditingState();
116116
}
117117

118118
void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int state )

src/app/qgssnappingdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
6868
void closeEvent( QCloseEvent* event );
6969

7070
private slots:
71-
void reloadLayers();
71+
void reload();
7272

7373

7474
private:

src/core/qgsproject.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ void QgsProject::setSnapSettingsForLayer( const QString& layerId, bool enabled,
16791679
}
16801680

16811681
bool QgsProject::snapSettingsForLayer( const QString& layerId, bool& enabled, QgsSnapper::SnappingType &type, QgsTolerance::UnitType& units, double& tolerance,
1682-
bool& avoidIntersection )
1682+
bool& avoidIntersection ) const
16831683
{
16841684
QStringList layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList;
16851685
snapSettings( layerIdList, enabledList, snapTypeList, toleranceUnitList, toleranceList, avoidIntersectionList );
@@ -1735,7 +1735,7 @@ bool QgsProject::snapSettingsForLayer( const QString& layerId, bool& enabled, Qg
17351735
}
17361736

17371737
void QgsProject::snapSettings( QStringList& layerIdList, QStringList& enabledList, QStringList& snapTypeList, QStringList& toleranceUnitList, QStringList& toleranceList,
1738-
QStringList& avoidIntersectionList )
1738+
QStringList& avoidIntersectionList ) const
17391739
{
17401740
layerIdList = readListEntry( "Digitizing", "/LayerSnappingList" );
17411741
enabledList = readListEntry( "Digitizing", "/LayerSnappingEnabledList" );
@@ -1745,6 +1745,17 @@ void QgsProject::snapSettings( QStringList& layerIdList, QStringList& enabledLis
17451745
avoidIntersectionList = readListEntry( "Digitizing", "/AvoidIntersectionsList" );
17461746
}
17471747

1748+
void QgsProject::setTopologicalEditing( bool enabled )
1749+
{
1750+
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", ( enabled ? 1 : 0 ) );
1751+
emit snapSettingsChanged();
1752+
}
1753+
1754+
bool QgsProject::topologicalEditing() const
1755+
{
1756+
return ( QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ) > 0 );
1757+
}
1758+
17481759
void QgsProjectBadLayerDefaultHandler::handleBadLayers( QList<QDomNode> /*layers*/, QDomDocument /*projectDom*/ )
17491760
{
17501761
// just ignore any bad layers

src/core/qgsproject.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ class CORE_EXPORT QgsProject : public QObject
295295
bool avoidIntersection );
296296

297297
bool snapSettingsForLayer( const QString& layerId, bool& enabled, QgsSnapper::SnappingType& type, QgsTolerance::UnitType& units, double& tolerance,
298-
bool& avoidIntersection );
298+
bool& avoidIntersection ) const;
299+
300+
void setTopologicalEditing( bool enabled );
301+
bool topologicalEditing() const;
299302

300303
protected:
301304

@@ -353,7 +356,7 @@ class CORE_EXPORT QgsProject : public QObject
353356
QHash< QString, QPair< QString, bool> > mEmbeddedLayers;
354357

355358
void snapSettings( QStringList& layerIdList, QStringList& enabledList, QStringList& snapTypeList, QStringList& snapUnitList, QStringList& toleranceUnitList,
356-
QStringList& avoidIntersectionList );
359+
QStringList& avoidIntersectionList ) const;
357360

358361
}; // QgsProject
359362

0 commit comments

Comments
 (0)