summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PySide/QtCore/qvariant_conversions.h11
-rw-r--r--tests/QtDeclarative/CMakeLists.txt10
-rw-r--r--tests/QtDeclarative/qdeclarativeview_test.py33
-rw-r--r--tests/QtDeclarative/viewmodel.qml14
4 files changed, 58 insertions, 10 deletions
diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h
index 6c7ebd7..a2ac427 100644
--- a/PySide/QtCore/qvariant_conversions.h
+++ b/PySide/QtCore/qvariant_conversions.h
@@ -18,7 +18,12 @@ struct Converter<QVariant>
{
if (PyObject_TypeCheck(type, &SbkObjectType_Type)) {
SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(type);
- const char* typeName = sbkType->original_name;
+ QByteArray typeName(sbkType->original_name);
+ bool valueType = !typeName.endsWith("*");
+
+ // Do not convert user type of value
+ if (valueType && sbkType->is_user_type)
+ return QByteArray();
int obTypeId = QMetaType::type(typeName);
if (obTypeId) {
@@ -27,7 +32,7 @@ struct Converter<QVariant>
}
// Do not resolve types to value type
- if (!QByteArray(typeName).endsWith("*"))
+ if (valueType)
return QByteArray();
// find in base types
@@ -81,7 +86,7 @@ struct Converter<QVariant>
return convertToVariantList(pyObj);
} else {
// a class supported by QVariant?
- if (Shiboken::isShibokenType(pyObj) && !Shiboken::isUserType(pyObj)) {
+ if (Shiboken::isShibokenType(pyObj)) {
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
int typeCode = 0;
QByteArray typeName = resolveMetaType(reinterpret_cast<PyTypeObject*>(objType), typeCode);
diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt
index 2773849..5ceba42 100644
--- a/tests/QtDeclarative/CMakeLists.txt
+++ b/tests/QtDeclarative/CMakeLists.txt
@@ -1,5 +1,5 @@
-PYSIDE_TEST(bug_451.py FALSE)
-PYSIDE_TEST(bug_456.py FALSE)
-PYSIDE_TEST(qdeclarativenetwork_test.py FALSE)
-PYSIDE_TEST(qdeclarativeview_test.py FALSE)
-PYSIDE_TEST(connect_python_qml.py FALSE)
+PYSIDE_TEST(bug_451.py)
+PYSIDE_TEST(bug_456.py)
+PYSIDE_TEST(qdeclarativenetwork_test.py)
+PYSIDE_TEST(qdeclarativeview_test.py)
+PYSIDE_TEST(connect_python_qml.py)
diff --git a/tests/QtDeclarative/qdeclarativeview_test.py b/tests/QtDeclarative/qdeclarativeview_test.py
index 7a2b657..f8f3a54 100644
--- a/tests/QtDeclarative/qdeclarativeview_test.py
+++ b/tests/QtDeclarative/qdeclarativeview_test.py
@@ -2,11 +2,26 @@
import unittest
-from PySide.QtCore import QUrl
+from PySide.QtCore import QUrl, QObject, Property, Slot
from PySide.QtDeclarative import QDeclarativeView
from helper import adjust_filename, TimedQApplication
+class MyObject(QObject):
+ def __init__(self, text, parent=None):
+ QObject.__init__(self, parent)
+ self._text = text
+
+ def getText(self):
+ return self._text
+
+
+ @Slot(str)
+ def qmlText(self, text):
+ self._qmlText = text
+
+ title = Property(str, getText)
+
class TestQDeclarativeView(TimedQApplication):
@@ -24,7 +39,21 @@ class TestQDeclarativeView(TimedQApplication):
self.assertEqual(view.status(), QDeclarativeView.Ready)
- self.app.exec_()
+
+ def testModelExport(self):
+ print "TEST"
+ view = QDeclarativeView()
+ dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]
+
+ ctxt = view.rootContext()
+ ctxt.setContextProperty("myModel", dataList)
+
+ url = QUrl.fromLocalFile(adjust_filename('viewmodel.qml', __file__))
+ view.setSource(url)
+ view.show()
+
+ self.assertEqual(view.status(), QDeclarativeView.Ready)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/QtDeclarative/viewmodel.qml b/tests/QtDeclarative/viewmodel.qml
new file mode 100644
index 0000000..badce7d
--- /dev/null
+++ b/tests/QtDeclarative/viewmodel.qml
@@ -0,0 +1,14 @@
+import Qt 4.7
+
+ListView {
+ width: 100; height: 100
+ anchors.fill: parent
+
+ model: myModel
+ delegate: Rectangle {
+ height: 25
+ width: 100
+ Text { text: title }
+ }
+}
+