Merge branch 1.0 into master
Conflicts: PySide/QtCore/qvariant_conversions.h
This commit is contained in:
commit
41b6f14acb
4 changed files with 58 additions and 10 deletions
|
|
@ -18,7 +18,12 @@ struct Converter<QVariant>
|
||||||
{
|
{
|
||||||
if (PyObject_TypeCheck(type, &SbkObjectType_Type)) {
|
if (PyObject_TypeCheck(type, &SbkObjectType_Type)) {
|
||||||
SbkObjectType* sbkType = reinterpret_cast<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);
|
int obTypeId = QMetaType::type(typeName);
|
||||||
if (obTypeId) {
|
if (obTypeId) {
|
||||||
|
|
@ -27,7 +32,7 @@ struct Converter<QVariant>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not resolve types to value type
|
// Do not resolve types to value type
|
||||||
if (!QByteArray(typeName).endsWith("*"))
|
if (valueType)
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
|
||||||
// find in base types
|
// find in base types
|
||||||
|
|
@ -81,7 +86,7 @@ struct Converter<QVariant>
|
||||||
return convertToVariantList(pyObj);
|
return convertToVariantList(pyObj);
|
||||||
} else {
|
} else {
|
||||||
// a class supported by QVariant?
|
// a class supported by QVariant?
|
||||||
if (Shiboken::isShibokenType(pyObj) && !Shiboken::isUserType(pyObj)) {
|
if (Shiboken::isShibokenType(pyObj)) {
|
||||||
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
|
SbkObjectType* objType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
|
||||||
int typeCode = 0;
|
int typeCode = 0;
|
||||||
QByteArray typeName = resolveMetaType(reinterpret_cast<PyTypeObject*>(objType), typeCode);
|
QByteArray typeName = resolveMetaType(reinterpret_cast<PyTypeObject*>(objType), typeCode);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
PYSIDE_TEST(bug_451.py FALSE)
|
PYSIDE_TEST(bug_451.py)
|
||||||
PYSIDE_TEST(bug_456.py FALSE)
|
PYSIDE_TEST(bug_456.py)
|
||||||
PYSIDE_TEST(qdeclarativenetwork_test.py FALSE)
|
PYSIDE_TEST(qdeclarativenetwork_test.py)
|
||||||
PYSIDE_TEST(qdeclarativeview_test.py FALSE)
|
PYSIDE_TEST(qdeclarativeview_test.py)
|
||||||
PYSIDE_TEST(connect_python_qml.py FALSE)
|
PYSIDE_TEST(connect_python_qml.py)
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,26 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from PySide.QtCore import QUrl
|
from PySide.QtCore import QUrl, QObject, Property, Slot
|
||||||
from PySide.QtDeclarative import QDeclarativeView
|
from PySide.QtDeclarative import QDeclarativeView
|
||||||
|
|
||||||
from helper import adjust_filename, TimedQApplication
|
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):
|
class TestQDeclarativeView(TimedQApplication):
|
||||||
|
|
||||||
|
|
@ -24,7 +39,21 @@ class TestQDeclarativeView(TimedQApplication):
|
||||||
|
|
||||||
self.assertEqual(view.status(), QDeclarativeView.Ready)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
14
tests/QtDeclarative/viewmodel.qml
Normal file
14
tests/QtDeclarative/viewmodel.qml
Normal file
|
|
@ -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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue