@@ -139,6 +139,17 @@ QgsLayoutObject *QgsLayoutItemBaseWidget::layoutObject()
139
139
return mObject ;
140
140
}
141
141
142
+ bool QgsLayoutItemBaseWidget::setItem ( QgsLayoutItem *item )
143
+ {
144
+ if ( setNewItem ( item ) )
145
+ {
146
+ mObject = item;
147
+ return true ;
148
+ }
149
+
150
+ return false ;
151
+ }
152
+
142
153
void QgsLayoutItemBaseWidget::registerDataDefinedButton ( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property )
143
154
{
144
155
mConfigObject ->initializeDataDefinedButton ( button, property );
@@ -154,6 +165,11 @@ QgsVectorLayer *QgsLayoutItemBaseWidget::coverageLayer() const
154
165
return mConfigObject ->coverageLayer ();
155
166
}
156
167
168
+ bool QgsLayoutItemBaseWidget::setNewItem ( QgsLayoutItem * )
169
+ {
170
+ return false ;
171
+ }
172
+
157
173
#if 0 //TODO
158
174
QgsAtlasComposition *QgsLayoutItemBaseWidget::atlasComposition() const
159
175
{
@@ -178,28 +194,26 @@ void QgsLayoutItemPropertiesWidget::updateVariables()
178
194
179
195
QgsLayoutItemPropertiesWidget::QgsLayoutItemPropertiesWidget ( QWidget *parent, QgsLayoutItem *item )
180
196
: QWidget( parent )
181
- , mItem( item )
182
197
, mConfigObject( new QgsLayoutConfigObject( this , item ) )
183
198
, mFreezeXPosSpin( false )
184
199
, mFreezeYPosSpin( false )
185
200
, mFreezeWidthSpin( false )
186
201
, mFreezeHeightSpin( false )
187
202
, mFreezePageSpin( false )
188
203
{
189
-
190
204
setupUi ( this );
191
205
192
206
mItemRotationSpinBox ->setClearValue ( 0 );
193
207
mStrokeUnitsComboBox ->linkToWidget ( mStrokeWidthSpinBox );
194
- mStrokeUnitsComboBox ->setConverter ( &mItem ->layout ()->context ().measurementConverter () );
208
+ mStrokeUnitsComboBox ->setConverter ( &item ->layout ()->context ().measurementConverter () );
195
209
196
210
mPosUnitsComboBox ->linkToWidget ( mXPosSpin );
197
211
mPosUnitsComboBox ->linkToWidget ( mYPosSpin );
198
212
mSizeUnitsComboBox ->linkToWidget ( mWidthSpin );
199
213
mSizeUnitsComboBox ->linkToWidget ( mHeightSpin );
200
214
201
- mPosUnitsComboBox ->setConverter ( &mItem ->layout ()->context ().measurementConverter () );
202
- mSizeUnitsComboBox ->setConverter ( &mItem ->layout ()->context ().measurementConverter () );
215
+ mPosUnitsComboBox ->setConverter ( &item ->layout ()->context ().measurementConverter () );
216
+ mSizeUnitsComboBox ->setConverter ( &item ->layout ()->context ().measurementConverter () );
203
217
204
218
mPosLockAspectRatio ->setWidthSpinBox ( mXPosSpin );
205
219
mPosLockAspectRatio ->setHeightSpinBox ( mYPosSpin );
@@ -249,25 +263,22 @@ QgsLayoutItemPropertiesWidget::QgsLayoutItemPropertiesWidget( QWidget *parent, Q
249
263
250
264
initializeDataDefinedButtons ();
251
265
252
- setValuesForGuiElements ();
253
-
254
266
#if 0 //TODO
255
267
connect( mItem->composition(), &QgsComposition::paperSizeChanged, this, &QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements );
256
268
#endif
257
269
258
- connect ( mItem , &QgsLayoutItem::sizePositionChanged, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements );
259
- connect ( mItem , &QgsLayoutObject::changed, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements );
270
+ setItem ( item );
260
271
261
272
connect ( mOpacityWidget , &QgsOpacityWidget::opacityChanged, this , &QgsLayoutItemPropertiesWidget::opacityChanged );
262
273
263
274
updateVariables ();
264
275
connect ( mVariableEditor , &QgsVariableEditorWidget::scopeChanged, this , &QgsLayoutItemPropertiesWidget::variablesChanged );
265
276
// listen out for variable edits
266
277
connect ( QgsApplication::instance (), &QgsApplication::customVariablesChanged, this , &QgsLayoutItemPropertiesWidget::updateVariables );
267
- connect ( mItem ->layout ()->project (), &QgsProject::customVariablesChanged, this , &QgsLayoutItemPropertiesWidget::updateVariables );
278
+ connect ( item ->layout ()->project (), &QgsProject::customVariablesChanged, this , &QgsLayoutItemPropertiesWidget::updateVariables );
268
279
269
- if ( mItem ->layout () )
270
- connect ( mItem ->layout (), &QgsLayout::variablesChanged, this , &QgsLayoutItemPropertiesWidget::updateVariables );
280
+ if ( item ->layout () )
281
+ connect ( item ->layout (), &QgsLayout::variablesChanged, this , &QgsLayoutItemPropertiesWidget::updateVariables );
271
282
}
272
283
273
284
void QgsLayoutItemPropertiesWidget::showBackgroundGroup ( bool showGroup )
@@ -280,6 +291,20 @@ void QgsLayoutItemPropertiesWidget::showFrameGroup( bool showGroup )
280
291
mFrameGroupBox ->setVisible ( showGroup );
281
292
}
282
293
294
+ void QgsLayoutItemPropertiesWidget::setItem ( QgsLayoutItem *item )
295
+ {
296
+ if ( mItem )
297
+ {
298
+ disconnect ( mItem , &QgsLayoutItem::sizePositionChanged, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements );
299
+ disconnect ( mItem , &QgsLayoutObject::changed, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements );
300
+ }
301
+ mItem = item;
302
+ connect ( mItem , &QgsLayoutItem::sizePositionChanged, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiPositionElements );
303
+ connect ( mItem , &QgsLayoutObject::changed, this , &QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements );
304
+
305
+ setValuesForGuiElements ();
306
+ }
307
+
283
308
// slots
284
309
285
310
void QgsLayoutItemPropertiesWidget::mFrameColorButton_colorChanged ( const QColor &newFrameColor )
0 commit comments