Skip to content
Permalink
Browse files
** Added getDefaultValue() in QgsVectorLayer and QgsVectorDataProvider,
   implemented it in the GPX provider


git-svn-id: http://svn.osgeo.org/qgis/trunk@2181 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
larsl committed Oct 29, 2004
1 parent c8be675 commit fb1927945038b59f0e0128b4458114926663f85e
Showing with 38 additions and 4 deletions.
  1. +4 −0 ChangeLog
  2. +1 −1 configure.in
  3. +7 −0 providers/gpx/qgsgpxprovider.cpp
  4. +4 −1 providers/gpx/qgsgpxprovider.h
  5. +2 −2 src/qgsmapcanvas.cpp
  6. +7 −0 src/qgsvectordataprovider.cpp
  7. +3 −0 src/qgsvectordataprovider.h
  8. +6 −0 src/qgsvectorlayer.cpp
  9. +4 −0 src/qgsvectorlayer.h
@@ -3,6 +3,10 @@ ChangeLog,v 1.200 2004/10/21 17:27:35 mcoletti Exp
------------------------------------------------------------------------------
Version 0.6 'Simon' .... development version

2004-10-29 [larsl] 0.5.0devel16
** Added getDefaultValue() in QgsVectorLayer and QgsVectorDataProvider,
implemented it in the GPX provider

2004-10-29 [stevehalasz] 0.5.0devel15
* Write layers to projects files in the proper order by iterating over the
zOrder in the map canvas. Fixes bug #1054332.
@@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=5
MICRO_VERSION=0
EXTRA_VERSION=15
EXTRA_VERSION=16
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
@@ -763,6 +763,13 @@ bool QgsGPXProvider::deleteFeature(int id) {
}


QString QgsGPXProvider::getDefaultValue(const QString& attr, QgsFeature* f) {
if (attr == "source")
return "Digitized in QGIS";
return "";
}


/**
* Check to see if the point is within the selection rectangle
*/
@@ -166,7 +166,10 @@ class QgsGPXProvider : public QgsVectorDataProvider {
@param id the number of the feature
@return true in case of success and false in case of failure*/
bool deleteFeature(int id);


/**Returns the default value for attribute @c attr for feature @c f. */
QString getDefaultValue(const QString& attr, QgsFeature* f);

/**
* Check to see if the point is withn the selection
* rectangle
@@ -1211,7 +1211,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
std::vector<QgsField> fields=vlayer->fields();
for(std::vector<QgsField>::iterator it=fields.begin();it!=fields.end();++it)
{
f->addAttribute((*it).name(),"");
f->addAttribute((*it).name(), vlayer->getDefaultValue(it->name(),f));
}

//show the dialog to enter attribute values
@@ -1331,7 +1331,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
std::vector<QgsField> fields=vlayer->fields();
for(std::vector<QgsField>::iterator it=fields.begin();it!=fields.end();++it)
{
f->addAttribute((*it).name(),"");
f->addAttribute((*it).name(),vlayer->getDefaultValue(it->name(), f));
}

//show the dialog to enter attribute values
@@ -94,6 +94,13 @@ bool QgsVectorDataProvider::deleteFeature(int id)
return false;
}


QString QgsVectorDataProvider::getDefaultValue(const QString& attr,
QgsFeature* f) {
return "";
}


bool QgsVectorDataProvider::commitFeature(QgsFeature* f)
{
//needs to be done by subclasses
@@ -101,6 +101,9 @@ class QgsVectorDataProvider: public QgsDataProvider
@return true in case of success and false in case of failure*/
virtual bool deleteFeature(int id);

/**Returns the default value for attribute @c attr for feature @c f. */
virtual QString getDefaultValue(const QString& attr, QgsFeature* f);

/**
* Identify features within the search radius specified by rect
* @param rect Bounding rectangle of search radius
@@ -1246,6 +1246,12 @@ void QgsVectorLayer::select(int number)
return false;
}


QString QgsVectorLayer::getDefaultValue(const QString& attr,
QgsFeature* f) {
return dataProvider->getDefaultValue(attr, f);
}

bool QgsVectorLayer::deleteSelectedFeatures()
{
#ifdef QGISDEBUG
@@ -195,6 +195,10 @@ class QgsVectorLayer : public QgsMapLayer
@return true in case of success and false otherwise*/
bool deleteSelectedFeatures();

/**Returns the default value for the attribute @c attr for the feature
@c f. */
QString getDefaultValue(const QString& attr, QgsFeature* f);

/**Set labels on */
void setLabelOn( bool on );

0 comments on commit fb19279

Please sign in to comment.