** Added getDefaultValue() in QgsVectorLayer and QgsVectorDataProvider,

implemented it in the GPX provider


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2181 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
larsl 2004-10-29 21:55:43 +00:00
parent 781a5f528b
commit aea621b426
9 changed files with 38 additions and 4 deletions

View File

@ -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.

View File

@ -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

View File

@ -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
*/

View File

@ -166,7 +166,10 @@ public:
@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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 );