Skip to content

Commit 8c2a02f

Browse files
author
jef
committed
apply #3206
git-svn-id: http://svn.osgeo.org/qgis/trunk@14623 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 72a5bfc commit 8c2a02f

10 files changed

+270
-341
lines changed

src/app/qgisapp.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
#include "qgsquerybuilder.h"
163163
#include "qgsattributeaction.h"
164164
#include "qgsgpsinformationwidget.h"
165+
#include "qgssnappingdialog.h"
165166

166167
//
167168
// Gdal/Ogr includes
@@ -430,6 +431,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
430431
addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
431432
mUndoWidget->hide();
432433

434+
mSnappingDialog = new QgsSnappingDialog( this, mMapCanvas );
435+
mSnappingDialog->setObjectName( "SnappingOption" );
436+
433437
mInternalClipboard = new QgsClipboard; // create clipboard
434438
mQgisInterface = new QgisAppInterface( this ); // create the interfce
435439

@@ -862,6 +866,11 @@ void QgisApp::createActions()
862866
connect( mActionRotatePointSymbols, SIGNAL( triggered() ), this, SLOT( rotatePointSymbols() ) );
863867
mActionRotatePointSymbols->setEnabled( false );
864868

869+
mActionSnappingOptions = new QAction( getThemeIcon( "mActionSnappingOptions.png" ), tr( "Snapping Options..." ), this );
870+
shortcuts->registerAction( mActionSnappingOptions );
871+
mActionSnappingOptions->setStatusTip( tr( "Manage the background snapping options" ) );
872+
connect( mActionSnappingOptions, SIGNAL( triggered() ), this, SLOT( snappingOptions() ) );
873+
865874
// View Menu Items
866875

867876
mActionPan = new QAction( getThemeIcon( "mActionPan.png" ), tr( "Pan Map" ), this );
@@ -1441,6 +1450,14 @@ void QgisApp::createMenus()
14411450
mEditMenu->addAction( mActionNodeTool );
14421451
mEditMenu->addAction( mActionRotatePointSymbols );
14431452

1453+
QSettings myQsettings;
1454+
bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool();
1455+
if ( !myDockFlag )
1456+
{
1457+
mActionEditSeparator4 = mEditMenu->addSeparator();
1458+
mEditMenu->addAction( mActionSnappingOptions );
1459+
}
1460+
14441461
if ( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout )
14451462
{
14461463
mActionEditSeparator3 = mEditMenu->addSeparator();
@@ -4446,6 +4463,11 @@ void QgisApp::rotatePointSymbols()
44464463
mMapCanvas->setMapTool( mMapTools.mRotatePointSymbolsTool );
44474464
}
44484465

4466+
void QgisApp::snappingOptions()
4467+
{
4468+
mSnappingDialog->show();
4469+
}
4470+
44494471
void QgisApp::splitFeatures()
44504472
{
44514473
mMapCanvas->setMapTool( mMapTools.mSplitFeatures );

src/app/qgisapp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class QNetworkReply;
6767
class QNetworkProxy;
6868
class QAuthenticator;
6969

70+
class QgsSnappingDialog;
7071
class QgsGPSInformationWidget;
7172

7273
#include <QMainWindow>
@@ -78,6 +79,7 @@ class QgsGPSInformationWidget;
7879
#include "qgsconfig.h"
7980
#include "qgsfeature.h"
8081
#include "qgspoint.h"
82+
#include "qgssnappingdialog.h"
8183

8284
/*! \class QgisApp
8385
* \brief Main window for the Qgis application
@@ -242,6 +244,8 @@ class QgisApp : public QMainWindow
242244
QAction *actionDeletePart() { return mActionDeletePart; }
243245
QAction *actionNodeTool() { return mActionNodeTool; }
244246
QAction *actionEditSeparator2() { return mActionEditSeparator2; }
247+
QAction *actionSnappingOptions() { return mActionSnappingOptions; }
248+
QAction *actionEditSeparator4() { return mActionEditSeparator4; }
245249

246250
QAction *actionPan() { return mActionPan; }
247251
QAction *actionZoomIn() { return mActionZoomIn; }
@@ -618,6 +622,8 @@ class QgisApp : public QMainWindow
618622
void nodeTool();
619623
//! activates the rotate points tool
620624
void rotatePointSymbols();
625+
//! shows the snapping Options
626+
void snappingOptions();
621627

622628
//! activates the selection tool
623629
void select();
@@ -900,6 +906,8 @@ class QgisApp : public QMainWindow
900906
QAction *mActionNodeTool;
901907
QAction *mActionRotatePointSymbols;
902908
QAction *mActionEditSeparator3;
909+
QAction *mActionSnappingOptions;
910+
QAction *mActionEditSeparator4;
903911

904912
QAction *mActionPan;
905913
QAction *mActionZoomIn;
@@ -1015,6 +1023,7 @@ class QgisApp : public QMainWindow
10151023
QDockWidget *mpTileScaleDock;
10161024
QDockWidget *mpGpsDock;
10171025

1026+
10181027
#ifdef Q_WS_MAC
10191028
//! Window menu action to select this window
10201029
QAction *mWindowAction;
@@ -1165,6 +1174,8 @@ class QgisApp : public QMainWindow
11651174

11661175
QgsUndoWidget* mUndoWidget;
11671176

1177+
QgsSnappingDialog* mSnappingDialog;
1178+
11681179
//! Persistent tile scale slider
11691180
QgsTileScaleWidget * mpTileScaleWidget;
11701181

src/app/qgsoptions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
249249
cbxHideSplash->setChecked( settings.value( "/qgis/hideSplash", false ).toBool() );
250250
cbxAttributeTableDocked->setChecked( settings.value( "/qgis/dockAttributeTable", false ).toBool() );
251251
cbxIdentifyResultsDocked->setChecked( settings.value( "/qgis/dockIdentifyResults", false ).toBool() );
252+
cbxSnappingOptionsDocked->setChecked( settings.value( "/qgis/dockSnapping", false ).toBool() );
252253
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
253254
cbxAddNewLayersToCurrentGroup->setChecked( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() );
254255
cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", true ).toBool() );
@@ -505,6 +506,7 @@ void QgsOptions::saveOptions()
505506
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
506507
settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() );
507508
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
509+
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
508510
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
509511
settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() );
510512
settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() );

src/app/qgsprojectproperties.cpp

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -127,91 +127,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
127127
}
128128
}
129129

130-
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk;
131-
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk );
132-
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk );
133-
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk );
134-
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk );
135-
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk );
136-
137-
QStringList::const_iterator idIter = layerIdList.constBegin();
138-
QStringList::const_iterator enabledIter = enabledList.constBegin();
139-
QStringList::const_iterator tolIter = toleranceList.constBegin();
140-
QStringList::const_iterator tolUnitIter = toleranceUnitList.constBegin();
141-
QStringList::const_iterator snapToIter = snapToList.constBegin();
142-
143130
QgsMapLayer* currentLayer = 0;
144131

145-
//create the new layer entries
146-
for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++tolUnitIter, ++snapToIter )
147-
{
148-
if ( layerIdListOk )
149-
{
150-
currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter );
151-
}
152-
else
153-
{
154-
break;
155-
}
156-
157-
if ( currentLayer )
158-
{
159-
LayerEntry newEntry;
160-
newEntry.layerName = currentLayer->name();
161-
162-
newEntry.checked = false;
163-
if ( enabledListOk && enabledIter != enabledList.constEnd() )
164-
{
165-
if (( *enabledIter ) == "enabled" )
166-
{
167-
newEntry.checked = true;
168-
}
169-
}
170-
171-
//snap to vertex / segment / vertex and segment
172-
if ( snapToListOk && snapToIter != snapToList.constEnd() )
173-
{
174-
if (( *snapToIter ) == "to_vertex" )
175-
{
176-
newEntry.snapTo = 0;
177-
}
178-
else if (( *snapToIter ) == "to_segment" )
179-
{
180-
newEntry.snapTo = 1;
181-
}
182-
else //to vertex and segment
183-
{
184-
newEntry.snapTo = 2;
185-
}
186-
}
187-
else
188-
{
189-
newEntry.snapTo = 0;
190-
}
191-
192-
//snap tolerance
193-
if ( toleranceListOk && tolIter != toleranceList.constEnd() )
194-
{
195-
newEntry.tolerance = tolIter->toDouble();
196-
}
197-
else
198-
{
199-
newEntry.tolerance = 0;
200-
}
201-
202-
//snap tolerance unit
203-
if ( toleranceUnitListOk && tolUnitIter != toleranceUnitList.constEnd() )
204-
{
205-
newEntry.toleranceUnit = tolUnitIter->toInt();
206-
}
207-
else
208-
{
209-
newEntry.toleranceUnit = 0;
210-
}
211-
mSnappingLayerSettings.insert( *idIter, newEntry );
212-
}
213-
}
214-
215132
QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" );
216133

217134
const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
@@ -418,51 +335,6 @@ void QgsProjectProperties::apply()
418335
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );
419336

420337

421-
QMap<QString, LayerEntry>::const_iterator layerEntryIt;
422-
423-
//store the layer snapping settings as string lists
424-
QStringList layerIdList;
425-
QStringList snapToList;
426-
QStringList toleranceList;
427-
QStringList enabledList;
428-
QStringList toleranceUnitList;
429-
430-
for ( layerEntryIt = mSnappingLayerSettings.constBegin(); layerEntryIt != mSnappingLayerSettings.constEnd(); ++layerEntryIt )
431-
{
432-
layerIdList << layerEntryIt.key();
433-
toleranceList << QString::number( layerEntryIt->tolerance, 'f' );
434-
toleranceUnitList << QString::number(( int )layerEntryIt->toleranceUnit );
435-
if ( layerEntryIt->checked )
436-
{
437-
enabledList << "enabled";
438-
}
439-
else
440-
{
441-
enabledList << "disabled";
442-
}
443-
if ( layerEntryIt->snapTo == 0 )
444-
{
445-
snapToList << "to_vertex";
446-
}
447-
else if ( layerEntryIt->snapTo == 1 )
448-
{
449-
snapToList << "to_segment";
450-
}
451-
else //to vertex and segment
452-
{
453-
snapToList << "to_vertex_and_segment";
454-
}
455-
}
456-
457-
if ( mSnappingLayerSettings.size() > 0 )
458-
{
459-
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList );
460-
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnapToList", snapToList );
461-
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList );
462-
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList );
463-
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList );
464-
}
465-
466338
QStringList noIdentifyLayerList;
467339
for ( int i = 0; i < twIdentifyLayers->rowCount(); i++ )
468340
{
@@ -517,15 +389,6 @@ void QgsProjectProperties::on_mAvoidIntersectionsPushButton_clicked()
517389
}
518390
}
519391

520-
void QgsProjectProperties::on_mSnappingOptionsPushButton_clicked()
521-
{
522-
QgsSnappingDialog d( mMapCanvas, mSnappingLayerSettings );
523-
if ( d.exec() == QDialog::Accepted )
524-
{
525-
//retrieve the new layer snapping settings from the dialog
526-
d.layerSettings( mSnappingLayerSettings );
527-
}
528-
}
529392

530393
void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
531394
{

src/app/qgsprojectproperties.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
9595
*/
9696
void on_mAvoidIntersectionsPushButton_clicked();
9797

98-
/*!
99-
* Slot to show dialog for the layer snapping options
100-
*/
101-
void on_mSnappingOptionsPushButton_clicked();
102-
10398
void on_cbxProjectionEnabled_stateChanged( int state );
10499

105100
/*!
@@ -118,15 +113,9 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
118113
private:
119114
QgsMapCanvas* mMapCanvas;
120115

121-
/**Snapping settings to pass/read from QgsSnappingDialog.
122-
Key is the layer id, the pair consists of snap to vertex = 0/snap to segment = 1,
123-
snapping tolerance*/
124-
QMap<QString, LayerEntry> mSnappingLayerSettings;
125-
126116
/**Stores ids of layers where intersections of new polygons is considered. Is passed to / read from QgsAvoidIntersectionsDialog*/
127117
QSet<QString> mAvoidIntersectionsSettings;
128118

129-
130119
/*!
131120
* Function to save dialog window state
132121
*/

0 commit comments

Comments
 (0)