本文整理汇总了C++中QgsVectorDataProvider::fields方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorDataProvider::fields方法的具体用法?C++ QgsVectorDataProvider::fields怎么用?C++ QgsVectorDataProvider::fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVectorDataProvider
的用法示例。
在下文中一共展示了QgsVectorDataProvider::fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_mcbLayers_selectItem
void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
{
mcbDirection->clear();
mcbSpeed->clear();
mcbDirection->insertItem( 0, tr( "Always use default" ) );
mcbSpeed->insertItem( 0, tr( "Always use default" ) );
QgsVectorLayer* vl = selectedLayer();
if ( !vl )
return;
QgsVectorDataProvider* provider = vl->dataProvider();
if ( !provider )
return;
const QgsFields& fields = provider->fields();
for ( int idx = 0; idx < fields.count(); ++idx )
{
const QgsField& currentField = fields[idx];
QVariant currentType = currentField.type();
if ( currentType == QVariant::Int || currentType == QVariant::String )
{
mcbDirection->insertItem( 1, currentField.name() );
}
if ( currentType == QVariant::Int || currentType == QVariant::Double )
{
mcbSpeed->insertItem( 1, currentField.name() );
}
}
} // RgDSettingsDlg::on_mcbLayers_selectItem()
示例2: on_mcbLayers_selectItem
void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
{
mcbDirection->clear();
mcbSpeed->clear();
mcbDirection->insertItem( 0, tr( "Always use default" ) );
mcbSpeed->insertItem( 0, tr( "Always use default" ) );
QgsVectorLayer* vl = selectedLayer();
if ( !vl )
return;
QgsVectorDataProvider* provider = vl->dataProvider();
if ( !provider )
return;
const QgsFieldMap& fields = provider->fields();
QgsFieldMap::const_iterator it;
for ( it = fields.constBegin(); it != fields.constEnd(); ++it )
{
QgsField currentField = it.value();
QVariant currentType = currentField.type();
if ( currentType == QVariant::Int || currentType == QVariant::String )
{
mcbDirection->insertItem( 1, currentField.name() );
}
if ( currentType == QVariant::Int || currentType == QVariant::Double )
{
mcbSpeed->insertItem( 1, currentField.name() );
}
}
} // RgDSettingsDlg::on_mcbLayers_selectItem()
示例3: prefixIsValid
bool QgsZonalStatisticsDialog::prefixIsValid( const QString& prefix ) const
{
QgsVectorLayer* vl = polygonLayer();
if ( !vl )
{
return false;
}
QgsVectorDataProvider* dp = vl->dataProvider();
if ( !dp )
{
return false;
}
QString currentFieldName;
Q_FOREACH ( const QgsField& field, dp->fields() )
{
currentFieldName = field.name();
if ( currentFieldName == ( prefix + "mean" ) || currentFieldName == ( prefix + "sum" ) || currentFieldName == ( prefix + "count" ) )
{
return false;
}
}
return true;
}
示例4: prefixIsValid
bool QgsZonalStatisticsDialog::prefixIsValid( const QString& prefix ) const
{
QgsVectorLayer* vl = polygonLayer();
if ( !vl )
{
return false;
}
QgsVectorDataProvider* dp = vl->dataProvider();
if ( !dp )
{
return false;
}
QgsFieldMap providerFieldMap = dp->fields();
QgsFieldMap::const_iterator it = providerFieldMap.constBegin();
QString currentFieldName;
for ( ; it != providerFieldMap.constEnd(); ++it )
{
currentFieldName = it.value().name();
if ( currentFieldName == ( prefix + "mean" ) || currentFieldName == ( prefix + "sum" ) || currentFieldName == ( prefix + "count" ) )
{
return false;
}
}
return true;
}
示例5: prefixIsValid
bool QgsZonalStatisticsDialog::prefixIsValid( const QString& prefix ) const
{
QgsVectorLayer* vl = polygonLayer();
if ( !vl )
{
return false;
}
QgsVectorDataProvider* dp = vl->dataProvider();
if ( !dp )
{
return false;
}
const QgsFields& providerFields = dp->fields();
QString currentFieldName;
for ( int idx = 0; idx < providerFields.count(); ++idx )
{
currentFieldName = providerFields[idx].name();
if ( currentFieldName == ( prefix + "mean" ) || currentFieldName == ( prefix + "sum" ) || currentFieldName == ( prefix + "count" ) )
{
return false;
}
}
return true;
}
示例6: getUniqueFieldName
QString QgsZonalStatistics::getUniqueFieldName( const QString &fieldName, const QList<QgsField> &newFields )
{
QgsVectorDataProvider *dp = mPolygonLayer->dataProvider();
if ( !dp->storageType().contains( QLatin1String( "ESRI Shapefile" ) ) )
{
return fieldName;
}
QList<QgsField> allFields = dp->fields().toList();
allFields.append( newFields );
QString shortName = fieldName.mid( 0, 10 );
bool found = false;
for ( int idx = 0; idx < allFields.count(); ++idx )
{
if ( shortName == allFields.at( idx ).name() )
{
found = true;
break;
}
}
if ( !found )
{
return shortName;
}
int n = 1;
shortName = QStringLiteral( "%1_%2" ).arg( fieldName.mid( 0, 8 ) ).arg( n );
found = true;
while ( found )
{
found = false;
for ( int idx = 0; idx < allFields.count(); ++idx )
{
if ( shortName == allFields.at( idx ).name() )
{
n += 1;
if ( n < 9 )
{
shortName = QStringLiteral( "%1_%2" ).arg( fieldName.mid( 0, 8 ) ).arg( n );
}
else
{
shortName = QStringLiteral( "%1_%2" ).arg( fieldName.mid( 0, 7 ) ).arg( n );
}
found = true;
}
}
}
return shortName;
}
示例7: getUniqueFieldName
QString QgsZonalStatistics::getUniqueFieldName( const QString& fieldName )
{
QgsVectorDataProvider* dp = mPolygonLayer->dataProvider();
if ( !dp->storageType().contains( "ESRI Shapefile" ) )
{
return fieldName;
}
const QgsFields& providerFields = dp->fields();
QString shortName = fieldName.mid( 0, 10 );
bool found = false;
for ( int idx = 0; idx < providerFields.count(); ++idx )
{
if ( shortName == providerFields[idx].name() )
{
found = true;
break;
}
}
if ( !found )
{
return shortName;
}
int n = 1;
shortName = QString( "%1_%2" ).arg( fieldName.mid( 0, 8 ) ).arg( n );
found = true;
while ( found )
{
found = false;
for ( int idx = 0; idx < providerFields.count(); ++idx )
{
if ( shortName == providerFields[idx].name() )
{
n += 1;
if ( n < 9 )
{
shortName = QString( "%1_%2" ).arg( fieldName.mid( 0, 8 ) ).arg( n );
}
else
{
shortName = QString( "%1_%2" ).arg( fieldName.mid( 0, 7 ) ).arg( n );
}
found = true;
}
}
}
return shortName;
}
示例8: 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;
}
示例9: on_mInputLayerComboBox_currentIndexChanged
void QgsInterpolationDialog::on_mInputLayerComboBox_currentIndexChanged( const QString& text )
{
Q_UNUSED( text );
mInterpolationAttributeComboBox->clear();
mUseZCoordCheckBox->setEnabled( false );
//get current vector layer
QString currentComboText = mInputLayerComboBox->currentText();
QgsVectorLayer* theVectorLayer = vectorLayerFromName( currentComboText );
if ( !theVectorLayer )
{
return;
}
QgsVectorDataProvider* provider = theVectorLayer->dataProvider();
if ( !provider )
{
return;
}
//find out if the layer has 25D type
QGis::WkbType geomType = provider->geometryType();
if ( geomType == QGis::WKBPoint25D ||
geomType == QGis::WKBLineString25D ||
geomType == QGis::WKBPolygon25D ||
geomType == QGis::WKBMultiPoint25D ||
geomType == QGis::WKBMultiLineString25D ||
geomType == QGis::WKBMultiPolygon25D )
{
mUseZCoordCheckBox->setEnabled( true );
}
//insert numeric attributes of layer into mInterpolationAttributesComboBox
const QgsFields& fields = provider->fields();
for ( int idx = 0; idx < fields.count(); ++idx )
{
const QgsField& currentField = fields[idx];
QVariant::Type currentType = currentField.type();
if ( currentType == QVariant::Int || currentType == QVariant::Double )
{
mInterpolationAttributeComboBox->insertItem( 0, currentField.name() );
}
}
}
示例10: QDialog
QgsAddJoinDialog::QgsAddJoinDialog( QgsVectorLayer* layer, QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f ), mLayer( layer )
{
setupUi( this );
if ( !mLayer )
{
return;
}
//insert possible vector layers into mJoinLayerComboBox
mJoinLayerComboBox->blockSignals( true );
const QMap<QString, QgsMapLayer*>& layerList = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::const_iterator layerIt = layerList.constBegin();
for ( ; layerIt != layerList.constEnd(); ++layerIt )
{
QgsMapLayer* currentLayer = layerIt.value();
if ( currentLayer->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* currentVectorLayer = dynamic_cast<QgsVectorLayer*>( currentLayer );
if ( currentVectorLayer && currentVectorLayer != mLayer )
{
if ( currentVectorLayer->dataProvider() && currentVectorLayer->dataProvider()->supportsSubsetString() )
mJoinLayerComboBox->addItem( currentLayer->name(), QVariant( currentLayer->id() ) );
}
}
}
mJoinLayerComboBox->blockSignals( false );
on_mJoinLayerComboBox_currentIndexChanged( mJoinLayerComboBox->currentIndex() );
//insert possible target fields
QgsVectorDataProvider* provider = mLayer->dataProvider();
if ( provider )
{
const QgsFields& layerFields = provider->fields();
for ( int idx = 0; idx < layerFields.count(); ++idx )
{
mTargetFieldComboBox->addItem( layerFields[idx].name(), idx );
}
}
mCacheInMemoryCheckBox->setChecked( true );
}
示例11: 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 );
}
示例12: intersection
bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* layerB,
const QString& shapefileName, bool onlySelectedFeatures,
QProgressDialog* p )
{
if ( !layerA && !layerB )
{
return false;
}
QgsVectorDataProvider* dpA = layerA->dataProvider();
QgsVectorDataProvider* dpB = layerB->dataProvider();
if ( !dpA && !dpB )
{
return false;
}
QGis::WkbType outputType = dpA->geometryType();
const QgsCoordinateReferenceSystem crs = layerA->srs();
QgsFieldMap fieldsA = dpA->fields();
QgsFieldMap fieldsB = dpB->fields();
combineFieldLists( fieldsA, fieldsB );
QgsVectorFileWriter vWriter( shapefileName, dpA->encoding(), fieldsA, outputType, &crs );
QgsFeature currentFeature;
QgsSpatialIndex index;
//take only selection
if ( onlySelectedFeatures )
{
const QgsFeatureIds selectionB = layerB->selectedFeaturesIds();
QgsFeatureIds::const_iterator it = selectionB.constBegin();
for ( ; it != selectionB.constEnd(); ++it )
{
if ( !layerB->featureAtId( *it, currentFeature, true, true ) )
{
continue;
}
index.insertFeature( currentFeature );
}
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selectionA = layerA->selectedFeaturesIds();
if ( p )
{
p->setMaximum( selectionA.size() );
}
QgsFeature currentFeature;
int processedFeatures = 0;
it = selectionA.constBegin();
for ( ; it != selectionA.constEnd(); ++it )
{
if ( p )
{
p->setValue( processedFeatures );
}
if ( p && p->wasCanceled() )
{
break;
}
if ( !layerA->featureAtId( *it, currentFeature, true, true ) )
{
continue;
}
intersectFeature( currentFeature, &vWriter, layerB, &index );
++processedFeatures;
}
if ( p )
{
p->setValue( selectionA.size() );
}
}
//take all features
else
{
layerB->select( layerB->pendingAllAttributesList(), QgsRectangle(), true, false );
while ( layerB->nextFeature( currentFeature ) )
{
index.insertFeature( currentFeature );
}
QgsFeature currentFeature;
layerA->select( layerA->pendingAllAttributesList(), QgsRectangle(), true, false );
int featureCount = layerA->featureCount();
if ( p )
{
p->setMaximum( featureCount );
}
int processedFeatures = 0;
while ( layerA->nextFeature( currentFeature ) )
{
if ( p )
{
p->setValue( processedFeatures );
}
if ( p && p->wasCanceled() )
{
break;
}
//.........这里部分代码省略.........
示例13: simplify
bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer,
const QString& shapefileName,
double tolerance,
bool onlySelectedFeatures,
QProgressDialog *p )
{
if ( !layer )
{
return false;
}
QgsVectorDataProvider* dp = layer->dataProvider();
if ( !dp )
{
return false;
}
QGis::WkbType outputType = dp->geometryType();
const QgsCoordinateReferenceSystem crs = layer->crs();
QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), dp->fields(), outputType, &crs );
QgsFeature currentFeature;
//take only selection
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
if ( p )
{
p->setMaximum( selection.size() );
}
int processedFeatures = 0;
QgsFeatureIds::const_iterator it = selection.constBegin();
for ( ; it != selection.constEnd(); ++it )
{
if ( p )
{
p->setValue( processedFeatures );
}
if ( p && p->wasCanceled() )
{
break;
}
if ( !layer->featureAtId( *it, currentFeature, true, true ) )
{
continue;
}
simplifyFeature( currentFeature, &vWriter, tolerance );
++processedFeatures;
}
if ( p )
{
p->setValue( selection.size() );
}
}
//take all features
else
{
layer->select( layer->pendingAllAttributesList(), QgsRectangle(), true, false );
int featureCount = layer->featureCount();
if ( p )
{
p->setMaximum( featureCount );
}
int processedFeatures = 0;
while ( layer->nextFeature( currentFeature ) )
{
if ( p )
{
p->setValue( processedFeatures );
}
if ( p && p->wasCanceled() )
{
break;
}
simplifyFeature( currentFeature, &vWriter, tolerance );
++processedFeatures;
}
if ( p )
{
p->setValue( featureCount );
}
}
return true;
}
示例14: createTransactionDocument
//.........这里部分代码省略.........
}
actionElem = upNodeList.at( j ).toElement();
// Get the Feature Ids for this filter on the layer
QDomElement filterElem = actionElem.elementsByTagName( QStringLiteral( "Filter" ) ).at( 0 ).toElement();
QgsFeatureIds fids = getFeatureIdsFromFilter( filterElem, layer );
// Loop through the property elements
// Store properties and the geometry element
QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral( "Property" ) );
QMap<QString, QString> propertyMap;
QDomElement propertyElem;
QDomElement nameElem;
QDomElement valueElem;
QDomElement geometryElem;
for ( int l = 0; l < propertyNodeList.count(); ++l )
{
propertyElem = propertyNodeList.at( l ).toElement();
nameElem = propertyElem.elementsByTagName( QStringLiteral( "Name" ) ).at( 0 ).toElement();
valueElem = propertyElem.elementsByTagName( QStringLiteral( "Value" ) ).at( 0 ).toElement();
if ( nameElem.text() != QLatin1String( "geometry" ) )
{
propertyMap.insert( nameElem.text(), valueElem.text() );
}
else
{
geometryElem = valueElem;
}
}
// Update the features
QgsFields fields = provider->fields();
QMap<QString, int> fieldMap = provider->fieldNameMap();
QMap<QString, int>::const_iterator fieldMapIt;
QString fieldName;
bool conversionSuccess;
QgsFeatureIds::const_iterator fidIt = fids.constBegin();
for ( ; fidIt != fids.constEnd(); ++fidIt )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest( *fidIt ) );
QgsFeature feature;
while ( fit.nextFeature( feature ) )
{
if ( !accessControl->allowToEdit( layer, feature ) )
{
throw QgsSecurityAccessException( QStringLiteral( "Feature modify permission denied" ) );
}
}
#endif
QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
for ( ; it != propertyMap.constEnd(); ++it )
{
fieldName = it.key();
fieldMapIt = fieldMap.find( fieldName );
if ( fieldMapIt == fieldMap.constEnd() )
{
continue;
}
QgsField field = fields.at( fieldMapIt.value() );
if ( field.type() == 2 )
layer->changeAttributeValue( *fidIt, fieldMapIt.value(), it.value().toInt( &conversionSuccess ) );
示例15: refreshMarkers
void QgsSingleSymbolDialog::refreshMarkers()
{
QgsMarkerListModel *m = new QgsMarkerListModel( lstSymbols );
lstSymbols->setModel( m );
connect( lstSymbols->selectionModel(), SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
this, SLOT( symbolChanged( const QModelIndex &, const QModelIndex & ) ) );
// Find out the numerical fields of mVectorLayer, and populate the ComboBoxes
QgsVectorDataProvider *provider = mVectorLayer->dataProvider();
if ( provider )
{
const QgsFieldMap & fields = provider->fields();
QString str;
mRotationClassificationComboBox->addItem( DO_NOT_USE_STR, -1 );
mScaleClassificationComboBox->addItem( DO_NOT_USE_STR, -1 );
mSymbolComboBox->addItem( DO_NOT_USE_STR, -1 );
for ( QgsFieldMap::const_iterator it = fields.begin();
it != fields.end();
++it )
{
QVariant::Type type = ( *it ).type();
if ( type == QVariant::Int || type == QVariant::Double )
{
mRotationClassificationComboBox->addItem( it->name(), it.key() );
mScaleClassificationComboBox->addItem( it->name(), it.key() );
}
else if ( type == QVariant::String )
{
mSymbolComboBox->addItem( it->name(), it.key() );
}
}
}
else
{
QgsDebugMsg( "Warning, data provider is null" );
return;
}
//
//set outline / line style
//
cboOutlineStyle->addItem( QIcon( QgsSymbologyUtils::char2LinePixmap( "SolidLine" ) ), "", "SolidLine" );
cboOutlineStyle->addItem( QIcon( QgsSymbologyUtils::char2LinePixmap( "NoPen" ) ), tr( "None" ), "NoPen" );
cboOutlineStyle->addItem( QIcon( QgsSymbologyUtils::char2LinePixmap( "DashLine" ) ), "", "DashLine" );
cboOutlineStyle->addItem( QIcon( QgsSymbologyUtils::char2LinePixmap( "DotLine" ) ), "", "DotLine" );
cboOutlineStyle->addItem( QIcon( QgsSymbologyUtils::char2LinePixmap( "DashDotLine" ) ), "" , "DashDotLine" );
cboOutlineStyle->addItem( QIcon( QgsSymbologyUtils::char2LinePixmap( "DashDotDotLine" ) ), "", "DashDotDotLine" );
//
//set pattern icons and state
//
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "SolidPattern" ) ), "", "SolidPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "NoBrush" ) ), tr( "None" ), "NoBrush" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "HorPattern" ) ), "", "HorPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "VerPattern" ) ), "", "VerPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "CrossPattern" ) ), "", "CrossPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "BDiagPattern" ) ), "", "BDiagPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "FDiagPattern" ) ), "", "FDiagPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "DiagCrossPattern" ) ), "", "DiagCrossPattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense1Pattern" ) ), "", "Dense1Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense2Pattern" ) ), "", "Dense2Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense3Pattern" ) ), "", "Dense3Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense4Pattern" ) ), "", "Dense4Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense5Pattern" ) ), "", "Dense5Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense6Pattern" ) ), "", "Dense6Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "Dense7Pattern" ) ), "", "Dense7Pattern" );
cboFillStyle->addItem( QIcon( QgsSymbologyUtils::char2PatternPixmap( "TexturePattern" ) ), tr( "Texture" ), "TexturePattern" );
if ( mVectorLayer && mVectorLayer->geometryType() != QGis::Point )
{
mGroupPoint->setVisible( false );
mGroupPoint->setEnabled( false );
mGroupDrawingByField->setVisible( false );
mGroupDrawingByField->setEnabled( false );
}
if ( mDisabled )
{
unset();
}
else
{
if ( mVectorLayer )
{
const QgsSingleSymbolRenderer *renderer = dynamic_cast<const QgsSingleSymbolRenderer *>( mVectorLayer->renderer() );
if ( renderer )
{
// Set from the existing renderer
set( renderer->symbols().first() );
}
else
{
// Take values from an example instance
QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->geometryType() );
set( exampleRenderer.symbols().first() );
}
}
else
//.........这里部分代码省略.........