Skip to content
Permalink
Browse files

Fixes #39031 : commitData on scale changed for advanced snap

configuration min/max scale
  • Loading branch information
troopa81 authored and nyalldawson committed Oct 5, 2020
1 parent 163941c commit 55c0f93c5dded8b93b81d269f16fc6f7a848d34a
Showing with 10 additions and 0 deletions.
  1. +7 −0 src/app/qgssnappinglayertreemodel.cpp
  2. +3 −0 src/app/qgssnappinglayertreemodel.h
@@ -129,19 +129,26 @@ QWidget *QgsSnappingLayerDelegate::createEditor( QWidget *parent, const QStyleOp
{
QgsScaleWidget *minLimitSp = new QgsScaleWidget( parent );
minLimitSp->setToolTip( tr( "Minimum scale from which snapping is enabled (i.e. most \"zoomed out\" scale)" ) );
connect( minLimitSp, &QgsScaleWidget::scaleChanged, this, &QgsSnappingLayerDelegate::onScaleChanged );
return minLimitSp;
}

if ( index.column() == QgsSnappingLayerTreeModel::MaxScaleColumn )
{
QgsScaleWidget *maxLimitSp = new QgsScaleWidget( parent );
maxLimitSp->setToolTip( tr( "Maximum scale up to which snapping is enabled (i.e. most \"zoomed in\" scale)" ) );
connect( maxLimitSp, &QgsScaleWidget::scaleChanged, this, &QgsSnappingLayerDelegate::onScaleChanged );
return maxLimitSp;
}

return nullptr;
}

void QgsSnappingLayerDelegate::onScaleChanged()
{
emit commitData( qobject_cast<QgsScaleWidget *>( sender() ) );
}

void QgsSnappingLayerDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const
{
QVariant val = index.model()->data( index, Qt::UserRole );
@@ -40,6 +40,9 @@ class APP_EXPORT QgsSnappingLayerDelegate : public QItemDelegate
void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;

private slots:
void onScaleChanged();

private:
QgsMapCanvas *mCanvas = nullptr;
};

0 comments on commit 55c0f93

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