Skip to content

Commit

Permalink
apply #3206
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14623 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 13, 2010
1 parent 72a5bfc commit 8c2a02f
Show file tree
Hide file tree
Showing 10 changed files with 270 additions and 341 deletions.
22 changes: 22 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
#include "qgsquerybuilder.h"
#include "qgsattributeaction.h"
#include "qgsgpsinformationwidget.h"
#include "qgssnappingdialog.h"

//
// Gdal/Ogr includes
Expand Down Expand Up @@ -430,6 +431,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
mUndoWidget->hide();

mSnappingDialog = new QgsSnappingDialog( this, mMapCanvas );
mSnappingDialog->setObjectName( "SnappingOption" );

mInternalClipboard = new QgsClipboard; // create clipboard
mQgisInterface = new QgisAppInterface( this ); // create the interfce

Expand Down Expand Up @@ -862,6 +866,11 @@ void QgisApp::createActions()
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

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

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();
Expand Down Expand Up @@ -4446,6 +4463,11 @@ void QgisApp::rotatePointSymbols()
mMapCanvas->setMapTool( mMapTools.mRotatePointSymbolsTool );
}

void QgisApp::snappingOptions()
{
mSnappingDialog->show();
}

void QgisApp::splitFeatures()
{
mMapCanvas->setMapTool( mMapTools.mSplitFeatures );
Expand Down
11 changes: 11 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class QNetworkReply;
class QNetworkProxy;
class QAuthenticator;

class QgsSnappingDialog;
class QgsGPSInformationWidget;

#include <QMainWindow>
Expand All @@ -78,6 +79,7 @@ class QgsGPSInformationWidget;
#include "qgsconfig.h"
#include "qgsfeature.h"
#include "qgspoint.h"
#include "qgssnappingdialog.h"

/*! \class QgisApp
* \brief Main window for the Qgis application
Expand Down Expand Up @@ -242,6 +244,8 @@ class QgisApp : public QMainWindow
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; }
Expand Down Expand Up @@ -618,6 +622,8 @@ class QgisApp : public QMainWindow
void nodeTool();
//! activates the rotate points tool
void rotatePointSymbols();
//! shows the snapping Options
void snappingOptions();

//! activates the selection tool
void select();
Expand Down Expand Up @@ -900,6 +906,8 @@ class QgisApp : public QMainWindow
QAction *mActionNodeTool;
QAction *mActionRotatePointSymbols;
QAction *mActionEditSeparator3;
QAction *mActionSnappingOptions;
QAction *mActionEditSeparator4;

QAction *mActionPan;
QAction *mActionZoomIn;
Expand Down Expand Up @@ -1015,6 +1023,7 @@ class QgisApp : public QMainWindow
QDockWidget *mpTileScaleDock;
QDockWidget *mpGpsDock;


#ifdef Q_WS_MAC
//! Window menu action to select this window
QAction *mWindowAction;
Expand Down Expand Up @@ -1165,6 +1174,8 @@ class QgisApp : public QMainWindow

QgsUndoWidget* mUndoWidget;

QgsSnappingDialog* mSnappingDialog;

//! Persistent tile scale slider
QgsTileScaleWidget * mpTileScaleWidget;

Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
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() );
Expand Down Expand Up @@ -505,6 +506,7 @@ void QgsOptions::saveOptions()
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() );
Expand Down
137 changes: 0 additions & 137 deletions src/app/qgsprojectproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,91 +127,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
}
}

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<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
Expand Down Expand Up @@ -418,51 +335,6 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );


QMap<QString, LayerEntry>::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++ )
{
Expand Down Expand Up @@ -517,15 +389,6 @@ void QgsProjectProperties::on_mAvoidIntersectionsPushButton_clicked()
}
}

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 )
{
Expand Down
11 changes: 0 additions & 11 deletions src/app/qgsprojectproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
*/
void on_mAvoidIntersectionsPushButton_clicked();

/*!
* Slot to show dialog for the layer snapping options
*/
void on_mSnappingOptionsPushButton_clicked();

void on_cbxProjectionEnabled_stateChanged( int state );

/*!
Expand All @@ -118,15 +113,9 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
private:
QgsMapCanvas* mMapCanvas;

/**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<QString, LayerEntry> mSnappingLayerSettings;

/**Stores ids of layers where intersections of new polygons is considered. Is passed to / read from QgsAvoidIntersectionsDialog*/
QSet<QString> mAvoidIntersectionsSettings;


/*!
* Function to save dialog window state
*/
Expand Down
Loading

0 comments on commit 8c2a02f

Please sign in to comment.