Skip to content
Permalink
Browse files

Convenient access functions also for topological editing

  • Loading branch information
mhugent committed Jun 20, 2012
1 parent 1e60028 commit 618832252f099e726d137b03bed66208999ffd95
Showing with 28 additions and 9 deletions.
  1. +5 −0 python/core/qgsproject.sip
  2. +4 −4 src/app/qgssnappingdialog.cpp
  3. +1 −1 src/app/qgssnappingdialog.h
  4. +13 −2 src/core/qgsproject.cpp
  5. +5 −2 src/core/qgsproject.h
@@ -245,6 +245,9 @@ public:
bool snapSettingsForLayer( const QString& layerId, bool& enabled /Out/, QgsSnapper::SnappingType& type /Out/, QgsTolerance::UnitType& units /Out/, double& tolerance /Out/,
bool& avoidIntersection /Out/ );

void setTopologicalEditing( bool enabled );
bool topologicalEditing() const;

protected:

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

void snapSettingsChanged();

private:

QgsProject(); // private 'cause it's a singleton
@@ -73,7 +73,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) );
connect( cbxEnableTopologicalEditingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ) ) );

reloadLayers();
reload();

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

setTopologicalEditingState();
connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), this, SLOT( reloadLayers() ) );
connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), this, SLOT( reload() ) );
}

QgsSnappingDialog::QgsSnappingDialog()
@@ -102,7 +101,7 @@ QgsSnappingDialog::~QgsSnappingDialog()
{
}

void QgsSnappingDialog::reloadLayers()
void QgsSnappingDialog::reload()
{
mLayerTreeWidget->clear();

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

setTopologicalEditingState();
}

void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int state )
@@ -68,7 +68,7 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
void closeEvent( QCloseEvent* event );

private slots:
void reloadLayers();
void reload();


private:
@@ -1679,7 +1679,7 @@ void QgsProject::setSnapSettingsForLayer( const QString& layerId, bool enabled,
}

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

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

void QgsProject::setTopologicalEditing( bool enabled )
{
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", ( enabled ? 1 : 0 ) );
emit snapSettingsChanged();
}

bool QgsProject::topologicalEditing() const
{
return ( QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ) > 0 );
}

void QgsProjectBadLayerDefaultHandler::handleBadLayers( QList<QDomNode> /*layers*/, QDomDocument /*projectDom*/ )
{
// just ignore any bad layers
@@ -295,7 +295,10 @@ class CORE_EXPORT QgsProject : public QObject
bool avoidIntersection );

bool snapSettingsForLayer( const QString& layerId, bool& enabled, QgsSnapper::SnappingType& type, QgsTolerance::UnitType& units, double& tolerance,
bool& avoidIntersection );
bool& avoidIntersection ) const;

void setTopologicalEditing( bool enabled );
bool topologicalEditing() const;

protected:

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

void snapSettings( QStringList& layerIdList, QStringList& enabledList, QStringList& snapTypeList, QStringList& snapUnitList, QStringList& toleranceUnitList,
QStringList& avoidIntersectionList );
QStringList& avoidIntersectionList ) const;

}; // QgsProject

0 comments on commit 6188322

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