Skip to content

Commit

Permalink
Fix snapping model
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 9, 2020
1 parent bc18ec9 commit f48cd39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/qgssnappinglayertreemodel.cpp
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgssnappingwidget.cpp
Expand Up @@ -43,6 +43,9 @@
#include "qgssettings.h"
#include "qgsscalewidget.h"

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

class SnapTypeMenu: public QMenu
{
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit f48cd39

Please sign in to comment.