Adding hasHeightForWidth as a virtual Widget funcion

Just implements what the note states (and removes the private function)

Change-Id: I9a6fd5134460712accf09ba01691df8b9b1f5d0d
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
Thorbjørn Lund Martsum 2012-02-06 09:24:50 +01:00 committed by Qt by Nokia
parent 908a080006
commit 466107107a
7 changed files with 20 additions and 22 deletions

View File

@ -522,7 +522,7 @@ bool QWidgetItem::hasHeightForWidth() const
{
if (isEmpty())
return false;
return wid->d_func()->hasHeightForWidth();
return wid->hasHeightForWidth();
}
/*!

View File

@ -9226,19 +9226,12 @@ int QWidget::heightForWidth(int w) const
/*!
\internal
*virtual private*
This is a bit hackish, but ideally we would have created a virtual function
in the public API (however, too late...) so that subclasses could reimplement
their own function.
Instead we add a virtual function to QWidgetPrivate.
### Qt5: move to public class and make virtual
Returns true if the widget's preferred height depends on its width; otherwise returns false.
*/
bool QWidgetPrivate::hasHeightForWidth() const
bool QWidget::hasHeightForWidth() const
{
return layout ? layout->hasHeightForWidth() : size_policy.hasHeightForWidth();
Q_D(const QWidget);
return d->layout ? d->layout->hasHeightForWidth() : d->size_policy.hasHeightForWidth();
}
/*!

View File

@ -524,6 +524,7 @@ public:
void setSizePolicy(QSizePolicy);
inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
virtual int heightForWidth(int) const;
virtual bool hasHeightForWidth() const;
QRegion visibleRegion() const;

View File

@ -468,7 +468,6 @@ public:
bool setMinimumSize_helper(int &minw, int &minh);
bool setMaximumSize_helper(int &maxw, int &maxh);
virtual bool hasHeightForWidth() const;
void setConstraints_sys();
bool pointInsideRectAndMask(const QPoint &) const;
QWidget *childAt_helper(const QPoint &, bool) const;

View File

@ -301,7 +301,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
// Use a native X11 sizegrip for "real" top-level windows if supported.
if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
&& !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) {
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE);
@ -323,7 +323,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
}
#endif // Q_WS_X11
#ifdef Q_OS_WIN
if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) {
uint orientation = 0;
if (d->atBottom())
orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT;
@ -413,11 +413,11 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
#ifdef Q_WS_X11
if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
&& tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth())
return;
#endif
#ifdef Q_OS_WIN
if (tlw->isWindow() && qt_getWindowsSystemMenu(tlw) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
if (tlw->isWindow() && qt_getWindowsSystemMenu(tlw) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) {
if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(tlw)) {
MSG msg;
while (PeekMessage(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) ;

View File

@ -186,7 +186,6 @@ public:
void _q_removeTab(int);
void _q_tabMoved(int from, int to);
void init();
bool hasHeightForWidth() const;
QTabBar *tabs;
QStackedWidget *stack;
@ -238,11 +237,16 @@ void QTabWidgetPrivate::init()
}
bool QTabWidgetPrivate::hasHeightForWidth() const
/*!
\reimp
*/
bool QTabWidget::hasHeightForWidth() const
{
bool has = size_policy.hasHeightForWidth();
if (!has && stack)
has = qt_widget_private(stack)->hasHeightForWidth();
Q_D(const QTabWidget);
bool has = d->size_policy.hasHeightForWidth();
if (!has && d->stack)
has = d->stack->hasHeightForWidth();
return has;
}

View File

@ -125,6 +125,7 @@ public:
QSize sizeHint() const;
QSize minimumSizeHint() const;
int heightForWidth(int width) const;
bool hasHeightForWidth() const;
void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;