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 Jan 16, 2017
1 parent 39a5f6a commit 3d38565
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/app/qgsaddattrdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ QgsField QgsAddAttrDialog::field() const
QgsDebugMsg( QString( "idx:%1 name:%2 type:%3 typeName:%4 length:%5 prec:%6 comment:%7" )
.arg( mTypeBox->currentIndex() )
.arg( mNameEdit->text() )
.arg( mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole ).toInt() )
.arg( mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole + 1 ).toString() )
.arg( mTypeBox->currentData( Qt::UserRole ).toInt() )
.arg( mTypeBox->currentData( Qt::UserRole + 1 ).toString() )
.arg( mLength->value() )
.arg( mPrec->value() )
.arg( mCommentEdit->text() ) );

return QgsField(
mNameEdit->text(),
( QVariant::Type ) mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole ).toInt(),
mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole + 1 ).toString(),
( QVariant::Type ) mTypeBox->currentData( Qt::UserRole ).toInt(),
mTypeBox->currentData( Qt::UserRole + 1 ).toString(),
mLength->value(),
mPrec->value(),
mCommentEdit->text() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsnewspatialitelayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void QgsNewSpatialiteLayerDialog::on_mAddAttributeButton_clicked()
{
QString myName = mNameEdit->text();
//use userrole to avoid translated type string
QString myType = mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole ).toString();
QString myType = mTypeBox->currentData( Qt::UserRole ).toString();
mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << myName << myType ) );

checkOk();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ QgsFeature QgsRelationReferenceWidget::referencedFeature() const
}
else
{
fid = mComboBox->itemData( mComboBox->currentIndex(), QgsAttributeTableModel::FeatureIdRole ).value<QgsFeatureId>();
fid = mComboBox->currentData( QgsAttributeTableModel::FeatureIdRole ).value<QgsFeatureId>();
}
mReferencedLayer->getFeatures( QgsFeatureRequest().setFilterFid( fid ) ).nextFeature( f );
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsnewgeopackagelayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ QgsNewGeoPackageLayerDialog::~QgsNewGeoPackageLayerDialog()

void QgsNewGeoPackageLayerDialog::on_mFieldTypeBox_currentIndexChanged( int )
{
QString myType = mFieldTypeBox->itemData( mFieldTypeBox->currentIndex(), Qt::UserRole ).toString();
QString myType = mFieldTypeBox->currentData( Qt::UserRole ).toString();
mFieldLengthEdit->setEnabled( myType == QLatin1String( "text" ) );
if ( myType != QLatin1String( "text" ) )
mFieldLengthEdit->setText( QLatin1String( "" ) );
Expand All @@ -121,7 +121,7 @@ void QgsNewGeoPackageLayerDialog::on_mFieldTypeBox_currentIndexChanged( int )
void QgsNewGeoPackageLayerDialog::on_mGeometryTypeBox_currentIndexChanged( int )
{
OGRwkbGeometryType geomType = static_cast<OGRwkbGeometryType>
( mGeometryTypeBox->itemData( mGeometryTypeBox->currentIndex(), Qt::UserRole ).toInt() );
( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
bool isSpatial = geomType != wkbNone;
mGeometryColumnEdit->setEnabled( isSpatial );
mCheckBoxCreateSpatialIndex->setEnabled( isSpatial );
Expand Down Expand Up @@ -196,7 +196,7 @@ void QgsNewGeoPackageLayerDialog::on_mAddAttributeButton_clicked()
}

//use userrole to avoid translated type string
QString myType = mFieldTypeBox->itemData( mFieldTypeBox->currentIndex(), Qt::UserRole ).toString();
QString myType = mFieldTypeBox->currentData( Qt::UserRole ).toString();
QString length = mFieldLengthEdit->text();
mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << myName << myType << length ) );

Expand Down Expand Up @@ -348,7 +348,7 @@ bool QgsNewGeoPackageLayerDialog::apply()
QString layerDescription( mLayerDescriptionEdit->text() );

OGRwkbGeometryType wkbType = static_cast<OGRwkbGeometryType>
( mGeometryTypeBox->itemData( mGeometryTypeBox->currentIndex(), Qt::UserRole ).toInt() );
( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );

OGRSpatialReferenceH hSRS = nullptr;
// consider spatial reference system of the layer
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsnewvectorlayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void QgsNewVectorLayerDialog::on_mAddAttributeButton_clicked()
QString myWidth = mWidth->text();
QString myPrecision = mPrecision->isEnabled() ? mPrecision->text() : QLatin1String( "" );
//use userrole to avoid translated type string
QString myType = mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole ).toString();
QString myType = mTypeBox->currentData( Qt::UserRole ).toString();
mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << myName << myType << myWidth << myPrecision ) );
if ( mAttributeView->topLevelItemCount() > 0 )
{
Expand Down Expand Up @@ -205,7 +205,7 @@ void QgsNewVectorLayerDialog::attributes( QList< QPair<QString, QString> >& at )
QString QgsNewVectorLayerDialog::selectedFileFormat() const
{
//use userrole to avoid translated type string
QString myType = mFileFormatComboBox->itemData( mFileFormatComboBox->currentIndex(), Qt::UserRole ).toString();
QString myType = mFileFormatComboBox->currentData( Qt::UserRole ).toString();
return myType;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsprojectionselectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ QgsCoordinateReferenceSystem QgsProjectionSelectionWidget::crs() const
return mCrs;
case QgsProjectionSelectionWidget::RecentCrs:
{
long srsid = mCrsComboBox->itemData( mCrsComboBox->currentIndex(), Qt::UserRole + 1 ).toLongLong();
long srsid = mCrsComboBox->currentData( Qt::UserRole + 1 ).toLongLong();
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromSrsId( srsid );
return crs;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgscptcitycolorrampdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void QgsCptCityColorRampDialog::on_cboVariantName_currentIndexChanged( int index
{
Q_UNUSED( index );
if ( cboVariantName->currentIndex() != -1 )
mRamp.setVariantName( cboVariantName->itemData( cboVariantName->currentIndex(), Qt::UserRole ).toString() );
mRamp.setVariantName( cboVariantName->currentData( Qt::UserRole ).toString() );
QgsDebugMsg( QString( "variant= %1 - %2 variants" ).arg( mRamp.variantName() ).arg( mRamp.variantList().count() ) );
updatePreview();
emit changed();
Expand Down

0 comments on commit 3d38565

Please sign in to comment.