@@ -18,6 +18,7 @@ which are not wrapped by PyQt:
18
18
- QMap<qint64, QgsOverlayObject*>
19
19
- QList< QPair< QString, QList<QString> > >
20
20
- QVector<TYPE*>
21
+ - QMap<qint64, QgsFeature*>
21
22
*/
22
23
23
24
%Feature QSETINT_CONVERSION
@@ -1386,7 +1387,8 @@ template<double, TYPE2>
1386
1387
while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
1387
1388
{
1388
1389
int state;
1389
- int t1 = (int)(PyFloat_AsDouble(t1obj));
1390
+ //int t1 = (int)(PyFloat_AsDouble(t1obj));
1391
+ qint64 t1 = PyLong_AsLongLong(t1obj);
1390
1392
QgsOverlayObject* t2 = reinterpret_cast<QgsOverlayObject*>(sipConvertToInstance(t2obj, sipClass_QgsOverlayObject, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
1391
1393
1392
1394
if (*sipIsErr)
@@ -1581,3 +1583,86 @@ template <TYPE>
1581
1583
return sipGetState(sipTransferObj);
1582
1584
%End
1583
1585
};
1586
+
1587
+ %MappedType QMap<qint64, QgsFeature*>
1588
+ {
1589
+ %TypeHeaderCode
1590
+ #include <QMap>
1591
+ #if (SIP_VERSION >= 0x040900)
1592
+ #define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
1593
+ #endif
1594
+ #if (SIP_VERSION >= 0x040900 && SIP_VERSION < 0x040c01)
1595
+ #define sipClass_QVariant ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QVariant))
1596
+ #endif
1597
+ %End
1598
+
1599
+ %ConvertFromTypeCode
1600
+
1601
+ //convert map to a python dictionary
1602
+ PyObject *d;
1603
+
1604
+ if ((d = PyDict_New()) == NULL)
1605
+ return NULL;
1606
+
1607
+ for (QMap<qint64, QgsFeature*>::iterator it = sipCpp->begin(); it != sipCpp->end(); ++it)
1608
+ {
1609
+ QgsFeature* oobj = new QgsFeature(*it.value());
1610
+
1611
+ PyObject* keyobj = PyInt_FromLong(it.key());
1612
+ PyObject* pyOobj = sipConvertFromInstance(oobj, sipClass_QgsFeature, sipTransferObj);
1613
+ PyDict_SetItem(d, keyobj, pyOobj);
1614
+
1615
+ if(pyOobj == NULL || keyobj == NULL || PyDict_SetItem(d, keyobj, pyOobj) < 0)
1616
+ {
1617
+ Py_DECREF(d);
1618
+
1619
+ if (pyOobj)
1620
+ {
1621
+ Py_DECREF(pyOobj);
1622
+ }
1623
+
1624
+ if (keyobj)
1625
+ {
1626
+ Py_DECREF(keyobj);
1627
+ }
1628
+ return NULL;
1629
+ }
1630
+ Py_DECREF(pyOobj);
1631
+ Py_DECREF(keyobj);
1632
+ }
1633
+ return d;
1634
+
1635
+ %End
1636
+ %ConvertToTypeCode
1637
+ PyObject *t1obj, *t2obj;
1638
+ #if PY_VERSION_HEX >= 0x02050000
1639
+ Py_ssize_t i = 0;
1640
+ #else
1641
+ int i = 0;
1642
+ #endif
1643
+
1644
+ QMap<qint64, QgsFeature*> *qm = new QMap<qint64, QgsFeature*>;
1645
+
1646
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
1647
+ {
1648
+ int state;
1649
+ qint64 t1 = PyLong_AsLongLong(t1obj);
1650
+ QgsFeature* t2 = reinterpret_cast<QgsFeature*>(sipConvertToInstance(t2obj, sipClass_QgsFeature, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
1651
+
1652
+ if (*sipIsErr)
1653
+ {
1654
+ sipReleaseInstance(t2, sipClass_QgsFeature, state);
1655
+ delete qm;
1656
+ return 0;
1657
+ }
1658
+
1659
+ qm->insert(t1, t2);
1660
+
1661
+ sipReleaseInstance(t2, sipClass_QgsFeature, state);
1662
+ }
1663
+
1664
+ *sipCppPtr = qm;
1665
+
1666
+ return sipGetState(sipTransferObj);
1667
+ %End
1668
+ };
0 commit comments