25
25
QgsComposerScaleBarWidget::QgsComposerScaleBarWidget ( QgsComposerScaleBar* scaleBar ): QWidget(), mComposerScaleBar( scaleBar )
26
26
{
27
27
setupUi ( this );
28
- if ( scaleBar )
29
- {
30
- QObject::connect ( scaleBar, SIGNAL ( itemChanged () ), this , SLOT ( setGuiElements () ) );
31
- }
28
+ connectUpdateSignal ();
32
29
33
30
// add widget for general composer item properties
34
31
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget ( this , scaleBar );
@@ -147,8 +144,10 @@ void QgsComposerScaleBarWidget::on_mMapComboBox_activated( const QString& text )
147
144
148
145
// set it to scale bar
149
146
mComposerScaleBar ->beginCommand ( tr ( " Scalebar map changed" ) );
147
+ disconnectUpdateSignal ();
150
148
mComposerScaleBar ->setComposerMap ( composerMap );
151
149
mComposerScaleBar ->update ();
150
+ connectUpdateSignal ();
152
151
mComposerScaleBar ->endCommand ();
153
152
}
154
153
@@ -204,10 +203,12 @@ void QgsComposerScaleBarWidget::on_mLineWidthSpinBox_valueChanged( double d )
204
203
}
205
204
206
205
mComposerScaleBar ->beginCommand ( tr ( " Scalebar line width" ), QgsComposerMergeCommand::ScaleBarLineWidth );
206
+ disconnectUpdateSignal ();
207
207
QPen newPen ( QColor ( 0 , 0 , 0 ) );
208
208
newPen.setWidthF ( d );
209
209
mComposerScaleBar ->setPen ( newPen );
210
210
mComposerScaleBar ->update ();
211
+ connectUpdateSignal ();
211
212
mComposerScaleBar ->endCommand ();
212
213
}
213
214
@@ -219,8 +220,10 @@ void QgsComposerScaleBarWidget::on_mSegmentSizeSpinBox_valueChanged( double d )
219
220
}
220
221
221
222
mComposerScaleBar ->beginCommand ( tr ( " Scalebar segment size" ), QgsComposerMergeCommand::ScaleBarSegmentSize );
223
+ disconnectUpdateSignal ();
222
224
mComposerScaleBar ->setNumUnitsPerSegment ( d );
223
225
mComposerScaleBar ->update ();
226
+ connectUpdateSignal ();
224
227
mComposerScaleBar ->endCommand ();
225
228
}
226
229
@@ -232,8 +235,10 @@ void QgsComposerScaleBarWidget::on_mSegmentsLeftSpinBox_valueChanged( int i )
232
235
}
233
236
234
237
mComposerScaleBar ->beginCommand ( tr ( " Scalebar segments left" ), QgsComposerMergeCommand::ScaleBarSegmentsLeft );
238
+ disconnectUpdateSignal ();
235
239
mComposerScaleBar ->setNumSegmentsLeft ( i );
236
240
mComposerScaleBar ->update ();
241
+ connectUpdateSignal ();
237
242
mComposerScaleBar ->endCommand ();
238
243
}
239
244
@@ -245,8 +250,10 @@ void QgsComposerScaleBarWidget::on_mNumberOfSegmentsSpinBox_valueChanged( int i
245
250
}
246
251
247
252
mComposerScaleBar ->beginCommand ( tr ( " Scalebar n segments" ), QgsComposerMergeCommand::ScaleBarNSegments );
253
+ disconnectUpdateSignal ();
248
254
mComposerScaleBar ->setNumSegments ( i );
249
255
mComposerScaleBar ->update ();
256
+ connectUpdateSignal ();
250
257
mComposerScaleBar ->endCommand ();
251
258
}
252
259
@@ -257,8 +264,10 @@ void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( int i )
257
264
return ;
258
265
}
259
266
mComposerScaleBar ->beginCommand ( tr ( " Scalebar height changed" ), QgsComposerMergeCommand::ScaleBarHeight );
267
+ disconnectUpdateSignal ();
260
268
mComposerScaleBar ->setHeight ( i );
261
269
mComposerScaleBar ->update ();
270
+ connectUpdateSignal ();
262
271
mComposerScaleBar ->endCommand ();
263
272
}
264
273
@@ -280,7 +289,9 @@ void QgsComposerScaleBarWidget::on_mFontButton_clicked()
280
289
if ( dialogAccepted )
281
290
{
282
291
mComposerScaleBar ->beginCommand ( tr ( " Scalebar font changed" ) );
292
+ disconnectUpdateSignal ();
283
293
mComposerScaleBar ->setFont ( newFont );
294
+ connectUpdateSignal ();
284
295
mComposerScaleBar ->endCommand ();
285
296
}
286
297
mComposerScaleBar ->update ();
@@ -302,9 +313,11 @@ void QgsComposerScaleBarWidget::on_mColorPushButton_clicked()
302
313
}
303
314
304
315
mComposerScaleBar ->beginCommand ( tr ( " Scalebar color changed" ) );
316
+ disconnectUpdateSignal ();
305
317
QBrush newBrush ( newColor );
306
318
mComposerScaleBar ->setBrush ( newBrush );
307
319
mComposerScaleBar ->update ();
320
+ connectUpdateSignal ();
308
321
mComposerScaleBar ->endCommand ();
309
322
}
310
323
@@ -316,8 +329,10 @@ void QgsComposerScaleBarWidget::on_mUnitLabelLineEdit_textChanged( const QString
316
329
}
317
330
318
331
mComposerScaleBar ->beginCommand ( tr ( " Scalebar unit text" ), QgsComposerMergeCommand::ScaleBarUnitText );
332
+ disconnectUpdateSignal ();
319
333
mComposerScaleBar ->setUnitLabeling ( text );
320
334
mComposerScaleBar ->update ();
335
+ connectUpdateSignal ();
321
336
mComposerScaleBar ->endCommand ();
322
337
}
323
338
@@ -329,8 +344,10 @@ void QgsComposerScaleBarWidget::on_mMapUnitsPerBarUnitSpinBox_valueChanged( doub
329
344
}
330
345
331
346
mComposerScaleBar ->beginCommand ( tr ( " Scalebar map units per segment" ), QgsComposerMergeCommand::ScaleBarMapUnitsSegment );
347
+ disconnectUpdateSignal ();
332
348
mComposerScaleBar ->setNumMapUnitsPerScaleBarUnit ( d );
333
349
mComposerScaleBar ->update ();
350
+ connectUpdateSignal ();
334
351
mComposerScaleBar ->endCommand ();
335
352
}
336
353
@@ -342,6 +359,7 @@ void QgsComposerScaleBarWidget::on_mStyleComboBox_currentIndexChanged( const QSt
342
359
}
343
360
344
361
mComposerScaleBar ->beginCommand ( tr ( " Scalebar style changed" ) );
362
+ disconnectUpdateSignal ();
345
363
QString untranslatedStyleName;
346
364
if ( text == tr ( " Single Box" ) )
347
365
{
@@ -373,6 +391,7 @@ void QgsComposerScaleBarWidget::on_mStyleComboBox_currentIndexChanged( const QSt
373
391
}
374
392
mComposerScaleBar ->setStyle ( untranslatedStyleName );
375
393
mComposerScaleBar ->update ();
394
+ connectUpdateSignal ();
376
395
mComposerScaleBar ->endCommand ();
377
396
}
378
397
@@ -384,8 +403,10 @@ void QgsComposerScaleBarWidget::on_mLabelBarSpaceSpinBox_valueChanged( double d
384
403
}
385
404
386
405
mComposerScaleBar ->beginCommand ( tr ( " Scalebar label bar space" ), QgsComposerMergeCommand::ScaleBarLabelBarSize );
406
+ disconnectUpdateSignal ();
387
407
mComposerScaleBar ->setLabelBarSpace ( d );
388
408
mComposerScaleBar ->update ();
409
+ connectUpdateSignal ();
389
410
mComposerScaleBar ->endCommand ();
390
411
}
391
412
@@ -397,8 +418,10 @@ void QgsComposerScaleBarWidget::on_mBoxSizeSpinBox_valueChanged( double d )
397
418
}
398
419
399
420
mComposerScaleBar ->beginCommand ( tr ( " Scalebar box content space" ), QgsComposerMergeCommand::ScaleBarBoxContentSpace );
421
+ disconnectUpdateSignal ();
400
422
mComposerScaleBar ->setBoxContentSpace ( d );
401
423
mComposerScaleBar ->update ();
424
+ connectUpdateSignal ();
402
425
mComposerScaleBar ->endCommand ();
403
426
}
404
427
@@ -410,7 +433,9 @@ void QgsComposerScaleBarWidget::on_mAlignmentComboBox_currentIndexChanged( int i
410
433
}
411
434
412
435
mComposerScaleBar ->beginCommand ( tr ( " Scalebar alignment" ) );
436
+ disconnectUpdateSignal ();
413
437
mComposerScaleBar ->setAlignment (( QgsComposerScaleBar::Alignment ) index );
438
+ connectUpdateSignal ();
414
439
mComposerScaleBar ->endCommand ();
415
440
}
416
441
@@ -428,8 +453,10 @@ void QgsComposerScaleBarWidget::on_mUnitsComboBox_currentIndexChanged( int index
428
453
}
429
454
430
455
mComposerScaleBar ->beginCommand ( tr ( " Scalebar unit changed" ) );
456
+ disconnectUpdateSignal ();
431
457
mComposerScaleBar ->setUnits (( QgsComposerScaleBar::ScaleBarUnits )unitData.toInt () );
432
458
mComposerScaleBar ->update ();
459
+ connectUpdateSignal ();
433
460
mComposerScaleBar ->endCommand ();
434
461
}
435
462
@@ -449,3 +476,19 @@ void QgsComposerScaleBarWidget::blockMemberSignals( bool block )
449
476
mAlignmentComboBox ->blockSignals ( block );
450
477
mUnitsComboBox ->blockSignals ( block );
451
478
}
479
+
480
+ void QgsComposerScaleBarWidget::connectUpdateSignal ()
481
+ {
482
+ if ( mComposerScaleBar )
483
+ {
484
+ QObject::connect ( mComposerScaleBar , SIGNAL ( itemChanged () ), this , SLOT ( setGuiElements () ) );
485
+ }
486
+ }
487
+
488
+ void QgsComposerScaleBarWidget::disconnectUpdateSignal ()
489
+ {
490
+ if ( mComposerScaleBar )
491
+ {
492
+ QObject::disconnect ( mComposerScaleBar , SIGNAL ( itemChanged () ), this , SLOT ( setGuiElements () ) );
493
+ }
494
+ }
0 commit comments