Skip to content
Permalink
Browse files
added a method in the vectordata provider which returns an index from…
… 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 2a006d814c58667ee933f063657799c9d11c61af
Showing with 21 additions and 0 deletions.
  1. +17 −0 src/core/qgsvectordataprovider.cpp
  2. +3 −0 src/core/qgsvectordataprovider.h
  3. +1 −0 src/gui/qgsvectorlayer.cpp
@@ -16,6 +16,7 @@

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

QgsVectorDataProvider::QgsVectorDataProvider()
@@ -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;
}
@@ -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;
@@ -3170,6 +3170,7 @@ void QgsVectorLayer::saveAsShapefile()
dataProvider->saveAsShapefile();
// QMessageBox::information(0,"Save As Shapefile", "Someday...");
}

void QgsVectorLayer::setCoordinateSystem()
{
delete mCoordinateTransform;

0 comments on commit 2a006d8

Please sign in to comment.