mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Python Bindings: Fix findParent that was not working as expected (#349)
This commit is contained in:
parent
b5b251dffb
commit
130b0de646
@ -1,138 +1,138 @@
|
|||||||
%Import QtWidgets/QtWidgetsmod.sip
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
%If (Qt_5_0_0 -)
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
%ModuleHeaderCode
|
%ModuleHeaderCode
|
||||||
PyObject *qtads_FindParent(PyObject* type, const QWidget *child);
|
PyObject *qtads_FindParent(PyObject* type, const QWidget *child);
|
||||||
%End
|
%End
|
||||||
|
|
||||||
%ModuleCode
|
%ModuleCode
|
||||||
PyObject *qtads_FindParent(PyObject* type, const QWidget *w)
|
PyObject *qtads_FindParent(PyObject* type, const QWidget *w)
|
||||||
{
|
{
|
||||||
// Check that the types checking was successful.
|
// Check that the types checking was successful.
|
||||||
if (!type)
|
if (!type)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QWidget* parentWidget = w->parentWidget();
|
QWidget* parentWidget = w->parentWidget();
|
||||||
|
|
||||||
while (parentWidget)
|
while (parentWidget)
|
||||||
{
|
{
|
||||||
PyObject *ParentImpl = sipConvertFromType(parentWidget, sipType_QObject, 0);
|
PyObject *ParentImpl = sipConvertFromType(parentWidget, sipType_QObject, 0);
|
||||||
if (!ParentImpl)
|
if (!ParentImpl)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PyType_IsSubtype((PyTypeObject *)type, Py_TYPE(ParentImpl)))
|
if (PyObject_IsInstance(ParentImpl, type))
|
||||||
return ParentImpl;
|
return ParentImpl;
|
||||||
|
|
||||||
Py_DECREF(ParentImpl);
|
Py_DECREF(ParentImpl);
|
||||||
|
|
||||||
parentWidget = parentWidget->parentWidget();
|
parentWidget = parentWidget->parentWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
%End
|
%End
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <ads_globals.h>
|
#include <ads_globals.h>
|
||||||
%End
|
%End
|
||||||
|
|
||||||
enum DockWidgetArea
|
enum DockWidgetArea
|
||||||
{
|
{
|
||||||
NoDockWidgetArea,
|
NoDockWidgetArea,
|
||||||
LeftDockWidgetArea,
|
LeftDockWidgetArea,
|
||||||
RightDockWidgetArea,
|
RightDockWidgetArea,
|
||||||
TopDockWidgetArea,
|
TopDockWidgetArea,
|
||||||
BottomDockWidgetArea,
|
BottomDockWidgetArea,
|
||||||
CenterDockWidgetArea,
|
CenterDockWidgetArea,
|
||||||
|
|
||||||
InvalidDockWidgetArea,
|
InvalidDockWidgetArea,
|
||||||
OuterDockAreas,
|
OuterDockAreas,
|
||||||
AllDockAreas
|
AllDockAreas
|
||||||
};
|
};
|
||||||
typedef QFlags<ads::DockWidgetArea> DockWidgetAreas;
|
typedef QFlags<ads::DockWidgetArea> DockWidgetAreas;
|
||||||
|
|
||||||
|
|
||||||
enum TitleBarButton
|
enum TitleBarButton
|
||||||
{
|
{
|
||||||
TitleBarButtonTabsMenu,
|
TitleBarButtonTabsMenu,
|
||||||
TitleBarButtonUndock,
|
TitleBarButtonUndock,
|
||||||
TitleBarButtonClose
|
TitleBarButtonClose
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eDragState
|
enum eDragState
|
||||||
{
|
{
|
||||||
DraggingInactive,
|
DraggingInactive,
|
||||||
DraggingMousePressed,
|
DraggingMousePressed,
|
||||||
DraggingTab,
|
DraggingTab,
|
||||||
DraggingFloatingWidget
|
DraggingFloatingWidget
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eIcon
|
enum eIcon
|
||||||
{
|
{
|
||||||
TabCloseIcon,
|
TabCloseIcon,
|
||||||
DockAreaMenuIcon,
|
DockAreaMenuIcon,
|
||||||
DockAreaUndockIcon,
|
DockAreaUndockIcon,
|
||||||
DockAreaCloseIcon,
|
DockAreaCloseIcon,
|
||||||
|
|
||||||
IconCount,
|
IconCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eBitwiseOperator
|
enum eBitwiseOperator
|
||||||
{
|
{
|
||||||
BitwiseAnd,
|
BitwiseAnd,
|
||||||
BitwiseOr
|
BitwiseOr
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal
|
namespace internal
|
||||||
{
|
{
|
||||||
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
|
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To);
|
||||||
void hideEmptyParentSplitters(ads::CDockSplitter* FirstParentSplitter);
|
void hideEmptyParentSplitters(ads::CDockSplitter* FirstParentSplitter);
|
||||||
|
|
||||||
class CDockInsertParam
|
class CDockInsertParam
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <ads_globals.h>
|
#include <ads_globals.h>
|
||||||
%End
|
%End
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Qt::Orientation orientation() const;
|
Qt::Orientation orientation() const;
|
||||||
bool append() const;
|
bool append() const;
|
||||||
int insertOffset() const;
|
int insertOffset() const;
|
||||||
};
|
};
|
||||||
ads::internal::CDockInsertParam dockAreaInsertParameters(ads::DockWidgetArea Area);
|
ads::internal::CDockInsertParam dockAreaInsertParameters(ads::DockWidgetArea Area);
|
||||||
|
|
||||||
SIP_PYOBJECT findParent(SIP_PYTYPE type, const QWidget *w) const /TypeHint="QObject"/;
|
SIP_PYOBJECT findParent(SIP_PYTYPE type, const QWidget *w) const /TypeHint="QObject"/;
|
||||||
%MethodCode
|
%MethodCode
|
||||||
sipRes = qtads_FindParent(a0, a1);
|
sipRes = qtads_FindParent(a0, a1);
|
||||||
|
|
||||||
if (!sipRes)
|
if (!sipRes)
|
||||||
{
|
{
|
||||||
sipIsErr = 1;
|
sipIsErr = 1;
|
||||||
}
|
}
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
|
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
|
||||||
|
|
||||||
QPoint globalPositionOf(QMouseEvent* ev);
|
QPoint globalPositionOf(QMouseEvent* ev);
|
||||||
|
|
||||||
void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap, ads::eIcon CustomIconId);
|
void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap, ads::eIcon CustomIconId);
|
||||||
|
|
||||||
enum eRepolishChildOptions
|
enum eRepolishChildOptions
|
||||||
{
|
{
|
||||||
RepolishIgnoreChildren,
|
RepolishIgnoreChildren,
|
||||||
RepolishDirectChildren,
|
RepolishDirectChildren,
|
||||||
RepolishChildrenRecursively
|
RepolishChildrenRecursively
|
||||||
};
|
};
|
||||||
|
|
||||||
void repolishStyle(QWidget* w, ads::internal::eRepolishChildOptions Options = ads::internal::RepolishIgnoreChildren);
|
void repolishStyle(QWidget* w, ads::internal::eRepolishChildOptions Options = ads::internal::RepolishIgnoreChildren);
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
%End
|
%End
|
||||||
|
Loading…
Reference in New Issue
Block a user