Skip to content
Permalink
Browse files

Fix snapping model

  • Loading branch information
elpaso committed Nov 9, 2020
1 parent bc18ec9 commit f48cd393290b3f00ed6624b81d4fb48234fdb4d4
Showing with 14 additions and 0 deletions.
  1. +5 −0 src/app/qgssnappinglayertreemodel.cpp
  2. +9 −0 src/app/qgssnappingwidget.cpp
@@ -328,6 +328,11 @@ Qt::ItemFlags QgsSnappingLayerTreeModel::flags( const QModelIndex &idx ) const

QModelIndex QgsSnappingLayerTreeModel::index( int row, int column, const QModelIndex &parent ) const
{
if ( row < 0 || column < 0 || row >= rowCount( parent ) || column >= columnCount( parent ) )
{
return QModelIndex();
}

QModelIndex newIndex = QSortFilterProxyModel::index( row, LayerColumn, parent );
if ( column == LayerColumn )
return newIndex;
@@ -43,6 +43,9 @@
#include "qgssettings.h"
#include "qgsscalewidget.h"

#ifdef ENABLE_MODELTEST
#include "modeltest.h"
#endif

class SnapTypeMenu: public QMenu
{
@@ -88,6 +91,12 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
mLayerTreeView = new QTreeView();
QgsSnappingLayerTreeModel *model = new QgsSnappingLayerTreeModel( mProject, mCanvas, this );
model->setLayerTreeModel( new QgsLayerTreeModel( mProject->layerTreeRoot(), model ) );

#ifdef ENABLE_MODELTEST
new ModelTest( model, this );
new ModelTest( model->layerTreeModel(), this );
#endif

// connections
connect( model, &QgsSnappingLayerTreeModel::rowsInserted, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );
connect( model, &QgsSnappingLayerTreeModel::modelReset, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );

0 comments on commit f48cd39

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