Index: app/qgssnappingdialog.cpp =================================================================== --- app/qgssnappingdialog.cpp (Revision 14780) +++ app/qgssnappingdialog.cpp (Arbeitskopie) @@ -16,7 +16,6 @@ ***************************************************************************/ #include "qgssnappingdialog.h" -#include "qgsavoidintersectionsdialog.h" #include "qgsmapcanvas.h" #include "qgsmaplayer.h" #include "qgsvectorlayer.h" @@ -96,22 +95,6 @@ QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", topologicalEditingEnabled ); } -void QgsSnappingDialog::on_mAvoidIntersectionsPushButton_clicked() -{ - QgsAvoidIntersectionsDialog d( mMapCanvas, mAvoidIntersectionsSettings ); - if ( d.exec() == QDialog::Accepted ) - { - d.enabledLayers( mAvoidIntersectionsSettings ); - //store avoid intersection layers - QStringList avoidIntersectionList; - QSet::const_iterator avoidIt = mAvoidIntersectionsSettings.constBegin(); - for ( ; avoidIt != mAvoidIntersectionsSettings.constEnd(); ++avoidIt ) - { - avoidIntersectionList.append( *avoidIt ); - } - QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList ); - } -} void QgsSnappingDialog::closeEvent( QCloseEvent* event ) { @@ -151,13 +134,15 @@ defaultSnappingStringIdx = 2; } - bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk; + bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk,avoidIntersectionListOk; QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk ); QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk ); QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk ); QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk ); QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk ); + QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk ); + mLayerTreeWidget->clear(); QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); @@ -200,6 +185,9 @@ cbxUnits->setCurrentIndex( defaultSnappingUnit ); mLayerTreeWidget->setItemWidget( item, 4, cbxUnits ); + QCheckBox *cbxAvoid = new QCheckBox( mLayerTreeWidget ); + mLayerTreeWidget->setItemWidget( item, 5, cbxAvoid ); + int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() ); if ( idx < 0 ) { @@ -208,7 +196,6 @@ } cbxEnable->setChecked( enabledList[ idx ] == "enabled" ); - int snappingStringIdx = 0; if ( snapToList[idx] == "to_vertex" ) { @@ -225,6 +212,18 @@ cbxSnapTo->setCurrentIndex( snappingStringIdx ); leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) ); cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() ); + + if ( avoidIntersectionListOk ) + { + QStringList::const_iterator avoidIt = avoidIntersectionsList.constBegin(); + for ( ; avoidIt != avoidIntersectionsList.constEnd(); ++avoidIt ) + { + if(*avoidIt == currentVectorLayer->getLayerID()) + { + cbxAvoid->setChecked( true ); + } + } + } } // read the digitizing settings @@ -238,18 +237,6 @@ cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked ); } - bool avoidIntersectionListOk; - mAvoidIntersectionsSettings.clear(); - QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk ); - if ( avoidIntersectionListOk ) - { - QStringList::const_iterator avoidIt = avoidIntersectionsList.constBegin(); - for ( ; avoidIt != avoidIntersectionsList.constEnd(); ++avoidIt ) - { - mAvoidIntersectionsSettings.insert( *avoidIt ); - } - } - if ( myDockFlag ) { for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i ) @@ -259,6 +246,7 @@ connect( mLayerTreeWidget->itemWidget( item, 2 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) ); connect( mLayerTreeWidget->itemWidget( item, 3 ), SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) ); connect( mLayerTreeWidget->itemWidget( item, 4 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) ); + connect( mLayerTreeWidget->itemWidget( item, 5 ), SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) ); } } } @@ -270,6 +258,7 @@ QStringList toleranceList; QStringList enabledList; QStringList toleranceUnitList; + QStringList avoidIntersectionsList; for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i ) { @@ -298,6 +287,11 @@ toleranceList << QString::number( qobject_cast( mLayerTreeWidget->itemWidget( currentItem, 3 ) )->text().toDouble(), 'f' ); toleranceUnitList << QString::number( qobject_cast( mLayerTreeWidget->itemWidget( currentItem, 4 ) )->currentIndex() ); + + if( qobject_cast( mLayerTreeWidget->itemWidget( currentItem, 5 ) )->isChecked() ) + { + avoidIntersectionsList << currentItem->data( 0, Qt::UserRole ).toString(); + } } QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList ); @@ -305,6 +299,7 @@ QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList ); QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList ); QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList ); + QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionsList ); } void QgsSnappingDialog::show() Index: app/qgsprojectproperties.cpp =================================================================== --- app/qgsprojectproperties.cpp (Revision 14780) +++ app/qgsprojectproperties.cpp (Arbeitskopie) @@ -20,7 +20,6 @@ #include "qgsprojectproperties.h" //qgis includes -#include "qgsavoidintersectionsdialog.h" #include "qgscontexthelp.h" #include "qgscoordinatetransform.h" #include "qgslogger.h" Index: app/qgssnappingdialog.h =================================================================== --- app/qgssnappingdialog.h (Revision 14780) +++ app/qgssnappingdialog.h (Arbeitskopie) @@ -49,7 +49,6 @@ void connectUpdate( QgsMapLayer* theMapLayer ); void on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ); - void on_mAvoidIntersectionsPushButton_clicked(); protected: /**Constructor @@ -68,9 +67,6 @@ /**Default constructor forbidden*/ QgsSnappingDialog(); - /**Stores ids of layers where intersections of new polygons is considered. Is passed to / read from QgsAvoidIntersectionsDialog*/ - QSet mAvoidIntersectionsSettings; - /**Used to query the loaded layers*/ QgsMapCanvas* mMapCanvas; Index: app/qgsavoidintersectionsdialog.h =================================================================== --- app/qgsavoidintersectionsdialog.h (Revision 14778) +++ app/qgsavoidintersectionsdialog.h (Arbeitskopie) @@ -1,21 +0,0 @@ -#ifndef QGSAVOIDINTERSECTIONSDIALOG_H -#define QGSAVOIDINTERSECTIONSDIALOG_H - -#include "ui_qgsavoidintersectionsdialogbase.h" - -class QgsMapCanvas; - -class QgsAvoidIntersectionsDialog: public QDialog, private Ui::QgsAvoidIntersectionsDialogBase -{ - Q_OBJECT - public: - QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet& enabledLayers, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - ~QgsAvoidIntersectionsDialog(); - /**Returns ids of layers that are considered for the avoid intersection function*/ - void enabledLayers( QSet& enabledLayers ); - - private: - QgsMapCanvas* mMapCanvas; -}; - -#endif // QGSAVOIDINTERSECTIONSDIALOG_H Index: app/CMakeLists.txt =================================================================== --- app/CMakeLists.txt (Revision 14780) +++ app/CMakeLists.txt (Arbeitskopie) @@ -9,7 +9,6 @@ qgsattributedialog.cpp qgsattributetypedialog.cpp qgsattributetypeloaddialog.cpp - qgsavoidintersectionsdialog.cpp qgsbookmarkitem.cpp qgsbookmarks.cpp qgsclipboard.cpp @@ -163,7 +162,6 @@ qgsattributedialog.h qgsattributetypedialog.h qgsattributetypeloaddialog.h - qgsavoidintersectionsdialog.h qgsbookmarks.h qgscontinuouscolordialog.h qgsconfigureshortcutsdialog.h Index: app/qgsavoidintersectionsdialog.cpp =================================================================== --- app/qgsavoidintersectionsdialog.cpp (Revision 14778) +++ app/qgsavoidintersectionsdialog.cpp (Arbeitskopie) @@ -1,51 +0,0 @@ -#include "qgsavoidintersectionsdialog.h" -#include "qgsvectorlayer.h" -#include "qgsmaplayerregistry.h" - -QgsAvoidIntersectionsDialog::QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet& enabledLayers, QWidget * parent, Qt::WindowFlags f ): - QDialog( parent, f ), mMapCanvas( canvas ) -{ - setupUi( this ); - - const QMap &mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); - - int i = 0; - for ( QMap::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ ) - { - QgsVectorLayer* currentLayer = dynamic_cast( it.value() ); - if ( !currentLayer || currentLayer->geometryType() != QGis::Polygon ) - continue; - - QListWidgetItem *newItem = new QListWidgetItem( mLayersListWidget ); - newItem->setText( currentLayer->name() ); - newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ); - newItem->setData( Qt::UserRole, currentLayer->getLayerID() ); - if ( enabledLayers.contains( currentLayer->getLayerID() ) ) - { - newItem->setCheckState( Qt::Checked ); - } - else - { - newItem->setCheckState( Qt::Unchecked ); - } - } -} - -QgsAvoidIntersectionsDialog::~QgsAvoidIntersectionsDialog() -{ - -} - -void QgsAvoidIntersectionsDialog::enabledLayers( QSet& enabledLayers ) -{ - enabledLayers.clear(); - - for ( int i = 0; i < mLayersListWidget->count(); ++i ) - { - QListWidgetItem *currentItem = mLayersListWidget->item( i ); - if ( currentItem->checkState() == Qt::Checked ) - { - enabledLayers.insert( currentItem->data( Qt::UserRole ).toString() ); - } - } -} Index: ui/qgsavoidintersectionsdialogbase.ui =================================================================== --- ui/qgsavoidintersectionsdialogbase.ui (Revision 14778) +++ ui/qgsavoidintersectionsdialogbase.ui (Arbeitskopie) @@ -1,66 +0,0 @@ - - QgsAvoidIntersectionsDialogBase - - - - 0 - 0 - 365 - 300 - - - - Remove intersections of new polygons with layers - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - mButtonBox - accepted() - QgsAvoidIntersectionsDialogBase - accept() - - - 248 - 254 - - - 157 - 274 - - - - - mButtonBox - rejected() - QgsAvoidIntersectionsDialogBase - reject() - - - 316 - 260 - - - 286 - 274 - - - - - Index: ui/qgssnappingdialogbase.ui =================================================================== --- ui/qgssnappingdialogbase.ui (Revision 14778) +++ ui/qgssnappingdialogbase.ui (Arbeitskopie) @@ -22,6 +22,9 @@ false + + 6 + @@ -47,6 +50,11 @@ Units + + + Avoid Intersection + + @@ -64,13 +72,6 @@ - - - - Avoid intersections of new polygons... - - -