本文整理汇总了C++中qgschangedattributesmap::const_iterator::value方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::value方法的具体用法?C++ const_iterator::value怎么用?C++ const_iterator::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgschangedattributesmap::const_iterator
的用法示例。
在下文中一共展示了const_iterator::value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeAttributeValues
bool QgsMemoryProvider::changeAttributeValues( const QgsChangedAttributesMap & attr_map )
{
for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
QgsFeatureMap::iterator fit = mFeatures.find( it.key() );
if ( fit == mFeatures.end() )
continue;
const QgsAttributeMap& attrs = it.value();
for ( QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2 )
fit->changeAttribute( it2.key(), it2.value() );
}
return TRUE;
}
示例2: QgsVectorLayerUndoCommand
QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute( QgsVectorLayerEditBuffer* buffer, int fieldIndex )
: QgsVectorLayerUndoCommand( buffer )
, mFieldIndex( fieldIndex )
{
const QgsFields& fields = layer()->fields();
QgsFields::FieldOrigin origin = fields.fieldOrigin( mFieldIndex );
mOriginIndex = fields.fieldOriginIndex( mFieldIndex );
mProviderField = ( origin == QgsFields::OriginProvider );
mFieldName = fields.field( mFieldIndex ).name();
mOldEditorWidgetConfig = mBuffer->L->editFormConfig().widgetConfig( mFieldName );
if ( !mProviderField )
{
// need to store the field definition
mOldField = mBuffer->mAddedAttributes[mOriginIndex];
}
if ( mBuffer->mRenamedAttributes.contains( fieldIndex ) )
{
mOldName = mBuffer->mRenamedAttributes.value( fieldIndex );
}
// save values of new features
for ( QgsFeatureMap::const_iterator it = mBuffer->mAddedFeatures.constBegin(); it != mBuffer->mAddedFeatures.constEnd(); ++it )
{
const QgsFeature& f = it.value();
mDeletedValues.insert( f.id(), f.attribute( mFieldIndex ) );
}
// save changed values
for ( QgsChangedAttributesMap::const_iterator it = mBuffer->mChangedAttributeValues.constBegin(); it != mBuffer->mChangedAttributeValues.constEnd(); ++it )
{
const QgsAttributeMap& attrs = it.value();
if ( attrs.contains( mFieldIndex ) )
mDeletedValues.insert( it.key(), attrs[mFieldIndex] );
}
}
示例3: committedAttributeValuesChanges
void QgsOfflineEditing::committedAttributeValuesChanges( const QString& qgisLayerId, const QgsChangedAttributesMap& changedAttrsMap )
{
sqlite3* db = openLoggingDb();
if ( db == NULL )
{
return;
}
// insert log
int layerId = getOrCreateLayerId( db, qgisLayerId );
int commitNo = getCommitNo( db );
for ( QgsChangedAttributesMap::const_iterator cit = changedAttrsMap.begin(); cit != changedAttrsMap.end(); ++cit )
{
QgsFeatureId fid = cit.key();
if ( isAddedFeature( db, layerId, fid ) )
{
// skip added features
continue;
}
QgsAttributeMap attrMap = cit.value();
for ( QgsAttributeMap::const_iterator it = attrMap.begin(); it != attrMap.end(); ++it )
{
QString sql = QString( "INSERT INTO 'log_feature_updates' VALUES ( %1, %2, %3, %4, '%5' )" )
.arg( layerId )
.arg( commitNo )
.arg( fid )
.arg( it.key() ) // attr
.arg( it.value().toString() ); // value
sqlExec( db, sql );
}
}
increaseCommitNo( db );
sqlite3_close( db );
}
示例4: changeAttributeValues
bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_map )
{
//find out typename from uri and strip namespace prefix
QString tname = mShared->mURI.typeName();
if ( tname.isNull() )
{
return false;
}
//create <Transaction> xml
QDomDocument transactionDoc;
QDomElement transactionElem = createTransactionElement( transactionDoc );
transactionDoc.appendChild( transactionElem );
QgsChangedAttributesMap::const_iterator attIt = attr_map.constBegin();
for ( ; attIt != attr_map.constEnd(); ++attIt )
{
QString gmlid = mShared->findGmlId( attIt.key() );
if ( gmlid.isEmpty() )
{
QgsDebugMsg( QString( "Cannot identify feature of id %1" ).arg( attIt.key() ) );
continue;
}
QDomElement updateElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Update" );
updateElem.setAttribute( "typeName", tname );
QgsAttributeMap::const_iterator attMapIt = attIt.value().constBegin();
for ( ; attMapIt != attIt.value().constEnd(); ++attMapIt )
{
QString fieldName = mShared->mFields.at( attMapIt.key() ).name();
QDomElement propertyElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Property" );
QDomElement nameElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Name" );
QDomText nameText = transactionDoc.createTextNode( fieldName );
nameElem.appendChild( nameText );
propertyElem.appendChild( nameElem );
QDomElement valueElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Value" );
QDomText valueText = transactionDoc.createTextNode( attMapIt.value().toString() );
valueElem.appendChild( valueText );
propertyElem.appendChild( valueElem );
updateElem.appendChild( propertyElem );
}
//Filter
QDomElement filterElem = transactionDoc.createElementNS( QgsWFSConstants::OGC_NAMESPACE, "Filter" );
QDomElement featureIdElem = transactionDoc.createElementNS( QgsWFSConstants::OGC_NAMESPACE, "FeatureId" );
featureIdElem.setAttribute( "fid", gmlid );
filterElem.appendChild( featureIdElem );
updateElem.appendChild( filterElem );
transactionElem.appendChild( updateElem );
}
QDomDocument serverResponse;
bool success = sendTransactionDocument( transactionDoc, serverResponse );
if ( !success )
{
return false;
}
if ( transactionSuccess( serverResponse ) )
{
mShared->changeAttributeValues( attr_map );
return true;
}
else
{
handleException( serverResponse );
return false;
}
}
示例5: if
bool QgsDb2Provider::changeAttributeValues( const QgsChangedAttributesMap &attr_map )
{
QgsDebugMsg( "Entering" );
if ( attr_map.isEmpty() )
return true;
if ( mFidColName.isEmpty() )
return false;
for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
QgsFeatureId fid = it.key();
// skip added features
if ( FID_IS_NEW( fid ) )
continue;
const QgsAttributeMap& attrs = it.value();
if ( attrs.isEmpty() )
continue;
QString statement = QString( "UPDATE %1.%2 SET " ).arg( mSchemaName, mTableName );
bool first = true;
if ( !mDatabase.isOpen() )
{
QString errMsg;
mDatabase = getDatabase( mConnInfo, errMsg );
if ( !errMsg.isEmpty() )
{
return false;
}
}
QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );
for ( QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2 )
{
QgsField fld = mAttributeFields.at( it2.key() );
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
continue; // skip identity field
if ( fld.name().isEmpty() )
continue; // invalid
if ( !first )
statement += ',';
else
first = false;
statement += QString( "%1=?" ).arg( fld.name() );
}
if ( first )
return true; // no fields have been changed
// set attribute filter
statement += QString( " WHERE %1=%2" ).arg( mFidColName, FID_TO_STRING( fid ) );
// use prepared statement to prevent from sql injection
if ( !query.prepare( statement ) )
{
QgsDebugMsg( query.lastError().text() );
return false;
}
QgsDebugMsg( statement );
for ( QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2 )
{
QgsField fld = mAttributeFields.at( it2.key() );
if ( fld.name().isEmpty() )
continue; // invalid
QVariant::Type type = fld.type();
if ( it2->isNull() || !it2->isValid() )
{
// binding null values
if ( type == QVariant::Date || type == QVariant::DateTime )
query.addBindValue( QVariant( QVariant::String ) );
else
query.addBindValue( QVariant( type ) );
}
else if ( type == QVariant::Int )
{
// binding an INTEGER value
query.addBindValue( it2->toInt() );
}
else if ( type == QVariant::Double )
{
// binding a DOUBLE value
query.addBindValue( it2->toDouble() );
}
else if ( type == QVariant::String )
{
// binding a TEXT value
query.addBindValue( it2->toString() );
}
else if ( type == QVariant::DateTime )
{
//.........这里部分代码省略.........