@@ -39,9 +39,18 @@ QgsItemPositionDialog::QgsItemPositionDialog( QgsComposerItem* item, QWidget* pa
39
39
40
40
mXLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
41
41
mYLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
42
+ mWidthLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
43
+ mHeightLineEdit ->setValidator ( new QDoubleValidator ( 0 ) );
42
44
43
45
// set lower left position of item
44
46
mUpperLeftCheckBox ->setCheckState ( Qt::Checked );
47
+
48
+ // set initial width and height
49
+ if ( mItem )
50
+ {
51
+ mWidthLineEdit ->setText ( QString::number ( mItem ->rect ().width () ) );
52
+ mHeightLineEdit ->setText ( QString::number ( mItem ->rect ().height () ) );
53
+ }
45
54
}
46
55
47
56
QgsItemPositionDialog::QgsItemPositionDialog (): mItem( 0 )
@@ -69,6 +78,22 @@ int QgsItemPositionDialog::position( QgsPoint& point ) const
69
78
return 0 ;
70
79
}
71
80
81
+ int QgsItemPositionDialog::size ( QSizeF& s ) const
82
+ {
83
+ bool convSuccessWidth, convSuccessHeight;
84
+ double width = mWidthLineEdit ->text ().toDouble ( &convSuccessWidth );
85
+ double height = mHeightLineEdit ->text ().toDouble ( &convSuccessHeight );
86
+
87
+ if ( !convSuccessWidth || !convSuccessHeight )
88
+ {
89
+ return 1 ;
90
+ }
91
+
92
+ s.setWidth ( width );
93
+ s.setHeight ( height );
94
+ return 0 ;
95
+ }
96
+
72
97
QgsComposerItem::ItemPositionMode QgsItemPositionDialog::positionMode () const
73
98
{
74
99
if ( mUpperLeftCheckBox ->checkState () == Qt::Checked )
@@ -123,10 +148,18 @@ void QgsItemPositionDialog::on_mSetPositionButton_clicked()
123
148
}
124
149
125
150
QgsPoint itemPosition;
151
+ QSizeF itemSize;
152
+
126
153
if ( position ( itemPosition ) == 0 )
127
154
{
128
- // query position and mode from dialog
129
- mItem ->setItemPosition ( itemPosition.x (), itemPosition.y (), positionMode () );
155
+ if ( size ( itemSize ) == 0 )
156
+ {
157
+ mItem ->setItemPosition ( itemPosition.x (), itemPosition.y (), itemSize.width (), itemSize.height (), positionMode () );
158
+ }
159
+ else
160
+ {
161
+ mItem ->setItemPosition ( itemPosition.x (), itemPosition.y (), positionMode () );
162
+ }
130
163
mItem ->update ();
131
164
}
132
165
}
0 commit comments