Skip to content
Permalink
Browse files

Qt 5.2 has QComboBox::currentData

  • Loading branch information
3nids committed Jan 16, 2017
1 parent 39a5f6a commit 3d3856580fd2ea7ff5b6a07f1d5d1fcb867e88f2
@@ -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() );
@@ -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();
@@ -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 );
}
@@ -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( "" ) );
@@ -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 );
@@ -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 ) );

@@ -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
@@ -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 )
{
@@ -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;
}

@@ -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;
}
@@ -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();

0 comments on commit 3d38565

Please sign in to comment.
You can’t perform that action at this time.