Skip to content
Permalink
Browse files

partial fix of snapping config issues

  • Loading branch information
3nids committed May 30, 2017
1 parent accf3f1 commit 8d073ce53e9c869404460ce858df85189c79443e
@@ -856,13 +856,14 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
endProfile();

startProfile( QStringLiteral( "Snapping dialog" ) );
mSnappingDialogWidget = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, this );
mSnappingDialog = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, this );
connect( mSnappingDialog, &QgsSnappingWidget::snappingConfigChanged, QgsProject::instance(), [ = ] { QgsProject::instance()->setSnappingConfig( mSnappingDialog->config() ); } );
QString mainSnappingWidgetMode = QgsSettings().value( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), "dialog" ).toString();
if ( mainSnappingWidgetMode == QLatin1String( "dock" ) )
{
QgsDockWidget *dock = new QgsDockWidget( tr( "Snapping and Digitizing Options" ), QgisApp::instance() );
dock->setAllowedAreas( Qt::AllDockWidgetAreas );
dock->setWidget( mSnappingDialogWidget );
dock->setWidget( mSnappingDialog );
dock->setObjectName( QStringLiteral( "Snapping and Digitizing Options" ) );
addDockWidget( Qt::LeftDockWidgetArea, dock );
mSnappingDialogContainer = dock;
@@ -873,7 +874,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
QDialog *dialog = new QDialog( this );
dialog->setWindowTitle( tr( "Project snapping settings" ) );
QVBoxLayout *layout = new QVBoxLayout( dialog );
layout->addWidget( mSnappingDialogWidget );
layout->addWidget( mSnappingDialog );
layout->setMargin( 0 );
mSnappingDialogContainer = dialog;
}
@@ -1273,7 +1274,7 @@ QgisApp::QgisApp()
, mBookMarksDockWidget( nullptr )
, mSnappingWidget( nullptr )
, mSnappingDialogContainer( nullptr )
, mSnappingDialogWidget( nullptr )
, mSnappingDialog( nullptr )
, mPluginManager( nullptr )
, mMapStylingDock( nullptr )
, mMapStyleWidget( nullptr )
@@ -1913,7 +1913,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! snapping widget
QgsSnappingWidget *mSnappingWidget = nullptr;
QWidget *mSnappingDialogContainer = nullptr;
QgsSnappingWidget *mSnappingDialogWidget = nullptr;
QgsSnappingWidget *mSnappingDialog = nullptr;

QgsPluginManager *mPluginManager = nullptr;
QgsDockWidget *mMapStylingDock = nullptr;
@@ -196,7 +196,7 @@ Qt::ItemFlags QgsSnappingLayerTreeModel::flags( const QModelIndex &idx ) const

QModelIndex QgsSnappingLayerTreeModel::index( int row, int column, const QModelIndex &parent ) const
{
QModelIndex newIndex = QSortFilterProxyModel::index( row, 0, parent );
QModelIndex newIndex = QSortFilterProxyModel::index( row, LayerColumn, parent );
if ( column == LayerColumn )
return newIndex;

@@ -205,7 +205,7 @@ QModelIndex QgsSnappingLayerTreeModel::index( int row, int column, const QModelI

QModelIndex QgsSnappingLayerTreeModel::parent( const QModelIndex &child ) const
{
return QSortFilterProxyModel::parent( createIndex( child.row(), 0, child.internalId() ) );
return QSortFilterProxyModel::parent( createIndex( child.row(), LayerColumn, child.internalId() ) );
}

QModelIndex QgsSnappingLayerTreeModel::sibling( int row, int column, const QModelIndex &idx ) const
@@ -223,7 +223,7 @@ QgsVectorLayer *QgsSnappingLayerTreeModel::vectorLayer( const QModelIndex &idx )
}
else
{
node = mLayerTreeModel->index2node( mapToSource( index( idx.row(), 0, idx.parent() ) ) );
node = mLayerTreeModel->index2node( mapToSource( index( idx.row(), LayerColumn, idx.parent() ) ) );
}

if ( !node || !QgsLayerTree::isLayer( node ) )
@@ -298,7 +298,7 @@ void QgsSnappingLayerTreeModel::setLayerTreeModel( QgsLayerTreeModel *layerTreeM

bool QgsSnappingLayerTreeModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const
{
QgsLayerTreeNode *node = mLayerTreeModel->index2node( mLayerTreeModel->index( sourceRow, 0, sourceParent ) );
QgsLayerTreeNode *node = mLayerTreeModel->index2node( mLayerTreeModel->index( sourceRow, LayerColumn, sourceParent ) );
return nodeShown( node );
}

@@ -380,7 +380,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
int n;
for ( n = 0; !hasChecked || !hasUnchecked; n++ )
{
QVariant v = data( idx.child( n, 0 ), role );
QVariant v = data( idx.child( n, LayerColumn ), role );
if ( !v.isValid() )
break;

@@ -518,7 +518,7 @@ bool QgsSnappingLayerTreeModel::setData( const QModelIndex &index, const QVarian
int i = 0;
for ( i = 0; ; i++ )
{
QModelIndex child = index.child( i, 0 );
QModelIndex child = index.child( i, LayerColumn );
if ( !child.isValid() )
break;

@@ -119,7 +119,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
// units
mUnitsComboBox = new QComboBox();
mUnitsComboBox->addItem( tr( "px" ), QgsTolerance::Pixels );
mUnitsComboBox->addItem( QgsUnitTypes::toString( QgsProject::instance()->distanceUnits() ), QgsTolerance::ProjectUnits );
mUnitsComboBox->addItem( QgsUnitTypes::toString( mProject->distanceUnits() ), QgsTolerance::ProjectUnits );
mUnitsComboBox->setToolTip( tr( "Snapping Unit Type: Pixels (px) or Map Units (mu)" ) );
mUnitsComboBox->setObjectName( QStringLiteral( "SnappingUnitComboBox" ) );
connect( mUnitsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSnappingWidget::changeUnit );
@@ -199,7 +199,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,

mLayerTreeView = new QTreeView();
QgsSnappingLayerTreeModel *model = new QgsSnappingLayerTreeModel( mProject, this );
model->setLayerTreeModel( new QgsLayerTreeModel( QgsProject::instance()->layerTreeRoot(), model ) );
model->setLayerTreeModel( new QgsLayerTreeModel( mProject->layerTreeRoot(), model ) );

connect( model, &QgsSnappingLayerTreeModel::rowsInserted, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );
connect( model, &QgsSnappingLayerTreeModel::modelReset, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );
@@ -310,9 +310,9 @@ void QgsSnappingWidget::projectSnapSettingsChanged()

void QgsSnappingWidget::projectTopologicalEditingChanged()
{
if ( QgsProject::instance()->topologicalEditing() != mTopologicalEditingAction->isChecked() )
if ( mProject->topologicalEditing() != mTopologicalEditingAction->isChecked() )
{
mTopologicalEditingAction->setChecked( QgsProject::instance()->topologicalEditing() );
mTopologicalEditingAction->setChecked( mProject->topologicalEditing() );
}
}

@@ -355,7 +355,7 @@ void QgsSnappingWidget::changeUnit( int idx )

void QgsSnappingWidget::enableTopologicalEditing( bool enabled )
{
QgsProject::instance()->setTopologicalEditing( enabled );
mProject->setTopologicalEditing( enabled );
}

void QgsSnappingWidget::enableIntersectionSnapping( bool enabled )
@@ -265,7 +265,7 @@ QgsSnappingConfig::IndividualLayerSettings QgsSnappingConfig::individualLayerSet

void QgsSnappingConfig::setIndividualLayerSettings( QgsVectorLayer *vl, const IndividualLayerSettings &individualLayerSettings )
{
if ( !vl || mIndividualLayerSettings.value( vl ) == individualLayerSettings )
if ( !vl || !vl->hasGeometryType() || mIndividualLayerSettings.value( vl ) == individualLayerSettings )
{
return;
}
@@ -382,7 +382,7 @@ bool QgsSnappingConfig::addLayers( const QList<QgsMapLayer *> &layers )
Q_FOREACH ( QgsMapLayer *ml, layers )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
if ( vl )
if ( vl && vl->hasGeometryType() )
{
mIndividualLayerSettings.insert( vl, IndividualLayerSettings( enabled, type, tolerance, units ) );
changed = true;
@@ -408,8 +408,8 @@ bool QgsSnappingConfig::removeLayers( const QList<QgsMapLayer *> &layers )

void QgsSnappingConfig::readLegacySettings()
{
//
mMode = ActiveLayer;
mIndividualLayerSettings.clear();

QString snapMode = mProject->readEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/SnappingMode" ) );

0 comments on commit 8d073ce

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