File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,32 @@ class QgsFeature
8
8
9
9
public:
10
10
11
+ SIP_PYOBJECT __getitem__(int key);
12
+ %MethodCode
13
+ const QgsAttributeMap& attrMap = sipCpp->attributeMap();
14
+ QgsAttributeMap::const_iterator it = attrMap.find(a0);
15
+ if (it == attrMap.end())
16
+ PyErr_SetString(PyExc_KeyError, QByteArray::number(a0));
17
+ else
18
+ {
19
+ QVariant* v = new QVariant(it.value());
20
+ sipRes = sipConvertFromInstance(v, sipClass_QVariant, Py_None);
21
+ }
22
+ %End
23
+
24
+ void __setitem__(int key, QVariant value);
25
+ %MethodCode
26
+ sipCpp->addAttribute(a0, *a1);
27
+ %End
28
+
29
+ void __delitem__(int key);
30
+ %MethodCode
31
+ if (sipCpp->attributeMap().contains(a0))
32
+ sipCpp->deleteAttribute(a0);
33
+ else
34
+ PyErr_SetString(PyExc_KeyError, QByteArray::number(a0));
35
+ %End
36
+
11
37
//! Constructor
12
38
QgsFeature(int id = 0, QString typeName = "" );
13
39
Original file line number Diff line number Diff line change @@ -7,6 +7,23 @@ class QgsVectorDataProvider : QgsDataProvider
7
7
8
8
public:
9
9
10
+ QgsVectorDataProvider* __iter__();
11
+ %MethodCode
12
+ sipRes = sipCpp;
13
+ %End
14
+
15
+ SIP_PYOBJECT __next__();
16
+ %MethodCode
17
+ QgsFeature* f = new QgsFeature;
18
+ if (sipCpp->nextFeature(*f))
19
+ sipRes = sipConvertFromInstance(f, sipClass_QgsFeature, Py_None);
20
+ else
21
+ {
22
+ delete f;
23
+ PyErr_SetString(PyExc_StopIteration,"");
24
+ }
25
+ %End
26
+
10
27
// If you add to this, please also add to capabilitiesString()
11
28
/**
12
29
* enumeration with capabilities that providers might implement
Original file line number Diff line number Diff line change @@ -5,6 +5,25 @@ class QgsVectorLayer : QgsMapLayer
5
5
%End
6
6
7
7
public:
8
+
9
+ QgsVectorLayer* __iter__();
10
+ %MethodCode
11
+ sipRes = sipCpp;
12
+ %End
13
+
14
+ SIP_PYOBJECT __next__();
15
+ %MethodCode
16
+ QgsFeature* f = new QgsFeature;
17
+ if (sipCpp->nextFeature(*f))
18
+ sipRes = sipConvertFromInstance(f, sipClass_QgsFeature, Py_None);
19
+ else
20
+ {
21
+ delete f;
22
+ PyErr_SetString(PyExc_StopIteration,"");
23
+ }
24
+ %End
25
+
26
+
8
27
enum EditType {
9
28
LineEdit,
10
29
UniqueValues,
You can’t perform that action at this time.
0 commit comments