@@ -126,11 +126,6 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem*
126126 buttonGroup->addButton ( mLowerRightCheckBox );
127127 buttonGroup->setExclusive ( true );
128128
129- mXLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
130- mYLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
131- mWidthLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
132- mHeightLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
133-
134129 setValuesForGuiElements ();
135130 connect ( mItem ->composition (), SIGNAL ( paperSizeChanged () ), this , SLOT ( setValuesForGuiPositionElements () ) );
136131 connect ( mItem , SIGNAL ( sizeChanged () ), this , SLOT ( setValuesForGuiPositionElements () ) );
@@ -251,18 +246,10 @@ void QgsComposerItemWidget::changeItemPosition()
251246{
252247 mItem ->beginCommand ( tr ( " Item position changed" ) );
253248
254- bool convXSuccess, convYSuccess;
255- double x = mXLineEdit ->text ().toDouble ( &convXSuccess );
256- double y = mYLineEdit ->text ().toDouble ( &convYSuccess );
257-
258- bool convSuccessWidth, convSuccessHeight;
259- double width = mWidthLineEdit ->text ().toDouble ( &convSuccessWidth );
260- double height = mHeightLineEdit ->text ().toDouble ( &convSuccessHeight );
261-
262- if ( !convXSuccess || !convYSuccess || !convSuccessWidth || !convSuccessHeight )
263- {
264- return ;
265- }
249+ double x = mXPosSpin ->value ();
250+ double y = mYPosSpin ->value ();
251+ double width = mWidthSpin ->value ();
252+ double height = mHeightSpin ->value ();
266253
267254 mItem ->setItemPosition ( x, y, width, height, positionMode (), false , mPageSpinBox ->value () );
268255
@@ -379,10 +366,10 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
379366 return ;
380367 }
381368
382- mXLineEdit ->blockSignals ( true );
383- mYLineEdit ->blockSignals ( true );
384- mWidthLineEdit ->blockSignals ( true );
385- mHeightLineEdit ->blockSignals ( true );
369+ mXPosSpin ->blockSignals ( true );
370+ mYPosSpin ->blockSignals ( true );
371+ mWidthSpin ->blockSignals ( true );
372+ mHeightSpin ->blockSignals ( true );
386373 mUpperLeftCheckBox ->blockSignals ( true );
387374 mUpperMiddleCheckBox ->blockSignals ( true );
388375 mUpperRightCheckBox ->blockSignals ( true );
@@ -399,75 +386,74 @@ void QgsComposerItemWidget::setValuesForGuiPositionElements()
399386 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::UpperLeft )
400387 {
401388 mUpperLeftCheckBox ->setChecked ( true );
402- mXLineEdit -> setText ( QString::number ( pos.x () ) );
403- mYLineEdit -> setText ( QString::number ( pos.y () ) );
389+ mXPosSpin -> setValue ( pos.x () );
390+ mYPosSpin -> setValue ( pos.y () );
404391 }
405392
406393 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::UpperMiddle )
407394 {
408395 mUpperMiddleCheckBox ->setChecked ( true );
409- mXLineEdit -> setText ( QString::number ( pos.x () + mItem ->rect ().width () / 2.0 ) );
410- mYLineEdit -> setText ( QString::number ( pos.y () ) );
396+ mXPosSpin -> setValue ( pos.x () + mItem ->rect ().width () / 2.0 );
397+ mYPosSpin -> setValue ( pos.y () );
411398 }
412399
413400 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::UpperRight )
414401 {
415402 mUpperRightCheckBox ->setChecked ( true );
416- mXLineEdit -> setText ( QString::number ( pos.x () + mItem ->rect ().width () ) );
417- mYLineEdit -> setText ( QString::number ( pos.y () ) );
403+ mXPosSpin -> setValue ( pos.x () + mItem ->rect ().width () );
404+ mYPosSpin -> setValue ( pos.y () );
418405 }
419406
420407 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::MiddleLeft )
421408 {
422409 mMiddleLeftCheckBox ->setChecked ( true );
423- mXLineEdit -> setText ( QString::number ( pos.x () ) );
424- mYLineEdit -> setText ( QString::number ( pos.y () + mItem ->rect ().height () / 2.0 ) );
410+ mXPosSpin -> setValue ( pos.x () );
411+ mYPosSpin -> setValue ( pos.y () + mItem ->rect ().height () / 2.0 );
425412 }
426413
427414 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::Middle )
428415 {
429416 mMiddleCheckBox ->setChecked ( true );
430- mXLineEdit -> setText ( QString::number ( pos.x () + mItem ->rect ().width () / 2.0 ) );
431- mYLineEdit -> setText ( QString::number ( pos.y () + mItem ->rect ().height () / 2.0 ) );
417+ mXPosSpin -> setValue ( pos.x () + mItem ->rect ().width () / 2.0 );
418+ mYPosSpin -> setValue ( pos.y () + mItem ->rect ().height () / 2.0 );
432419 }
433420
434421 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::MiddleRight )
435422 {
436423 mMiddleRightCheckBox ->setChecked ( true );
437- mXLineEdit -> setText ( QString::number ( pos.x () + mItem ->rect ().width () ) );
438- mYLineEdit -> setText ( QString::number ( pos.y () + mItem ->rect ().height () / 2.0 ) );
424+ mXPosSpin -> setValue ( pos.x () + mItem ->rect ().width () );
425+ mYPosSpin -> setValue ( pos.y () + mItem ->rect ().height () / 2.0 );
439426 }
440427
441428 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::LowerLeft )
442429 {
443430 mLowerLeftCheckBox ->setChecked ( true );
444- mXLineEdit -> setText ( QString::number ( pos.x () ) );
445- mYLineEdit -> setText ( QString::number ( pos.y () + mItem ->rect ().height () ) );
431+ mXPosSpin -> setValue ( pos.x () );
432+ mYPosSpin -> setValue ( pos.y () + mItem ->rect ().height () );
446433 }
447434
448435 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::LowerMiddle )
449436 {
450437 mLowerMiddleCheckBox ->setChecked ( true );
451- mXLineEdit -> setText ( QString::number ( pos.x () + mItem ->rect ().width () / 2.0 ) );
452- mYLineEdit -> setText ( QString::number ( pos.y () + mItem ->rect ().height () ) );
438+ mXPosSpin -> setValue ( pos.x () + mItem ->rect ().width () / 2.0 );
439+ mYPosSpin -> setValue ( pos.y () + mItem ->rect ().height () );
453440 }
454441
455442 if ( mItem ->lastUsedPositionMode () == QgsComposerItem::LowerRight )
456443 {
457444 mLowerRightCheckBox ->setChecked ( true );
458- mXLineEdit -> setText ( QString::number ( pos.x () + mItem ->rect ().width () ) );
459- mYLineEdit -> setText ( QString::number ( pos.y () + mItem ->rect ().height () ) );
445+ mXPosSpin -> setValue ( pos.x () + mItem ->rect ().width () );
446+ mYPosSpin -> setValue ( pos.y () + mItem ->rect ().height () );
460447 }
461448
462- mWidthLineEdit -> setText ( QString::number ( mItem ->rect ().width () ) );
463- mHeightLineEdit -> setText ( QString::number ( mItem ->rect ().height () ) );
449+ mWidthSpin -> setValue ( mItem ->rect ().width () );
450+ mHeightSpin -> setValue ( mItem ->rect ().height () );
464451 mPageSpinBox ->setValue ( mItem ->page () );
465452
466-
467- mXLineEdit ->blockSignals ( false );
468- mYLineEdit ->blockSignals ( false );
469- mWidthLineEdit ->blockSignals ( false );
470- mHeightLineEdit ->blockSignals ( false );
453+ mXPosSpin ->blockSignals ( false );
454+ mYPosSpin ->blockSignals ( false );
455+ mWidthSpin ->blockSignals ( false );
456+ mHeightSpin ->blockSignals ( false );
471457 mUpperLeftCheckBox ->blockSignals ( false );
472458 mUpperMiddleCheckBox ->blockSignals ( false );
473459 mUpperRightCheckBox ->blockSignals ( false );
0 commit comments