Changeset 846 for trunk/src/gui/widgets/qdockarealayout.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/qdockarealayout.cpp
r769 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) … … 61 61 QT_BEGIN_NAMESPACE 62 62 63 // qmainwindow.cpp 64 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 65 63 66 enum { StateFlagVisible = 1, StateFlagFloating = 2 }; 64 67 … … 221 224 #endif 222 225 226 static const int zero = 0; 227 223 228 QDockAreaLayoutInfo::QDockAreaLayoutInfo() 224 : sep( 0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)225 #ifndef QT_NO_TABBAR 226 , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) , tabBarVisible(false)227 #endif 228 { 229 } 230 231 QDockAreaLayoutInfo::QDockAreaLayoutInfo( int_sep, QInternal::DockPosition _dockPos,229 : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) 230 #ifndef QT_NO_TABBAR 231 , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) 232 #endif 233 { 234 } 235 236 QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, 232 237 Qt::Orientation _o, int tbshape, 233 238 QMainWindow *window) 234 239 : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) 235 240 #ifndef QT_NO_TABBAR 236 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) , tabBarVisible(false)241 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) 237 242 #endif 238 243 { … … 282 287 { 283 288 if (!first) 284 a += sep;289 a += *sep; 285 290 a += pick(o, min_size); 286 291 } … … 295 300 296 301 #ifndef QT_NO_TABBAR 297 if (tabbed) {298 QSize tbm = tabBarMinimumSize();302 QSize tbm = tabBarMinimumSize(); 303 if (!tbm.isNull()) { 299 304 switch (tabBarShape) { 300 305 case QTabBar::RoundedNorth: … … 350 355 { 351 356 if (!first) 352 a += sep;357 a += *sep; 353 358 a += pick(o, max_size); 354 359 } … … 368 373 369 374 #ifndef QT_NO_TABBAR 370 if (tabbed) {371 QSize tbh = tabBarSizeHint();375 QSize tbh = tabBarSizeHint(); 376 if (!tbh.isNull()) { 372 377 switch (tabBarShape) { 373 378 case QTabBar::RoundedNorth: … … 416 421 if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem) 417 422 && !previous->hasFixedSize(o)) { 418 a += sep;423 a += *sep; 419 424 } 420 425 a += gap ? item.size : pick(o, size_hint); … … 492 497 493 498 if (!first) 494 result += info.sep;499 result += *info.sep; 495 500 result += min; 496 501 … … 517 522 518 523 if (!first) 519 result += info.sep;524 result += *info.sep; 520 525 result += max; 521 526 … … 556 561 QLayoutStruct &ls = layout_struct_list[j++]; 557 562 ls.init(); 558 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep;563 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep; 559 564 ls.empty = false; 560 565 } … … 939 944 ls.empty = true; 940 945 } else { 941 const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;946 const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep; 942 947 ls.empty = false; 943 948 ls.pos = item.pos; … … 957 962 continue; 958 963 QLayoutStruct &ls = list[i]; 959 const int separatorSpace = item.hasFixedSize(o) ? 0 : sep;964 const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep; 960 965 item.size = ls.size - separatorSpace; 961 966 item.pos = ls.pos; … … 1042 1047 1043 1048 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { 1044 item.pos += sep;1045 item.size -= sep;1049 item.pos += *sep; 1050 item.size -= *sep; 1046 1051 } 1047 1052 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) 1048 item.size -= sep;1053 item.size -= *sep; 1049 1054 1050 1055 QPoint pos; … … 1084 1089 { 1085 1090 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) { 1086 item.pos -= sep;1087 item.size += sep;1091 item.pos -= *sep; 1092 item.size += *sep; 1088 1093 } 1089 1094 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) 1090 item.size += sep;1095 item.size += *sep; 1091 1096 } 1092 1097 … … 1256 1261 gap_size = pick(o, r.size()); 1257 1262 if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) 1258 sep_size += sep;1263 sep_size += *sep; 1259 1264 if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem)) 1260 sep_size += sep;1265 sep_size += *sep; 1261 1266 } 1262 1267 if (gap_size + sep_size > space) … … 1365 1370 rpick(o, pos) = item.pos + item.size; 1366 1371 QSize s = rect.size(); 1367 rpick(o, s) = sep;1372 rpick(o, s) = *sep; 1368 1373 1369 1374 return QRect(pos, s); … … 1414 1419 1415 1420 QRect sepRect = separatorRect(i); 1416 if (!sepRect.isNull() && sep == 1)1421 if (!sepRect.isNull() && *sep == 1) 1417 1422 sepRect.adjust(-2, -2, 2, 2); 1418 1423 //we also make sure we don't find a separator that's not there … … 1479 1484 QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const 1480 1485 { 1481 QMainWindowLayout *result = q object_cast<QMainWindowLayout*>(mainWindow->layout());1486 QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); 1482 1487 Q_ASSERT(result != 0); 1483 1488 return result; … … 1499 1504 QSize tbh = tabBarSizeHint(); 1500 1505 1501 if ( tabBarVisible) {1506 if (!tbh.isNull()) { 1502 1507 switch (tabBarShape) { 1503 1508 case QTabBar::RoundedNorth: … … 1561 1566 } 1562 1567 #ifndef QT_NO_TABBAR 1563 if ( sep == 1)1568 if (*sep == 1) 1564 1569 updateSeparatorWidgets(); 1565 1570 #endif //QT_NO_TABBAR … … 1984 1989 } 1985 1990 } 1986 1991 if (testing) { 1992 //was it is not really added to the layout, we need to delete the object here 1993 delete item.widgetItem; 1994 } 1987 1995 } 1988 1996 } else if (nextMarker == SequenceMarker) { … … 2014 2022 setCurrentTabId(tabId(item_list.at(index))); 2015 2023 } 2016 if (!testing && sep == 1)2024 if (!testing && *sep == 1) 2017 2025 updateSeparatorWidgets(); 2018 2026 #endif … … 2075 2083 2076 2084 #ifndef QT_NO_TABBAR 2077 void QDockAreaLayoutInfo::updateTabBar() const 2085 //returns whether the tabbar is visible or not 2086 bool QDockAreaLayoutInfo::updateTabBar() const 2078 2087 { 2079 2088 if (!tabbed) 2080 return ;2089 return false; 2081 2090 2082 2091 QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); … … 2146 2155 tabBar->blockSignals(blocked); 2147 2156 2148 that->tabBarVisible = ( (gap ? 1 : 0) + tabBar->count()) > 1; 2149 2150 if (changed || !tabBarMin.isValid() | !tabBarHint.isValid()) { 2151 that->tabBarMin = tabBar->minimumSizeHint(); 2152 that->tabBarHint = tabBar->sizeHint(); 2153 } 2157 //returns if the tabbar is visible or not 2158 return ( (gap ? 1 : 0) + tabBar->count()) > 1; 2154 2159 } 2155 2160 … … 2159 2164 return; 2160 2165 tabBarShape = shape; 2161 if (tabBar != 0) {2166 if (tabBar != 0) 2162 2167 tabBar->setShape(static_cast<QTabBar::Shape>(shape)); 2163 tabBarMin = QSize();2164 tabBarHint = QSize();2165 }2166 2168 2167 2169 for (int i = 0; i < item_list.count(); ++i) { … … 2174 2176 QSize QDockAreaLayoutInfo::tabBarMinimumSize() const 2175 2177 { 2176 if (! tabbed)2178 if (!updateTabBar()) 2177 2179 return QSize(0, 0); 2178 2180 2179 updateTabBar(); 2180 2181 return tabBarMin; 2181 return tabBar->minimumSizeHint(); 2182 2182 } 2183 2183 2184 2184 QSize QDockAreaLayoutInfo::tabBarSizeHint() const 2185 2185 { 2186 if (! tabbed)2186 if (!updateTabBar()) 2187 2187 return QSize(0, 0); 2188 2188 2189 updateTabBar(); 2190 2191 return tabBarHint; 2189 return tabBar->sizeHint(); 2192 2190 } 2193 2191 … … 2236 2234 QSize tbh = tabBarSizeHint(); 2237 2235 2238 if ( tabBarVisible) {2236 if (!tbh.isNull()) { 2239 2237 switch (tabBarShape) { 2240 2238 case QTabBar::RoundedNorth: … … 2277 2275 #endif 2278 2276 docks[QInternal::LeftDock] 2279 = QDockAreaLayoutInfo( sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);2277 = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win); 2280 2278 docks[QInternal::RightDock] 2281 = QDockAreaLayoutInfo( sep, QInternal::RightDock, Qt::Vertical, tabShape, win);2279 = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win); 2282 2280 docks[QInternal::TopDock] 2283 = QDockAreaLayoutInfo( sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);2281 = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win); 2284 2282 docks[QInternal::BottomDock] 2285 = QDockAreaLayoutInfo( sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);2283 = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); 2286 2284 centralWidgetItem = 0; 2287 2285 … … 2995 2993 dockWidget->d_func()->setWindowState(true, true, r); 2996 2994 } 2997 dockWidget->show(); 2998 // dockWidget->setVisible(!placeHolder->hidden); 2995 dockWidget->setVisible(!placeHolder->hidden); 2999 2996 #ifdef Q_WS_X11 3000 2997 if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag … … 3032 3029 int tbshape = 0; 3033 3030 #endif 3034 QDockAreaLayoutInfo new_info( sep, pos, orientation, tbshape, mainWindow);3031 QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow); 3035 3032 new_info.item_list.append(new QDockAreaLayoutInfo(info)); 3036 3033 new_info.item_list.append(dockWidgetItem); … … 3077 3074 void QDockAreaLayout::apply(bool animate) 3078 3075 { 3079 QWidgetAnimator &widgetAnimator 3080 = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator; 3076 QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator; 3081 3077 3082 3078 for (int i = 0; i < QInternal::DockCount; ++i) … … 3168 3164 3169 3165 #ifndef QT_NO_TABBAR 3170 // Sets the correct positions for the sep erator widgets3166 // Sets the correct positions for the separator widgets 3171 3167 // Allocates new sepearator widgets with getSeparatorWidget 3172 3168 void QDockAreaLayout::updateSeparatorWidgets() const … … 3183 3179 sepWidget = separatorWidgets.at(j); 3184 3180 } else { 3185 sepWidget = q object_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget();3181 sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget(); 3186 3182 separatorWidgets.append(sepWidget); 3187 3183 } … … 3328 3324 } 3329 3325 3326 void QDockAreaLayout::styleChangedEvent() 3327 { 3328 sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow); 3329 fitLayout(); 3330 } 3331 3330 3332 QT_END_NAMESPACE 3331 3333
Note:
See TracChangeset
for help on using the changeset viewer.