本文整理汇总了C++中qgsfieldmap::const_iterator::type方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::type方法的具体用法?C++ const_iterator::type怎么用?C++ const_iterator::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgsfieldmap::const_iterator
的用法示例。
在下文中一共展示了const_iterator::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillMinMaxCache
void QgsVectorDataProvider::fillMinMaxCache()
{
if ( !mCacheMinMaxDirty )
return;
const QgsFieldMap& flds = fields();
for ( QgsFieldMap::const_iterator it = flds.begin(); it != flds.end(); ++it )
{
if ( it->type() == QVariant::Int )
{
mCacheMinValues[it.key()] = QVariant( INT_MAX );
mCacheMaxValues[it.key()] = QVariant( INT_MIN );
}
else if ( it->type() == QVariant::Double )
{
mCacheMinValues[it.key()] = QVariant( DBL_MAX );
mCacheMaxValues[it.key()] = QVariant( -DBL_MAX );
}
else
{
mCacheMinValues[it.key()] = QVariant();
mCacheMaxValues[it.key()] = QVariant();
}
}
QgsFeature f;
QgsAttributeList keys = mCacheMinValues.keys();
select( keys, QgsRectangle(), false );
while ( nextFeature( f ) )
{
QgsAttributeMap attrMap = f.attributeMap();
for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it )
{
const QVariant& varValue = attrMap[*it];
if ( flds[*it].type() == QVariant::Int )
{
int value = varValue.toInt();
if ( value < mCacheMinValues[*it].toInt() )
mCacheMinValues[*it] = value;
if ( value > mCacheMaxValues[*it].toInt() )
mCacheMaxValues[*it] = value;
}
else if ( flds[*it].type() == QVariant::Double )
{
double value = varValue.toDouble();
if ( value < mCacheMinValues[*it].toDouble() )
mCacheMinValues[*it] = value;
if ( value > mCacheMaxValues[*it].toDouble() )
mCacheMaxValues[*it] = value;
}
else
{
QString value = varValue.toString();
if ( mCacheMinValues[*it].isNull() || value < mCacheMinValues[*it].toString() )
{
mCacheMinValues[*it] = value;
}
if ( mCacheMaxValues[*it].isNull() || value > mCacheMaxValues[*it].toString() )
{
mCacheMaxValues[*it] = value;
}
}
}
}
mCacheMinMaxDirty = false;
}
示例2: 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 );
}
}