Changeset 561 for trunk/src/gui/widgets/qdockarealayout.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/widgets/qdockarealayout.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 156 156 } 157 157 158 bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const 159 { 160 return perp(o, minimumSize()) == perp(o, maximumSize()); 161 } 162 158 163 bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const 159 164 { … … 217 222 218 223 QDockAreaLayoutInfo::QDockAreaLayoutInfo() 219 : sep(0), dockPos(QInternal::LeftDock), o(Qt::Horizontal), rect(0, 0, -1, -1),mainWindow(0)220 #ifndef QT_NO_TABBAR 221 , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) 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) 222 227 #endif 223 228 { … … 227 232 Qt::Orientation _o, int tbshape, 228 233 QMainWindow *window) 229 : sep(_sep), dockPos(_dockPos), o(_o), rect(0, 0, -1, -1),mainWindow(window)230 #ifndef QT_NO_TABBAR 231 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) 234 : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) 235 #ifndef QT_NO_TABBAR 236 , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)), tabBarVisible(false) 232 237 #endif 233 238 { … … 245 250 { 246 251 item_list.clear(); 247 rect = QRect( 0, 0, -1, -1);252 rect = QRect(); 248 253 #ifndef QT_NO_TABBAR 249 254 tabbed = false; … … 389 394 390 395 int a = 0, b = 0; 391 bool prev_gap = false;392 bool first = true;393 396 int min_perp = 0; 394 397 int max_perp = QWIDGETSIZE_MAX; 398 const QDockAreaLayoutItem *previous = 0; 395 399 for (int i = 0; i < item_list.size(); ++i) { 396 400 const QDockAreaLayoutItem &item = item_list.at(i); … … 410 414 #endif 411 415 { 412 if (!first && !gap && !prev_gap) 416 if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem) 417 && !previous->hasFixedSize(o)) { 413 418 a += sep; 419 } 414 420 a += gap ? item.size : pick(o, size_hint); 415 421 } 416 422 b = qMax(b, perp(o, size_hint)); 417 423 418 prev_gap = gap; 419 first = false; 424 previous = &item; 420 425 } 421 426 … … 540 545 int last_index = -1; 541 546 542 bool prev_gap = false; 543 bool first = true; 547 const QDockAreaLayoutItem *previous = 0; 544 548 for (int i = 0; i < item_list.size(); ++i) { 545 549 QDockAreaLayoutItem &item = item_list[i]; … … 548 552 549 553 bool gap = item.flags & QDockAreaLayoutItem::GapItem; 550 if ( !first && !gap && !prev_gap) {551 QLayoutStruct &ls = layout_struct_list[j++];552 ls.init();553 ls.minimumSize = sep;554 ls.maximumSize =sep;555 ls.sizeHint = sep;556 ls.empty = false;554 if (previous && !gap) { 555 if (!(previous->flags & QDockAreaLayoutItem::GapItem)) { 556 QLayoutStruct &ls = layout_struct_list[j++]; 557 ls.init(); 558 ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : sep; 559 ls.empty = false; 560 } 557 561 } 558 562 … … 593 597 594 598 item.flags &= ~QDockAreaLayoutItem::KeepSize; 595 prev_gap = gap; 596 first = false; 599 previous = &item; 597 600 } 598 601 layout_struct_list.resize(j); … … 608 611 609 612 j = 0; 610 prev_gap = false;611 first = true;613 bool prev_gap = false; 614 bool first = true; 612 615 for (int i = 0; i < item_list.size(); ++i) { 613 616 QDockAreaLayoutItem &item = item_list[i]; … … 922 925 } 923 926 924 int QDockAreaLayoutInfo::separatorMove(int index, int delta , QVector<QLayoutStruct> *cache)927 int QDockAreaLayoutInfo::separatorMove(int index, int delta) 925 928 { 926 929 #ifndef QT_NO_TABBAR … … 928 931 #endif 929 932 930 if (cache->isEmpty()) { 931 QVector<QLayoutStruct> &list = *cache; 932 list.resize(item_list.size()); 933 for (int i = 0; i < item_list.size(); ++i) { 934 const QDockAreaLayoutItem &item = item_list.at(i); 935 QLayoutStruct &ls = list[i]; 936 Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); 937 if (item.skip()) { 938 ls.empty = true; 939 } else { 940 ls.empty = false; 941 ls.pos = item.pos; 942 ls.size = item.size; 943 ls.minimumSize = pick(o, item.minimumSize()); 944 ls.maximumSize = pick(o, item.maximumSize()); 945 } 946 } 947 } 948 949 QVector<QLayoutStruct> list = *cache; 950 951 delta = separatorMoveHelper(list, index, delta, sep); 952 953 for (int i = 0; i < item_list.size(); ++i) { 933 QVector<QLayoutStruct> list(item_list.size()); 934 for (int i = 0; i < list.size(); ++i) { 935 const QDockAreaLayoutItem &item = item_list.at(i); 936 QLayoutStruct &ls = list[i]; 937 Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); 938 if (item.skip()) { 939 ls.empty = true; 940 } else { 941 const int separatorSpace = item.hasFixedSize(o) ? 0 : sep; 942 ls.empty = false; 943 ls.pos = item.pos; 944 ls.size = item.size + separatorSpace; 945 ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace; 946 ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace; 947 948 } 949 } 950 951 //the separator space has been added to the size, so we pass 0 as a parameter 952 delta = separatorMoveHelper(list, index, delta, 0 /*separator*/); 953 954 for (int i = 0; i < list.size(); ++i) { 954 955 QDockAreaLayoutItem &item = item_list[i]; 955 956 if (item.skip()) 956 957 continue; 957 958 QLayoutStruct &ls = list[i]; 958 item.size = ls.size; 959 const int separatorSpace = item.hasFixedSize(o) ? 0 : sep; 960 item.size = ls.size - separatorSpace; 959 961 item.pos = ls.pos; 960 961 962 if (item.subinfo != 0) { 962 963 item.subinfo->rect = itemRect(i); … … 994 995 } 995 996 996 void QDockAreaLayoutInfo::remove( QList<int>path)997 void QDockAreaLayoutInfo::remove(const QList<int> &path) 997 998 { 998 999 Q_ASSERT(!path.isEmpty()); 999 1000 1000 1001 if (path.count() > 1) { 1001 int index = path.takeFirst();1002 const int index = path.first(); 1002 1003 QDockAreaLayoutItem &item = item_list[index]; 1003 1004 Q_ASSERT(item.subinfo != 0); 1004 item.subinfo->remove(path );1005 item.subinfo->remove(path.mid(1)); 1005 1006 unnest(index); 1006 1007 } else { … … 1010 1011 } 1011 1012 1012 QLayoutItem *QDockAreaLayoutInfo::plug( QList<int>path)1013 QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) 1013 1014 { 1014 1015 Q_ASSERT(!path.isEmpty()); 1015 1016 1016 int index = path. takeFirst();1017 int index = path.first(); 1017 1018 if (index < 0) 1018 1019 index = -index - 1; 1019 1020 1020 if ( !path.isEmpty()) {1021 if (path.count() > 1) { 1021 1022 const QDockAreaLayoutItem &item = item_list.at(index); 1022 1023 Q_ASSERT(item.subinfo != 0); 1023 return item.subinfo->plug(path );1024 return item.subinfo->plug(path.mid(1)); 1024 1025 } 1025 1026 … … 1059 1060 } 1060 1061 1061 QLayoutItem *QDockAreaLayoutInfo::unplug( QList<int>path)1062 QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) 1062 1063 { 1063 1064 Q_ASSERT(!path.isEmpty()); 1064 1065 1066 const int index = path.first(); 1065 1067 if (path.count() > 1) { 1066 int index = path.takeFirst();1067 1068 const QDockAreaLayoutItem &item = item_list.at(index); 1068 1069 Q_ASSERT(item.subinfo != 0); 1069 return item.subinfo->unplug(path); 1070 } 1071 1072 int index = path.first(); 1070 return item.subinfo->unplug(path.mid(1)); 1071 } 1072 1073 1073 QDockAreaLayoutItem &item = item_list[index]; 1074 1074 int prev = this->prev(index); … … 1142 1142 } 1143 1143 1144 bool QDockAreaLayoutInfo::insertGap( QList<int>path, QLayoutItem *dockWidgetItem)1144 bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) 1145 1145 { 1146 1146 Q_ASSERT(!path.isEmpty()); 1147 1147 1148 1148 bool insert_tabbed = false; 1149 int index = path. takeFirst();1149 int index = path.first(); 1150 1150 if (index < 0) { 1151 1151 insert_tabbed = true; … … 1155 1155 // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString()); 1156 1156 1157 if ( !path.isEmpty()) {1157 if (path.count() > 1) { 1158 1158 QDockAreaLayoutItem &item = item_list[index]; 1159 1159 … … 1168 1168 QDockAreaLayoutInfo *subinfo = item.subinfo; 1169 1169 QLayoutItem *widgetItem = item.widgetItem; 1170 QRect r = subinfo == 0 ? dockedGeometry(widgetItem->widget()) : subinfo->rect; 1170 QPlaceHolderItem *placeHolderItem = item.placeHolderItem; 1171 QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect; 1171 1172 1172 1173 Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; … … 1177 1178 = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow); 1178 1179 1180 //item become a new top-level 1179 1181 item.subinfo = new_info; 1180 1182 item.widgetItem = 0; 1183 item.placeHolderItem = 0; 1181 1184 1182 1185 QDockAreaLayoutItem new_item 1183 1186 = widgetItem == 0 1184 1187 ? QDockAreaLayoutItem(subinfo) 1185 : QDockAreaLayoutItem(widgetItem);1188 : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem); 1186 1189 new_item.size = pick(opposite, r.size()); 1187 1190 new_item.pos = pick(opposite, r.topLeft()); … … 1194 1197 } 1195 1198 1196 bool result = item.subinfo->insertGap(path, dockWidgetItem); 1197 return result; 1199 return item.subinfo->insertGap(path.mid(1), dockWidgetItem); 1198 1200 } 1199 1201 … … 1295 1297 } 1296 1298 1297 QDockAreaLayoutInfo *QDockAreaLayoutInfo::info( QList<int>path)1298 { 1299 int index = path. takeFirst();1299 QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) 1300 { 1301 int index = path.first(); 1300 1302 if (index < 0) 1301 1303 index = -index - 1; 1302 1304 if (index >= item_list.count()) 1303 1305 return this; 1304 if (path. isEmpty() || item_list.at(index).subinfo == 0)1306 if (path.count() == 1 || item_list[index].subinfo == 0) 1305 1307 return this; 1306 return item_list .at(index).subinfo->info(path);1308 return item_list[index].subinfo->info(path.mid(1)); 1307 1309 } 1308 1310 … … 1335 1337 } 1336 1338 1337 QRect QDockAreaLayoutInfo::itemRect( QList<int>path) const1339 QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const 1338 1340 { 1339 1341 Q_ASSERT(!path.isEmpty()); 1340 1342 1343 const int index = path.first(); 1341 1344 if (path.count() > 1) { 1342 const QDockAreaLayoutItem &item = item_list.at( path.takeFirst());1345 const QDockAreaLayoutItem &item = item_list.at(index); 1343 1346 Q_ASSERT(item.subinfo != 0); 1344 return item.subinfo->itemRect(path );1345 } 1346 1347 return itemRect( path.first());1347 return item.subinfo->itemRect(path.mid(1)); 1348 } 1349 1350 return itemRect(index); 1348 1351 } 1349 1352 … … 1367 1370 } 1368 1371 1369 QRect QDockAreaLayoutInfo::separatorRect( QList<int>path) const1372 QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const 1370 1373 { 1371 1374 Q_ASSERT(!path.isEmpty()); 1372 1375 1376 const int index = path.first(); 1373 1377 if (path.count() > 1) { 1374 const QDockAreaLayoutItem &item = item_list.at( path.takeFirst());1378 const QDockAreaLayoutItem &item = item_list.at(index); 1375 1379 Q_ASSERT(item.subinfo != 0); 1376 return item.subinfo->separatorRect(path );1377 } 1378 return separatorRect( path.first());1380 return item.subinfo->separatorRect(path.mid(1)); 1381 } 1382 return separatorRect(index); 1379 1383 } 1380 1384 … … 1409 1413 continue; 1410 1414 1411 int margin = (sep == 1? 2 : 0); 1412 if (pos >= item.pos + item.size - margin && item.pos + item.size + sep + margin > pos) { 1413 QList<int> result; 1414 result.append(i); 1415 return result; 1415 QRect sepRect = separatorRect(i); 1416 if (!sepRect.isNull() && sep == 1) 1417 sepRect.adjust(-2, -2, 2, 2); 1418 //we also make sure we don't find a separator that's not there 1419 if (sepRect.contains(_pos) && !item.hasFixedSize(o)) { 1420 return QList<int>() << i; 1416 1421 } 1417 1422 … … 1479 1484 } 1480 1485 1486 bool QDockAreaLayoutInfo::hasFixedSize() const 1487 { 1488 return perp(o, minimumSize()) == perp(o, maximumSize()); 1489 } 1490 1491 1481 1492 void QDockAreaLayoutInfo::apply(bool animate) 1482 1493 { 1483 QWidgetAnimator *widgetAnimator = mainWindowLayout()->widgetAnimator;1494 QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator; 1484 1495 1485 1496 #ifndef QT_NO_TABBAR … … 1514 1525 } 1515 1526 1516 widgetAnimator ->animate(tabBar, tab_rect, animate);1527 widgetAnimator.animate(tabBar, tab_rect, animate); 1517 1528 } 1518 1529 #endif // QT_NO_TABBAR … … 1537 1548 1538 1549 QRect geo = w->geometry(); 1539 widgetAnimator ->animate(w, r, animate);1540 if (!w->isHidden() ) {1550 widgetAnimator.animate(w, r, animate); 1551 if (!w->isHidden() && w->window()->isVisible()) { 1541 1552 QDockWidget *dw = qobject_cast<QDockWidget*>(w); 1542 1553 if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) { … … 1549 1560 } 1550 1561 } 1551 1562 #ifndef QT_NO_TABBAR 1552 1563 if (sep == 1) 1553 1564 updateSeparatorWidgets(); 1565 #endif //QT_NO_TABBAR 1554 1566 } 1555 1567 … … 1630 1642 break; 1631 1643 QRect r = separatorRect(i); 1632 if (clip.contains(r) )1644 if (clip.contains(r) && !item.hasFixedSize(o)) 1633 1645 paintSep(p, widget, r, o, r.contains(mouse)); 1634 1646 } … … 1695 1707 } 1696 1708 1697 QDockAreaLayoutItem &QDockAreaLayoutInfo::item( QList<int>path)1709 QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) 1698 1710 { 1699 1711 Q_ASSERT(!path.isEmpty()); 1712 const int index = path.first(); 1700 1713 if (path.count() > 1) { 1701 QDockAreaLayoutItem &item = item_list[path.takeFirst()];1714 const QDockAreaLayoutItem &item = item_list[index]; 1702 1715 Q_ASSERT(item.subinfo != 0); 1703 return item.subinfo->item(path );1704 } 1705 return item_list[ path.first()];1716 return item.subinfo->item(path.mid(1)); 1717 } 1718 return item_list[index]; 1706 1719 } 1707 1720 … … 1832 1845 } 1833 1846 1834 #ifdef Q_WS_MAC1835 1847 static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos) 1836 1848 { … … 1844 1856 return Qt::NoDockWidgetArea; 1845 1857 } 1846 #endif1847 1858 1848 1859 static QRect constrainedRect(QRect rect, const QRect &desktop) … … 1961 1972 if (!testing) { 1962 1973 widget->setVisible(flags & StateFlagVisible); 1974 item_list.append(item); 1963 1975 } 1964 1976 } else { 1965 1977 int dummy; 1966 1978 stream >> item.pos >> item.size >> dummy >> dummy; 1967 // qDebug() << widget << item.pos << item.size;1968 1979 if (!testing) { 1980 item_list.append(item); 1969 1981 widget->setFloating(false); 1970 1982 widget->setVisible(flags & StateFlagVisible); 1983 emit widget->dockLocationChanged(toDockWidgetArea(dockPos)); 1971 1984 } 1972 1985 } 1973 1986 1974 if (!testing) {1975 item_list.append(item);1976 }1977 1987 } 1978 1988 } else if (nextMarker == SequenceMarker) { … … 2001 2011 setCurrentTabId(tabId(item_list.at(index))); 2002 2012 } 2003 #endif2004 2013 if (!testing && sep == 1) 2005 2014 updateSeparatorWidgets(); 2015 #endif 2006 2016 2007 2017 return true; 2008 2018 } 2009 2019 2020 #ifndef QT_NO_TABBAR 2010 2021 void QDockAreaLayoutInfo::updateSeparatorWidgets() const 2011 2022 { 2012 QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);2013 2014 2023 if (tabbed) { 2015 that->separatorWidgets.clear();2024 separatorWidgets.clear(); 2016 2025 return; 2017 2026 } … … 2041 2050 } else { 2042 2051 sepWidget = mainWindowLayout()->getSeparatorWidget(); 2043 that->separatorWidgets.append(sepWidget);2052 separatorWidgets.append(sepWidget); 2044 2053 } 2045 2054 j++; … … 2054 2063 } 2055 2064 2056 for (int k = j; k < that->separatorWidgets.size(); ++k) {2057 that->separatorWidgets[k]->hide();2058 } 2059 that->separatorWidgets.resize(j);2065 for (int k = j; k < separatorWidgets.size(); ++k) { 2066 separatorWidgets[k]->hide(); 2067 } 2068 separatorWidgets.resize(j); 2060 2069 Q_ASSERT(separatorWidgets.size() == j); 2061 2070 } 2071 #endif //QT_NO_TABBAR 2062 2072 2063 2073 #ifndef QT_NO_TABBAR … … 2069 2079 QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); 2070 2080 2071 if (t abBar == 0) {2081 if (that->tabBar == 0) { 2072 2082 that->tabBar = mainWindowLayout()->getTabBar(); 2073 2083 that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape)); … … 2203 2213 QSet<QWidget*> result; 2204 2214 2205 for each (QWidget *sepWidget, separatorWidgets)2206 result << sep Widget;2215 for (int i = 0; i < separatorWidgets.count(); ++i) 2216 result << separatorWidgets.at(i); 2207 2217 2208 2218 for (int i = 0; i < item_list.count(); ++i) { … … 2254 2264 */ 2255 2265 2256 QDockAreaLayout::QDockAreaLayout(QMainWindow *win) 2266 QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) 2257 2267 { 2258 2268 mainWindow = win; … … 2272 2282 = QDockAreaLayoutInfo(sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); 2273 2283 centralWidgetItem = 0; 2274 centralWidgetRect = QRect(0, 0, -1, -1); 2284 2275 2285 2276 2286 corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea; … … 2341 2351 corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]); 2342 2352 } 2353 2354 if (!testing) 2355 fallbackToSizeHints = false; 2343 2356 } 2344 2357 … … 2443 2456 continue; 2444 2457 QRect rect = separatorRect(i); 2445 if ( sep == 1)2458 if (!rect.isNull() && sep == 1) 2446 2459 rect.adjust(-2, -2, 2, 2); 2447 if (rect.contains(pos) ) {2460 if (rect.contains(pos) && !info.hasFixedSize()) { 2448 2461 result << i; 2449 2462 break; … … 2470 2483 } 2471 2484 2472 QDockAreaLayoutInfo *QDockAreaLayout::info( QList<int>path)2485 QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) 2473 2486 { 2474 2487 Q_ASSERT(!path.isEmpty()); 2475 int index = path.takeFirst();2488 const int index = path.first(); 2476 2489 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2477 2490 2478 if (path. isEmpty())2491 if (path.count() == 1) 2479 2492 return &docks[index]; 2480 2493 2481 return docks[index].info(path );2482 } 2483 2484 const QDockAreaLayoutInfo *QDockAreaLayout::info( QList<int>path) const2494 return docks[index].info(path.mid(1)); 2495 } 2496 2497 const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const 2485 2498 { 2486 2499 return const_cast<QDockAreaLayout*>(this)->info(path); 2487 2500 } 2488 2501 2489 QDockAreaLayoutItem &QDockAreaLayout::item( QList<int>path)2502 QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path) 2490 2503 { 2491 2504 Q_ASSERT(!path.isEmpty()); 2492 int index = path.takeFirst();2505 const int index = path.first(); 2493 2506 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2494 return docks[index].item(path );2495 } 2496 2497 QRect QDockAreaLayout::itemRect( QList<int>path) const2507 return docks[index].item(path.mid(1)); 2508 } 2509 2510 QRect QDockAreaLayout::itemRect(const QList<int> &path) const 2498 2511 { 2499 2512 Q_ASSERT(!path.isEmpty()); 2500 int index = path.takeFirst();2513 const int index = path.first(); 2501 2514 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2502 return docks[index].itemRect(path );2515 return docks[index].itemRect(path.mid(1)); 2503 2516 } 2504 2517 2505 2518 QRect QDockAreaLayout::separatorRect(int index) const 2506 2519 { 2507 if (docks[index].isEmpty()) 2520 const QDockAreaLayoutInfo &dock = docks[index]; 2521 if (dock.isEmpty()) 2508 2522 return QRect(); 2509 QRect r = dock s[index].rect;2523 QRect r = dock.rect; 2510 2524 switch (index) { 2511 2525 case QInternal::LeftDock: … … 2523 2537 } 2524 2538 2525 QRect QDockAreaLayout::separatorRect( QList<int>path) const2539 QRect QDockAreaLayout::separatorRect(const QList<int> &path) const 2526 2540 { 2527 2541 Q_ASSERT(!path.isEmpty()); 2528 2542 2529 int index = path.takeFirst();2543 const int index = path.first(); 2530 2544 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2531 2545 2532 if (path. isEmpty())2546 if (path.count() == 1) 2533 2547 return separatorRect(index); 2534 2548 else 2535 return docks[index].separatorRect(path );2536 } 2537 2538 bool QDockAreaLayout::insertGap( QList<int>path, QLayoutItem *dockWidgetItem)2549 return docks[index].separatorRect(path.mid(1)); 2550 } 2551 2552 bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) 2539 2553 { 2540 2554 Q_ASSERT(!path.isEmpty()); 2541 int index = path.takeFirst();2555 const int index = path.first(); 2542 2556 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2543 return docks[index].insertGap(path , dockWidgetItem);2544 } 2545 2546 QLayoutItem *QDockAreaLayout::plug( QList<int>path)2557 return docks[index].insertGap(path.mid(1), dockWidgetItem); 2558 } 2559 2560 QLayoutItem *QDockAreaLayout::plug(const QList<int> &path) 2547 2561 { 2548 2562 Q_ASSERT(!path.isEmpty()); 2549 int index = path.takeFirst();2563 const int index = path.first(); 2550 2564 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2551 return docks[index].plug(path );2552 } 2553 2554 QLayoutItem *QDockAreaLayout::unplug( QList<int>path)2565 return docks[index].plug(path.mid(1)); 2566 } 2567 2568 QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path) 2555 2569 { 2556 2570 Q_ASSERT(!path.isEmpty()); 2557 int index = path.takeFirst();2571 const int index = path.first(); 2558 2572 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2559 return docks[index].unplug(path );2560 } 2561 2562 void QDockAreaLayout::remove( QList<int>path)2573 return docks[index].unplug(path.mid(1)); 2574 } 2575 2576 void QDockAreaLayout::remove(const QList<int> &path) 2563 2577 { 2564 2578 Q_ASSERT(!path.isEmpty()); 2565 int index = path.takeFirst();2579 const int index = path.first(); 2566 2580 Q_ASSERT(index >= 0 && index < QInternal::DockCount); 2567 docks[index].remove(path );2581 docks[index].remove(path.mid(1)); 2568 2582 } 2569 2583 … … 2576 2590 QSize center_hint(0, 0); 2577 2591 QSize center_min(0, 0); 2578 bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();2592 const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); 2579 2593 if (have_central) { 2580 2594 center_hint = centralWidgetRect.size(); … … 2595 2609 2596 2610 QSize left_hint = docks[QInternal::LeftDock].size(); 2597 if ( !left_hint.isValid())2611 if (left_hint.isNull() || fallbackToSizeHints) 2598 2612 left_hint = docks[QInternal::LeftDock].sizeHint(); 2599 2613 QSize left_min = docks[QInternal::LeftDock].minimumSize(); … … 2602 2616 2603 2617 QSize right_hint = docks[QInternal::RightDock].size(); 2604 if ( !right_hint.isValid())2618 if (right_hint.isNull() || fallbackToSizeHints) 2605 2619 right_hint = docks[QInternal::RightDock].sizeHint(); 2606 2620 QSize right_min = docks[QInternal::RightDock].minimumSize(); … … 2609 2623 2610 2624 QSize top_hint = docks[QInternal::TopDock].size(); 2611 if ( !top_hint.isValid())2625 if (top_hint.isNull() || fallbackToSizeHints) 2612 2626 top_hint = docks[QInternal::TopDock].sizeHint(); 2613 2627 QSize top_min = docks[QInternal::TopDock].minimumSize(); … … 2616 2630 2617 2631 QSize bottom_hint = docks[QInternal::BottomDock].size(); 2618 if ( !bottom_hint.isValid())2632 if (bottom_hint.isNull() || fallbackToSizeHints) 2619 2633 bottom_hint = docks[QInternal::BottomDock].sizeHint(); 2620 2634 QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); 2621 2635 QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); 2622 2636 bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); 2637 2638 fallbackToSizeHints = !have_central; 2623 2639 2624 2640 if (_ver_struct_list != 0) { … … 2855 2871 docks[i].clear(); 2856 2872 2857 rect = QRect( 0, 0, -1, -1);2858 centralWidgetRect = QRect( 0, 0, -1, -1);2873 rect = QRect(); 2874 centralWidgetRect = QRect(); 2859 2875 } 2860 2876 … … 3058 3074 void QDockAreaLayout::apply(bool animate) 3059 3075 { 3060 QWidgetAnimator *widgetAnimator3076 QWidgetAnimator &widgetAnimator 3061 3077 = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator; 3062 3078 … … 3064 3080 docks[i].apply(animate); 3065 3081 if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) { 3066 widgetAnimator ->animate(centralWidgetItem->widget(), centralWidgetRect,3082 widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, 3067 3083 animate); 3068 3084 } 3069 3085 #ifndef QT_NO_TABBAR 3070 3086 if (sep == 1) 3071 3087 updateSeparatorWidgets(); 3088 #endif //QT_NO_TABBAR 3072 3089 } 3073 3090 … … 3081 3098 continue; 3082 3099 QRect r = separatorRect(i); 3083 if (clip.contains(r) ) {3100 if (clip.contains(r) && !dock.hasFixedSize()) { 3084 3101 Qt::Orientation opposite = dock.o == Qt::Horizontal 3085 3102 ? Qt::Vertical : Qt::Horizontal; … … 3106 3123 } 3107 3124 3108 int QDockAreaLayout::separatorMove(QList<int> separator, const QPoint &origin, 3109 const QPoint &dest, 3110 QVector<QLayoutStruct> *cache) 3125 int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin, 3126 const QPoint &dest) 3111 3127 { 3112 3128 int delta = 0; … … 3117 3133 delta = pick(info->o, dest - origin); 3118 3134 if (delta != 0) 3119 delta = info->separatorMove(index, delta , cache);3135 delta = info->separatorMove(index, delta); 3120 3136 info->apply(false); 3121 3137 return delta; 3122 3138 } 3123 3139 3124 if (cache->isEmpty()) { 3125 QVector<QLayoutStruct> &list = *cache; 3126 3127 if (index == QInternal::LeftDock || index == QInternal::RightDock) 3128 getGrid(0, &list); 3129 else 3130 getGrid(&list, 0); 3131 } 3132 3133 QVector<QLayoutStruct> list = *cache; 3140 QVector<QLayoutStruct> list; 3141 3142 if (index == QInternal::LeftDock || index == QInternal::RightDock) 3143 getGrid(0, &list); 3144 else 3145 getGrid(&list, 0); 3146 3134 3147 int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock 3135 3148 ? 0 : 1; … … 3151 3164 } 3152 3165 3166 #ifndef QT_NO_TABBAR 3153 3167 // Sets the correct positions for the seperator widgets 3154 3168 // Allocates new sepearator widgets with getSeparatorWidget 3155 3169 void QDockAreaLayout::updateSeparatorWidgets() const 3156 3170 { 3157 QDockAreaLayout *that = const_cast<QDockAreaLayout*>(this);3158 3159 3171 int j = 0; 3160 3172 … … 3169 3181 } else { 3170 3182 sepWidget = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget(); 3171 that->separatorWidgets.append(sepWidget);3183 separatorWidgets.append(sepWidget); 3172 3184 } 3173 3185 j++; … … 3184 3196 separatorWidgets.at(i)->hide(); 3185 3197 3186 that->separatorWidgets.resize(j); 3187 } 3198 separatorWidgets.resize(j); 3199 } 3200 #endif //QT_NO_TABBAR 3188 3201 3189 3202 QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const … … 3238 3251 return result; 3239 3252 } 3240 #endif3241 3253 3242 3254 // Returns the set of all used separator widgets … … 3245 3257 QSet<QWidget*> result; 3246 3258 3247 for each (QWidget *sepWidget, separatorWidgets)3248 result << sep Widget;3259 for (int i = 0; i < separatorWidgets.count(); ++i) 3260 result << separatorWidgets.at(i); 3249 3261 for (int i = 0; i < QInternal::DockCount; ++i) { 3250 3262 const QDockAreaLayoutInfo &dock = docks[i]; … … 3253 3265 return result; 3254 3266 } 3255 3256 QRect QDockAreaLayout::gapRect(QList<int> path) const 3267 #endif 3268 3269 QRect QDockAreaLayout::gapRect(const QList<int> &path) const 3257 3270 { 3258 3271 const QDockAreaLayoutInfo *info = this->info(path);
Note:
See TracChangeset
for help on using the changeset viewer.