Skip to content

Commit

Permalink
Qt 5.2 has QComboBox::currentData()
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 21, 2016
1 parent 0542aac commit 6653e77
Show file tree
Hide file tree
Showing 74 changed files with 166 additions and 165 deletions.
2 changes: 1 addition & 1 deletion src/app/composer/qgsattributeselectiondialog.cpp
Expand Up @@ -76,7 +76,7 @@ void QgsComposerColumnAlignmentDelegate::setEditorData( QWidget* editor, const Q
void QgsComposerColumnAlignmentDelegate::setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const
{
QComboBox *comboBox = static_cast<QComboBox*>( editor );
Qt::AlignmentFlag alignment = ( Qt::AlignmentFlag ) comboBox->itemData( comboBox->currentIndex() ).toInt();
Qt::AlignmentFlag alignment = ( Qt::AlignmentFlag ) comboBox->currentData().toInt();
model->setData( index, alignment, Qt::EditRole );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposermanager.cpp
Expand Up @@ -249,7 +249,7 @@ void QgsComposerManager::on_mAddButton_clicked()
}
else
{
templateFile.setFileName( mTemplate->itemData( mTemplate->currentIndex() ).toString() );
templateFile.setFileName( mTemplate->currentData().toString() );
}

if ( !templateFile.exists() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -260,7 +260,7 @@ QgsGPSInformationWidget::~QgsGPSInformationWidget()
#endif

QSettings mySettings;
mySettings.setValue( "/gps/lastPort", mCboDevices->itemData( mCboDevices->currentIndex() ).toString() );
mySettings.setValue( "/gps/lastPort", mCboDevices->currentData().toString() );
mySettings.setValue( "/gps/trackWidth", mSpinTrackWidth->value() );
mySettings.setValue( "/gps/trackColor", mTrackColor );
mySettings.setValue( "/gps/markerSize", mSliderMarkerSize->value() );
Expand Down Expand Up @@ -396,7 +396,7 @@ void QgsGPSInformationWidget::connectGps()

if ( mRadUserPath->isChecked() )
{
port = mCboDevices->itemData( mCboDevices->currentIndex() ).toString();
port = mCboDevices->currentData().toString();

if ( port.isEmpty() )
{
Expand Down
12 changes: 6 additions & 6 deletions src/app/ogr/qgsvectorlayersaveasdialog.cpp
Expand Up @@ -518,7 +518,7 @@ QString QgsVectorLayerSaveAsDialog::encoding() const

QString QgsVectorLayerSaveAsDialog::format() const
{
return mFormatComboBox->itemData( mFormatComboBox->currentIndex() ).toString();
return mFormatComboBox->currentData().toString();
}

long QgsVectorLayerSaveAsDialog::crs() const
Expand Down Expand Up @@ -551,7 +551,7 @@ QStringList QgsVectorLayerSaveAsDialog::datasourceOptions() const
case QgsVectorFileWriter::Set:
{
QComboBox* cb = mDatasourceOptionsGroupBox->findChild<QComboBox*>( it.key() );
if ( cb && !cb->itemData( cb->currentIndex() ).isNull() )
if ( cb && !cb->currentData().isNull() )
options << QString( "%1=%2" ).arg( it.key(), cb->currentText() );
break;
}
Expand Down Expand Up @@ -603,7 +603,7 @@ QStringList QgsVectorLayerSaveAsDialog::layerOptions() const
case QgsVectorFileWriter::Set:
{
QComboBox* cb = mLayerOptionsGroupBox->findChild<QComboBox*>( it.key() );
if ( cb && !cb->itemData( cb->currentIndex() ).isNull() )
if ( cb && !cb->currentData().isNull() )
options << QString( "%1=%2" ).arg( it.key(), cb->currentText() );
break;
}
Expand Down Expand Up @@ -669,7 +669,7 @@ bool QgsVectorLayerSaveAsDialog::addToCanvas() const

int QgsVectorLayerSaveAsDialog::symbologyExport() const
{
return mSymbologyExportComboBox->itemData( mSymbologyExportComboBox->currentIndex() ).toInt();
return mSymbologyExportComboBox->currentData().toInt();
}

double QgsVectorLayerSaveAsDialog::scaleDenominator() const
Expand Down Expand Up @@ -699,7 +699,7 @@ bool QgsVectorLayerSaveAsDialog::onlySelected() const

QgsWkbTypes::Type QgsVectorLayerSaveAsDialog::geometryType() const
{
int currentIndexData = mGeometryTypeComboBox->itemData( mGeometryTypeComboBox->currentIndex() ).toInt();
int currentIndexData = mGeometryTypeComboBox->currentData().toInt();
if ( currentIndexData == -1 )
{
//automatic
Expand All @@ -711,7 +711,7 @@ QgsWkbTypes::Type QgsVectorLayerSaveAsDialog::geometryType() const

bool QgsVectorLayerSaveAsDialog::automaticGeometryType() const
{
int currentIndexData = mGeometryTypeComboBox->itemData( mGeometryTypeComboBox->currentIndex() ).toInt();
int currentIndexData = mGeometryTypeComboBox->currentData().toInt();
return currentIndexData == -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddtaborgroup.cpp
Expand Up @@ -68,7 +68,7 @@ QString QgsAddTabOrGroup::name()

QTreeWidgetItem* QgsAddTabOrGroup::tab()
{
TabPair tab = mTabs.at( mTabList->itemData( mTabList->currentIndex() ).toInt() );
TabPair tab = mTabs.at( mTabList->currentData().toInt() );
return tab.second;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsalignrasterdialog.cpp
Expand Up @@ -439,7 +439,7 @@ QString QgsAlignRasterLayerConfigDialog::outputFilename() const

QgsAlignRaster::ResampleAlg QgsAlignRasterLayerConfigDialog::resampleMethod() const
{
return static_cast< QgsAlignRaster::ResampleAlg >( cboResample->itemData( cboResample->currentIndex() ).toInt() );
return static_cast< QgsAlignRaster::ResampleAlg >( cboResample->currentData().toInt() );
}

bool QgsAlignRasterLayerConfigDialog::rescaleValues() const
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdecorationcopyrightdialog.cpp
Expand Up @@ -90,7 +90,7 @@ void QgsDecorationCopyrightDialog::apply()
mDeco.mQFont = txtCopyrightText->currentFont();
mDeco.mLabelQString = txtCopyrightText->toPlainText();
mDeco.mLabelQColor = pbnColorChooser->color();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
mDeco.mMarginUnit = wgtUnitSelection->unit();
mDeco.mMarginHorizontal = spnHorizontal->value();
mDeco.mMarginVertical = spnVertical->value();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdecorationnortharrowdialog.cpp
Expand Up @@ -93,7 +93,7 @@ void QgsDecorationNorthArrowDialog::on_sliderRotation_valueChanged( int theInt )
void QgsDecorationNorthArrowDialog::apply()
{
mDeco.mRotationInt = sliderRotation->value();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
mDeco.mMarginUnit = wgtUnitSelection->unit();
mDeco.setEnabled( grpEnable->isChecked() );
mDeco.mAutomatic = cboxAutomatic->isChecked();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdecorationscalebardialog.cpp
Expand Up @@ -89,7 +89,7 @@ void QgsDecorationScaleBarDialog::on_buttonBox_helpRequested()

void QgsDecorationScaleBarDialog::apply()
{
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
mDeco.mMarginUnit = wgtUnitSelection->unit();
mDeco.mMarginHorizontal = spnHorizontal->value();
mDeco.mMarginVertical = spnVertical->value();
Expand Down
16 changes: 8 additions & 8 deletions src/app/qgsdiagramproperties.cpp
Expand Up @@ -667,7 +667,7 @@ void QgsDiagramProperties::apply()
}
else
{
maxVal = provider->maximumValue( mSizeAttributeComboBox->itemData( mSizeAttributeComboBox->currentIndex() ).toInt() ).toDouble();
maxVal = provider->maximumValue( mSizeAttributeComboBox->currentData().toInt() ).toDouble();
}
}

Expand Down Expand Up @@ -724,8 +724,8 @@ void QgsDiagramProperties::apply()
ds.sizeScale = mDiagramUnitComboBox->getMapUnitScale();
ds.lineSizeUnit = mDiagramLineUnitComboBox->unit();
ds.lineSizeScale = mDiagramLineUnitComboBox->getMapUnitScale();
ds.labelPlacementMethod = static_cast<QgsDiagramSettings::LabelPlacementMethod>( mLabelPlacementComboBox->itemData( mLabelPlacementComboBox->currentIndex() ).toInt() );
ds.scaleByArea = mScaleDependencyComboBox->itemData( mScaleDependencyComboBox->currentIndex() ).toBool();
ds.labelPlacementMethod = static_cast<QgsDiagramSettings::LabelPlacementMethod>( mLabelPlacementComboBox->currentData().toInt() );
ds.scaleByArea = mScaleDependencyComboBox->currentData().toBool();

if ( mIncreaseSmallDiagramsCheck->isChecked() )
{
Expand All @@ -745,7 +745,7 @@ void QgsDiagramProperties::apply()
ds.scaleBasedVisibility = mScaleVisibilityGroupBox->isChecked();

// Diagram angle offset (pie)
ds.angleOffset = mAngleOffsetComboBox->itemData( mAngleOffsetComboBox->currentIndex() ).toInt();
ds.angleOffset = mAngleOffsetComboBox->currentData().toInt();

// Diagram orientation (histogram)
ds.diagramOrientation = static_cast<QgsDiagramSettings::DiagramOrientation>( mOrientationButtonGroup->checkedButton()->property( "direction" ).toInt() );
Expand Down Expand Up @@ -795,23 +795,23 @@ void QgsDiagramProperties::apply()
dls.setShowAllDiagrams( mShowAllCheckBox->isChecked() );
if ( mDataDefinedVisibilityGroupBox->isChecked() )
{
dls.showColumn = mDataDefinedVisibilityComboBox->itemData( mDataDefinedVisibilityComboBox->currentIndex() ).toInt();
dls.showColumn = mDataDefinedVisibilityComboBox->currentData().toInt();
}
else
{
dls.showColumn = -1;
}
if ( mDataDefinedPositionGroupBox->isChecked() )
{
dls.xPosColumn = mDataDefinedXComboBox->itemData( mDataDefinedXComboBox->currentIndex() ).toInt();
dls.yPosColumn = mDataDefinedYComboBox->itemData( mDataDefinedYComboBox->currentIndex() ).toInt();
dls.xPosColumn = mDataDefinedXComboBox->currentData().toInt();
dls.yPosColumn = mDataDefinedYComboBox->currentData().toInt();
}
else
{
dls.xPosColumn = -1;
dls.yPosColumn = -1;
}
dls.setPlacement(( QgsDiagramLayerSettings::Placement )mPlacementComboBox->itemData( mPlacementComboBox->currentIndex() ).toInt() );
dls.setPlacement(( QgsDiagramLayerSettings::Placement )mPlacementComboBox->currentData().toInt() );

unsigned int flags = 0;
if ( chkLineAbove->isChecked() )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfieldcalculator.cpp
Expand Up @@ -201,7 +201,7 @@ void QgsFieldCalculator::accept()
//update existing field
if ( mUpdateExistingGroupBox->isChecked() || !mNewFieldGroupBox->isEnabled() )
{
if ( mExistingFieldComboBox->itemData( mExistingFieldComboBox->currentIndex() ).toString() == "geom" )
if ( mExistingFieldComboBox->currentData().toString() == "geom" )
{
//update geometry
mAttributeId = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfieldsproperties.cpp
Expand Up @@ -994,7 +994,7 @@ void QgsFieldsProperties::apply()
QgsEditorWidgetConfig cfg;

QComboBox* cb = qobject_cast<QComboBox*>( mRelationsList->cellWidget( i, RelNmCol ) );
QVariant otherRelation = cb->itemData( cb->currentIndex() );
QVariant otherRelation = cb->currentData();

if ( otherRelation.isValid() )
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgslabelinggui.cpp
Expand Up @@ -940,7 +940,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.dist = mLineDistanceSpnBx->value();
lyr.distInMapUnits = ( mLineDistanceUnitWidget->unit() == QgsUnitTypes::RenderMapUnits );
lyr.distMapUnitScale = mLineDistanceUnitWidget->getMapUnitScale();
lyr.offsetType = static_cast< QgsPalLayerSettings::OffsetType >( mOffsetTypeComboBox->itemData( mOffsetTypeComboBox->currentIndex() ).toInt() );
lyr.offsetType = static_cast< QgsPalLayerSettings::OffsetType >( mOffsetTypeComboBox->currentData().toInt() );
lyr.quadOffset = ( QgsPalLayerSettings::QuadrantPosition )mQuadrantBtnGrp->checkedId();
lyr.xOffset = mPointOffsetXSpinBox->value();
lyr.yOffset = mPointOffsetYSpinBox->value();
Expand Down Expand Up @@ -1010,7 +1010,7 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
lyr.priority = mPrioritySlider->value();
lyr.obstacle = mChkNoObstacle->isChecked() || mMode == ObstaclesOnly;
lyr.obstacleFactor = mObstacleFactorSlider->value() / 50.0;
lyr.obstacleType = ( QgsPalLayerSettings::ObstacleType )mObstacleTypeComboBox->itemData( mObstacleTypeComboBox->currentIndex() ).toInt();
lyr.obstacleType = ( QgsPalLayerSettings::ObstacleType )mObstacleTypeComboBox->currentData().toInt();
lyr.labelPerPart = chkLabelPerFeaturePart->isChecked();
lyr.displayAll = mPalShowAllLabelsForLayerChkBx->isChecked();
lyr.mergeLines = chkMergeLines->isChecked();
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgsmeasuretool.cpp
Expand Up @@ -206,14 +206,15 @@ void QgsMeasureTool::canvasReleaseEvent( QgsMapMouseEvent* e )
if ( e->button() == Qt::RightButton ) // if we clicked the right button we stop measuring
{
mDone = true;
mRubberBand->removeLastPoint();
mDialog->removeLastPoint();
}
else if ( e->button() == Qt::LeftButton )
{
mDone = false;
addPoint( point );
}

// we always add the clicked point to the measuring feature
addPoint( point );
mDialog->show();

}
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -289,7 +289,7 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
}

//evaluate behaviour (feature value or min / max / mean )
QString mergeBehaviourString = comboBox->itemData( comboBox->currentIndex() ).toString();
QString mergeBehaviourString = comboBox->currentData().toString();
QVariant mergeResult; // result to show in the merge result field
if ( mergeBehaviourString == "concat" )
{
Expand All @@ -312,7 +312,7 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
else
{
//numerical statistic
QgsStatisticalSummary::Statistic stat = ( QgsStatisticalSummary::Statistic )( comboBox->itemData( comboBox->currentIndex() ).toInt() );
QgsStatisticalSummary::Statistic stat = ( QgsStatisticalSummary::Statistic )( comboBox->currentData().toInt() );
mergeResult = calcStatistic( col, stat );
}

Expand Down Expand Up @@ -557,7 +557,7 @@ QgsAttributes QgsMergeAttributesDialog::mergedAttributes() const
if ( fieldIdx >= results.count() )
results.resize( fieldIdx + 1 ); // make sure the results vector is long enough (maybe not necessary)

if ( comboBox->itemData( comboBox->currentIndex() ).toString() != "skip" )
if ( comboBox->currentData().toString() != "skip" )
{
results[fieldIdx] = currentItem->data( Qt::DisplayRole );
}
Expand Down Expand Up @@ -595,7 +595,7 @@ QSet<int> QgsMergeAttributesDialog::skippedAttributeIndexes() const
continue;
}

if ( comboBox->itemData( comboBox->currentIndex() ).toString() == "skip" )
if ( comboBox->currentData().toString() == "skip" )
{
skipped << i;
}
Expand Down

1 comment on commit 6653e77

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's MUCH nicer, thanks!

Please sign in to comment.