Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qdockwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6969extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp
    7070
     71// qmainwindow.cpp
     72extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     73
    7174static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
    7275{ return (priv->features & feature) == feature; }
     
    691694    QMainWindow *win = qobject_cast<QMainWindow*>(parent);
    692695    Q_ASSERT(win != 0);
    693     QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
     696    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    694697    Q_ASSERT(layout != 0);
    695698    if (layout->pluggingWidget != 0) // the main window is animating a docking operation
     
    712715        return;
    713716
    714     QMainWindowLayout *layout
    715         = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     717    QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    716718    Q_ASSERT(layout != 0);
    717719
     
    740742
    741743    if (state->dragging) {
    742         QMainWindowLayout *mwLayout =
    743             qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     744        QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    744745        Q_ASSERT(mwLayout != 0);
    745746
     
    781782        return false;
    782783
    783     QMainWindowLayout *mainWinLayout
    784         = qobject_cast<QMainWindowLayout*>(mainWin->layout());
     784    QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
    785785    if (mainWinLayout == 0)
    786786        return false;
     
    848848
    849849    QDockWidgetLayout *dwlayout
    850         = qobject_cast<QDockWidgetLayout*>(layout);
    851     QMainWindowLayout *mwlayout
    852         = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout());
     850        = qobject_cast<QDockWidgetLayout *>(layout);
     851    QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    853852    if (!dwlayout->nativeWindowDeco()) {
    854853        if (!state->dragging
     
    944943#ifdef Q_OS_MAC
    945944            else { // workaround for lack of mouse-grab on Mac
    946                 QMainWindowLayout *layout
    947                     = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     945                QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    948946                Q_ASSERT(layout != 0);
    949947
     
    981979        return;
    982980
    983     QMainWindowLayout *layout
    984         = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     981    QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    985982    Q_ASSERT(layout != 0);
    986983
     
    10101007
    10111008    if (!floating && parent) {
    1012         QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
    1013         if (!mwlayout || mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
     1009        QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
     1010        if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
    10141011            return; // this dockwidget can't be redocked
    10151012    }
     
    10561053        emit q->topLevelChanged(floating);
    10571054        if (!floating && parent) {
    1058             QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
     1055            QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
    10591056            if (mwlayout)
    10601057                emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
     
    12701267
    12711268    d->setWindowState(floating, false, floating ? r : QRect());
     1269
    12721270    if (floating && r.isNull()) {
    1273         QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
    1274         QRect titleArea = layout->titleArea();
    1275         int h = layout->verticalTitleBar ? titleArea.width() : titleArea.height();
    1276         QPoint p = mapToGlobal(QPoint(h, h));
    1277         move(p);
     1271        if (x() < 0 || y() < 0) //may happen if we have been hidden
     1272            move(QPoint());
     1273        setAttribute(Qt::WA_Moved, false); //we want it at the default position
    12781274    }
    12791275}
     
    13281324        {
    13291325            QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    1330             if (QMainWindowLayout *winLayout =
    1331                 (win ? qobject_cast<QMainWindowLayout*>(win->layout()) : 0))
     1326            if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
    13321327                if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
    13331328                    info->updateTabBar();
     1329            }
    13341330        }
    13351331#endif // QT_NO_TABBAR
     
    13841380
    13851381    QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
    1386     QMainWindowLayout *layout = 0;
    1387     if (win != 0)
    1388         layout = qobject_cast<QMainWindowLayout*>(win->layout());
     1382    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    13891383
    13901384    switch (event->type()) {
     
    15381532/*!
    15391533    \since 4.3
     1534
    15401535    Sets an arbitrary \a widget as the dock widget's title bar. If \a widget
    1541     is 0, the title bar widget is removed, but not deleted.
     1536    is 0, any custom title bar widget previously set on the dock widget is
     1537    removed, but not deleted, and the default title bar will be used
     1538    instead.
    15421539
    15431540    If a title bar widget is set, QDockWidget will not use native window
     
    15471544
    15481545    \list
    1549     \i Mouse events that are not explicitly handled by the title bar widget
     1546    \o Mouse events that are not explicitly handled by the title bar widget
    15501547       must be ignored by calling QMouseEvent::ignore(). These events then
    15511548       propagate to the QDockWidget parent, which handles them in the usual
     
    15531550       when it is double-clicked, etc.
    15541551
    1555     \i When DockWidgetVerticalTitleBar is set on QDockWidget, the title
     1552    \o When DockWidgetVerticalTitleBar is set on QDockWidget, the title
    15561553       bar widget is repositioned accordingly. In resizeEvent(), the title
    15571554       bar should check what orientation it should assume:
    15581555       \snippet doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp 0
    15591556
    1560     \i The title bar widget must have a valid QWidget::sizeHint() and
     1557    \o The title bar widget must have a valid QWidget::sizeHint() and
    15611558       QWidget::minimumSizeHint(). These functions should take into account
    15621559       the current orientation of the title bar.
     1560
     1561    \o It is not possible to remove a title bar from a dock widget. However,
     1562       a similar effect can be achieved by setting a default constructed
     1563       QWidget as the title bar widget.
    15631564    \endlist
    15641565
    1565     Using qobject_cast as shown above, the title bar widget has full access
     1566    Using qobject_cast() as shown above, the title bar widget has full access
    15661567    to its parent QDockWidget. Hence it can perform such operations as docking
    15671568    and hiding in response to user actions.
Note: See TracChangeset for help on using the changeset viewer.