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
88
99 public:
1010
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+
1137 //! Constructor
1238 QgsFeature(int id = 0, QString typeName = "" );
1339
Original file line number Diff line number Diff line change @@ -7,6 +7,23 @@ class QgsVectorDataProvider : QgsDataProvider
77
88 public:
99
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+
1027 // If you add to this, please also add to capabilitiesString()
1128 /**
1229 * enumeration with capabilities that providers might implement
Original file line number Diff line number Diff line change @@ -5,6 +5,25 @@ class QgsVectorLayer : QgsMapLayer
55%End
66
77public:
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+
827 enum EditType {
928 LineEdit,
1029 UniqueValues,
You can’t perform that action at this time.
0 commit comments