Skip to content
Permalink
Browse files
QgsFeatureAttribute class has been removed and QVariant is used inste…
…ad (supports arbitrary data types).

All providers and python bindings have been updated accordingly.
Currently supported variant types by providers are String, Int and Double.

Other API changes:
- QgsField
  - type info as QString is now typeName() and setTypeName()
  - added variant type (QVariant::Type) info: type(), setType()
- QgsFeature
  - removed fields() - use QgsVectorDataProvider::fields()
  - removed boundingBox() - use QgsGeometry::boundingBox()
- QgsVectorLayer - removed fields(), fieldCount(), getDefaultValue() - use directly QgsVectorDataProvider
- QgsVectorDataProvider - getDefaultValue() - field now addressed by id, returns variant
- QgsLabel - setLabelField() - field now addressed by id


git-svn-id: http://svn.osgeo.org/qgis/trunk@6833 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 24, 2007
1 parent 39f11cf commit 00a43bc7dc7e034df8c85d12e1fe8942f972fb18
Showing with 727 additions and 2,146 deletions.
  1. +0 −1 python/core/core.sip
  2. +4 −13 python/core/qgsfeature.sip
  3. +0 −53 python/core/qgsfeatureattribute.sip
  4. +27 −14 python/core/qgsfield.sip
  5. +1 −1 python/core/qgslabel.sip
  6. +3 −3 python/core/qgsvectordataprovider.sip
  7. +2 −16 python/core/qgsvectorlayer.sip
  8. +2 −2 src/app/qgisapp.cpp
  9. +10 −7 src/app/qgsattributedialog.cpp
  10. +5 −2 src/app/qgsattributedialog.h
  11. +2 −3 src/app/qgsattributetable.cpp
  12. +4 −2 src/app/qgsattributetabledisplay.cpp
  13. +14 −20 src/app/qgsclipboard.cpp
  14. +4 −2 src/app/qgsclipboard.h
  15. +2 −2 src/app/qgscontinuouscolordialog.cpp
  16. +3 −4 src/app/qgsgraduatedsymboldialog.cpp
  17. +23 −13 src/app/qgslabeldialog.cpp
  18. +3 −1 src/app/qgslabeldialog.h
  19. +10 −11 src/app/qgsmaptoolcapture.cpp
  20. +8 −7 src/app/qgsmaptoolidentify.cpp
  21. +5 −5 src/app/qgspgquerybuilder.cpp
  22. +16 −19 src/app/qgssearchquerybuilder.cpp
  23. +1 −4 src/app/qgssearchquerybuilder.h
  24. +2 −3 src/app/qgsuniquevaluedialog.cpp
  25. +3 −3 src/app/qgsvectorlayerproperties.cpp
  26. +0 −2 src/core/CMakeLists.txt
  27. +7 −1,182 src/core/qgsfeature.cpp
  28. +7 −89 src/core/qgsfeature.h
  29. +0 −45 src/core/qgsfeatureattribute.cpp
  30. +0 −76 src/core/qgsfeatureattribute.h
  31. +27 −22 src/core/qgsfield.cpp
  32. +31 −27 src/core/qgsfield.h
  33. +188 −139 src/core/qgslabel.cpp
  34. +1 −1 src/core/qgslabel.h
  35. +0 −1 src/core/qgsmaplayer.cpp
  36. +42 −36 src/core/qgssearchtreenode.cpp
  37. +7 −8 src/core/qgssearchtreenode.h
  38. +3 −3 src/core/qgsvectordataprovider.cpp
  39. +2 −2 src/core/qgsvectordataprovider.h
  40. +2 −3 src/core/qgsvectorfilewriter.cpp
  41. +3 −45 src/core/qgsvectorlayer.cpp
  42. +0 −12 src/core/qgsvectorlayer.h
  43. +1 −2 src/core/renderer/qgscontinuouscolorrenderer.cpp
  44. +1 −2 src/core/renderer/qgsgraduatedsymbolrenderer.cpp
  45. +1 −2 src/core/renderer/qgsuniquevaluerenderer.cpp
  46. +1 −1 src/plugins/geoprocessing/qgspggeoprocessing.cpp
  47. +0 −1 src/plugins/grass/qgsgrassattributes.cpp
  48. +9 −11 src/plugins/grass/qgsgrassedit.cpp
  49. +0 −1 src/plugins/grass/qgsgrassmapcalc.cpp
  50. +0 −1 src/plugins/grass/qgsgrassmodel.cpp
  51. +2 −3 src/plugins/grass/qgsgrassmodule.cpp
  52. +0 −1 src/plugins/grass/qgsgrassplugin.cpp
  53. +0 −1 src/plugins/grass/qgsgrasstools.cpp
  54. +3 −4 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  55. +70 −69 src/providers/gpx/qgsgpxprovider.cpp
  56. +22 −18 src/providers/grass/qgsgrassprovider.cpp
  57. +1 −2 src/providers/grass/qgsgrassprovider.h
  58. +59 −44 src/providers/ogr/qgsogrprovider.cpp
  59. +73 −67 src/providers/postgres/qgspostgresprovider.cpp
  60. +2 −2 src/providers/postgres/qgspostgresprovider.h
  61. +1 −2 src/providers/wfs/qgswfsdata.cpp
  62. +7 −8 src/providers/wfs/qgswfsprovider.cpp
@@ -16,7 +16,6 @@
%Include qgsdatasourceuri.sip
%Include qgsdistancearea.sip
%Include qgsfeature.sip
%Include qgsfeatureattribute.sip
%Include qgsfield.sip
%Include qgsgeometry.sip
%Include qgsgeometryvertexindex.sip
@@ -22,7 +22,7 @@ class QgsFeature
want a copy of the "current" feature, not the on-disk feature.
*/
QgsFeature( const QgsFeature & rhs,
const QMap<int, QMap<int, QgsFeatureAttribute> >& changedAttributes,
const QMap<int, QMap<int, QVariant> >& changedAttributes,
const QMap<int, QgsGeometry> & changedGeometries );

/** copy ctor needed due to internal pointer */
@@ -58,26 +58,20 @@ class QgsFeature
* Get the attributes for this feature.
* @return A std::map containing the field name/value mapping
*/
const QMap<int, QgsFeatureAttribute> & attributeMap() const;
const QMap<int, QVariant> & attributeMap() const;

/**
* Add an attribute to the map
*/
void addAttribute(int field, QgsFeatureAttribute attr);
void addAttribute(int field, QVariant attr);

/**Deletes an attribute and its value*/
void deleteAttribute(int field);

/**Changes an existing attribute value
@param field index of the field
@param attr attribute name and value to be set */
void changeAttribute(int field, QgsFeatureAttribute attr);

/**
* Get the fields for this feature
* @return A std::map containing field position (index) and field name
*/
QMap<int, QString> fields() const;
void changeAttribute(int field, QVariant attr);

/**
* Return the validity of this feature. This is normally set by
@@ -125,9 +119,6 @@ class QgsFeature
*/
void setGeometryAndOwnership(unsigned char * geom, size_t length);

/**Returns the bounding box of this feature*/
QgsRect boundingBox() const;


}; // class QgsFeature

This file was deleted.

@@ -17,33 +17,41 @@ class QgsField
public:
/** Constructor. Constructs a new QgsField object.
* @param nam Field name
* @param typ Field type (eg. char, varchar, text, int, serial, double).
* @param type Field variant type, currently supported: String / Int / Double
* @param typeName Field type (eg. char, varchar, text, int, serial, double).
Field types are usually unique to the source and are stored exactly
as returned from the data store.
* @param len Field length
* @param prec Field precision. Usually decimal places but may also be
* used in conjunction with other fields types (eg. variable character fields)
* @param num Has to be true if field contains numeric values.
* @param comment Comment for the field
*/
QgsField(QString nam = "", QString typ = "", int len = 0, int prec = 0, bool num = false);

QgsField(QString name = QString(),
QVariant::Type type = QVariant::Invalid,
QString typeName = QString(),
int len = 0,
int prec = 0,
QString comment = QString());

//! Destructor
~QgsField();

bool operator==(const QgsField other) const;
bool operator!=(const QgsField other) const;
bool operator==(const QgsField& other) const;

//! Gets the name of the field
const QString & name() const;

//! Gets variant type of the field as it will be retreived from data source
QVariant::Type type() const;

/**
Gets the field type. Field types vary depending on the data source. Examples
are char, int, double, blob, geometry, etc. The type is stored exactly as
the data store reports it, with no attenpt to standardize the value.
@return QString containing the field type
*/
const QString & type() const;
const QString & typeName() const;


/**
@@ -59,23 +67,27 @@ public:
*/
int precision() const;

/**
Returns true if field contains numeric values. This information is set by provider.
*/
bool isNumeric() const;

/**
Returns the field comment
*/
const QString & comment() const;

/**
Set the field name.
@param nam Name of the field
*/
void setName(const QString & nam);

/**
Set variant type.
*/
void setType(QVariant::Type type);

/**
Set the field type.
@param typ Field type
*/
void setType(const QString & typ);
void setTypeName(const QString & typ);

/**
Set the field length.
@@ -89,10 +101,11 @@ public:
*/
void setPrecision(int prec);


/**
Set whether field is numeric
Set the field comment
*/
void setNumeric(bool num);
void setComment(const QString & comment);

}; // class QgsField

@@ -69,7 +69,7 @@ public:
QgsLabelAttributes *layerAttributes ( );

//! Set label field
void setLabelField ( int attr, const QString str );
void setLabelField ( int attr, int fieldId );

//! label field
QString labelField ( int attr );
@@ -343,12 +343,12 @@ class QgsVectorDataProvider : QgsDataProvider
* @param attr_map a map containing changed attributes
* @return true in case of success and false in case of failure
*/
virtual bool changeAttributeValues(const QMap<int, QMap<int, QgsFeatureAttribute> > & attr_map);
virtual bool changeAttributeValues(const QMap<int, QMap<int, QVariant> > & attr_map);

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

/**
* Changes geometries of existing features
@@ -151,17 +151,6 @@ public:
*/
virtual QString subsetString();

/**
* Number of attribute fields for a feature in the layer
*/
virtual int fieldCount() const;

/**
Return a list of field names for this layer
@return vector of field names
*/
virtual const QMap<int, QgsField> & fields() const;

/** Adds a feature
@param lastFeatureInBatch If True, will also go to the effort of e.g. updating the extents.
@return Irue in case of success and False in case of error
@@ -194,9 +183,6 @@ public:
*/
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 );

@@ -270,7 +256,7 @@ public:
*/
bool commitAttributeChanges(const QSet<int>& deleted,
const QMap<QString, QString>& added,
const QMap<int, QMap<int, QgsFeatureAttribute> >& changed);
const QMap<int, QMap<int, QVariant> >& changed);

/** Draws the layer using coordinate transformation
* @return FALSE if an error occurred during drawing
@@ -308,7 +294,7 @@ public:
QSet<int>& deletedFeatureIds();

/** returns array of features with changed attributes */
QMap<int, QMap<int, QgsFeatureAttribute> >& changedAttributes();
QMap<int, QMap<int, QVariant> >& changedAttributes();

/** Sets whether some features are modified or not */
void setModified(bool modified = TRUE, bool onlyGeometryWasModified = FALSE);
@@ -3437,7 +3437,7 @@ void QgisApp::editCut(QgsMapLayer * layerContainingSelection)
if (selectionVectorLayer != 0)
{
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
clipboard()->replaceWithCopyOf( features );
clipboard()->replaceWithCopyOf( selectionVectorLayer->getDataProvider()->fields(), features );
selectionVectorLayer->deleteSelectedFeatures();
}
}
@@ -3458,7 +3458,7 @@ void QgisApp::editCopy(QgsMapLayer * layerContainingSelection)
if (selectionVectorLayer != 0)
{
QgsFeatureList features = selectionVectorLayer->selectedFeatures();
clipboard()->replaceWithCopyOf( features );
clipboard()->replaceWithCopyOf( selectionVectorLayer->getDataProvider()->fields(), features );
}
}
}
@@ -16,12 +16,13 @@
***************************************************************************/
/* $Id$ */
#include "qgsattributedialog.h"
#include "qgsfeatureattribute.h"
#include "qgsfield.h"
#include "qgslogger.h"

#include <QTableWidgetItem>
#include <QSettings>

QgsAttributeDialog::QgsAttributeDialog(const QgsAttributeMap& attributes)
QgsAttributeDialog::QgsAttributeDialog(const QgsFieldMap& fields, const QgsAttributeMap& attributes)
: QDialog(),
_settingsPath("/Windows/AttributeDialog/"),
mRowIsDirty(attributes.size(), FALSE)
@@ -35,14 +36,16 @@ QgsAttributeDialog::QgsAttributeDialog(const QgsAttributeMap& attributes)
for (QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it)
{
// set attribute name

QString fieldName = fields[it.key()].name();

QTableWidgetItem * myFieldItem = new QTableWidgetItem((*it).fieldName());
QTableWidgetItem * myFieldItem = new QTableWidgetItem(fieldName);
myFieldItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
mTable->setItem(index, 0, myFieldItem);

// set attribute value

QTableWidgetItem * myValueItem = new QTableWidgetItem((*it).fieldValue());
QTableWidgetItem * myValueItem = new QTableWidgetItem((*it).toString());
mTable->setItem(index, 1, myValueItem);

++index;
@@ -72,16 +75,16 @@ bool QgsAttributeDialog::isDirty(int row)
return mRowIsDirty.at(row);
}

bool QgsAttributeDialog::queryAttributes(QgsFeature& f)
bool QgsAttributeDialog::queryAttributes(const QgsFieldMap& fields, QgsFeature& f)
{
QgsAttributeMap featureAttributes = f.attributeMap();
QgsAttributeDialog attdialog(featureAttributes);
QgsAttributeDialog attdialog(fields, featureAttributes);

if (attdialog.exec() == QDialog::Accepted)
{
for (int i = 0; i < featureAttributes.size(); ++i)
{
f.changeAttribute(i, QgsFeatureAttribute(featureAttributes[i].fieldName(), attdialog.value(i)));
f.changeAttribute(i, QVariant(attdialog.value(i)) );
}
return true;
}
@@ -26,12 +26,15 @@
class QDialog;
class QgsFeature;

class QgsField;
typedef QMap<int, QgsField> QgsFieldMap;

class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
{
Q_OBJECT

public:
QgsAttributeDialog(const QgsAttributeMap& attributes);
QgsAttributeDialog(const QgsFieldMap& fields, const QgsAttributeMap& attributes);

~QgsAttributeDialog();

@@ -45,7 +48,7 @@ class QgsAttributeDialog: public QDialog, private Ui::QgsAttributeDialogBase
attribute values are set to the feature if the dialog is accepted.
\retval true if accepted
\retval false if canceled */
static bool queryAttributes(QgsFeature& f);
static bool queryAttributes(const QgsFieldMap& fields, QgsFeature& f);

// Saves and restores the size and position from the last time
// this dialog box was used.

0 comments on commit 00a43bc

Please sign in to comment.