本文整理汇总了C++中qgsfieldmap::const_iterator::key方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::key方法的具体用法?C++ const_iterator::key怎么用?C++ const_iterator::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgsfieldmap::const_iterator
的用法示例。
在下文中一共展示了const_iterator::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadAttributes
void QgsAttributeTableModel::loadAttributes()
{
if ( !mLayer )
{
return;
}
bool ins = false, rm = false;
QgsAttributeList attributes;
for ( QgsFieldMap::const_iterator it = mLayer->pendingFields().constBegin(); it != mLayer->pendingFields().end(); it++ )
{
switch ( mLayer->editType( it.key() ) )
{
case QgsVectorLayer::Hidden:
continue;
case QgsVectorLayer::ValueMap:
mValueMaps.insert( it.key(), &mLayer->valueMap( it.key() ) );
break;
default:
break;
}
attributes << it.key();
}
if ( mFieldCount < attributes.size() )
{
ins = true;
beginInsertColumns( QModelIndex(), mFieldCount, attributes.size() - 1 );
}
else if ( attributes.size() < mFieldCount )
{
rm = true;
beginRemoveColumns( QModelIndex(), attributes.size(), mFieldCount - 1 );
}
mFieldCount = attributes.size();
mAttributes = attributes;
mValueMaps.clear();
if ( ins )
{
endInsertColumns();
}
else if ( rm )
{
endRemoveColumns();
}
}
示例2: addFeatureWithDefaultValue
int OptVectorLayer::addFeatureWithDefaultValue( OptFeature& f )
{
//{zhangliye2715:api}
if ( !isEditable() )
{
startEditing();
}
// add the fields to the QgsFeature
QgsVectorDataProvider* provider = dataProvider();
const QgsFieldMap fields = provider->fields();
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
f.addAttribute( it.key(), provider->defaultValue( it.key() ) );
}
int id = -1;
id = OptVectorLayer::addFeature( f );
if ( id != -1 )
{
//add points to other features to keep topology up-to-date
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
if( topologicalEditing )
{
addTopologicalPoints( f.geometry() );
}
}
else
{
return -1;
}
//vlayer->setModified(true);
//commit or rollBack the change
if ( isModified() )
{
commitChanges();
}
else
{
rollBack();
return -1;
}
//make the layer still editable for the next adding operation
startEditing();
return id;
}
示例3: loadRows
void QgsVectorLayerProperties::loadRows()
{
const QgsFieldMap &fields = layer->pendingFields();
tblAttributes->clear();
tblAttributes->setColumnCount( 8 );
tblAttributes->setRowCount( fields.size() );
tblAttributes->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "id" ) ) );
tblAttributes->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "name" ) ) );
tblAttributes->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr( "type" ) ) );
tblAttributes->setHorizontalHeaderItem( 3, new QTableWidgetItem( tr( "length" ) ) );
tblAttributes->setHorizontalHeaderItem( 4, new QTableWidgetItem( tr( "precision" ) ) );
tblAttributes->setHorizontalHeaderItem( 5, new QTableWidgetItem( tr( "comment" ) ) );
tblAttributes->setHorizontalHeaderItem( 6, new QTableWidgetItem( tr( "edit widget" ) ) );
tblAttributes->setHorizontalHeaderItem( 7, new QTableWidgetItem( tr( "values" ) ) );
tblAttributes->setSelectionBehavior( QAbstractItemView::SelectRows );
tblAttributes->setSelectionMode( QAbstractItemView::MultiSelection );
int row = 0;
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); it++, row++ )
setRow( row, it.key(), it.value() );
tblAttributes->resizeColumnsToContents();
}
示例4: initializeAliasMap
void QgsComposerAttributeTable::initializeAliasMap()
{
mFieldAliasMap.clear();
if ( mVectorLayer )
{
QgsFieldMap fieldMap = mVectorLayer->pendingFields();
QgsFieldMap::const_iterator it = fieldMap.constBegin();
for ( ; it != fieldMap.constEnd(); ++it )
{
QString currentAlias = mVectorLayer->attributeAlias( it.key() );
if ( !currentAlias.isEmpty() )
{
mFieldAliasMap.insert( it.key(), currentAlias );
}
}
}
}
示例5: attributeDisplayName
QMap<int, QString> QgsComposerAttributeTable::getHeaderLabels() const
{
QMap<int, QString> header;
if ( mVectorLayer )
{
QgsFieldMap vectorFields = mVectorLayer->pendingFields();
QgsFieldMap::const_iterator fieldIt = vectorFields.constBegin();
for ( ; fieldIt != vectorFields.constEnd(); ++fieldIt )
{
if ( mDisplayAttributes.size() > 0 && !mDisplayAttributes.contains( fieldIt.key() ) )
{
continue;
}
header.insert( fieldIt.key(), attributeDisplayName( fieldIt.key(), fieldIt.value().name() ) );
}
}
return header;
}
示例6: fieldIndexFromName
int QgsLabelDialog::fieldIndexFromName( QString name )
{
const QgsFieldMap& fields = mLabel->fields();
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
if ( it->name() == name )
return it.key();
}
return -1;
}
示例7: populateDataDefinedCombos
void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s )
{
QList<QComboBox*> comboList;
comboList << mSizeAttributeComboBox;
comboList << mColorAttributeComboBox;
comboList << mBoldAttributeComboBox;
comboList << mItalicAttributeComboBox;
comboList << mUnderlineAttributeComboBox;
comboList << mStrikeoutAttributeComboBox;
comboList << mFontFamilyAttributeComboBox;
comboList << mBufferSizeAttributeComboBox;
comboList << mBufferColorAttributeComboBox;
comboList << mXCoordinateComboBox;
comboList << mYCoordinateComboBox;
comboList << mHorizontalAlignmentComboBox;
comboList << mVerticalAlignmentComboBox;
comboList << mLabelDistanceComboBox;
comboList << mRotationComboBox;
QList<QComboBox*>::iterator comboIt = comboList.begin();
for ( ; comboIt != comboList.end(); ++comboIt )
{
( *comboIt )->addItem( "", QVariant() );
}
const QgsFieldMap& fields = mLayer->dataProvider()->fields();
for ( QgsFieldMap::const_iterator it = fields.constBegin(); it != fields.constEnd(); it++ )
{
for ( comboIt = comboList.begin(); comboIt != comboList.end(); ++comboIt )
{
( *comboIt )->addItem( it.value().name(), it.key() );
}
}
//set current combo boxes to already existing indices
setCurrentComboValue( mSizeAttributeComboBox, s, QgsPalLayerSettings::Size );
setCurrentComboValue( mColorAttributeComboBox, s, QgsPalLayerSettings::Color );
setCurrentComboValue( mBoldAttributeComboBox, s, QgsPalLayerSettings::Bold );
setCurrentComboValue( mItalicAttributeComboBox, s, QgsPalLayerSettings::Italic );
setCurrentComboValue( mUnderlineAttributeComboBox, s, QgsPalLayerSettings::Underline );
setCurrentComboValue( mStrikeoutAttributeComboBox, s, QgsPalLayerSettings::Strikeout );
setCurrentComboValue( mFontFamilyAttributeComboBox, s, QgsPalLayerSettings::Family );
setCurrentComboValue( mBufferSizeAttributeComboBox, s , QgsPalLayerSettings::BufferSize );
setCurrentComboValue( mBufferColorAttributeComboBox, s, QgsPalLayerSettings::BufferColor );
setCurrentComboValue( mXCoordinateComboBox, s, QgsPalLayerSettings::PositionX );
setCurrentComboValue( mYCoordinateComboBox, s, QgsPalLayerSettings::PositionY );
setCurrentComboValue( mHorizontalAlignmentComboBox, s, QgsPalLayerSettings::Hali );
setCurrentComboValue( mVerticalAlignmentComboBox, s, QgsPalLayerSettings::Vali );
setCurrentComboValue( mLabelDistanceComboBox, s, QgsPalLayerSettings::LabelDistance );
setCurrentComboValue( mRotationComboBox, s, QgsPalLayerSettings::Rotation );
}
示例8: populateFields
void SaQueryBuilder::populateFields()
{
for ( QgsFieldMap::const_iterator it = mLayer->pendingFields().begin(); it != mLayer->pendingFields().end(); it++ )
{
QStandardItem *myItem = new QStandardItem( it->name() );
myItem->setData( it.key() );
myItem->setEditable( false );
mModelFields->insertRow( mModelFields->rowCount(), myItem );
}
// All fields get ... setup
setupLstFieldsModel();
}
示例9: fieldNameIndex
int QgsVectorDataProvider::fieldNameIndex( const QString& fieldName ) const
{
const QgsFieldMap &theFields = fields();
for ( QgsFieldMap::const_iterator it = theFields.constBegin(); it != theFields.constEnd(); ++it )
{
if ( QString::compare( it->name(), fieldName, Qt::CaseInsensitive ) == 0 )
{
return it.key();
}
}
return -1;
}
示例10: QDialog
QgsDelAttrDialog::QgsDelAttrDialog( const QgsVectorLayer* vl ): QDialog()
{
setupUi( this );
if ( vl )
{
listBox2->clear();
const QgsFieldMap layerAttributes = vl->pendingFields();
QgsFieldMap::const_iterator attIt = layerAttributes.constBegin();
for ( ; attIt != layerAttributes.constEnd(); ++attIt )
{
QListWidgetItem* item = new QListWidgetItem( attIt.value().name(), listBox2 );
item->setData( Qt::UserRole, attIt.key() );
}
}
}
示例11: populateFields
void QgsFieldCalculator::populateFields()
{
if ( !mVectorLayer )
return;
const QgsFieldMap fieldMap = mVectorLayer->pendingFields();
QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();
for ( ; fieldIt != fieldMap.constEnd(); ++fieldIt )
{
QString fieldName = fieldIt.value().name();
//insert into field list and field combo box
mFieldMap.insert( fieldName, fieldIt.key() );
mExistingFieldComboBox->addItem( fieldName );
}
}
示例12: populateFields
void QgsSearchQueryBuilder::populateFields()
{
if ( !mLayer )
return;
QgsDebugMsg( "entering." );
QRegExp reQuote( "[A-Za-z_][A-Za-z0-9_]*" );
const QgsFieldMap& fields = mLayer->pendingFields();
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
QString fieldName = it->name();
mFieldMap[fieldName] = it.key();
if ( !reQuote.exactMatch( fieldName ) ) // quote if necessary
fieldName = QgsExpression::quotedColumnRef( fieldName );
QStandardItem *myItem = new QStandardItem( fieldName );
myItem->setEditable( false );
mModelFields->insertRow( mModelFields->rowCount(), myItem );
}
}
示例13: readFieldName
int QgsSymbol::readFieldName( QDomNode &synode, QString name, const QgsVectorLayer &vl )
{
QDomNode node = synode.namedItem( name + "name" );
if ( !node.isNull() )
{
const QgsFieldMap &fields = vl.pendingFields();
QString name = node.toElement().text();
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); it++ )
if ( it->name() == name )
return it.key();
return -1;
}
node = synode.namedItem( name );
return node.isNull() ? -1 : node.toElement().text().toInt();
}
示例14: QDialog
QgsUniqueValueDialog::QgsUniqueValueDialog( QgsVectorLayer* vl ): QDialog(), mVectorLayer( vl ), sydialog( vl, true )
{
setupUi( this );
setOrientation( Qt::Vertical );
//find out the fields of mVectorLayer
if ( mVectorLayer )
{
//we cannot use unique values for not-commited fields because QgsVectorLayer has no 'unique values' method...
QgsVectorDataProvider* provider = mVectorLayer->dataProvider();
if ( provider )
{
const QgsFieldMap & fields = provider->fields();
QString str;
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
str = ( *it ).name();
str = mVectorLayer->attributeDisplayName( it.key() );
mClassificationComboBox->addItem( str, it.key() );
}
}
}
mClassListWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
mClassListWidget->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed );
mClassListWidget->setSortingEnabled( true );
if ( mVectorLayer )
{
const QgsUniqueValueRenderer* renderer = dynamic_cast<const QgsUniqueValueRenderer *>( mVectorLayer->renderer() );
if ( renderer )
{
mClassListWidget->clear();
QString field = mVectorLayer->attributeDisplayName( renderer->classificationField() );
mOldClassificationAttribute = field;
mClassificationComboBox->setCurrentIndex( mClassificationComboBox->findText( field ) );
const QList<QgsSymbol*> list = renderer->symbols();
//fill the items of the renderer into mValues
for ( QList<QgsSymbol*>::const_iterator iter = list.begin(); iter != list.end(); ++iter )
{
QgsSymbol* symbol = *iter;
QString symbolvalue = symbol->lowerValue();
QgsSymbol* sym = new QgsSymbol( mVectorLayer->geometryType(), symbol->lowerValue(), symbol->upperValue(), symbol->label() );
sym->setPen( symbol->pen() );
sym->setCustomTexture( symbol->customTexture() );
sym->setBrush( symbol->brush() );
sym->setNamedPointSymbol( symbol->pointSymbolName() );
sym->setPointSize( symbol->pointSize() );
sym->setPointSizeUnits( symbol->pointSizeUnits() );
sym->setScaleClassificationField( symbol->scaleClassificationField() );
sym->setRotationClassificationField( symbol->rotationClassificationField() );
mValues.insert( symbolvalue, sym );
QListWidgetItem *item = new QListWidgetItem( symbolvalue );
mClassListWidget->addItem( item );
updateEntryIcon( symbol, item );
item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
item->setData( Qt::UserRole, symbol->lowerValue() );
item->setToolTip( symbol->label() );
}
}
}
mDeletePushButton->setEnabled( false );
connect( mClassifyButton, SIGNAL( clicked() ), this, SLOT( changeClassificationAttribute() ) );
connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addClass() ) );
connect( mDeletePushButton, SIGNAL( clicked() ), this, SLOT( deleteSelectedClasses() ) );
connect( mRandomizeColors, SIGNAL( clicked() ), this, SLOT( randomizeColors() ) );
connect( mResetColors, SIGNAL( clicked() ), this, SLOT( resetColors() ) );
connect( mClassListWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
connect( mCommonPropertyLock, SIGNAL( clicked() ), this, SLOT( selectionChanged() ) );
connect( mClassListWidget, SIGNAL( itemChanged( QListWidgetItem * ) ), this, SLOT( itemChanged( QListWidgetItem * ) ) );
connect( &sydialog, SIGNAL( settingsChanged() ), this, SLOT( applySymbologyChanges() ) );
mSymbolWidgetStack->addWidget( &sydialog );
mSymbolWidgetStack->setCurrentWidget( &sydialog );
}
示例15: createTableWidgetContents
void QgsMergeAttributesDialog::createTableWidgetContents()
{
//get information about attributes from vector layer
if ( !mVectorLayer )
{
return;
}
//combo box row, attributes titles, feature values and current merge results
mTableWidget->setRowCount( mFeatureList.size() + 2 );
//create combo boxes and insert attribute names
const QgsFieldMap& fieldMap = mVectorLayer->pendingFields();
int col = 0;
for ( QgsFieldMap::const_iterator fieldIt = fieldMap.constBegin();
fieldIt != fieldMap.constEnd();
++fieldIt )
{
if ( mVectorLayer->editType( fieldIt.key() ) == QgsVectorLayer::Hidden ||
mVectorLayer->editType( fieldIt.key() ) == QgsVectorLayer::Immutable )
continue;
mTableWidget->setColumnCount( col + 1 );
mTableWidget->setCellWidget( 0, col, createMergeComboBox( fieldIt->type() ) );
QTableWidgetItem *item = new QTableWidgetItem( fieldIt.value().name() );
item->setData( Qt::UserRole, fieldIt.key() );
mTableWidget->setHorizontalHeaderItem( col++, item );
}
//insert the attribute values
QStringList verticalHeaderLabels; //the id column is in the
verticalHeaderLabels << tr( "Id" );
for ( int i = 0; i < mFeatureList.size(); ++i )
{
verticalHeaderLabels << QString::number( mFeatureList[i].id() );
const QgsAttributeMap &attrs = mFeatureList[i].attributeMap();
for ( int j = 0; j < mTableWidget->columnCount(); j++ )
{
int idx = mTableWidget->horizontalHeaderItem( j )->data( Qt::UserRole ).toInt();
QTableWidgetItem* attributeValItem = new QTableWidgetItem( attrs[idx].toString() );
attributeValItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mTableWidget->setItem( i + 1, j, attributeValItem );
mTableWidget->setCellWidget( i + 1, j, QgsAttributeEditor::createAttributeEditor( mTableWidget, NULL, mVectorLayer, idx, attrs[idx] ) );
}
}
//merge
verticalHeaderLabels << tr( "Merge" );
mTableWidget->setVerticalHeaderLabels( verticalHeaderLabels );
//insert currently merged values
for ( int i = 0; i < mTableWidget->columnCount(); ++i )
{
refreshMergedValue( i );
}
}