diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-11-10 20:23:57 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-11-10 20:23:57 -0200 |
commit | 41b6f14acbde484cad2c8b670e5a3556ec62d7cf (patch) | |
tree | e65034254700a0510b801335b9da7155baba5d51 | |
parent | 23c1b92073a25e23e2c3bdb2e1a758cfbb64fe79 (diff) | |
parent | 2ef14fcc12f003620f85a30f6a4b00e8fee654d2 (diff) | |
download | pyside-41b6f14acbde484cad2c8b670e5a3556ec62d7cf.tar.gz pyside-41b6f14acbde484cad2c8b670e5a3556ec62d7cf.tar.xz pyside-41b6f14acbde484cad2c8b670e5a3556ec62d7cf.zip |
Merge branch 1.0 into master
Conflicts:
PySide/QtCore/qvariant_conversions.h
-rw-r--r-- | PySide/QtCore/qvariant_conversions.h | 11 | ||||
-rw-r--r-- | tests/QtDeclarative/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/QtDeclarative/qdeclarativeview_test.py | 33 | ||||
-rw-r--r-- | tests/QtDeclarative/viewmodel.qml | 14 |
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 } + } +} + |