@@ -78,10 +78,13 @@ QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget( QgsLayoutItemScaleBar *scaleBa
78
78
mAlignmentComboBox ->insertItem ( 2 , tr ( " Right" ) );
79
79
80
80
// units combo box
81
- mUnitsComboBox ->insertItem ( 0 , tr ( " Map units" ), QgsUnitTypes::DistanceUnknownUnit );
82
- mUnitsComboBox ->insertItem ( 1 , tr ( " Meters" ), QgsUnitTypes::DistanceMeters );
83
- mUnitsComboBox ->insertItem ( 2 , tr ( " Feet" ), QgsUnitTypes::DistanceFeet );
84
- mUnitsComboBox ->insertItem ( 3 , tr ( " Nautical Miles" ), QgsUnitTypes::DistanceNauticalMiles );
81
+ mUnitsComboBox ->addItem ( tr ( " Map units" ), QgsUnitTypes::DistanceUnknownUnit );
82
+ mUnitsComboBox ->addItem ( tr ( " Meters" ), QgsUnitTypes::DistanceMeters );
83
+ mUnitsComboBox ->addItem ( tr ( " Kilometers" ), QgsUnitTypes::DistanceKilometers );
84
+ mUnitsComboBox ->addItem ( tr ( " Feet" ), QgsUnitTypes::DistanceFeet );
85
+ mUnitsComboBox ->addItem ( tr ( " Yards" ), QgsUnitTypes::DistanceYards );
86
+ mUnitsComboBox ->addItem ( tr ( " Miles" ), QgsUnitTypes::DistanceMiles );
87
+ mUnitsComboBox ->addItem ( tr ( " Nautical Miles" ), QgsUnitTypes::DistanceNauticalMiles );
85
88
86
89
mFillColorButton ->setColorDialogTitle ( tr ( " Select Fill Color" ) );
87
90
mFillColorButton ->setAllowOpacity ( true );
@@ -193,7 +196,7 @@ void QgsLayoutScaleBarWidget::setGuiElements()
193
196
mAlignmentComboBox ->setCurrentIndex ( ( int )( mScalebar ->alignment () ) );
194
197
195
198
// units
196
- mUnitsComboBox ->setCurrentIndex ( mUnitsComboBox ->findData ( ( int ) mScalebar ->units () ) );
199
+ mUnitsComboBox ->setCurrentIndex ( mUnitsComboBox ->findData ( static_cast < int >( mScalebar ->units () ) ) );
197
200
198
201
if ( mScalebar ->segmentSizeMode () == QgsScaleBarSettings::SegmentSizeFixed )
199
202
{
@@ -546,36 +549,8 @@ void QgsLayoutScaleBarWidget::mUnitsComboBox_currentIndexChanged( int index )
546
549
}
547
550
548
551
disconnectUpdateSignal ();
549
- mScalebar ->setUnits ( ( QgsUnitTypes::DistanceUnit )unitData.toInt () );
550
- switch ( mUnitsComboBox ->currentIndex () )
551
- {
552
- case 0 :
553
- {
554
- mScalebar ->beginCommand ( tr ( " Set Scalebar Units" ) );
555
- mScalebar ->applyDefaultSize ( QgsUnitTypes::DistanceUnknownUnit );
556
- break ;
557
- }
558
- case 2 :
559
- {
560
- mScalebar ->beginCommand ( tr ( " Set Scalebar Units" ) );
561
- mScalebar ->applyDefaultSize ( QgsUnitTypes::DistanceFeet );
562
- break ;
563
- }
564
- case 3 :
565
- {
566
- mScalebar ->beginCommand ( tr ( " Set Scalebar Units" ) );
567
- mScalebar ->applyDefaultSize ( QgsUnitTypes::DistanceNauticalMiles );
568
- break ;
569
- }
570
- case 1 :
571
- default :
572
- {
573
- mScalebar ->beginCommand ( tr ( " Set Scalebar Units" ) );
574
- mScalebar ->applyDefaultSize ( QgsUnitTypes::DistanceMeters );
575
- break ;
576
- }
577
- }
578
-
552
+ mScalebar ->beginCommand ( tr ( " Set Scalebar Units" ) );
553
+ mScalebar ->applyDefaultSize ( static_cast < QgsUnitTypes::DistanceUnit >( unitData.toInt () ) );
579
554
mScalebar ->update ();
580
555
581
556
mUnitLabelLineEdit ->setText ( mScalebar ->unitLabel () );
0 commit comments