Skip to content
Permalink
Browse files

Remove unused magnet control

  • Loading branch information
nyalldawson committed Jan 12, 2021
1 parent 3e9e689 commit b64283ae48f253b17c6e617c0022f3b5b3040907
Showing with 1 addition and 40 deletions.
  1. +1 −37 src/app/qgsmaptoolscalefeature.cpp
  2. +0 −3 src/app/qgsmaptoolscalefeature.h
@@ -59,18 +59,6 @@ QgsScaleMagnetWidget::QgsScaleMagnetWidget( const QString &label, QWidget *paren
mScaleSpinBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
mLayout->addWidget( mScaleSpinBox );

mMagnetSpinBox = new QgsSpinBox( this );
mMagnetSpinBox->setMinimum( 0 );
mMagnetSpinBox->setMaximum( 180 );
mMagnetSpinBox->setPrefix( tr( "Snap to " ) );
mMagnetSpinBox->setSuffix( tr( "x" ) );
mMagnetSpinBox->setSingleStep( 5 );
mMagnetSpinBox->setValue( 0 );
mMagnetSpinBox->setClearValue( 0, tr( "No snapping" ) );
//mMagnetSpinBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
mMagnetSpinBox->setMinimumWidth( 120 );
mLayout->addWidget( mMagnetSpinBox );

// connect signals
mScaleSpinBox->installEventFilter( this );
connect( mScaleSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsScaleMagnetWidget::scaleSpinBoxValueChanged );
@@ -81,33 +69,14 @@ QgsScaleMagnetWidget::QgsScaleMagnetWidget( const QString &label, QWidget *paren

void QgsScaleMagnetWidget::setScale( double scale )
{
const int m = magnet();
if ( m )
{
mScaleSpinBox->setValue( std::round( scale / m ) * m );
}
else
{
mScaleSpinBox->setValue( scale );
}
mScaleSpinBox->setValue( scale );
}

double QgsScaleMagnetWidget::scale() const
{
return mScaleSpinBox->value();
}

void QgsScaleMagnetWidget::setMagnet( int magnet )
{
mMagnetSpinBox->setValue( magnet );
}

int QgsScaleMagnetWidget::magnet() const
{
return mMagnetSpinBox->value();
}


bool QgsScaleMagnetWidget::eventFilter( QObject *obj, QEvent *ev )
{
if ( obj == mScaleSpinBox && ev->type() == QEvent::KeyPress )
@@ -165,16 +134,11 @@ void QgsMapToolScaleFeature::canvasMoveEvent( QgsMapMouseEvent *e )
mScalingWidget->setFocus( Qt::TabFocusReason );
mScalingWidget->editor()->selectAll();
connect( mScalingWidget, &QgsScaleMagnetWidget::scaleChanged, this, &QgsMapToolScaleFeature::updateRubberband );
if ( mScalingWidget->magnet() )
{
scale = mScalingWidget->scale();
}
}
updateRubberband( scale );
}
}


void QgsMapToolScaleFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
{
if ( !mCanvas )
@@ -38,8 +38,6 @@ class APP_EXPORT QgsScaleMagnetWidget : public QWidget

void setScale( double scale );
double scale() const;
void setMagnet( int magnet );
int magnet() const;

QgsDoubleSpinBox *editor() const {return mScaleSpinBox;}

@@ -60,7 +58,6 @@ class APP_EXPORT QgsScaleMagnetWidget : public QWidget
private:
QHBoxLayout *mLayout = nullptr;
QgsDoubleSpinBox *mScaleSpinBox = nullptr;
QgsSpinBox *mMagnetSpinBox = nullptr;
};


0 comments on commit b64283a

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