Skip to content
Permalink
Browse files

Add `QgsVectorLayer::fields()` as alias to `pendingFields()`

pendingFields() is not very intuitive and leads to confusion for new developers.
  • Loading branch information
m-kuhn committed Aug 4, 2015
1 parent c27f357 commit e832b2a28a660f6e1f25cafe45e26020ef9d05ee
Showing with 304 additions and 294 deletions.
  1. +10 −1 python/core/qgsvectorlayer.sip
  2. +6 −6 src/analysis/vector/qgsgeometryanalyzer.cpp
  3. +2 −2 src/analysis/vector/qgsoverlayanalyzer.cpp
  4. +1 −1 src/analysis/vector/qgspointsample.cpp
  5. +3 −3 src/analysis/vector/qgstransectsample.cpp
  6. +3 −3 src/app/qgisapp.cpp
  7. +4 −4 src/app/qgsattributetabledialog.cpp
  8. +3 −3 src/app/qgsattributetypedialog.cpp
  9. +1 −1 src/app/qgsclipboard.cpp
  10. +2 −2 src/app/qgsdelattrdialog.cpp
  11. +5 −5 src/app/qgsdiagramproperties.cpp
  12. +4 −4 src/app/qgsdxfexportdialog.cpp
  13. +2 −2 src/app/qgsfeatureaction.cpp
  14. +5 −5 src/app/qgsfieldcalculator.cpp
  15. +9 −9 src/app/qgsfieldsproperties.cpp
  16. +8 −8 src/app/qgsidentifyresultsdialog.cpp
  17. +1 −1 src/app/qgsjoindialog.cpp
  18. +2 −2 src/app/qgslabelpropertydialog.cpp
  19. +2 −2 src/app/qgsmaptooladdfeature.cpp
  20. +1 −1 src/app/qgsmaptoolfillring.cpp
  21. +2 −2 src/app/qgsmaptooloffsetcurve.cpp
  22. +1 −1 src/app/qgsmaptoolrotatepointsymbols.cpp
  23. +2 −2 src/app/qgsmaptoolselectutils.cpp
  24. +7 −7 src/app/qgsmergeattributesdialog.cpp
  25. +9 −9 src/app/qgsvectorlayerproperties.cpp
  26. +5 −5 src/core/composer/qgsatlascomposition.cpp
  27. +5 −5 src/core/composer/qgscomposerattributetable.cpp
  28. +4 −4 src/core/composer/qgscomposerattributetablev2.cpp
  29. +5 −5 src/core/composer/qgscomposition.cpp
  30. +1 −1 src/core/composer/qgscomposition.h
  31. +6 −6 src/core/dxf/qgsdxfexport.cpp
  32. +2 −2 src/core/qgsattributeaction.cpp
  33. +2 −2 src/core/qgsdatadefined.cpp
  34. +1 −1 src/core/qgsexpression.cpp
  35. +1 −1 src/core/qgslegacyhelpers.cpp
  36. +1 −1 src/core/qgsmaphittest.cpp
  37. +2 −2 src/core/qgsofflineediting.cpp
  38. +10 −12 src/core/qgspallabeling.cpp
  39. +1 −1 src/core/qgspallabeling.h
  40. +5 −5 src/core/qgsrelation.cpp
  41. +2 −2 src/core/qgsvectorfilewriter.cpp
  42. +29 −35 src/core/qgsvectorlayer.cpp
  43. +10 −1 src/core/qgsvectorlayer.h
  44. +9 −9 src/core/qgsvectorlayereditbuffer.cpp
  45. +4 −4 src/core/qgsvectorlayerfeatureiterator.cpp
  46. +1 −1 src/core/qgsvectorlayerimport.cpp
  47. +4 −4 src/core/qgsvectorlayerjoinbuffer.cpp
  48. +1 −1 src/core/qgsvectorlayerrenderer.cpp
  49. +3 −3 src/core/qgsvectorlayerundocommand.cpp
  50. +1 −1 src/core/symbology-ng/qgsrendererv2.cpp
  51. +1 −1 src/gui/attributetable/qgsattributetablefiltermodel.cpp
  52. +4 −4 src/gui/attributetable/qgsattributetablemodel.cpp
  53. +1 −1 src/gui/attributetable/qgsdualview.cpp
  54. +1 −1 src/gui/attributetable/qgsfeaturelistmodel.cpp
  55. +1 −1 src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp
  56. +2 −2 src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
  57. +2 −2 src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
  58. +2 −2 src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp
  59. +3 −3 src/gui/editorwidgets/qgsrangeconfigdlg.cpp
  60. +1 −1 src/gui/editorwidgets/qgsrangewidgetfactory.cpp
  61. +4 −4 src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
  62. +1 −1 src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp
  63. +5 −5 src/gui/editorwidgets/qgsrelationreferencewidget.cpp
  64. +2 −2 src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.cpp
  65. +1 −1 src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
  66. +7 −7 src/gui/qgsattributeform.cpp
  67. +1 −1 src/gui/qgsdatadefinedbutton.cpp
  68. +2 −2 src/gui/qgsexpressionbuilderwidget.cpp
  69. +4 −4 src/gui/qgsexpressionselectiondialog.cpp
  70. +2 −2 src/gui/qgsfieldexpressionwidget.cpp
  71. +4 −4 src/gui/qgsfieldmodel.cpp
  72. +1 −1 src/gui/qgsformannotationitem.cpp
  73. +1 −1 src/gui/qgshighlight.cpp
  74. +1 −1 src/gui/qgsmaptoolidentify.cpp
  75. +2 −2 src/gui/qgsquerybuilder.cpp
  76. +1 −1 src/gui/qgsrelationadddlg.cpp
  77. +2 −2 src/gui/qgsrelationeditorwidget.cpp
  78. +3 −3 src/gui/qgssearchquerybuilder.cpp
  79. +1 −1 src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
  80. +1 −1 src/gui/symbology-ng/qgsdatadefinedsymboldialog.cpp
  81. +1 −1 src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp
  82. +1 −1 src/gui/symbology-ng/qgsrendererv2widget.cpp
  83. +2 −2 src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
  84. +2 −2 src/gui/symbology-ng/qgssizescalewidget.cpp
  85. +1 −1 src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp
  86. +3 −3 src/plugins/heatmap/heatmapgui.cpp
  87. +1 −1 src/plugins/roadgraph/shortestpathwidget.cpp
  88. +1 −1 tests/src/core/testqgsrulebasedrenderer.cpp
  89. +2 −2 tests/src/core/testqgsvectorlayercache.cpp
  90. +16 −16 tests/src/core/testqgsvectorlayerjoinbuffer.cpp
@@ -807,7 +807,16 @@ class QgsVectorLayer : QgsMapLayer
*
* @return A list of fields
*/
const QgsFields &pendingFields() const;
const QgsFields fields() const;

/**
* Returns the list of fields of this layer.
* This also includes fields which have not yet been saved to the provider.
* Alias for {@link fields()}
*
* @return A list of fields
*/
const QgsFields pendingFields() const;

/** Returns list of attributes */
QList<int> pendingAllAttributesList();
@@ -47,7 +47,7 @@ bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer,
QGis::WkbType outputType = dp->geometryType();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->pendingFields(), outputType, &crs );
QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->fields(), outputType, &crs );
QgsFeature currentFeature;

//take only selection
@@ -163,7 +163,7 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
QGis::WkbType outputType = QGis::WKBPoint;
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->pendingFields(), outputType, &crs );
QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->fields(), outputType, &crs );
QgsFeature currentFeature;

//take only selection
@@ -622,7 +622,7 @@ bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapef
QGis::WkbType outputType = dp->geometryType();
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->pendingFields(), outputType, &crs );
QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->fields(), outputType, &crs );
QgsFeature currentFeature;
QMultiMap<QString, QgsFeatureId> map;

@@ -775,7 +775,7 @@ bool QgsGeometryAnalyzer::buffer( QgsVectorLayer* layer, const QString& shapefil
}
const QgsCoordinateReferenceSystem crs = layer->crs();

QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->pendingFields(), outputType, &crs );
QgsVectorFileWriter vWriter( shapefileName, dp->encoding(), layer->fields(), outputType, &crs );
QgsFeature currentFeature;
QgsGeometry *dissolveGeometry = 0; //dissolve geometry (if dissolve enabled)

@@ -946,14 +946,14 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
}
fileWriter = new QgsVectorFileWriter( outputLayer,
eventLayer->dataProvider()->encoding(),
eventLayer->pendingFields(),
eventLayer->fields(),
memoryProviderType,
&( lineLayer->crs() ),
outputFormat );
}
else
{
memoryProvider->addAttributes( eventLayer->pendingFields().toList() );
memoryProvider->addAttributes( eventLayer->fields().toList() );
}

//iterate over eventLayer and write new features to output file or layer
@@ -45,8 +45,8 @@ bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* l

QGis::WkbType outputType = dpA->geometryType();
const QgsCoordinateReferenceSystem crs = layerA->crs();
QgsFields fieldsA = layerA->pendingFields();
QgsFields fieldsB = layerB->pendingFields();
QgsFields fieldsA = layerA->fields();
QgsFields fieldsB = layerB->fields();
combineFieldLists( fieldsA, fieldsB );

QgsVectorFileWriter vWriter( shapefileName, dpA->encoding(), fieldsA, outputType, &crs );
@@ -67,7 +67,7 @@ int QgsPointSample::createRandomPoints( QProgressDialog* pd )
mNCreatedPoints = 0;

QgsFeatureIterator fIt = mInputLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes(
QStringList() << mNumberOfPointsAttribute << mMinDistanceAttribute, mInputLayer->pendingFields() ) );
QStringList() << mNumberOfPointsAttribute << mMinDistanceAttribute, mInputLayer->fields() ) );
while ( fIt.nextFeature( fet ) )
{
nPoints = fet.attribute( mNumberOfPointsAttribute ).toInt();
@@ -55,7 +55,7 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
QVariant::Type stratumIdType = QVariant::Int;
if ( !mStrataIdAttribute.isEmpty() )
{
stratumIdType = mStrataLayer->pendingFields().field( mStrataIdAttribute ).type();
stratumIdType = mStrataLayer->fields().field( mStrataIdAttribute ).type();
}

//create vector file writers for output
@@ -118,7 +118,7 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
mt_srand( QTime::currentTime().msec() );

QgsFeatureRequest fr;
fr.setSubsetOfAttributes( QStringList() << mStrataIdAttribute << mMinDistanceAttribute << mNPointsAttribute, mStrataLayer->pendingFields() );
fr.setSubsetOfAttributes( QStringList() << mStrataIdAttribute << mMinDistanceAttribute << mNPointsAttribute, mStrataLayer->fields() );
QgsFeatureIterator strataIt = mStrataLayer->getFeatures( fr );

QgsFeature fet;
@@ -333,7 +333,7 @@ QgsGeometry* QgsTransectSample::findBaselineGeometry( QVariant strataId )
return 0;
}

QgsFeatureIterator baseLineIt = mBaselineLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QStringList( mBaselineStrataId ), mBaselineLayer->pendingFields() ) );
QgsFeatureIterator baseLineIt = mBaselineLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QStringList( mBaselineStrataId ), mBaselineLayer->fields() ) );
QgsFeature fet;

while ( baseLineIt.nextFeature( fet ) ) //todo: cache this in case there are many baslines
@@ -6275,11 +6275,11 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
QgsFeatureList features;
if ( mMapCanvas->mapSettings().hasCrsTransformEnabled() )
{
features = clipboard()->transformedCopyOf( pasteVectorLayer->crs(), pasteVectorLayer->pendingFields() );
features = clipboard()->transformedCopyOf( pasteVectorLayer->crs(), pasteVectorLayer->fields() );
}
else
{
features = clipboard()->copyOf( pasteVectorLayer->pendingFields() );
features = clipboard()->copyOf( pasteVectorLayer->fields() );
}
int nTotalFeatures = features.count();

@@ -6295,7 +6295,7 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
remap.insert( idx, dst );
}

int dstAttrCount = pasteVectorLayer->pendingFields().count();
int dstAttrCount = pasteVectorLayer->fields().count();

QgsFeatureList::iterator featureIt = features.begin();
while ( featureIt != features.end() )
@@ -307,7 +307,7 @@ void QgsAttributeTableDialog::columnBoxInit()
mFilterButton->addAction( mActionFilterColumnsMenu );
mFilterButton->addAction( mActionAdvancedFilter );

QList<QgsField> fields = mLayer->pendingFields().toList();
QList<QgsField> fields = mLayer->fields().toList();

foreach ( const QgsField field, fields )
{
@@ -364,7 +364,7 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer* layer, QStrin

int rownum = 1;

const QgsField &fld = layer->pendingFields()[ fieldindex ];
const QgsField &fld = layer->fields()[ fieldindex ];

//go through all the features and change the new attributes
QgsFeatureIterator fit = layer->getFeatures( request );
@@ -762,7 +762,7 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )
return;
}

if ( ! filterExpression.prepare( mLayer->pendingFields() ) )
if ( ! filterExpression.prepare( mLayer->fields() ) )
{
QgisApp::instance()->messageBar()->pushMessage( tr( "Evaluation error" ), filterExpression.evalErrorString(), QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
}
@@ -773,7 +773,7 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )

filterExpression.setGeomCalculator( myDa );
QgsFeatureRequest request( mMainView->masterModel()->request() );
request.setSubsetOfAttributes( filterExpression.referencedColumns(), mLayer->pendingFields() );
request.setSubsetOfAttributes( filterExpression.referencedColumns(), mLayer->fields() );
if ( !fetchGeom )
{
request.setFlags( QgsFeatureRequest::NoGeometry );
@@ -43,7 +43,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx
, mFieldIdx( fieldIdx )
{
setupUi( this );
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->pendingFields()[fieldIdx].name() ).arg( vl->name() ) );
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields()[fieldIdx].name() ).arg( vl->name() ) );

connect( selectionListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( setStackPage( int ) ) );

@@ -65,8 +65,8 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx
selectionListWidget->setMaximumWidth( selectionListWidget->sizeHintForColumn( 0 )
+ 2 );

if ( vl->pendingFields().fieldOrigin( fieldIdx ) == QgsFields::OriginJoin ||
vl->pendingFields().fieldOrigin( fieldIdx ) == QgsFields::OriginExpression )
if ( vl->fields().fieldOrigin( fieldIdx ) == QgsFields::OriginJoin ||
vl->fields().fieldOrigin( fieldIdx ) == QgsFields::OriginExpression )
{
isFieldEditableCheckBox->setEnabled( false );
}
@@ -52,7 +52,7 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorLayer *src )
return;

// Replace the QGis clipboard.
mFeatureFields = src->pendingFields();
mFeatureFields = src->fields();
mFeatureClipboard = src->selectedFeatures();
mCRS = src->crs();

@@ -31,11 +31,11 @@ QgsDelAttrDialog::QgsDelAttrDialog( const QgsVectorLayer* vl )
{
bool canDeleteAttributes = vl->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
listBox2->clear();
const QgsFields& layerAttributes = vl->pendingFields();
const QgsFields& layerAttributes = vl->fields();
for ( int idx = 0; idx < layerAttributes.count(); ++idx )
{
QListWidgetItem* item = new QListWidgetItem( layerAttributes[idx].name(), listBox2 );
switch ( vl->pendingFields().fieldOrigin( idx ) )
switch ( vl->fields().fieldOrigin( idx ) )
{
case QgsFields::OriginExpression:
item->setIcon( QgsApplication::getThemeIcon( "/mIconExpression.svg" ) );
@@ -157,7 +157,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mSizeFieldExpressionWidget->setGeomCalculator( myDa );

//insert all attributes into the combo boxes
const QgsFields& layerFields = layer->pendingFields();
const QgsFields& layerFields = layer->fields();
for ( int idx = 0; idx < layerFields.count(); ++idx )
{
QTreeWidgetItem *newItem = new QTreeWidgetItem( mAttributesTreeWidget );
@@ -342,7 +342,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
}
else
{
mSizeFieldExpressionWidget->setField( mLayer->pendingFields().at( lidr->classificationAttribute() ).name() );
mSizeFieldExpressionWidget->setField( mLayer->fields().at( lidr->classificationAttribute() ).name() );
}
}
}
@@ -526,7 +526,7 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
if ( isExpression )
{
QgsExpression exp( sizeFieldNameOrExp );
exp.prepare( mLayer->pendingFields() );
exp.prepare( mLayer->fields() );
if ( !exp.hasEvalError() )
{
QgsFeature feature;
@@ -543,7 +543,7 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
}
else
{
int attributeNumber = mLayer->pendingFields().fieldNameIndex( sizeFieldNameOrExp );
int attributeNumber = mLayer->fields().fieldNameIndex( sizeFieldNameOrExp );
maxValue = mLayer->maximumValue( attributeNumber ).toFloat();
}

@@ -726,7 +726,7 @@ void QgsDiagramProperties::apply()
}
else
{
int attributeNumber = mLayer->pendingFields().fieldNameIndex( sizeFieldNameOrExp );
int attributeNumber = mLayer->fields().fieldNameIndex( sizeFieldNameOrExp );
dr->setClassificationAttribute( attributeNumber );
}
dr->setDiagram( diagram );
@@ -70,8 +70,8 @@ void FieldSelectorDelegate::setEditorData( QWidget *editor, const QModelIndex &i
return;

int idx = m->attributeIndex( vl );
if ( vl->pendingFields().exists( idx ) )
fcb->setField( vl->pendingFields()[ idx ].name() );
if ( vl->fields().exists( idx ) )
fcb->setField( vl->fields()[ idx ].name() );
}

void FieldSelectorDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
@@ -215,8 +215,8 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex& idx, int role

if ( role == Qt::DisplayRole )
{
if ( vl->pendingFields().exists( idx ) )
return vl->pendingFields()[ idx ].name();
if ( vl->fields().exists( idx ) )
return vl->fields()[ idx ].name();
else
return vl->name();
}
@@ -141,7 +141,7 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo
QgsDebugMsg( QString( "reuseLastValues: %1" ).arg( reuseLastValues ) );

// add the fields to the QgsFeature
const QgsFields& fields = mLayer->pendingFields();
const QgsFields& fields = mLayer->fields();
mFeature.initAttributes( fields.count() );
for ( int idx = 0; idx < fields.count(); ++idx )
{
@@ -226,7 +226,7 @@ void QgsFeatureAction::onFeatureSaved( const QgsFeature& feature )

if ( reuseLastValues )
{
QgsFields fields = mLayer->pendingFields();
QgsFields fields = mLayer->fields();
for ( int idx = 0; idx < fields.count(); ++idx )
{
QgsAttributes newValues = feature.attributes();
@@ -152,7 +152,7 @@ void QgsFieldCalculator::accept()
QgsExpression exp( calcString );
exp.setGeomCalculator( myDa );

if ( ! exp.prepare( mVectorLayer->pendingFields() ) )
if ( ! exp.prepare( mVectorLayer->fields() ) )
{
QMessageBox::critical( 0, tr( "Evaluation error" ), exp.evalErrorString() );
return;
@@ -198,7 +198,7 @@ void QgsFieldCalculator::accept()
}

//get index of the new field
const QgsFields& fields = mVectorLayer->pendingFields();
const QgsFields& fields = mVectorLayer->fields();

for ( int idx = 0; idx < fields.count(); ++idx )
{
@@ -209,7 +209,7 @@ void QgsFieldCalculator::accept()
}
}

if ( ! exp.prepare( mVectorLayer->pendingFields() ) )
if ( ! exp.prepare( mVectorLayer->fields() ) )
{
QApplication::restoreOverrideCursor();
QMessageBox::critical( 0, tr( "Evaluation error" ), exp.evalErrorString() );
@@ -235,7 +235,7 @@ void QgsFieldCalculator::accept()
bool useGeometry = exp.needsGeometry();
int rownum = 1;

const QgsField& field = mVectorLayer->pendingFields()[mAttributeId];
const QgsField& field = mVectorLayer->fields()[mAttributeId];

bool newField = !mUpdateExistingGroupBox->isChecked();
QVariant emptyAttribute;
@@ -400,7 +400,7 @@ void QgsFieldCalculator::populateFields()
if ( !mVectorLayer )
return;

const QgsFields& fields = mVectorLayer->pendingFields();
const QgsFields& fields = mVectorLayer->fields();
for ( int idx = 0; idx < fields.count(); ++idx )
{

0 comments on commit e832b2a

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