diff options
Diffstat (limited to 'src/gui/widgets/qdockwidget.cpp')
-rw-r--r-- | src/gui/widgets/qdockwidget.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index a5be5f8..5810c81 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -59,6 +59,7 @@ #include "qdockwidget_p.h" #include "qmainwindowlayout_p.h" #ifdef Q_WS_MAC +#include <private/qapplication_p.h> #include <private/qt_mac_p.h> #include <qmacstyle_mac.h> #endif @@ -67,7 +68,8 @@ QT_BEGIN_NAMESPACE extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp -extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp +static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) +{ return (priv->features & feature) == feature; } static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) { return (dockwidget->features() & feature) == feature; } @@ -203,7 +205,7 @@ bool QDockWidgetLayout::nativeWindowDeco() const bool QDockWidgetLayout::nativeWindowDeco(bool floating) const { -#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_WINCE) +#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_WINCE) Q_UNUSED(floating); return false; #else @@ -221,7 +223,8 @@ void QDockWidgetLayout::addItem(QLayoutItem*) QLayoutItem *QDockWidgetLayout::itemAt(int index) const { int cnt = 0; - foreach (QLayoutItem *item, item_list) { + for (int i = 0; i < item_list.count(); ++i) { + QLayoutItem *item = item_list.at(i); if (item == 0) continue; if (index == cnt++) @@ -250,8 +253,8 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index) int QDockWidgetLayout::count() const { int result = 0; - foreach (QLayoutItem *item, item_list) { - if (item != 0) + for (int i = 0; i < item_list.count(); ++i) { + if (item_list.at(i)) ++result; } return result; @@ -646,25 +649,25 @@ void QDockWidgetPrivate::_q_toggleView(bool b) void QDockWidgetPrivate::updateButtons() { Q_Q(QDockWidget); - QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout()); + QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); QStyleOptionDockWidget opt; q->initStyleOption(&opt); - bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; - bool nativeDeco = layout->nativeWindowDeco(); + bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; + bool nativeDeco = dwLayout->nativeWindowDeco(); bool hideButtons = nativeDeco || customTitleBar; - bool canClose = hasFeature(q, QDockWidget::DockWidgetClosable); - bool canFloat = hasFeature(q, QDockWidget::DockWidgetFloatable); + bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable); + bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable); QAbstractButton *button - = qobject_cast<QAbstractButton*>(layout->widgetForRole(QDockWidgetLayout::FloatButton)); + = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton)); button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q)); button->setVisible(canFloat && !hideButtons); button - = qobject_cast <QAbstractButton*>(layout->widgetForRole(QDockWidgetLayout::CloseButton)); + = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton)); button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q)); button->setVisible(canClose && !hideButtons); @@ -687,7 +690,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) if (state != 0) return; - QMainWindow *win = qobject_cast<QMainWindow*>(q->parentWidget()); + QMainWindow *win = qobject_cast<QMainWindow*>(parent); Q_ASSERT(win != 0); QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); Q_ASSERT(layout != 0); @@ -740,15 +743,15 @@ void QDockWidgetPrivate::endDrag(bool abort) q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *layout = + QMainWindowLayout *mwLayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); - Q_ASSERT(layout != 0); + Q_ASSERT(mwLayout != 0); - if (abort || !layout->plug(state->widgetItem)) { - if (hasFeature(q, QDockWidget::DockWidgetFloatable)) { + if (abort || !mwLayout->plug(state->widgetItem)) { + if (hasFeature(this, QDockWidget::DockWidgetFloatable)) { if (state->ownWidgetItem) delete state->widgetItem; - layout->restore(); + mwLayout->restore(); #ifdef Q_WS_X11 // get rid of the X11BypassWindowManager window flag and activate the resizer Qt::WindowFlags flags = q->windowFlags(); @@ -758,14 +761,14 @@ void QDockWidgetPrivate::endDrag(bool abort) q->show(); #else QDockWidgetLayout *myLayout - = qobject_cast<QDockWidgetLayout*>(q->layout()); + = qobject_cast<QDockWidgetLayout*>(layout); resizer->setActive(QWidgetResizeHandler::Resize, myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0); #endif undockedGeometry = q->geometry(); q->activateWindow(); } else { - layout->revert(state->widgetItem); + mwLayout->revert(state->widgetItem); } } } @@ -777,7 +780,7 @@ bool QDockWidgetPrivate::isAnimating() const { Q_Q(const QDockWidget); - QMainWindow *mainWin = qobject_cast<QMainWindow*>(q->parentWidget()); + QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent); if (mainWin == 0) return false; @@ -794,18 +797,18 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) #if !defined(QT_NO_MAINWINDOW) Q_Q(QDockWidget); - QDockWidgetLayout *layout - = qobject_cast<QDockWidgetLayout*>(q->layout()); + QDockWidgetLayout *dwLayout + = qobject_cast<QDockWidgetLayout*>(layout); - if (!layout->nativeWindowDeco()) { - QRect titleArea = layout->titleArea(); + if (!dwLayout->nativeWindowDeco()) { + QRect titleArea = dwLayout->titleArea(); if (event->button() != Qt::LeftButton || !titleArea.contains(event->pos()) || // check if the tool window is movable... do nothing if it // is not (but allow moving if the window is floating) - (!hasFeature(q, QDockWidget::DockWidgetMovable) && !q->isFloating()) || - qobject_cast<QMainWindow*>(q->parentWidget()) == 0 || + (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) || + qobject_cast<QMainWindow*>(parent) == 0 || isAnimating() || state != 0) { return false; } @@ -813,7 +816,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) initDrag(event->pos(), false); if (state) - state->ctrlDrag = hasFeature(q, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier; + state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier; return true; } @@ -824,15 +827,13 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event) { - Q_Q(QDockWidget); + QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); - QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout()); - - if (!layout->nativeWindowDeco()) { - QRect titleArea = layout->titleArea(); + if (!dwLayout->nativeWindowDeco()) { + QRect titleArea = dwLayout->titleArea(); if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) && - hasFeature(q, QDockWidget::DockWidgetFloatable)) { + hasFeature(this, QDockWidget::DockWidgetFloatable)) { _q_toggleTopLevel(); return true; } @@ -850,7 +851,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) return ret; QDockWidgetLayout *dwlayout - = qobject_cast<QDockWidgetLayout*>(q->layout()); + = qobject_cast<QDockWidgetLayout*>(layout); QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout()); if (!dwlayout->nativeWindowDeco()) { @@ -923,7 +924,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) break; if (state != 0) break; - if (qobject_cast<QMainWindow*>(q->parentWidget()) == 0) + if (qobject_cast<QMainWindow*>(parent) == 0) break; if (isAnimating()) break; @@ -996,9 +997,9 @@ void QDockWidgetPrivate::unplug(const QRect &rect) Q_Q(QDockWidget); QRect r = rect; r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); - QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout()); - if (layout->nativeWindowDeco(true)) - r.adjust(0, layout->titleHeight(), 0, 0); + QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); + if (dwLayout->nativeWindowDeco(true)) + r.adjust(0, dwLayout->titleHeight(), 0, 0); setWindowState(true, true, r); } @@ -1019,12 +1020,12 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; - QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout()); - const bool nativeDeco = layout->nativeWindowDeco(floating); + QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); + const bool nativeDeco = dwLayout->nativeWindowDeco(floating); if (nativeDeco) { flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; - if (hasFeature(q, QDockWidget::DockWidgetClosable)) + if (hasFeature(this, QDockWidget::DockWidgetClosable)) flags |= Qt::WindowCloseButtonHint; } else { flags |= Qt::FramelessWindowHint; @@ -1051,7 +1052,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect if (floating != wasFloating) { emit q->topLevelChanged(floating); - if (!floating && q->parentWidget()) { + if (!floating && parent) { QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); @@ -1321,8 +1322,7 @@ void QDockWidget::changeEvent(QEvent *event) QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); if (QMainWindowLayout *winLayout = (win ? qobject_cast<QMainWindowLayout*>(win->layout()) : 0)) - if (QDockAreaLayoutInfo *info = - (winLayout ? winLayout->layoutState.dockAreaLayout.info(this) : 0)) + if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this)) info->updateTabBar(); } #endif // QT_NO_TABBAR |