54 Commits

Author SHA1 Message Date
Nyall Dawson
967d37adc7 QgsFeature::fields() returns a value, not a pointer
Also remove all other QgsFields pointers and replace with
references/values, since QgsFields objects are implicitly shared
2016-08-05 06:07:02 +10:00
Nyall Dawson
bd7d913379 Refine QgsFeature geometry getters/setters
All pointer based methods have been removed.

Now we have only:

  void setGeometry( const QgsGeometry& geom )

and

  QgsGeometry geometry() const

Benefits include avoiding a whole lot of tricky pointer lifetime
issues, potential memory leaks, and finally closing #777, which
has survived for over 9 years!...

Impacts on PyQGIS code:
- no more need for the messy
  g = QgsGeometry( feature.geometry() )
  workaround, just use g = feature.geometry() instead
- IMPORTANT: you can no longer test whether a feature has geometry
 using `if f.geometry():`, since QgsFeature::geometry() will
 *always* return an object. Instead, use
 `if not f.geometry().isEmpty():`, or preferably the new method
 `if not f.hasGeometry():`

Fix #777
2016-08-01 16:25:46 +10:00
Nyall Dawson
aceddae65a QgsFeature cleanup, part 1
Deprecate some QgsFeature methods which take or return pointers,
update other classes as required
2016-07-31 21:23:07 +10:00
Nyall Dawson
0fcff9f2a0 Allow direct QVariant creation from some QGIS metatypes 2016-05-20 09:48:18 +10:00
Juergen E. Fischer
71dc339106 more stl to qt ports and size_t => int fixups 2015-12-26 00:59:09 +01:00
Nyall Dawson
9cc9d424ce Add extra check for deprecations to documentation test
This check tests that if a function has been declared deprecated
with either Q_DECL_DEPRECATED or has a @deprecated Doxygen note
then it MUST have both the Q_DECL_DEPRECATD and @deprecated note.

It's important that both are used, as Q_DECL_DEPRECATED allows
throwing a warning if that method is used in code, while the
@deprecated doxygen note gives an indication to devs/PyQGIS users
of why it's deprecated and what should be used instead.

Ideally we'd also test for SIP /Deprecated/ tags, but I can't
find any reliable way to do this.
2015-12-07 21:55:36 +11:00
Matthias Kuhn
56ccb2b858 sipClass_Klass is deprecated for a long time: replace with sipType_Klass 2015-11-11 23:22:51 +01:00
Juergen E. Fischer
b5794b2f2d sip coverage fixes:
* make sip coverage test aware that there are less classes where QSci sip
  headers are not available
* exclude properties from members
* fix QgsFeatureIds typedef (fixes missing signal
  QgsVectorLayer.featuresDeleted and others)
* add missing notes for PyNames
* include some missing new methods in bindings
2015-11-08 19:30:39 +00:00
Nyall Dawson
c49b5b777f Change a lot of arguments to const references in core/gui
Rationale:
- there was a lot of large objects passed by value, so potentially
there's a speed bump from this
- even for implicitly shared classes like QString/QList there's still
a (small) cost for copying the objects when there's no reason to
- it's the right thing to do!
2015-10-07 12:02:04 +11:00
Matthias Kuhn
c6f7873585 Add QgsAttributes::operator== that takes care of NULL variants 2015-07-13 09:48:12 +02:00
Nyall Dawson
b1ffff826d Fix build 2015-05-21 05:49:04 +10:00
Nyall Dawson
267d9528d5 Implicit sharing for QgsFeature 2015-05-21 00:55:57 +10:00
Nyall Dawson
d393d268e1 Fix up non-const getters for attributes and geometry in QgsFeature
(preparation for implicit sharing)
2015-05-20 21:46:15 +10:00
Nyall Dawson
2863f20d67 Add a const geometry getter to QgsFeature 2015-05-11 19:46:32 +10:00
Juergen E. Fischer
9ceb5ceab6 sip sync 2014-11-21 01:17:21 +01:00
Juergen E. Fischer
c4c131ef75 sip sync 2014-05-27 23:32:42 +02:00
Juergen E. Fischer
d647354a52 sip fixes 2014-01-28 00:26:13 +01:00
Juergen E. Fischer
d4e369414b update sip bindings 2014-01-26 18:36:29 +01:00
Matthias Kuhn
52ab06e295 python: represent NULL attributes as QPyNullVariant 2013-08-28 13:15:08 +02:00
Nathan Woodrow
20e274a413 Add __iter__ for QgsFeature 2013-08-03 22:50:49 +10:00
Nathan Woodrow
0bb9543278 Remove __getattr__, __setattr__ for QgsFeature
Not such a good idea after all :)
2013-07-09 21:03:15 +10:00
Matthias Kuhn
c1cd3e84b5 Fix wrong python None type reference counting 2013-06-19 13:03:05 +02:00
Matthias Kuhn
9fc01a6d1f Fix memory leak in QgsFeature sip api 2013-06-15 11:43:15 +02:00
Nathan Woodrow
f8cafe81b4 Fix build error 2013-06-12 09:32:13 +10:00
Nathan Woodrow
052669f5c5 Fix #8040. Build error with sip 2013-06-12 08:10:22 +10:00
Matthias Kuhn
6381d626a1 Use python None object for NULL attributes 2013-06-11 14:48:29 +02:00
Nathan Woodrow
d539739089 Add __getattr__ and __setattr__ to QgsFeature 2013-06-10 09:21:31 +10:00
Matthias Kuhn
dc860f75ed When calling setFields, automatically initalize attributes
That what you want most of the time when creating a new feature within a plugin.
Therefore defaults to true when used from python, but to false when used from C++
2013-06-05 11:59:50 +02:00
Nathan Woodrow
fe59da52da Add overload for QgsFeature with QgsFields 2013-03-30 12:51:55 +10:00
Juergen E. Fischer
7f7b5dd63e more fTools api updates 2013-02-03 21:18:39 +01:00
Juergen E. Fischer
4cbec1811c fix warnings, add copyright headers, cosmetics 2013-01-28 01:39:58 +01:00
Martin Dobias
81b0930498 QgsVectorLayer: large internal refactoring
Most important changes:
- introduced feature iterator for QgsVectorLayer
- vector editing moved to QgsVectorEditBuffer
- complete rework of undo/redo commands for vector layers
- geometry cache separated from editing (QgsVectorLayerCache)
- non-essential editing functionality moved to QgsVectorLayerEditUtils
2012-12-17 21:22:42 +01:00
Martin Dobias
51122d263a Store attributes and fields in vectors instead of maps 2012-10-20 22:19:55 +02:00
Martin Dobias
8bf959093f QgsFeature: use a vector of attributes instead of a map (for faster access) 2012-10-19 00:31:03 +02:00
Martin Dobias
4bc60ff423 Removed unused QgsFeature::isDirty() and QgsFeature::clean() 2012-10-13 13:33:12 +02:00
Martin Dobias
eb6d4d384d Removed unused QgsFeature::typeName() and QgsFeature::setTypeName() 2012-10-13 13:06:57 +02:00
Martin Dobias
f217a7fb19 Fixes after rebase 2012-10-09 20:57:35 +02:00
Martin Dobias
b863ca195e Allow access to feature attributes by name 2012-10-08 17:16:54 +02:00
Juergen E. Fischer
f3cb57b1eb SIP bindings update:
- update methods of existing classes
- add comment to methods missing in the sip bindings
- split up collective sip files into single files and use
  same directory structure in python/ as in src/
- add a lot of missing classes (some might not make sense because of
  missing python methods in those classes)
- remove some non-existing methods from the header files
- add scripts/sipdiff
- replace some usages of std::vector and std::set with QVector/QSet
2012-09-24 02:42:57 +02:00
Juergen E. Fischer
f08ffc6fd8 fix sip bindings 2012-01-09 00:43:51 +01:00
Juergen E. Fischer
5a3a87fde2 [FEATURE] support 64bit feature ids 2011-06-16 20:30:07 +02:00
wonder
1d66171ff3 PyQGIS fixes: added few typedefs (IIRC they were not supported by some old SIP versions) and added missing signals in QgsVectorLayer
git-svn-id: http://svn.osgeo.org/qgis/trunk@14978 c8812cc2-4d05-0410-92ff-de0c093fc19c
2010-12-27 21:27:01 +00:00
wonder
2034de2bc9 PyQGIS: few additions for more pythonic api
- QgsVectorLayer and QgsVectorDataProvider support iterating
- QgsFeature allows direct access to attributes (get/set/del)


git-svn-id: http://svn.osgeo.org/qgis/trunk@12878 c8812cc2-4d05-0410-92ff-de0c093fc19c
2010-02-04 21:08:33 +00:00
wonder
5fcab9157a wrapped new method from r12869
git-svn-id: http://svn.osgeo.org/qgis/trunk@12873 c8812cc2-4d05-0410-92ff-de0c093fc19c
2010-02-04 13:43:20 +00:00
wonder
8241b607f6 Fix #2324.
git-svn-id: http://svn.osgeo.org/qgis/trunk@12627 c8812cc2-4d05-0410-92ff-de0c093fc19c
2009-12-27 19:27:34 +00:00
wonder
7d175fb97b Leave only one setGeometry method to avoid ambiguous behaviour, added missing /Transfer/ annotation.
git-svn-id: http://svn.osgeo.org/qgis/trunk@12597 c8812cc2-4d05-0410-92ff-de0c093fc19c
2009-12-23 15:36:11 +00:00
wonder
acd3a32c1f typedef for size_t changed to be defined outside classes.
git-svn-id: http://svn.osgeo.org/qgis/trunk@9629 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-11-12 19:54:21 +00:00
timlinux
314e8e6065 Api cleanups for qgsfeature
git-svn-id: http://svn.osgeo.org/qgis/trunk@9506 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-10-20 21:44:15 +00:00
jef
43278d720b handling vector data geometry and attribute updates refactored
QgsVectorLayer:
  - move attribute part of editing to vector layer class and unify with geometry handling:
    * remove commitAttributeChanges(), addedFeatures(), deletedFeatureIds(), changedAttributes()
      and replace with changeAttributeValue(), deleteFeature(), addAttribute()
      and deleteAttribute()
    * add pendingFields(), pendingAttributeList(), pendingFeatureCount()
    * emit signals on start editing and commit, change of attribute values, adding/deleting of
      attributes and layer or feature removal (currently used in the attribute table)
  - new commitErrors() method to query errors from commitChanges()
  - replaced featuresInRectangle with select/getNextFeature combo
  - edit types added to support more input widgets and input constraints

QgsFeature:
  - remove update aware ctor
  - unify geometry handling in ctors

QgsVectorDataProvider:
  - add QVariant::Type to supportNativeTypes()

QgisApp:
  - add instance() method to query QgisApp object
  - replace code at various place to use it instead of passing the pointer
    arround or searching it in the widget tree.
  - move toggleEditing() code from the legend here

QgsAttributeTable/QgsAttributeTableDisplay:
  - move attribute table creation legend here
  - make attribute table dockable (from Tim)
  - most editing logic moved to QgsVectorLayer
  - adding/deleting attributes moved to QgsVectorLayerProperties

QgsIdentifyResults:
  - add support for attribute editing when it edit mode

QgsVectorLayerProperties:
  add a new tab to show attribute list:
    * start/stop editing
    * add/delete attributes
    * assign edit type to attributes (unique values, value map, ranges)

QgsAttributeDialog:
  add support for attribute edit types:
   * selection from unique value render classes (combobox)
   * selection from unique values of existing features (combobox or line edits with completion)
   * spinboxes for ranges

QgsPostgresProvider:
 - use read-only connection for cursors and read-write connection for updates
 - updated native types

QgsOgrProvider:
 - remove unused references to GEOS geometry factory
 - updated native types


git-svn-id: http://svn.osgeo.org/qgis/trunk@9092 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-08-20 12:15:14 +00:00
wonder
4a28f76aa4 Made setGeometry() argument const.
git-svn-id: http://svn.osgeo.org/qgis/trunk@8736 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-07-08 14:03:09 +00:00