@@ -6,6 +6,7 @@ which are not wrapped by PyQt:
6
6
- QSet<int>
7
7
- QSet<TYPE>
8
8
- QMap<int, QMap<int, TYPE> >
9
+ - QMap<QString, QVariant::Type>
9
10
- QMap<TYPE1, TYPE2*>
10
11
- QMultiMap<double, TYPE2>
11
12
*/
@@ -172,9 +173,6 @@ template <TYPE>
172
173
};
173
174
174
175
175
-
176
-
177
-
178
176
%MappedType QSet<int>
179
177
{
180
178
%TypeHeaderCode
@@ -191,16 +189,16 @@ template <TYPE>
191
189
// Set the list elements.
192
190
QSet<int>::iterator it = sipCpp->begin();
193
191
for (int i = 0; it != sipCpp->end(); ++it, ++i)
194
- {
192
+ {
195
193
PyObject *tobj;
196
194
197
195
if ((tobj = PyInt_FromLong(*it)) == NULL)
198
- {
196
+ {
199
197
Py_DECREF(l);
200
198
return NULL;
201
- }
199
+ }
202
200
PyList_SET_ITEM(l, i, tobj);
203
- }
201
+ }
204
202
205
203
return l;
206
204
%End
@@ -213,9 +211,9 @@ template <TYPE>
213
211
QSet<int> *qset = new QSet<int>;
214
212
215
213
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
216
- {
214
+ {
217
215
qset->insert(PyInt_AsLong(PyList_GET_ITEM(sipPy, i)));
218
- }
216
+ }
219
217
220
218
*sipCppPtr = qset;
221
219
return sipGetState(sipTransferObj);
@@ -224,7 +222,6 @@ template <TYPE>
224
222
};
225
223
226
224
227
-
228
225
template <TYPE>
229
226
%MappedType QSet<TYPE>
230
227
{
@@ -415,6 +412,105 @@ template<TYPE>
415
412
416
413
};
417
414
415
+ %MappedType QMap<QString, QVariant::Type>
416
+ {
417
+ %TypeHeaderCode
418
+ #include <QMap>
419
+ %End
420
+
421
+ %ConvertFromTypeCode
422
+ // Create the dictionary.
423
+ PyObject *d = PyDict_New();
424
+
425
+ if (!d)
426
+ return NULL;
427
+
428
+ // Set the dictionary elements.
429
+ QMap<QString, QVariant::Type>::const_iterator i = sipCpp->constBegin();
430
+
431
+ while (i != sipCpp->constEnd())
432
+ {
433
+ QString *t1 = new QString(i.key());
434
+
435
+ PyObject *t1obj = sipConvertFromNewInstance(t1, sipClass_QString, sipTransferObj);
436
+ PyObject *t2obj = PyInt_FromLong( (long) i.value() );
437
+
438
+ if (t1obj == NULL || t2obj == NULL || PyDict_SetItem(d, t1obj, t2obj) < 0)
439
+ {
440
+ Py_DECREF(d);
441
+
442
+ if (t1obj) {
443
+ Py_DECREF(t1obj);
444
+ } else {
445
+ delete t1;
446
+ }
447
+
448
+ if (t2obj) {
449
+ Py_DECREF(t2obj);
450
+ }
451
+
452
+ return NULL;
453
+ }
454
+
455
+ Py_DECREF(t1obj);
456
+ Py_DECREF(t2obj);
457
+
458
+ ++i;
459
+ }
460
+
461
+ return d;
462
+ %End
463
+
464
+ %ConvertToTypeCode
465
+ PyObject *t1obj, *t2obj;
466
+ #if PY_VERSION_HEX >= 0x02050000
467
+ Py_ssize_t i = 0;
468
+ #else
469
+ int i = 0;
470
+ #endif
471
+
472
+
473
+ // Check the type if that is all that is required.
474
+ if (sipIsErr == NULL)
475
+ {
476
+ if (!PyDict_Check(sipPy))
477
+ return 0;
478
+
479
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
480
+ {
481
+ if (!sipCanConvertToInstance(t1obj, sipClass_QString, SIP_NOT_NONE))
482
+ return 0;
483
+ }
484
+
485
+ return 1;
486
+ }
487
+
488
+ QMap<QString, QVariant::Type> *qm = new QMap<QString, QVariant::Type>;
489
+
490
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
491
+ {
492
+ int state;
493
+
494
+ QString *t1 = reinterpret_cast<QString *>(sipConvertToInstance(t1obj, sipClass_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
495
+ QVariant::Type t2 = (QVariant::Type) PyInt_AsLong(t1obj);
496
+
497
+ if (*sipIsErr)
498
+ {
499
+ sipReleaseInstance(t1, sipClass_QString, state);
500
+ delete qm;
501
+ return 0;
502
+ }
503
+
504
+ qm->insert(*t1, t2);
505
+
506
+ sipReleaseInstance(t1, sipClass_QString, state);
507
+ }
508
+
509
+ *sipCppPtr = qm;
510
+
511
+ return sipGetState(sipTransferObj);
512
+ %End
513
+ };
418
514
419
515
template<TYPE1, TYPE2>
420
516
%MappedType QMap<TYPE1, TYPE2*>
@@ -523,8 +619,6 @@ template<TYPE1, TYPE2>
523
619
%End
524
620
};
525
621
526
-
527
-
528
622
template<double, TYPE2>
529
623
%MappedType QMultiMap<double, TYPE2>
530
624
{
0 commit comments