@@ -93,7 +93,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
9393 QPixmap pix = QgsApplication::getThemePixmap ( " pie-chart" );
9494 mDiagramTypeComboBox ->addItem ( pix, tr ( " Pie chart" ), DIAGRAM_NAME_PIE );
9595 pix = QgsApplication::getThemePixmap ( " text" );
96- mDiagramTypeComboBox ->addItem ( pix, tr ( " Text diagram" , DIAGRAM_NAME_TEXT ) );
96+ mDiagramTypeComboBox ->addItem ( pix, tr ( " Text diagram" ) , DIAGRAM_NAME_TEXT );
9797 pix = QgsApplication::getThemePixmap ( " histogram" );
9898 mDiagramTypeComboBox ->addItem ( pix, tr ( " Histogram" ), DIAGRAM_NAME_HISTOGRAM );
9999
@@ -286,7 +286,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
286286 {
287287 QMessageBox::warning ( this , tr ( " Unknown diagram type." ),
288288 tr ( " The diagram type '%1' is unknown. A default type is selected for you." ).arg ( diagramName ), QMessageBox::Ok );
289- mDiagramTypeComboBox ->setCurrentIndex ( mDiagramTypeComboBox ->findText ( tr ( " Pie chart " ) ) );
289+ mDiagramTypeComboBox ->setCurrentIndex ( mDiagramTypeComboBox ->findData ( DIAGRAM_NAME_PIE ) );
290290 }
291291 }
292292 } // if ( !dr )
@@ -295,9 +295,10 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
295295 on_mDisplayDiagramsGroupBox_toggled ( mDisplayDiagramsGroupBox ->isChecked () );
296296}
297297
298- void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged ( const QString& itemtext )
298+ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged ( int index )
299299{
300- if ( tr ( " Text diagram" ) == itemtext )
300+ QString diagramType = mDiagramTypeComboBox ->itemData ( index ).toString ();
301+ if ( diagramType == DIAGRAM_NAME_TEXT )
301302 {
302303 mLabelPlacementComboBox ->show ();
303304 mLabelPlacementLabel ->show ();
@@ -307,7 +308,7 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( const QS
307308 mLabelPlacementLabel ->hide ();
308309 }
309310
310- if ( tr ( " Histogram " ) == itemtext )
311+ if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
311312 {
312313 mBarWidthLabel ->show ();
313314 mBarWidthSpinBox ->show ();
@@ -320,7 +321,7 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( const QS
320321 mOrientationFrame ->hide ();
321322 }
322323
323- if ( tr ( " Histogram " ) == itemtext || tr ( " Text diagram " ) == itemtext )
324+ if ( diagramType == DIAGRAM_NAME_HISTOGRAM || diagramType == DIAGRAM_NAME_TEXT )
324325 {
325326 mDiagramPropertiesTabWidget ->setTabEnabled ( 3 , true );
326327 }
@@ -329,7 +330,7 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( const QS
329330 mDiagramPropertiesTabWidget ->setTabEnabled ( 3 , false );
330331 }
331332
332- if ( tr ( " Text diagram " ) == itemtext || tr ( " Pie chart " ) == itemtext )
333+ if ( diagramType == DIAGRAM_NAME_TEXT || diagramType == DIAGRAM_NAME_PIE )
333334 {
334335 mScaleDependencyComboBox ->show ();
335336 mScaleDependencyLabel ->show ();
@@ -419,7 +420,7 @@ void QgsDiagramProperties::on_mDisplayDiagramsGroupBox_toggled( bool checked )
419420 // if enabled show diagram specific options
420421 if ( checked )
421422 {
422- on_mDiagramTypeComboBox_currentIndexChanged ( mDiagramTypeComboBox ->currentText () );
423+ on_mDiagramTypeComboBox_currentIndexChanged ( mDiagramTypeComboBox ->currentIndex () );
423424 // Update enabled/disabled state
424425 }
425426}
@@ -464,15 +465,17 @@ void QgsDiagramProperties::apply()
464465 }
465466
466467 QgsDiagram* diagram = 0 ;
467- if ( mDiagramTypeComboBox ->itemData ( mDiagramTypeComboBox ->currentIndex () ) == DIAGRAM_NAME_TEXT )
468+ int index = mDiagramTypeComboBox ->currentIndex ();
469+ QString diagramType = mDiagramTypeComboBox ->itemData ( index ).toString ();
470+ if ( diagramType == DIAGRAM_NAME_TEXT )
468471 {
469472 diagram = new QgsTextDiagram ();
470473 }
471- else if ( mDiagramTypeComboBox -> itemData ( mDiagramTypeComboBox -> currentIndex () ) == DIAGRAM_NAME_PIE )
474+ else if ( diagramType == DIAGRAM_NAME_PIE )
472475 {
473476 diagram = new QgsPieDiagram ();
474477 }
475- else if ( mDiagramTypeComboBox -> itemData ( mDiagramTypeComboBox -> currentIndex () ) == DIAGRAM_NAME_HISTOGRAM )
478+ else // if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
476479 {
477480 diagram = new QgsHistogramDiagram ();
478481 }
0 commit comments