Index: src/app/qgsoptions.cpp =================================================================== --- src/app/qgsoptions.cpp (Revision 14616) +++ src/app/qgsoptions.cpp (Arbeitskopie) @@ -249,6 +249,7 @@ cbxHideSplash->setChecked( settings.value( "/qgis/hideSplash", false ).toBool() ); cbxAttributeTableDocked->setChecked( settings.value( "/qgis/dockAttributeTable", false ).toBool() ); cbxIdentifyResultsDocked->setChecked( settings.value( "/qgis/dockIdentifyResults", false ).toBool() ); + cbxSnappingOptionsDocked->setChecked( settings.value( "/qgis/dockSnapping", false ).toBool() ); cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() ); cbxAddNewLayersToCurrentGroup->setChecked( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() ); cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", true ).toBool() ); @@ -505,6 +506,7 @@ settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() ); settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() ); settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() ); + settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() ); settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() ); settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() ); settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() ); Index: src/app/qgssnappingdialog.cpp =================================================================== --- src/app/qgssnappingdialog.cpp (Revision 14616) +++ src/app/qgssnappingdialog.cpp (Arbeitskopie) @@ -19,28 +19,246 @@ #include "qgsmapcanvas.h" #include "qgsmaplayer.h" #include "qgsvectorlayer.h" +#include "qgsmaplayerregistry.h" +#include "qgisapp.h" +#include "qgsproject.h" #include #include #include #include +#include -QgsSnappingDialog::QgsSnappingDialog( QgsMapCanvas* canvas, const QMap& settings ): mMapCanvas( canvas ) + +class QgsSnappingDock : public QDockWidget { + public: + QgsSnappingDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 ) + : QDockWidget( title, parent, flags ) + { + setObjectName( "Snapping Options" ); // set object name so the position can be saved + } + + virtual void closeEvent( QCloseEvent * ev ) + { + //deleteLater(); + } + +}; + + +QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): QDialog(parent), mMapCanvas( canvas ) +{ setupUi( this ); - connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); - connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); + + QSettings myQsettings; + bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool(); + if ( myDockFlag ) + { + mDock = new QgsSnappingDock( tr( "Snapping Options"), QgisApp::instance() ); + mDock->setAllowedAreas( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea ); + mDock->setWidget( this ); + connect( this, SIGNAL( destroyed() ), mDock, SLOT( close() ) ); + QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock ); + mButtonBox->setVisible(false); + } + else + { + connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) ); + } + connect( QgsMapLayerRegistry::instance(),SIGNAL(layerWasAdded ( QgsMapLayer * ) ),this,SLOT( update() ) ); + connect( QgsMapLayerRegistry::instance(),SIGNAL(layerWillBeRemoved ( QString ) ),this,SLOT( update() ) ); + + + update(); + mLayerTreeWidget->setHeaderLabels(QStringList() << ""); + mLayerTreeWidget->resizeColumnToContents( 0); + mLayerTreeWidget->setColumnWidth( 1, 200 ); //hardcoded for now + mLayerTreeWidget->setColumnWidth( 2, 200 ); //hardcoded for now + mLayerTreeWidget->resizeColumnToContents( 3 ); + mLayerTreeWidget->resizeColumnToContents( 4 ); +} +QgsSnappingDialog::QgsSnappingDialog() +{ + +} + +QgsSnappingDialog::~QgsSnappingDialog() +{ + +} + +void QgsSnappingDialog::layerSettings( ) +{ + mSnappingLayerSettings .clear(); + + int nRows = mLayerTreeWidget->topLevelItemCount(); + QTreeWidgetItem* currentItem = 0; + QString layerId; + QString layerName; + QString snapToItemText; + QString toleranceItemText; + int snapTo; + int toleranceUnit; + double tolerance; + bool checked = false; + + for ( int i = 0; i < nRows; ++i ) + { + currentItem = mLayerTreeWidget->topLevelItem( i ); + if ( !currentItem ) + { + continue; + } + + //get layer id, to vertex/to segment and tolerance + layerName = currentItem->text( 1 ); + layerId = mLayerIds.at( i ); + //checked = ( currentItem->checkState( 0 ) == Qt::Checked ); + checked = ( (( QCheckBox* )( mLayerTreeWidget->itemWidget( currentItem, 0 ) ) )->checkState() == Qt::Checked ); + snapToItemText = (( QComboBox* )( mLayerTreeWidget->itemWidget( currentItem, 2 ) ) )->currentText(); + toleranceItemText = (( QComboBox* )( mLayerTreeWidget->itemWidget( currentItem, 4 ) ) )->currentText(); + if ( snapToItemText == tr( "to vertex" ) ) + { + snapTo = 0; + } + else if ( snapToItemText == tr( "to segment" ) ) + { + snapTo = 1; + } + else //to vertex and segment + { + snapTo = 2; + } + if ( toleranceItemText == tr( "map units" ) ) + { + toleranceUnit = 0; + } + else //to vertex and segment + { + toleranceUnit = 1; + } + tolerance = (( QLineEdit* )( mLayerTreeWidget->itemWidget( currentItem, 3 ) ) )->text().toDouble(); + LayerEntry newEntry; + newEntry.checked = checked; newEntry.snapTo = snapTo; newEntry.layerName = layerName; + newEntry.tolerance = tolerance; newEntry.toleranceUnit = toleranceUnit; + mSnappingLayerSettings.insert( layerId, newEntry ); + } +} + +void QgsSnappingDialog::closeEvent( QCloseEvent* event ) +{ + QDialog::closeEvent( event ); + + if ( mDock == NULL ) + { + QSettings settings; + settings.setValue( "/Windows/BetterSnapping/geometry", saveGeometry() ); + } +} + + +void QgsSnappingDialog::update( ) +{ + QSettings myQsettings; + bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool(); + + bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk; + 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::const_iterator idIter = layerIdList.constBegin(); + QStringList::const_iterator enabledIter = enabledList.constBegin(); + QStringList::const_iterator tolIter = toleranceList.constBegin(); + QStringList::const_iterator tolUnitIter = toleranceUnitList.constBegin(); + QStringList::const_iterator snapToIter = snapToList.constBegin(); + + QgsMapLayer* currentLayer = 0; + + //create the new layer entries + for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++tolUnitIter, ++snapToIter ) + { + if ( layerIdListOk ) + { + currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter ); + } + else + { + break; + } + + if ( currentLayer ) + { + LayerEntry newEntry; + newEntry.layerName = currentLayer->name(); + + newEntry.checked = false; + if ( enabledListOk && enabledIter != enabledList.constEnd() ) + { + if (( *enabledIter ) == "enabled" ) + { + newEntry.checked = true; + } + } + + //snap to vertex / segment / vertex and segment + if ( snapToListOk && snapToIter != snapToList.constEnd() ) + { + if (( *snapToIter ) == "to_vertex" ) + { + newEntry.snapTo = 0; + } + else if (( *snapToIter ) == "to_segment" ) + { + newEntry.snapTo = 1; + } + else //to vertex and segment + { + newEntry.snapTo = 2; + } + } + else + { + newEntry.snapTo = 0; + } + + //snap tolerance + if ( toleranceListOk && tolIter != toleranceList.constEnd() ) + { + newEntry.tolerance = tolIter->toDouble(); + } + else + { + newEntry.tolerance = 0; + } + + //snap tolerance unit + if ( toleranceUnitListOk && tolUnitIter != toleranceUnitList.constEnd() ) + { + newEntry.toleranceUnit = tolUnitIter->toInt(); + } + else + { + newEntry.toleranceUnit = 0; + } + + mSnappingLayerSettings.insert( *idIter, newEntry ); + + } + } //an entry for each layer int nLayers = mMapCanvas->layerCount(); int nVectorLayers = 0; //mLayerTableWidget->setRowCount(nLayers); + mLayerTreeWidget->clear(); - QgsMapLayer* currentLayer = 0; - QgsVectorLayer* currentVectorLayer = 0; + QgsVectorLayer* currentVectorLayer = 0; QString currentLayerName; QMap::const_iterator settingIt; QTreeWidgetItem* newItem = 0; - if ( mMapCanvas ) { for ( int i = 0; i < nLayers; ++i ) @@ -53,32 +271,52 @@ { //snap to layer yes/no newItem = new QTreeWidgetItem( mLayerTreeWidget ); - newItem->setText( 0, currentLayer->name() ); + + newItem->setText( 1, currentLayer->name() ); mLayerIds << currentLayer->getLayerID(); //store also the layer id - newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ); - newItem->setCheckState( 0, Qt::Unchecked ); + //newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ); + newItem->setFlags( Qt::ItemIsEnabled ); + //newItem->setCheckState( 0, Qt::Unchecked ); + QCheckBox* snapToLayerChkBox = new QCheckBox ( mLayerTreeWidget); + mLayerTreeWidget->setItemWidget( newItem, 0, snapToLayerChkBox ); + if ( myDockFlag ) + { + connect(snapToLayerChkBox,SIGNAL(stateChanged ( int )),this,SLOT(apply())); + } //snap to vertex/ snap to segment QComboBox* snapToComboBox = new QComboBox( mLayerTreeWidget ); snapToComboBox->insertItem( 0, tr( "to vertex" ) ); snapToComboBox->insertItem( 1, tr( "to segment" ) ); snapToComboBox->insertItem( 2, tr( "to vertex and segment" ) ); - mLayerTreeWidget->setItemWidget( newItem, 1, snapToComboBox ); + mLayerTreeWidget->setItemWidget( newItem, 2, snapToComboBox ); + if ( myDockFlag ) + { + connect(snapToComboBox,SIGNAL(currentIndexChanged ( int )),this,SLOT(apply())); + } //snapping tolerance QLineEdit* snappingToleranceEdit = new QLineEdit( mLayerTreeWidget ); QDoubleValidator* validator = new QDoubleValidator( snappingToleranceEdit ); snappingToleranceEdit->setValidator( validator ); - mLayerTreeWidget->setItemWidget( newItem, 2, snappingToleranceEdit ); + mLayerTreeWidget->setItemWidget( newItem, 3, snappingToleranceEdit ); + if ( myDockFlag ) + { + connect(snappingToleranceEdit,SIGNAL(textEdited ( const QString )),this,SLOT(apply())); + } //snap to vertex/ snap to segment QComboBox* toleranceUnitsComboBox = new QComboBox( mLayerTreeWidget ); toleranceUnitsComboBox->insertItem( 0, tr( "map units" ) ); toleranceUnitsComboBox->insertItem( 1, tr( "pixels" ) ); - mLayerTreeWidget->setItemWidget( newItem, 3, toleranceUnitsComboBox ); + mLayerTreeWidget->setItemWidget( newItem, 4, toleranceUnitsComboBox ); + if ( myDockFlag ) + { + connect(toleranceUnitsComboBox,SIGNAL(currentIndexChanged ( int )),this,SLOT(apply())); + } - settingIt = settings.find( currentVectorLayer->getLayerID() ); - if ( settingIt != settings.constEnd() ) + settingIt = mSnappingLayerSettings.find( currentVectorLayer->getLayerID() ); + if ( settingIt != mSnappingLayerSettings.constEnd() ) { snappingToleranceEdit->setText( QString::number( settingIt.value().tolerance ) ); int index; @@ -117,76 +355,54 @@ } } } - mLayerTreeWidget->resizeColumnToContents( 0 ); - mLayerTreeWidget->setColumnWidth( 1, 200 ); //hardcoded for now - mLayerTreeWidget->resizeColumnToContents( 2 ); - mLayerTreeWidget->resizeColumnToContents( 3 ); } } -QgsSnappingDialog::QgsSnappingDialog() +void QgsSnappingDialog::apply() { + layerSettings( ); + QMap::const_iterator layerEntryIt; -} + //store the layer snapping settings as string lists + QStringList layerIdList; + QStringList snapToList; + QStringList toleranceList; + QStringList enabledList; + QStringList toleranceUnitList; -QgsSnappingDialog::~QgsSnappingDialog() -{ - -} - -void QgsSnappingDialog::layerSettings( QMap& settings ) const -{ - settings.clear(); - - int nRows = mLayerTreeWidget->topLevelItemCount(); - QTreeWidgetItem* currentItem = 0; - QString layerId; - QString layerName; - QString snapToItemText; - QString toleranceItemText; - int snapTo; - int toleranceUnit; - double tolerance; - bool checked = false; - - for ( int i = 0; i < nRows; ++i ) + for ( layerEntryIt = mSnappingLayerSettings.constBegin(); layerEntryIt != mSnappingLayerSettings.constEnd(); ++layerEntryIt ) { - currentItem = mLayerTreeWidget->topLevelItem( i ); - if ( !currentItem ) + layerIdList << layerEntryIt.key(); + toleranceList << QString::number( layerEntryIt->tolerance, 'f' ); + toleranceUnitList << QString::number(( int )layerEntryIt->toleranceUnit ); + if ( layerEntryIt->checked ) { - continue; + enabledList << "enabled"; } - - //get layer id, to vertex/to segment and tolerance - layerName = currentItem->text( 0 ); - layerId = mLayerIds.at( i ); - checked = ( currentItem->checkState( 0 ) == Qt::Checked ); - snapToItemText = (( QComboBox* )( mLayerTreeWidget->itemWidget( currentItem, 1 ) ) )->currentText(); - toleranceItemText = (( QComboBox* )( mLayerTreeWidget->itemWidget( currentItem, 3 ) ) )->currentText(); - if ( snapToItemText == tr( "to vertex" ) ) + else { - snapTo = 0; + enabledList << "disabled"; } - else if ( snapToItemText == tr( "to segment" ) ) + if ( layerEntryIt->snapTo == 0 ) { - snapTo = 1; + snapToList << "to_vertex"; } - else //to vertex and segment + else if ( layerEntryIt->snapTo == 1 ) { - snapTo = 2; + snapToList << "to_segment"; } - if ( toleranceItemText == tr( "map units" ) ) - { - toleranceUnit = 0; - } else //to vertex and segment { - toleranceUnit = 1; + snapToList << "to_vertex_and_segment"; } - tolerance = (( QLineEdit* )( mLayerTreeWidget->itemWidget( currentItem, 2 ) ) )->text().toDouble(); - LayerEntry newEntry; - newEntry.checked = checked; newEntry.snapTo = snapTo; newEntry.layerName = layerName; - newEntry.tolerance = tolerance; newEntry.toleranceUnit = toleranceUnit; - settings.insert( layerId, newEntry ); } + + if ( mSnappingLayerSettings.size() > 0 ) + { + QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList ); + QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnapToList", snapToList ); + QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList ); + QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList ); + QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList ); + } } Index: src/app/qgsprojectproperties.cpp =================================================================== --- src/app/qgsprojectproperties.cpp (Revision 14616) +++ src/app/qgsprojectproperties.cpp (Arbeitskopie) @@ -127,91 +127,8 @@ } } - bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk; - 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::const_iterator idIter = layerIdList.constBegin(); - QStringList::const_iterator enabledIter = enabledList.constBegin(); - QStringList::const_iterator tolIter = toleranceList.constBegin(); - QStringList::const_iterator tolUnitIter = toleranceUnitList.constBegin(); - QStringList::const_iterator snapToIter = snapToList.constBegin(); - QgsMapLayer* currentLayer = 0; - //create the new layer entries - for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++tolUnitIter, ++snapToIter ) - { - if ( layerIdListOk ) - { - currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter ); - } - else - { - break; - } - - if ( currentLayer ) - { - LayerEntry newEntry; - newEntry.layerName = currentLayer->name(); - - newEntry.checked = false; - if ( enabledListOk && enabledIter != enabledList.constEnd() ) - { - if (( *enabledIter ) == "enabled" ) - { - newEntry.checked = true; - } - } - - //snap to vertex / segment / vertex and segment - if ( snapToListOk && snapToIter != snapToList.constEnd() ) - { - if (( *snapToIter ) == "to_vertex" ) - { - newEntry.snapTo = 0; - } - else if (( *snapToIter ) == "to_segment" ) - { - newEntry.snapTo = 1; - } - else //to vertex and segment - { - newEntry.snapTo = 2; - } - } - else - { - newEntry.snapTo = 0; - } - - //snap tolerance - if ( toleranceListOk && tolIter != toleranceList.constEnd() ) - { - newEntry.tolerance = tolIter->toDouble(); - } - else - { - newEntry.tolerance = 0; - } - - //snap tolerance unit - if ( toleranceUnitListOk && tolUnitIter != toleranceUnitList.constEnd() ) - { - newEntry.toleranceUnit = tolUnitIter->toInt(); - } - else - { - newEntry.toleranceUnit = 0; - } - mSnappingLayerSettings.insert( *idIter, newEntry ); - } - } - QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); const QMap &mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); @@ -418,51 +335,6 @@ QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList ); - QMap::const_iterator layerEntryIt; - - //store the layer snapping settings as string lists - QStringList layerIdList; - QStringList snapToList; - QStringList toleranceList; - QStringList enabledList; - QStringList toleranceUnitList; - - for ( layerEntryIt = mSnappingLayerSettings.constBegin(); layerEntryIt != mSnappingLayerSettings.constEnd(); ++layerEntryIt ) - { - layerIdList << layerEntryIt.key(); - toleranceList << QString::number( layerEntryIt->tolerance, 'f' ); - toleranceUnitList << QString::number(( int )layerEntryIt->toleranceUnit ); - if ( layerEntryIt->checked ) - { - enabledList << "enabled"; - } - else - { - enabledList << "disabled"; - } - if ( layerEntryIt->snapTo == 0 ) - { - snapToList << "to_vertex"; - } - else if ( layerEntryIt->snapTo == 1 ) - { - snapToList << "to_segment"; - } - else //to vertex and segment - { - snapToList << "to_vertex_and_segment"; - } - } - - if ( mSnappingLayerSettings.size() > 0 ) - { - QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList ); - QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnapToList", snapToList ); - QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList ); - QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList ); - QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList ); - } - QStringList noIdentifyLayerList; for ( int i = 0; i < twIdentifyLayers->rowCount(); i++ ) { @@ -517,15 +389,6 @@ } } -void QgsProjectProperties::on_mSnappingOptionsPushButton_clicked() -{ - QgsSnappingDialog d( mMapCanvas, mSnappingLayerSettings ); - if ( d.exec() == QDialog::Accepted ) - { - //retrieve the new layer snapping settings from the dialog - d.layerSettings( mSnappingLayerSettings ); - } -} void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state ) { Index: src/app/qgisapp.h =================================================================== --- src/app/qgisapp.h (Revision 14616) +++ src/app/qgisapp.h (Arbeitskopie) @@ -67,6 +67,7 @@ class QNetworkProxy; class QAuthenticator; +class QgsSnappingDialog; class QgsGPSInformationWidget; #include @@ -78,6 +79,7 @@ #include "qgsconfig.h" #include "qgsfeature.h" #include "qgspoint.h" +#include "qgssnappingdialog.h" /*! \class QgisApp * \brief Main window for the Qgis application @@ -242,6 +244,8 @@ QAction *actionDeletePart() { return mActionDeletePart; } QAction *actionNodeTool() { return mActionNodeTool; } QAction *actionEditSeparator2() { return mActionEditSeparator2; } + QAction *actionSnappingOptions() { return mActionSnappingOptions; } + QAction *actionEditSeparator4() { return mActionEditSeparator4; } QAction *actionPan() { return mActionPan; } QAction *actionZoomIn() { return mActionZoomIn; } @@ -618,6 +622,8 @@ void nodeTool(); //! activates the rotate points tool void rotatePointSymbols(); + //! shows the snapping Options + void snappingOptions(); //! activates the selection tool void select(); @@ -900,6 +906,8 @@ QAction *mActionNodeTool; QAction *mActionRotatePointSymbols; QAction *mActionEditSeparator3; + QAction *mActionSnappingOptions; + QAction *mActionEditSeparator4; QAction *mActionPan; QAction *mActionZoomIn; @@ -1015,6 +1023,7 @@ QDockWidget *mpTileScaleDock; QDockWidget *mpGpsDock; + #ifdef Q_WS_MAC //! Window menu action to select this window QAction *mWindowAction; @@ -1164,7 +1173,9 @@ static QgisApp *smInstance; QgsUndoWidget* mUndoWidget; - + + QgsSnappingDialog* mSnappingDialog; + //! Persistent tile scale slider QgsTileScaleWidget * mpTileScaleWidget; Index: src/app/qgssnappingdialog.h =================================================================== --- src/app/qgssnappingdialog.h (Revision 14616) +++ src/app/qgssnappingdialog.h (Arbeitskopie) @@ -20,6 +20,8 @@ #include "ui_qgssnappingdialogbase.h" +class QDockWidget; + class QgsMapCanvas; struct LayerEntry @@ -38,16 +40,40 @@ Q_OBJECT public: - /**Constructor - @param canvas pointer to the map canvas (for detecting which vector layers are loaded - @param settings existing snapping layer settings*/ - QgsSnappingDialog( QgsMapCanvas* canvas, const QMap& settings ); + + //! Returns the instance pointer, creating the object on the first call + //static QgsSnappingDialog * instance( QgsMapCanvas* canvas ); + QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ); ~QgsSnappingDialog(); /**Returns the snapping settings per layer. Key of the map is the layer id and value the corresponding layer entry*/ - void layerSettings( QMap& settings ) const; + void layerSettings( ) ; + + public slots: + /** + * apply the changes + */ + void apply ( ); + /** + * update the Dialog + */ + void update( ); + + + protected: + /**Constructor + @param canvas pointer to the map canvas (for detecting which vector layers are loaded + */ + //QgsSnappingDialog( QgsMapCanvas* canvas ); + /** + * Handle closing of the window + * @param event unused + */ + void closeEvent( QCloseEvent* event ); + + private: /**Default constructor forbidden*/ QgsSnappingDialog(); @@ -55,6 +81,10 @@ QgsMapCanvas* mMapCanvas; /**Stores the layer ids from top to bottom*/ QStringList mLayerIds; + + QDockWidget *mDock; + QMap mSnappingLayerSettings; + }; #endif Index: src/app/qgsprojectproperties.h =================================================================== --- src/app/qgsprojectproperties.h (Revision 14616) +++ src/app/qgsprojectproperties.h (Arbeitskopie) @@ -98,7 +98,7 @@ /*! * Slot to show dialog for the layer snapping options */ - void on_mSnappingOptionsPushButton_clicked(); + // void on_mSnappingOptionsPushButton_clicked(); void on_cbxProjectionEnabled_stateChanged( int state ); @@ -121,7 +121,7 @@ /**Snapping settings to pass/read from QgsSnappingDialog. Key is the layer id, the pair consists of snap to vertex = 0/snap to segment = 1, snapping tolerance*/ - QMap mSnappingLayerSettings; + //QMap mSnappingLayerSettings; /**Stores ids of layers where intersections of new polygons is considered. Is passed to / read from QgsAvoidIntersectionsDialog*/ QSet mAvoidIntersectionsSettings; Index: src/app/qgisapp.cpp =================================================================== --- src/app/qgisapp.cpp (Revision 14616) +++ src/app/qgisapp.cpp (Arbeitskopie) @@ -162,6 +162,7 @@ #include "qgsquerybuilder.h" #include "qgsattributeaction.h" #include "qgsgpsinformationwidget.h" +#include "qgssnappingdialog.h" // // Gdal/Ogr includes @@ -212,6 +213,7 @@ #include "qgsmaptoolsimplify.h" #include "qgsmeasuretool.h" + // // Conditional Includes // @@ -413,7 +415,9 @@ // create undo widget mUndoWidget = new QgsUndoWidget( NULL, mMapCanvas ); mUndoWidget->setObjectName( "Undo" ); - + + + createActions(); createActionGroups(); createMenus(); @@ -429,7 +433,11 @@ addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget ); mUndoWidget->hide(); - + + mSnappingDialog = 0; + mSnappingDialog = new QgsSnappingDialog ( this, mMapCanvas ); + mSnappingDialog->setObjectName( "SnappingOption" ); + mInternalClipboard = new QgsClipboard; // create clipboard mQgisInterface = new QgisAppInterface( this ); // create the interfce @@ -861,6 +869,11 @@ mActionRotatePointSymbols->setStatusTip( tr( "Rotate Point Symbols" ) ); connect( mActionRotatePointSymbols, SIGNAL( triggered() ), this, SLOT( rotatePointSymbols() ) ); mActionRotatePointSymbols->setEnabled( false ); + + mActionSnappingOptions = new QAction( getThemeIcon( "mActionSnappingOptions.png" ), tr( "Snapping Options..." ), this ); + shortcuts->registerAction( mActionSnappingOptions ); + mActionSnappingOptions->setStatusTip( tr( "Manage the background snapping options" ) ); + connect( mActionSnappingOptions, SIGNAL( triggered() ), this, SLOT( snappingOptions() ) ); // View Menu Items @@ -1428,7 +1441,7 @@ #endif mActionEditSeparator2 = mEditMenu->addSeparator(); - + mEditMenu->addAction( mActionSimplifyFeature ); mEditMenu->addAction( mActionAddRing ); mEditMenu->addAction( mActionAddIsland ); @@ -1441,8 +1454,16 @@ mEditMenu->addAction( mActionNodeTool ); mEditMenu->addAction( mActionRotatePointSymbols ); - if ( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout ) + QSettings myQsettings; + bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool(); + if(!myDockFlag) { + mActionEditSeparator4 = mEditMenu->addSeparator(); + mEditMenu->addAction( mActionSnappingOptions ); + } + + if( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout ) + { mActionEditSeparator3 = mEditMenu->addSeparator(); mEditMenu->addAction( mActionOptions ); mEditMenu->addAction( mActionConfigureShortcuts ); @@ -2541,7 +2562,7 @@ abt->setVersion( versionString ); QString whatsNew = "" ; whatsNew += "

" + tr( "Version" ) + " " + QString( QGis::QGIS_VERSION ) + "

"; - whatsNew += "

" + trUtf8( "What's new in Version 1.6.0 'Capiapó'?" ) + "

"; + whatsNew += "

" + trUtf8( "What's new in Version 1.6.0 'Capiap贸'?" ) + "

"; whatsNew += "

"; whatsNew += tr( "Please note that this is a release in our 'cutting edge' release series. As such it contains new features and extends the programmatic interface over QGIS 1.0.x and QGIS 1.5.0. We recommend that you use this version over previous releases." ); whatsNew += "

"; @@ -4446,6 +4467,11 @@ mMapCanvas->setMapTool( mMapTools.mRotatePointSymbolsTool ); } +void QgisApp::snappingOptions() +{ + mSnappingDialog->show(); +} + void QgisApp::splitFeatures() { mMapCanvas->setMapTool( mMapTools.mSplitFeatures ); Index: src/ui/qgsoptionsbase.ui =================================================================== --- src/ui/qgsoptionsbase.ui (Revision 14616) +++ src/ui/qgsoptionsbase.ui (Arbeitskopie) @@ -41,7 +41,7 @@ 32 - + :/images/themes/default/propertyicons/general.png:/images/themes/default/propertyicons/general.png @@ -59,9 +59,9 @@ 0 - 0 - 746 - 530 + -126 + 744 + 574 @@ -247,9 +247,16 @@ + + + Open snapping options in a dock window (QGIS restart required) + + + + - Open attribute table in a dock window + Open attribute table in a dock window (QGIS restart required) @@ -318,7 +325,7 @@ - + :/images/themes/default/propertyicons/rendering.png:/images/themes/default/propertyicons/rendering.png @@ -337,8 +344,8 @@ 0 0 - 746 - 473 + 621 + 479 @@ -489,7 +496,7 @@ - + :/images/themes/default/propertyicons/map_tools.png:/images/themes/default/propertyicons/map_tools.png @@ -508,8 +515,8 @@ 0 0 - 746 - 490 + 541 + 496 @@ -769,7 +776,7 @@ - + :/images/themes/default/propertyicons/overlay.png:/images/themes/default/propertyicons/overlay.png @@ -788,8 +795,8 @@ 0 0 - 762 - 448 + 277 + 87 @@ -844,7 +851,7 @@ - + :/images/themes/default/propertyicons/digitising.png:/images/themes/default/propertyicons/digitising.png @@ -863,8 +870,8 @@ 0 0 - 762 - 448 + 744 + 454 @@ -1174,7 +1181,7 @@ - + :/images/themes/default/propertyicons/CRS.png:/images/themes/default/propertyicons/CRS.png @@ -1193,8 +1200,8 @@ 0 0 - 746 - 531 + 390 + 563 @@ -1270,7 +1277,7 @@ - + :/images/themes/default/propertyicons/locale.png:/images/themes/default/propertyicons/locale.png @@ -1289,8 +1296,8 @@ 0 0 - 746 - 548 + 519 + 565 @@ -1361,7 +1368,7 @@ - + :/images/themes/default/propertyicons/network_and_proxy.png:/images/themes/default/propertyicons/network_and_proxy.png @@ -1380,8 +1387,8 @@ 0 0 - 746 - 538 + 352 + 544 Index: src/ui/qgssnappingdialogbase.ui =================================================================== --- src/ui/qgssnappingdialogbase.ui (Revision 14616) +++ src/ui/qgssnappingdialogbase.ui (Arbeitskopie) @@ -1,7 +1,8 @@ - + + QgsSnappingDialogBase - - + + 0 0 @@ -9,59 +10,58 @@ 290 - + Snapping options - - + + 9 - - 9 - - - 9 - - - 9 - - + 6 - - 6 - - - + + + + 0 + + + false + - + + + + + + Layer - + Mode - + Tolerance - + Units - - - + + + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -75,11 +75,11 @@ QgsSnappingDialogBase accept() - + 248 254 - + 157 274 @@ -91,11 +91,11 @@ QgsSnappingDialogBase reject() - + 316 260 - + 286 274 Index: src/ui/qgsprojectpropertiesbase.ui =================================================================== --- src/ui/qgsprojectpropertiesbase.ui (Revision 14616) +++ src/ui/qgsprojectpropertiesbase.ui (Arbeitskopie) @@ -6,8 +6,8 @@ 0 0 - 552 - 525 + 555 + 538 @@ -301,13 +301,6 @@ - - - - Snapping options... - - - @@ -413,7 +406,6 @@ spinBoxDP mEnableTopologicalEditingCheckBox mAvoidIntersectionsPushButton - mSnappingOptionsPushButton cbxProjectionEnabled twIdentifyLayers tabWidget