1165 |
1165 |
1166 // this is not yet a nested layout - make it |
1166 // this is not yet a nested layout - make it |
1167 |
1167 |
1168 QDockAreaLayoutInfo *subinfo = item.subinfo; |
1168 QDockAreaLayoutInfo *subinfo = item.subinfo; |
1169 QLayoutItem *widgetItem = item.widgetItem; |
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 Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; |
1173 Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; |
1173 #ifdef QT_NO_TABBAR |
1174 #ifdef QT_NO_TABBAR |
1174 const int tabBarShape = 0; |
1175 const int tabBarShape = 0; |
1175 #endif |
1176 #endif |
1176 QDockAreaLayoutInfo *new_info |
1177 QDockAreaLayoutInfo *new_info |
1177 = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow); |
1178 = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow); |
1178 |
1179 |
|
1180 //item become a new top-level |
1179 item.subinfo = new_info; |
1181 item.subinfo = new_info; |
1180 item.widgetItem = 0; |
1182 item.widgetItem = 0; |
|
1183 item.placeHolderItem = 0; |
1181 |
1184 |
1182 QDockAreaLayoutItem new_item |
1185 QDockAreaLayoutItem new_item |
1183 = widgetItem == 0 |
1186 = widgetItem == 0 |
1184 ? QDockAreaLayoutItem(subinfo) |
1187 ? QDockAreaLayoutItem(subinfo) |
1185 : QDockAreaLayoutItem(widgetItem); |
1188 : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem); |
1186 new_item.size = pick(opposite, r.size()); |
1189 new_item.size = pick(opposite, r.size()); |
1187 new_item.pos = pick(opposite, r.topLeft()); |
1190 new_item.pos = pick(opposite, r.topLeft()); |
1188 new_info->item_list.append(new_item); |
1191 new_info->item_list.append(new_item); |
1189 #ifndef QT_NO_TABBAR |
1192 #ifndef QT_NO_TABBAR |
1190 if (insert_tabbed) { |
1193 if (insert_tabbed) { |
1554 && (geo.right() < 0 || geo.bottom() < 0)) { |
1557 && (geo.right() < 0 || geo.bottom() < 0)) { |
1555 emit dw->visibilityChanged(true); |
1558 emit dw->visibilityChanged(true); |
1556 } |
1559 } |
1557 } |
1560 } |
1558 } |
1561 } |
1559 |
1562 #ifndef QT_NO_TABBAR |
1560 if (sep == 1) |
1563 if (sep == 1) |
1561 updateSeparatorWidgets(); |
1564 updateSeparatorWidgets(); |
|
1565 #endif //QT_NO_TABBAR |
1562 } |
1566 } |
1563 |
1567 |
1564 static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over) |
1568 static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over) |
1565 { |
1569 { |
1566 QStyleOption opt(0); |
1570 QStyleOption opt(0); |
1967 widget->resize(r.size()); |
1969 widget->resize(r.size()); |
1968 } |
1970 } |
1969 |
1971 |
1970 if (!testing) { |
1972 if (!testing) { |
1971 widget->setVisible(flags & StateFlagVisible); |
1973 widget->setVisible(flags & StateFlagVisible); |
|
1974 item_list.append(item); |
1972 } |
1975 } |
1973 } else { |
1976 } else { |
1974 int dummy; |
1977 int dummy; |
1975 stream >> item.pos >> item.size >> dummy >> dummy; |
1978 stream >> item.pos >> item.size >> dummy >> dummy; |
1976 if (!testing) { |
1979 if (!testing) { |
|
1980 item_list.append(item); |
1977 widget->setFloating(false); |
1981 widget->setFloating(false); |
1978 widget->setVisible(flags & StateFlagVisible); |
1982 widget->setVisible(flags & StateFlagVisible); |
|
1983 emit widget->dockLocationChanged(toDockWidgetArea(dockPos)); |
1979 } |
1984 } |
1980 } |
1985 } |
1981 |
1986 |
1982 if (!testing) { |
|
1983 item_list.append(item); |
|
1984 } |
|
1985 } |
1987 } |
1986 } else if (nextMarker == SequenceMarker) { |
1988 } else if (nextMarker == SequenceMarker) { |
1987 int dummy; |
1989 int dummy; |
1988 #ifdef QT_NO_TABBAR |
1990 #ifdef QT_NO_TABBAR |
1989 const int tabBarShape = 0; |
1991 const int tabBarShape = 0; |
2006 #ifndef QT_NO_TABBAR |
2008 #ifndef QT_NO_TABBAR |
2007 if (!testing && tabbed && index >= 0 && index < item_list.count()) { |
2009 if (!testing && tabbed && index >= 0 && index < item_list.count()) { |
2008 updateTabBar(); |
2010 updateTabBar(); |
2009 setCurrentTabId(tabId(item_list.at(index))); |
2011 setCurrentTabId(tabId(item_list.at(index))); |
2010 } |
2012 } |
2011 #endif |
|
2012 if (!testing && sep == 1) |
2013 if (!testing && sep == 1) |
2013 updateSeparatorWidgets(); |
2014 updateSeparatorWidgets(); |
|
2015 #endif |
2014 |
2016 |
2015 return true; |
2017 return true; |
2016 } |
2018 } |
2017 |
2019 |
|
2020 #ifndef QT_NO_TABBAR |
2018 void QDockAreaLayoutInfo::updateSeparatorWidgets() const |
2021 void QDockAreaLayoutInfo::updateSeparatorWidgets() const |
2019 { |
2022 { |
2020 if (tabbed) { |
2023 if (tabbed) { |
2021 separatorWidgets.clear(); |
2024 separatorWidgets.clear(); |
2022 return; |
2025 return; |
2580 void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, |
2587 void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, |
2581 QVector<QLayoutStruct> *_hor_struct_list) |
2588 QVector<QLayoutStruct> *_hor_struct_list) |
2582 { |
2589 { |
2583 QSize center_hint(0, 0); |
2590 QSize center_hint(0, 0); |
2584 QSize center_min(0, 0); |
2591 QSize center_min(0, 0); |
2585 bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); |
2592 const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); |
2586 if (have_central) { |
2593 if (have_central) { |
2587 center_hint = centralWidgetRect.size(); |
2594 center_hint = centralWidgetRect.size(); |
2588 if (!center_hint.isValid()) |
2595 if (!center_hint.isValid()) |
2589 center_hint = centralWidgetItem->sizeHint(); |
2596 center_hint = centralWidgetItem->sizeHint(); |
2590 center_min = centralWidgetItem->minimumSize(); |
2597 center_min = centralWidgetItem->minimumSize(); |
2599 center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep); |
2606 center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep); |
2600 if (!docks[QInternal::BottomDock].isEmpty()) |
2607 if (!docks[QInternal::BottomDock].isEmpty()) |
2601 center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep); |
2608 center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep); |
2602 |
2609 |
2603 QSize left_hint = docks[QInternal::LeftDock].size(); |
2610 QSize left_hint = docks[QInternal::LeftDock].size(); |
2604 if (left_hint.isNull()) |
2611 if (left_hint.isNull() || fallbackToSizeHints) |
2605 left_hint = docks[QInternal::LeftDock].sizeHint(); |
2612 left_hint = docks[QInternal::LeftDock].sizeHint(); |
2606 QSize left_min = docks[QInternal::LeftDock].minimumSize(); |
2613 QSize left_min = docks[QInternal::LeftDock].minimumSize(); |
2607 QSize left_max = docks[QInternal::LeftDock].maximumSize(); |
2614 QSize left_max = docks[QInternal::LeftDock].maximumSize(); |
2608 left_hint = left_hint.boundedTo(left_max).expandedTo(left_min); |
2615 left_hint = left_hint.boundedTo(left_max).expandedTo(left_min); |
2609 |
2616 |
2610 QSize right_hint = docks[QInternal::RightDock].size(); |
2617 QSize right_hint = docks[QInternal::RightDock].size(); |
2611 if (right_hint.isNull()) |
2618 if (right_hint.isNull() || fallbackToSizeHints) |
2612 right_hint = docks[QInternal::RightDock].sizeHint(); |
2619 right_hint = docks[QInternal::RightDock].sizeHint(); |
2613 QSize right_min = docks[QInternal::RightDock].minimumSize(); |
2620 QSize right_min = docks[QInternal::RightDock].minimumSize(); |
2614 QSize right_max = docks[QInternal::RightDock].maximumSize(); |
2621 QSize right_max = docks[QInternal::RightDock].maximumSize(); |
2615 right_hint = right_hint.boundedTo(right_max).expandedTo(right_min); |
2622 right_hint = right_hint.boundedTo(right_max).expandedTo(right_min); |
2616 |
2623 |
2617 QSize top_hint = docks[QInternal::TopDock].size(); |
2624 QSize top_hint = docks[QInternal::TopDock].size(); |
2618 if (top_hint.isNull()) |
2625 if (top_hint.isNull() || fallbackToSizeHints) |
2619 top_hint = docks[QInternal::TopDock].sizeHint(); |
2626 top_hint = docks[QInternal::TopDock].sizeHint(); |
2620 QSize top_min = docks[QInternal::TopDock].minimumSize(); |
2627 QSize top_min = docks[QInternal::TopDock].minimumSize(); |
2621 QSize top_max = docks[QInternal::TopDock].maximumSize(); |
2628 QSize top_max = docks[QInternal::TopDock].maximumSize(); |
2622 top_hint = top_hint.boundedTo(top_max).expandedTo(top_min); |
2629 top_hint = top_hint.boundedTo(top_max).expandedTo(top_min); |
2623 |
2630 |
2624 QSize bottom_hint = docks[QInternal::BottomDock].size(); |
2631 QSize bottom_hint = docks[QInternal::BottomDock].size(); |
2625 if (bottom_hint.isNull()) |
2632 if (bottom_hint.isNull() || fallbackToSizeHints) |
2626 bottom_hint = docks[QInternal::BottomDock].sizeHint(); |
2633 bottom_hint = docks[QInternal::BottomDock].sizeHint(); |
2627 QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); |
2634 QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); |
2628 QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); |
2635 QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); |
2629 bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); |
2636 bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); |
|
2637 |
|
2638 fallbackToSizeHints = !have_central; |
2630 |
2639 |
2631 if (_ver_struct_list != 0) { |
2640 if (_ver_struct_list != 0) { |
2632 QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list; |
2641 QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list; |
2633 ver_struct_list.resize(3); |
2642 ver_struct_list.resize(3); |
2634 |
2643 |
3071 docks[i].apply(animate); |
3080 docks[i].apply(animate); |
3072 if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) { |
3081 if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) { |
3073 widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, |
3082 widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, |
3074 animate); |
3083 animate); |
3075 } |
3084 } |
3076 |
3085 #ifndef QT_NO_TABBAR |
3077 if (sep == 1) |
3086 if (sep == 1) |
3078 updateSeparatorWidgets(); |
3087 updateSeparatorWidgets(); |
|
3088 #endif //QT_NO_TABBAR |
3079 } |
3089 } |
3080 |
3090 |
3081 void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget, |
3091 void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget, |
3082 const QRegion &clip, |
3092 const QRegion &clip, |
3083 const QPoint &mouse) const |
3093 const QPoint &mouse) const |