diff options
Diffstat (limited to 'PySide/QtGui')
-rw-r--r-- | PySide/QtGui/glue/qlayout_help_functions.cpp (renamed from PySide/QtGui/glue/qlayout_help_functions.h) | 38 | ||||
-rw-r--r-- | PySide/QtGui/glue/qmenu_glue.cpp (renamed from PySide/QtGui/glue/qmenu_glue.h) | 3 | ||||
-rw-r--r-- | PySide/QtGui/glue/qmenubar_glue.cpp (renamed from PySide/QtGui/glue/qmenubar_glue.h) | 2 | ||||
-rw-r--r-- | PySide/QtGui/glue/qtgui_qapp.cpp | 2 | ||||
-rw-r--r-- | PySide/QtGui/glue/qwidget_glue.cpp (renamed from PySide/QtGui/glue/qwidget_glue.h) | 8 | ||||
-rw-r--r-- | PySide/QtGui/glue/wid_conversions.h | 39 | ||||
-rw-r--r-- | PySide/QtGui/qpixmap_conversion.h | 49 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 41 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_win.xml | 2 |
9 files changed, 40 insertions, 144 deletions
diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.cpp index 00f0dbde7..b36606136 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.cpp @@ -1,6 +1,3 @@ -#ifndef QLAYOUT_HELP_FUNCTIONS -#define QLAYOUT_HELP_FUNCTIONS - void addLayoutOwnership(QLayout* layout, QLayoutItem* item); void removeLayoutOwnership(QLayout* layout, QWidget* widget); @@ -16,21 +13,20 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget) QWidget *lw = layout->parentWidget(); QWidget *pw = widget->parentWidget(); - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget)); - //Transfer parent to layout widget + //Transfer parent to layout widget if (pw && lw && pw != lw) Shiboken::Object::setParent(0, pyChild); if (!lw && !pw) { //keep the reference while the layout is orphan - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout)); Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true); } else { if (!lw) lw = pw; - - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(lw)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](lw)); Shiboken::Object::setParent(pyParent, pyChild); } } @@ -41,8 +37,8 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other) QWidget* parent = layout->parentWidget(); if (!parent) { //keep the reference while the layout is orphan - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other)); Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true); return; } @@ -51,14 +47,12 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other) QLayoutItem* item = other->itemAt(i); if (PyErr_Occurred() || !item) return; - addLayoutOwnership(layout, item); } - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other)); Shiboken::Object::setParent(pyParent, pyChild); - } inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item) @@ -75,8 +69,8 @@ inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item) addLayoutOwnership(layout, l); } - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayoutItem*>::toPython(item)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item)); Shiboken::Object::setParent(pyParent, pyChild); } @@ -86,13 +80,13 @@ static void removeWidgetFromLayout(QLayout* layout, QWidget* widget) if (!parent) { //remove reference on layout - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(layout)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget)); Shiboken::Object::removeReference(reinterpret_cast<SbkObject*>(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild); } else { //give the ownership to parent - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget)); Shiboken::Object::setParent(pyParent, pyChild); } } @@ -108,7 +102,7 @@ inline void removeLayoutOwnership(QLayout* layout, QLayoutItem* item) removeLayoutOwnership(layout, l); } - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayoutItem*>::toPython(item)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item)); Shiboken::Object::invalidate(pyChild); Shiboken::Object::setParent(0, pyChild); } @@ -126,5 +120,3 @@ inline void removeLayoutOwnership(QLayout* layout, QWidget* widget) removeLayoutOwnership(layout, item); } } - -#endif diff --git a/PySide/QtGui/glue/qmenu_glue.h b/PySide/QtGui/glue/qmenu_glue.cpp index 94eab15e0..0636dfab0 100644 --- a/PySide/QtGui/glue/qmenu_glue.h +++ b/PySide/QtGui/glue/qmenu_glue.cpp @@ -1,4 +1,3 @@ - inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QString& text, PyObject* callback, const QKeySequence& shortcut) { QAction* act = new QAction(text, self); @@ -11,7 +10,7 @@ inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QSt self->addAction(act); - PyObject* pyAct = Shiboken::Converter<QAction*>::toPython(act); + PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act); Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback)); if (result.isNull()) { Py_DECREF(pyAct); diff --git a/PySide/QtGui/glue/qmenubar_glue.h b/PySide/QtGui/glue/qmenubar_glue.cpp index 9568fa87c..2326a76cc 100644 --- a/PySide/QtGui/glue/qmenubar_glue.h +++ b/PySide/QtGui/glue/qmenubar_glue.cpp @@ -5,7 +5,7 @@ addActionWithPyObject(QMenuBar* self, const QString& text, PyObject* callback) self->addAction(act); - PyObject* pyAct = Shiboken::Converter<QAction*>::toPython(act); + PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act); PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered(bool)), callback); diff --git a/PySide/QtGui/glue/qtgui_qapp.cpp b/PySide/QtGui/glue/qtgui_qapp.cpp index 4c4508b70..5148b579b 100644 --- a/PySide/QtGui/glue/qtgui_qapp.cpp +++ b/PySide/QtGui/glue/qtgui_qapp.cpp @@ -1,6 +1,6 @@ // Init qApp macro to None. if (qApp) { - PyObject* pyApp = Shiboken::Converter<QApplication*>::toPython(qApp); + PyObject* pyApp = %CONVERTTOPYTHON[QApplication*](qApp); Py_INCREF(pyApp); PyModule_AddObject(module, "qApp", pyApp); } else { diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.cpp index 931a5288e..cfa3f6757 100644 --- a/PySide/QtGui/glue/qwidget_glue.h +++ b/PySide/QtGui/glue/qwidget_glue.cpp @@ -10,7 +10,7 @@ static QString retrieveObjectName(PyObject *obj) **/ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) { - Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent)); + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent)); for (int i=0; i < layout->count(); i++) { QLayoutItem* item = layout->itemAt(i); @@ -21,7 +21,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) if (w) { QWidget* pw = w->parentWidget(); if (pw != parent) { - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(w)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](w)); Shiboken::Object::setParent(pyParent, pyChild); } } else { @@ -31,7 +31,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) } } - Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](layout)); Shiboken::Object::setParent(pyParent, pyChild); //remove previous references Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None); @@ -46,7 +46,7 @@ static inline void qwidgetSetLayout(QWidget *self, QLayout *layout) if (oldParent && oldParent != self) { if (oldParent->isWidgetType()) { // remove old parent policy - Shiboken::AutoDecRef pyLayout(Shiboken::Converter<QLayout*>::toPython(layout)); + Shiboken::AutoDecRef pyLayout(%CONVERTTOPYTHON[QLayout*](layout)); Shiboken::Object::setParent(Py_None, pyLayout); } else { PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", diff --git a/PySide/QtGui/glue/wid_conversions.h b/PySide/QtGui/glue/wid_conversions.h deleted file mode 100644 index 68d752884..000000000 --- a/PySide/QtGui/glue/wid_conversions.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef Q_WS_WIN - -namespace Shiboken { -template <> -struct Converter<WId> -{ - static bool checkType(PyObject* pyObj) - { - return false; - } - - static bool isConvertible(PyObject* pyobj) - { - return pyobj == Py_None || PyNumber_Check(pyobj); - } - - static inline PyObject* toPython(void* cppobj) - { - // not supported - Q_ASSERT(true); - return 0; - } - - static PyObject* toPython(WId cppobj) - { - return PyLong_FromVoidPtr((void*)cppobj); - } - - static WId toCpp(PyObject* pyobj) - { - if (pyobj == Py_None) - return 0; - return (WId)PyLong_AsVoidPtr(pyobj); - } -}; - -} - -#endif diff --git a/PySide/QtGui/qpixmap_conversion.h b/PySide/QtGui/qpixmap_conversion.h deleted file mode 100644 index fc49af6be..000000000 --- a/PySide/QtGui/qpixmap_conversion.h +++ /dev/null @@ -1,49 +0,0 @@ -namespace Shiboken { -inline bool Converter<QPixmap>::checkType(PyObject* pyObj) -{ - return ValueTypeConverter<QPixmap>::checkType(pyObj); -} - -inline bool Converter<QPixmap>::isConvertible(PyObject* pyobj) -{ - if (ValueTypeConverter<QPixmap>::isConvertible(pyobj)) - return true; - SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<QPixmap>()); - bool isVariant = Shiboken::Converter<QVariant>::checkType(pyobj); - if (isVariant) { - QVariant var(Shiboken::Converter<QVariant>::toCpp(pyobj)); - return var.type() == QVariant::Pixmap; - } else if (Shiboken::Converter<QSize>::checkType(pyobj) || Shiboken::Converter<QString>::checkType(pyobj)) { - return true; - } else { - return Shiboken::ObjectType::isExternalConvertible(shiboType, pyobj); - } - return false; - -} - -inline QPixmap Converter<QPixmap>::toCpp(PyObject* pyobj) -{ - SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<QPixmap>()); - bool isVariant = Converter<QVariant>::checkType(pyobj); - if (isVariant) { - QVariant var(Converter<QVariant>::toCpp(pyobj)); - return var.value<QPixmap>(); - } else if (Converter<QSize>::checkType(pyobj)) { - return QPixmap(Shiboken::Converter<QSize >::toCpp(pyobj)); - } else if (Converter<QString>::checkType(pyobj)) { - return QPixmap(Shiboken::Converter<QString >::toCpp(pyobj)); - } else if (Shiboken::ObjectType::isExternalConvertible(shiboType, pyobj) && Shiboken::ObjectType::hasExternalCppConversions(shiboType)) { - QPixmap* cptr = reinterpret_cast<QPixmap*>(Shiboken::ObjectType::callExternalCppConversion(shiboType, pyobj)); - std::auto_ptr<QPixmap> cptr_auto_ptr(cptr); - return *cptr; - } - - return *Converter<QPixmap*>::toCpp(pyobj); -} - -inline PyObject* Converter<QPixmap>::toPython(const QPixmap& cppObj) -{ - return ValueTypeConverter<QPixmap>::toPython(cppObj); -} -} diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 6922bcfa9..e9058b563 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -798,7 +798,14 @@ free(xpm); </template> <value-type name="QPixmap" > - <conversion-rule file="qpixmap_conversion.h" /> + <!--<conversion-rule>--> + <!--<target-to-native replace="no">--> + <!--<add-conversion type="QVariant" check="%CHECKTYPE[QVariant](%in)">--> + <!--QVariant in = %CONVERTTOCPP[QVariant](%in);--> + <!--%out = in.value<%OUTTYPE>();--> + <!--</add-conversion>--> + <!--</target-to-native>--> + <!--</conversion-rule>--> <add-function signature="QPixmap(const QImage&)"> <modify-argument index="1"> <rename to="image"/> @@ -2357,9 +2364,7 @@ </modify-function> </object-type> <object-type name="QMenu"> - <extra-includes> - <include file-name="glue/qmenu_glue.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qmenu_glue.cpp"/> <modify-function signature="exec()" rename="exec_" allow-thread="yes" /> <modify-function signature="exec(const QPoint&, QAction*)" rename="exec_" allow-thread="yes" /> @@ -2453,9 +2458,7 @@ </object-type> <object-type name="QMenuBar"> - <extra-includes> - <include file-name="glue/qmenubar_glue.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qmenubar_glue.cpp"/> <modify-function signature="addAction(const QString&)"> <modify-argument index="return"> <parent index="this" action="add"/> @@ -3136,10 +3139,7 @@ <modify-function signature="getColor(const QColor&, QWidget*, const QString&, QFlags<QColorDialog::ColorDialogOption>)" allow-thread="yes" /> </object-type> <object-type name="QLayout"> - - <extra-includes> - <include file-name="glue/qlayout_help_functions.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/> <enum-type name="SizeConstraint"/> @@ -3239,9 +3239,7 @@ </object-type> <object-type name="QStackedLayout"> - <extra-includes> - <include file-name="glue/qlayout_help_functions.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/> <enum-type name="StackingMode"/> <modify-function signature="insertWidget(int,QWidget*)"> <inject-code class="target" position="beginning"> @@ -3251,9 +3249,7 @@ </object-type> <object-type name="QBoxLayout"> - <extra-includes> - <include file-name="glue/qlayout_help_functions.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/> <enum-type name="Direction" /> @@ -3297,9 +3293,7 @@ </object-type> <object-type name="QGridLayout"> - <extra-includes> - <include file-name="glue/qlayout_help_functions.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/> <modify-function signature="itemAtPosition (int, int) const"> <modify-argument index="return"> <define-ownership owner="default"/> @@ -4027,9 +4021,10 @@ <extra-includes> <include file-name="QIcon" location="global"/> <include file-name="QMessageBox" location="global"/> - <include file-name="glue/qwidget_glue.h" location="local"/> </extra-includes> + <inject-code class="native" file="glue/qwidget_glue.cpp" position="beginning" /> + <enum-type name="RenderFlag" flags="RenderFlags"/> <modify-function signature="setParent(QWidget*)"> @@ -5687,9 +5682,7 @@ </modify-function> </object-type> <object-type name="QFormLayout"> - <extra-includes> - <include file-name="glue/qlayout_help_functions.h" location="local"/> - </extra-includes> + <inject-code class="native" position="beginning" file="glue/qlayout_help_functions.cpp"/> <enum-type name="FieldGrowthPolicy"/> <enum-type name="ItemRole"/> diff --git a/PySide/QtGui/typesystem_gui_win.xml b/PySide/QtGui/typesystem_gui_win.xml index 93d422a22..387964d2b 100644 --- a/PySide/QtGui/typesystem_gui_win.xml +++ b/PySide/QtGui/typesystem_gui_win.xml @@ -20,7 +20,7 @@ --> <typesystem package="PySide.QtGui"> <primitive-type name="WId" target-lang-api-name="PyObject"> - <conversion-rule file="glue/wid_conversions.h"> + <conversion-rule> <native-to-target> #ifdef IS_PY3K return PyCapsule_New(%in, 0, 0); |