Skip to content

Commit

Permalink
added a method in the vectordata provider which returns an index from…
Browse files Browse the repository at this point in the history
… a field name

git-svn-id: http://svn.osgeo.org/qgis/trunk@5459 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 15, 2006
1 parent 8e7de6f commit 2a006d8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/qgsvectordataprovider.cpp
Expand Up @@ -16,6 +16,7 @@

#include "qgsvectordataprovider.h"
#include "qgsfeature.h"
#include "qgsfield.h"
#include "qgssearchtreenode.h"

QgsVectorDataProvider::QgsVectorDataProvider()
Expand Down Expand Up @@ -197,3 +198,19 @@ bool QgsVectorDataProvider::setAttributeFilter(const QgsSearchString& attributeF
// TODO: maybe check if all referenced columns are there, return false if not
return true;
}

int QgsVectorDataProvider::indexFromFieldName(const QString& fieldName) const
{
const std::vector<QgsField> theFields = fields();
int counter = 0;

for(std::vector<QgsField>::const_iterator it = theFields.begin(); it != theFields.end(); ++it)
{
if(it->name() == fieldName)
{
return counter;
}
++counter;
}
return -1;
}
3 changes: 3 additions & 0 deletions src/core/qgsvectordataprovider.h
Expand Up @@ -304,6 +304,9 @@ class QgsVectorDataProvider : public QgsDataProvider
*/
virtual void setWKT(QString wkt){};

/**Returns the index of a field name or -1 if the field does not exist*/
int indexFromFieldName(const QString& fieldName) const;

protected:
/**Encoding*/
QTextCodec* mEncoding;
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsvectorlayer.cpp
Expand Up @@ -3170,6 +3170,7 @@ void QgsVectorLayer::saveAsShapefile()
dataProvider->saveAsShapefile();
// QMessageBox::information(0,"Save As Shapefile", "Someday...");
}

void QgsVectorLayer::setCoordinateSystem()
{
delete mCoordinateTransform;
Expand Down

0 comments on commit 2a006d8

Please sign in to comment.