@@ -14,6 +14,7 @@ which are not wrapped by PyQt:
14
14
- QMap<TYPE1, TYPE2*>
15
15
- QMap<double, TYPE>
16
16
- QMultiMap<double, TYPE2>
17
+ - QMultiMap<int, TYPE2>
17
18
- QMap<qint64, TYPE>
18
19
- QList< QPair< QString, QList<QString> > >
19
20
- QVector<TYPE*>
@@ -1407,6 +1408,131 @@ template<double, TYPE2>
1407
1408
%End
1408
1409
};
1409
1410
1411
+
1412
+ template<int, TYPE2*>
1413
+ %MappedType QMultiMap<int, TYPE2*>
1414
+ {
1415
+ %TypeHeaderCode
1416
+ #include <QMultiMap>
1417
+ %End
1418
+
1419
+ %ConvertFromTypeCode
1420
+ // Convert to Python: create the dictionary.
1421
+ PyObject *d = PyDict_New();
1422
+
1423
+ if (!d)
1424
+ {
1425
+ return NULL;
1426
+ }
1427
+
1428
+ // Set the dictionary elements.
1429
+ QMultiMap<int, TYPE2*>::iterator i = sipCpp->begin();
1430
+
1431
+ while (i != sipCpp->end())
1432
+ {
1433
+
1434
+ const int t1 = i.key();
1435
+ TYPE2 * t2 = i.value();
1436
+ PyObject *t1obj = PyInt_FromSize_t(t1);
1437
+ PyObject *t2obj = sipConvertFromType(t2, sipType_TYPE2, sipTransferObj);
1438
+ if (PyDict_GetItem(d, t1obj) == NULL)
1439
+ {
1440
+ PyObject *lst = PyList_New(0);
1441
+ PyDict_SetItem(d, t1obj, lst);
1442
+ if (lst)
1443
+ {
1444
+ Py_DECREF(lst);
1445
+ }
1446
+ }
1447
+
1448
+ if (t1obj == NULL || t2obj == NULL ||
1449
+ PyList_Append(PyDict_GetItem(d, t1obj), t2obj) < 0)
1450
+ {
1451
+ Py_DECREF(d);
1452
+ if (t1obj)
1453
+ {
1454
+ Py_DECREF(t1obj);
1455
+ }
1456
+
1457
+ if (t2obj)
1458
+ {
1459
+ Py_DECREF(t2obj);
1460
+ }
1461
+
1462
+ return NULL;
1463
+ }
1464
+ Py_DECREF(t1obj);
1465
+ Py_DECREF(t2obj);
1466
+
1467
+ ++i;
1468
+ }
1469
+
1470
+ return d;
1471
+ %End
1472
+
1473
+ %ConvertToTypeCode
1474
+ // Convert from Python:
1475
+ PyObject *t1obj, *t2obj;
1476
+ #if PY_VERSION_HEX >= 0x02050000
1477
+ Py_ssize_t i = 0;
1478
+ #else
1479
+ int i = 0;
1480
+ #endif
1481
+
1482
+ // Check the type if that is all that is required.
1483
+ if (sipIsErr == NULL)
1484
+ {
1485
+ if (!PyDict_Check(sipPy))
1486
+ return 0;
1487
+
1488
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
1489
+ {
1490
+ for (int i = 0; i < PyList_GET_SIZE(t2obj); ++i) {
1491
+ if (!sipCanConvertToType(PyList_GET_ITEM(t2obj, i),
1492
+ sipType_TYPE2, SIP_NOT_NONE))
1493
+ return 0;
1494
+ }
1495
+ }
1496
+
1497
+ return 1;
1498
+ }
1499
+
1500
+ QMultiMap<int, TYPE2*> *qm = new QMultiMap<int, TYPE2*>;
1501
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
1502
+ {
1503
+ int state2;
1504
+ int k = (int) PyInt_AsLong(t1obj);
1505
+ for (int i = 0; i < PyList_GET_SIZE(t2obj); ++i)
1506
+ {
1507
+ TYPE2 *t2 =
1508
+ reinterpret_cast<TYPE2 *>(sipConvertToType(PyList_GET_ITEM(t2obj, i),
1509
+ sipType_TYPE2,
1510
+ sipTransferObj,
1511
+ SIP_NOT_NONE,
1512
+ &state2,
1513
+ sipIsErr));
1514
+
1515
+ if (*sipIsErr)
1516
+ {
1517
+ sipReleaseType(t2, sipType_TYPE2, state2);
1518
+
1519
+ delete qm;
1520
+ return 0;
1521
+ }
1522
+
1523
+ qm->insert(k, t2);
1524
+
1525
+ sipReleaseType(t2, sipType_TYPE2, state2);
1526
+ }
1527
+ }
1528
+
1529
+ *sipCppPtr = qm;
1530
+
1531
+ return sipGetState(sipTransferObj);
1532
+ %End
1533
+ };
1534
+
1535
+
1410
1536
%MappedType QList < QPair< QString, QList<QString> > >
1411
1537
{
1412
1538
%TypeHeaderCode
0 commit comments