aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue/qtcore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/PySide2/glue/qtcore.cpp')
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 930ad9349..3e1bab97b 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -56,6 +56,56 @@ bool py2kStrCheck(PyObject *obj)
}
// @snippet pystring-check
+// @snippet qsettings-value
+QVariant out = %CPPSELF.value(%1, %2);
+PyTypeObject *typeObj = reinterpret_cast<PyTypeObject*>(%PYARG_3);
+
+if (typeObj) {
+ if (typeObj == &PyList_Type) {
+ QByteArrayList valuesList = out.toByteArray().split(',');
+ const int valuesSize = valuesList.size();
+ if (valuesSize > 0) {
+ PyObject *list = PyList_New(valuesSize);
+ for (int i = 0; i < valuesSize; i++) {
+ PyObject *item = PyUnicode_FromString(valuesList[i].data());
+ PyList_SET_ITEM(list, i, item);
+ Py_DECREF(item);
+ }
+ %PYARG_0 = list;
+
+ } else {
+ %PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
+ }
+ } else if (typeObj == &PyBytes_Type) {
+ QByteArray asByteArray = out.toByteArray();
+ %PYARG_0 = PyBytes_FromString(asByteArray.data());
+ } else if (typeObj == &PyUnicode_Type) {
+ QByteArray asByteArray = out.toByteArray();
+ %PYARG_0 = PyUnicode_FromString(asByteArray.data());
+#ifdef IS_PY3K
+ } else if (typeObj == &PyLong_Type) {
+ float asFloat = out.toFloat();
+ pyResult = PyLong_FromDouble(asFloat);
+#else
+ } else if (typeObj == &PyInt_Type) {
+ float asFloat = out.toFloat();
+ pyResult = PyInt_FromLong(long(asFloat));
+#endif
+ } else if (typeObj == &PyFloat_Type) {
+ float asFloat = out.toFloat();
+ %PYARG_0 = PyFloat_FromDouble(asFloat);
+ }
+ // TODO: PyDict_Type and PyTuple_Type
+}
+else {
+ if (out == 0)
+ %PYARG_0 = Py_None;
+ else
+ %PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
+}
+
+// @snippet qsettings-value
+
// @snippet qvariant-conversion
static const char *QVariant_resolveMetaType(PyTypeObject *type, int *typeId)
{