aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-02-08 15:29:58 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-02-09 19:17:02 -0200
commitfad2f7e53de6274027637b6b61858fb825f6616f (patch)
tree0519d186cfe411be19b9a7b26dc7e3377c27b99b
parentd54d860e13fb76e96460f9a4268c2649cf8152c4 (diff)
Adding support for connect(obj, signal, slot)
window.connect(button, SIGNAL('clicked()'), SLOT('close()') should connect button.clicked to window.close
-rw-r--r--PySide/QtCore/typesystem_core.xml5
-rw-r--r--tests/signals/self_connect_test.py37
2 files changed, 41 insertions, 1 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 33f63bc09..63f67fac9 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -1447,7 +1447,10 @@
</modify-argument>
</modify-function>
<modify-function signature="thread() const" remove="all"/>
- <modify-function signature="connect(const QObject*, const char*, const char *, Qt::ConnectionType) const" remove="all"/>
+ <modify-function signature="connect(const QObject*, const char*, const char *, Qt::ConnectionType) const">
+ // %FUNCTION_NAME() - disable generation of function call.
+ %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %CPPSELF, %4));
+ </modify-function>
<modify-function signature="connect(const QObject*, const char*, const QObject*, const char *, Qt::ConnectionType)">
<inject-code class="target" position="beginning" file="">
// %FUNCTION_NAME() - disable generation of function call.
diff --git a/tests/signals/self_connect_test.py b/tests/signals/self_connect_test.py
new file mode 100644
index 000000000..f4d90c6bb
--- /dev/null
+++ b/tests/signals/self_connect_test.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+'''Using self.connect(signal, method)'''
+
+import unittest
+
+from PySide.QtCore import QObject, SIGNAL, SLOT
+from PySide.QtGui import QPushButton, QWidget
+
+from helper import UsesQApplication
+
+
+class SelfConnect(UsesQApplication):
+
+ def testButtonClickClose(self):
+ button = QPushButton()
+ button.connect(button, SIGNAL('clicked()'), SLOT('close()'))
+
+ button.show()
+ self.assert_(button.isVisible())
+ button.click()
+ self.assert_(not button.isVisible())
+
+ def testWindowButtonClickClose(self):
+ button = QPushButton()
+ window = QWidget()
+ window.connect(button, SIGNAL('clicked()'), SLOT('close()'))
+
+ window.show()
+ self.assert_(window.isVisible())
+ button.click()
+ self.assert_(not window.isVisible())
+
+
+
+if __name__ == '__main__':
+ unittest.main()