30
30
#include < QLineEdit>
31
31
#include < QDockWidget>
32
32
#include < QPushButton>
33
+ #include < QDoubleSpinBox>
33
34
34
35
35
36
class QgsSnappingDock : public QDockWidget
@@ -172,7 +173,7 @@ void QgsSnappingDialog::apply()
172
173
snapToList << " to_vertex_and_segment" ;
173
174
}
174
175
175
- toleranceList << QString::number ( qobject_cast<QLineEdit *>( mLayerTreeWidget ->itemWidget ( currentItem, 3 ) )->text (). toDouble (), ' f' );
176
+ toleranceList << QString::number ( qobject_cast<QDoubleSpinBox *>( mLayerTreeWidget ->itemWidget ( currentItem, 3 ) )->value (), ' f' );
176
177
toleranceUnitList << QString::number ( qobject_cast<QComboBox*>( mLayerTreeWidget ->itemWidget ( currentItem, 4 ) )->currentIndex () );
177
178
178
179
QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget ->itemWidget ( currentItem, 5 ) );
@@ -274,12 +275,12 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
274
275
mLayerTreeWidget ->setItemWidget ( item, 2 , cbxSnapTo );
275
276
276
277
// snapping tolerance
277
- QLineEdit *leTolerance = new QLineEdit ( mLayerTreeWidget );
278
- QDoubleValidator *validator = new QDoubleValidator ( leTolerance );
279
- leTolerance-> setValidator ( validator );
280
- leTolerance-> setText ( QString::number ( defaultSnappingTolerance, ' f ' ) );
278
+ QDoubleSpinBox* sbTolerance = new QDoubleSpinBox ( mLayerTreeWidget );
279
+ sbTolerance-> setRange ( 0 ., 100000000 . );
280
+ sbTolerance-> setDecimals ( 5 );
281
+ sbTolerance-> setValue ( defaultSnappingTolerance );
281
282
282
- mLayerTreeWidget ->setItemWidget ( item, 3 , leTolerance );
283
+ mLayerTreeWidget ->setItemWidget ( item, 3 , sbTolerance );
283
284
284
285
// snap to vertex/ snap to segment
285
286
QComboBox *cbxUnits = new QComboBox ( mLayerTreeWidget );
@@ -295,14 +296,20 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
295
296
mLayerTreeWidget ->setItemWidget ( item, 5 , cbxAvoidIntersection );
296
297
}
297
298
299
+ // resize treewidget columns
300
+ for ( int i = 0 ; i < 4 ; ++i )
301
+ {
302
+ mLayerTreeWidget ->resizeColumnToContents ( i );
303
+ }
304
+
298
305
int idx = layerIdList.indexOf ( currentVectorLayer->id () );
299
306
if ( idx < 0 )
300
307
{
301
308
if ( myDockFlag )
302
309
{
303
310
connect ( cbxEnable, SIGNAL ( stateChanged ( int ) ), this , SLOT ( apply () ) );
304
311
connect ( cbxSnapTo, SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( apply () ) );
305
- connect ( leTolerance , SIGNAL ( textEdited ( const QString ) ), this , SLOT ( apply () ) );
312
+ connect ( sbTolerance , SIGNAL ( valueChanged ( double ) ), this , SLOT ( apply () ) );
306
313
connect ( cbxUnits, SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( apply () ) );
307
314
308
315
if ( cbxAvoidIntersection )
@@ -336,7 +343,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
336
343
}
337
344
338
345
cbxSnapTo->setCurrentIndex ( snappingStringIdx );
339
- leTolerance-> setText ( QString::number ( toleranceList[idx].toDouble (), ' f ' ) );
346
+ sbTolerance-> setValue ( toleranceList[idx].toDouble () );
340
347
cbxUnits->setCurrentIndex ( toleranceUnitList[idx].toInt () );
341
348
if ( cbxAvoidIntersection )
342
349
{
@@ -347,7 +354,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
347
354
{
348
355
connect ( cbxEnable, SIGNAL ( stateChanged ( int ) ), this , SLOT ( apply () ) );
349
356
connect ( cbxSnapTo, SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( apply () ) );
350
- connect ( leTolerance , SIGNAL ( textEdited ( const QString ) ), this , SLOT ( apply () ) );
357
+ connect ( sbTolerance , SIGNAL ( valueChanged ( double ) ), this , SLOT ( apply () ) );
351
358
connect ( cbxUnits, SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( apply () ) );
352
359
353
360
if ( cbxAvoidIntersection )
0 commit comments