Skip to content

Commit 130b0de

Browse files
authored
Python Bindings: Fix findParent that was not working as expected (#349)
1 parent b5b251d commit 130b0de

File tree

1 file changed

+138
-138
lines changed

1 file changed

+138
-138
lines changed

sip/ads_globals.sip

Lines changed: 138 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,138 @@
1-
%Import QtWidgets/QtWidgetsmod.sip
2-
3-
%If (Qt_5_0_0 -)
4-
5-
%ModuleHeaderCode
6-
PyObject *qtads_FindParent(PyObject* type, const QWidget *child);
7-
%End
8-
9-
%ModuleCode
10-
PyObject *qtads_FindParent(PyObject* type, const QWidget *w)
11-
{
12-
// Check that the types checking was successful.
13-
if (!type)
14-
return 0;
15-
16-
QWidget* parentWidget = w->parentWidget();
17-
18-
while (parentWidget)
19-
{
20-
PyObject *ParentImpl = sipConvertFromType(parentWidget, sipType_QObject, 0);
21-
if (!ParentImpl)
22-
{
23-
return 0;
24-
}
25-
26-
if (PyType_IsSubtype((PyTypeObject *)type, Py_TYPE(ParentImpl)))
27-
return ParentImpl;
28-
29-
Py_DECREF(ParentImpl);
30-
31-
parentWidget = parentWidget->parentWidget();
32-
}
33-
34-
Py_INCREF(Py_None);
35-
return Py_None;
36-
}
37-
%End
38-
39-
namespace ads
40-
{
41-
%TypeHeaderCode
42-
#include <ads_globals.h>
43-
%End
44-
45-
enum DockWidgetArea
46-
{
47-
NoDockWidgetArea,
48-
LeftDockWidgetArea,
49-
RightDockWidgetArea,
50-
TopDockWidgetArea,
51-
BottomDockWidgetArea,
52-
CenterDockWidgetArea,
53-
54-
InvalidDockWidgetArea,
55-
OuterDockAreas,
56-
AllDockAreas
57-
};
58-
typedef QFlags<ads::DockWidgetArea> DockWidgetAreas;
59-
60-
61-
enum TitleBarButton
62-
{
63-
TitleBarButtonTabsMenu,
64-
TitleBarButtonUndock,
65-
TitleBarButtonClose
66-
};
67-
68-
enum eDragState
69-
{
70-
DraggingInactive,
71-
DraggingMousePressed,
72-
DraggingTab,
73-
DraggingFloatingWidget
74-
};
75-
76-
enum eIcon
77-
{
78-
TabCloseIcon,
79-
DockAreaMenuIcon,
80-
DockAreaUndockIcon,
81-
DockAreaCloseIcon,
82-
83-
IconCount,
84-
};
85-
86-
enum eBitwiseOperator
87-
{
88-
BitwiseAnd,
89-
BitwiseOr
90-
};
91-
92-
namespace internal
93-
{
94-
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
95-
void hideEmptyParentSplitters(ads::CDockSplitter* FirstParentSplitter);
96-
97-
class CDockInsertParam
98-
{
99-
%TypeHeaderCode
100-
#include <ads_globals.h>
101-
%End
102-
103-
public:
104-
Qt::Orientation orientation() const;
105-
bool append() const;
106-
int insertOffset() const;
107-
};
108-
ads::internal::CDockInsertParam dockAreaInsertParameters(ads::DockWidgetArea Area);
109-
110-
SIP_PYOBJECT findParent(SIP_PYTYPE type, const QWidget *w) const /TypeHint="QObject"/;
111-
%MethodCode
112-
sipRes = qtads_FindParent(a0, a1);
113-
114-
if (!sipRes)
115-
{
116-
sipIsErr = 1;
117-
}
118-
%End
119-
120-
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
121-
122-
QPoint globalPositionOf(QMouseEvent* ev);
123-
124-
void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap, ads::eIcon CustomIconId);
125-
126-
enum eRepolishChildOptions
127-
{
128-
RepolishIgnoreChildren,
129-
RepolishDirectChildren,
130-
RepolishChildrenRecursively
131-
};
132-
133-
void repolishStyle(QWidget* w, ads::internal::eRepolishChildOptions Options = ads::internal::RepolishIgnoreChildren);
134-
};
135-
136-
};
137-
138-
%End
1+
%Import QtWidgets/QtWidgetsmod.sip
2+
3+
%If (Qt_5_0_0 -)
4+
5+
%ModuleHeaderCode
6+
PyObject *qtads_FindParent(PyObject* type, const QWidget *child);
7+
%End
8+
9+
%ModuleCode
10+
PyObject *qtads_FindParent(PyObject* type, const QWidget *w)
11+
{
12+
// Check that the types checking was successful.
13+
if (!type)
14+
return 0;
15+
16+
QWidget* parentWidget = w->parentWidget();
17+
18+
while (parentWidget)
19+
{
20+
PyObject *ParentImpl = sipConvertFromType(parentWidget, sipType_QObject, 0);
21+
if (!ParentImpl)
22+
{
23+
return 0;
24+
}
25+
26+
if (PyObject_IsInstance(ParentImpl, type))
27+
return ParentImpl;
28+
29+
Py_DECREF(ParentImpl);
30+
31+
parentWidget = parentWidget->parentWidget();
32+
}
33+
34+
Py_INCREF(Py_None);
35+
return Py_None;
36+
}
37+
%End
38+
39+
namespace ads
40+
{
41+
%TypeHeaderCode
42+
#include <ads_globals.h>
43+
%End
44+
45+
enum DockWidgetArea
46+
{
47+
NoDockWidgetArea,
48+
LeftDockWidgetArea,
49+
RightDockWidgetArea,
50+
TopDockWidgetArea,
51+
BottomDockWidgetArea,
52+
CenterDockWidgetArea,
53+
54+
InvalidDockWidgetArea,
55+
OuterDockAreas,
56+
AllDockAreas
57+
};
58+
typedef QFlags<ads::DockWidgetArea> DockWidgetAreas;
59+
60+
61+
enum TitleBarButton
62+
{
63+
TitleBarButtonTabsMenu,
64+
TitleBarButtonUndock,
65+
TitleBarButtonClose
66+
};
67+
68+
enum eDragState
69+
{
70+
DraggingInactive,
71+
DraggingMousePressed,
72+
DraggingTab,
73+
DraggingFloatingWidget
74+
};
75+
76+
enum eIcon
77+
{
78+
TabCloseIcon,
79+
DockAreaMenuIcon,
80+
DockAreaUndockIcon,
81+
DockAreaCloseIcon,
82+
83+
IconCount,
84+
};
85+
86+
enum eBitwiseOperator
87+
{
88+
BitwiseAnd,
89+
BitwiseOr
90+
};
91+
92+
namespace internal
93+
{
94+
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
95+
void hideEmptyParentSplitters(ads::CDockSplitter* FirstParentSplitter);
96+
97+
class CDockInsertParam
98+
{
99+
%TypeHeaderCode
100+
#include <ads_globals.h>
101+
%End
102+
103+
public:
104+
Qt::Orientation orientation() const;
105+
bool append() const;
106+
int insertOffset() const;
107+
};
108+
ads::internal::CDockInsertParam dockAreaInsertParameters(ads::DockWidgetArea Area);
109+
110+
SIP_PYOBJECT findParent(SIP_PYTYPE type, const QWidget *w) const /TypeHint="QObject"/;
111+
%MethodCode
112+
sipRes = qtads_FindParent(a0, a1);
113+
114+
if (!sipRes)
115+
{
116+
sipIsErr = 1;
117+
}
118+
%End
119+
120+
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
121+
122+
QPoint globalPositionOf(QMouseEvent* ev);
123+
124+
void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap, ads::eIcon CustomIconId);
125+
126+
enum eRepolishChildOptions
127+
{
128+
RepolishIgnoreChildren,
129+
RepolishDirectChildren,
130+
RepolishChildrenRecursively
131+
};
132+
133+
void repolishStyle(QWidget* w, ads::internal::eRepolishChildOptions Options = ads::internal::RepolishIgnoreChildren);
134+
};
135+
136+
};
137+
138+
%End

0 commit comments

Comments
 (0)