aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtGui/glue
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-02-03 13:26:36 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-02-03 18:26:34 -0200
commitecf529ce6a0d75f4694168f62e83d49230ed27eb (patch)
tree917c3e9231cafc70ea946dbceb7c7558727197b2 /PySide/QtGui/glue
parent3b41e703769b036072e3e3345dd480778ee93918 (diff)
Ported QWidget inject code.
Reviewed by Lauro Moura <lauro.neto@openbossa.org>
Diffstat (limited to 'PySide/QtGui/glue')
-rw-r--r--PySide/QtGui/glue/qwidget_glue.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h
new file mode 100644
index 000000000..a6cd3b7d4
--- /dev/null
+++ b/PySide/QtGui/glue/qwidget_glue.h
@@ -0,0 +1,39 @@
+/**
+ * Tranfer objects ownership from layout to widget
+ **/
+static inline void
+qwidgetReparentLayout(QWidget *parent, QLayout *layout)
+{
+ Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
+
+ for (int i=0; i < layout->count(); i++)
+ {
+ QLayoutItem *item = layout->itemAt(i);
+ QWidget *w = item->widget();
+
+ if (w)
+ {
+ Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(w));
+ Shiboken::setParent(pyParent, pyChild);
+ }
+ else
+ {
+ QLayout *l = item->layout();
+ if (l)
+ qwidgetReparentLayout(parent, l);
+ }
+ }
+
+ Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout));
+ Shiboken::setParent(pyParent, pyChild);
+}
+
+static inline void
+qwidgetSetLayout(QWidget *self, QLayout *layout)
+{
+ if (self->layout())
+ return;
+
+ qwidgetReparentLayout(self, layout);
+ self->setLayout(layout);
+}