Skip to content

Commit

Permalink
** Added getDefaultValue() in QgsVectorLayer and QgsVectorDataProvider,
Browse files Browse the repository at this point in the history
   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 fb19279
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions providers/gpx/qgsgpxprovider.cpp
Expand Up @@ -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
*/
Expand Down
5 changes: 4 additions & 1 deletion providers/gpx/qgsgpxprovider.h
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/qgsmapcanvas.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/qgsvectordataprovider.cpp
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/qgsvectordataprovider.h
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/qgsvectorlayer.cpp
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/qgsvectorlayer.h
Expand Up @@ -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 );

Expand Down

0 comments on commit fb19279

Please sign in to comment.