diff options
author | renatofilho <renato.filho@openbossa.org> | 2010-10-19 15:21:23 -0300 |
---|---|---|
committer | renatofilho <renato.filho@openbossa.org> | 2010-10-19 17:07:37 -0300 |
commit | ae942fd5dae9e59cae78a32ed598001bf70e523e (patch) | |
tree | 0da428c3cdee66337ad15164b1accf9392ffd347 | |
parent | bea4934c04fe49eedff218e9905926ec3477e0b1 (diff) |
Included QSignalTransition constructor to support Signal objects.
Created unit test.
Fixes bug #416
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com>
Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 20 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/bug_416.py | 43 |
3 files changed, 62 insertions, 2 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index e9f5f318a..6f9524be0 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2640,7 +2640,24 @@ <object-type name="QSequentialAnimationGroup"/> - <object-type name="QSignalTransition"/> + <object-type name="QSignalTransition"> + <add-function signature="QSignalTransition(PyObject*, QState*)" return-type="QSignalTransition*"> + <modify-argument index="2"> + <replace-default-expression with="0" /> + </modify-argument> + <inject-code> + if (PyObject_TypeCheck(%1, &PySide::SignalInstance_Type)) { + PySide::SignalInstanceData* data = (PySide::SignalInstanceData*) %PYARG_1; + Shiboken::AutoDecRef obType(PyObject_Type(data->source)); + QObject* sender = %CONVERTTOCPP[QObject*](data->source); + if (sender) { + QByteArray signature(data->signature); // Append SIGNAL flag (2) + %0 = new QSignalTransitionWrapper(sender, "2" + signature, %2); + } + } + </inject-code> + </add-function> + </object-type> <object-type name="QState"> <enum-type name="ChildMode"/> @@ -2663,7 +2680,6 @@ } </inject-code> </modify-function> - <modify-function signature="addTransition(QAbstractState*)"> <modify-argument index="1"> <parent index="this" action="add"/> diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 4a293f2dd..21aa7690d 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -12,6 +12,7 @@ PYSIDE_TEST(bug_363.py) PYSIDE_TEST(bug_367.py) PYSIDE_TEST(bug_389.py) PYSIDE_TEST(bug_400.py) +PYSIDE_TEST(bug_416.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_416.py b/tests/QtGui/bug_416.py new file mode 100644 index 000000000..20b8d0c12 --- /dev/null +++ b/tests/QtGui/bug_416.py @@ -0,0 +1,43 @@ +#!/usr/bin/python + +import unittest +from helper import TimedQApplication +from PySide.QtCore import QSignalTransition, QState, Qt, QStateMachine +from PySide.QtGui import QCheckBox + +class CheckedTransition(QSignalTransition): + def __init__(self, check): + QSignalTransition.__init__(self, check.stateChanged[int]) + self.eventTested = False + + def eventTest(self, event): + self.eventTested = True + if not QSignalTransition.eventTest(self, event): + return False + return event.arguments()[0] == Qt.Checked + +class TestBug(TimedQApplication): + def testCase(self): + check = QCheckBox() + check.setTristate(True) + + s1 = QState() + s2 = QState() + + t1 = CheckedTransition(check) + t1.setTargetState(s2) + s1.addTransition(t1) + + machine = QStateMachine() + machine.addState(s1) + machine.addState(s2) + machine.setInitialState(s1) + machine.start() + + check.stateChanged[int].emit(1) + check.show() + self.app.exec_() + self.assert_(t1.eventTested) + +if __name__ == '__main__': + unittest.main() |