Changeset 846 for trunk/src/gui/widgets/qdockwidget.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/widgets/qdockwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 69 69 extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp 70 70 71 // qmainwindow.cpp 72 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 73 71 74 static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) 72 75 { return (priv->features & feature) == feature; } … … 691 694 QMainWindow *win = qobject_cast<QMainWindow*>(parent); 692 695 Q_ASSERT(win != 0); 693 QMainWindowLayout *layout = q object_cast<QMainWindowLayout*>(win->layout());696 QMainWindowLayout *layout = qt_mainwindow_layout(win); 694 697 Q_ASSERT(layout != 0); 695 698 if (layout->pluggingWidget != 0) // the main window is animating a docking operation … … 712 715 return; 713 716 714 QMainWindowLayout *layout 715 = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 717 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 716 718 Q_ASSERT(layout != 0); 717 719 … … 740 742 741 743 if (state->dragging) { 742 QMainWindowLayout *mwLayout = 743 qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 744 QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 744 745 Q_ASSERT(mwLayout != 0); 745 746 … … 781 782 return false; 782 783 783 QMainWindowLayout *mainWinLayout 784 = qobject_cast<QMainWindowLayout*>(mainWin->layout()); 784 QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin); 785 785 if (mainWinLayout == 0) 786 786 return false; … … 848 848 849 849 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())); 853 852 if (!dwlayout->nativeWindowDeco()) { 854 853 if (!state->dragging … … 944 943 #ifdef Q_OS_MAC 945 944 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())); 948 946 Q_ASSERT(layout != 0); 949 947 … … 981 979 return; 982 980 983 QMainWindowLayout *layout 984 = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); 981 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 985 982 Q_ASSERT(layout != 0); 986 983 … … 1010 1007 1011 1008 if (!floating && parent) { 1012 QMainWindowLayout *mwlayout = q object_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) 1014 1011 return; // this dockwidget can't be redocked 1015 1012 } … … 1056 1053 emit q->topLevelChanged(floating); 1057 1054 if (!floating && parent) { 1058 QMainWindowLayout *mwlayout = q object_cast<QMainWindowLayout *>(q->parentWidget()->layout());1055 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); 1059 1056 if (mwlayout) 1060 1057 emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); … … 1270 1267 1271 1268 d->setWindowState(floating, false, floating ? r : QRect()); 1269 1272 1270 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 1278 1274 } 1279 1275 } … … 1328 1324 { 1329 1325 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)) { 1332 1327 if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this)) 1333 1328 info->updateTabBar(); 1329 } 1334 1330 } 1335 1331 #endif // QT_NO_TABBAR … … 1384 1380 1385 1381 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); 1389 1383 1390 1384 switch (event->type()) { … … 1538 1532 /*! 1539 1533 \since 4.3 1534 1540 1535 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. 1542 1539 1543 1540 If a title bar widget is set, QDockWidget will not use native window … … 1547 1544 1548 1545 \list 1549 \ iMouse events that are not explicitly handled by the title bar widget1546 \o Mouse events that are not explicitly handled by the title bar widget 1550 1547 must be ignored by calling QMouseEvent::ignore(). These events then 1551 1548 propagate to the QDockWidget parent, which handles them in the usual … … 1553 1550 when it is double-clicked, etc. 1554 1551 1555 \ iWhen DockWidgetVerticalTitleBar is set on QDockWidget, the title1552 \o When DockWidgetVerticalTitleBar is set on QDockWidget, the title 1556 1553 bar widget is repositioned accordingly. In resizeEvent(), the title 1557 1554 bar should check what orientation it should assume: 1558 1555 \snippet doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp 0 1559 1556 1560 \ iThe title bar widget must have a valid QWidget::sizeHint() and1557 \o The title bar widget must have a valid QWidget::sizeHint() and 1561 1558 QWidget::minimumSizeHint(). These functions should take into account 1562 1559 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. 1563 1564 \endlist 1564 1565 1565 Using qobject_cast as shown above, the title bar widget has full access1566 Using qobject_cast() as shown above, the title bar widget has full access 1566 1567 to its parent QDockWidget. Hence it can perform such operations as docking 1567 1568 and hiding in response to user actions.
Note:
See TracChangeset
for help on using the changeset viewer.