| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdockarealayout.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com> | - | ||||||||||||||||||||||||
| 5 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 6 | ** | - | ||||||||||||||||||||||||
| 7 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 8 | ** | - | ||||||||||||||||||||||||
| 9 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
| 10 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 15 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 16 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 17 | ** | - | ||||||||||||||||||||||||
| 18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 20 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
| 21 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
| 22 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
| 23 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
| 24 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
| 25 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
| 26 | ** | - | ||||||||||||||||||||||||
| 27 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
| 28 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
| 29 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
| 30 | ** | - | ||||||||||||||||||||||||
| 31 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 32 | ** | - | ||||||||||||||||||||||||
| 33 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | #include "QtWidgets/qapplication.h" | - | ||||||||||||||||||||||||
| 36 | #include "QtWidgets/qwidget.h" | - | ||||||||||||||||||||||||
| 37 | #include "QtWidgets/qtabbar.h" | - | ||||||||||||||||||||||||
| 38 | #include "QtWidgets/qstyle.h" | - | ||||||||||||||||||||||||
| 39 | #include "QtWidgets/qdesktopwidget.h" | - | ||||||||||||||||||||||||
| 40 | #include "QtWidgets/qapplication.h" | - | ||||||||||||||||||||||||
| 41 | #include "QtCore/qvariant.h" | - | ||||||||||||||||||||||||
| 42 | #include "qdockarealayout_p.h" | - | ||||||||||||||||||||||||
| 43 | #include "qdockwidget.h" | - | ||||||||||||||||||||||||
| 44 | #include "qmainwindow.h" | - | ||||||||||||||||||||||||
| 45 | #include "qwidgetanimator_p.h" | - | ||||||||||||||||||||||||
| 46 | #include "qmainwindowlayout_p.h" | - | ||||||||||||||||||||||||
| 47 | #include "qdockwidget_p.h" | - | ||||||||||||||||||||||||
| 48 | #include <private/qlayoutengine_p.h> | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | #include <qpainter.h> | - | ||||||||||||||||||||||||
| 51 | #include <qstyleoption.h> | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | #ifndef QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | // qmainwindow.cpp | - | ||||||||||||||||||||||||
| 58 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); | - | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | enum { StateFlagVisible = 1, StateFlagFloating = 2 }; | - | ||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 63 | ** QPlaceHolderItem | - | ||||||||||||||||||||||||
| 64 | */ | - | ||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | QPlaceHolderItem::QPlaceHolderItem(QWidget *w) | - | ||||||||||||||||||||||||
| 67 | { | - | ||||||||||||||||||||||||
| 68 | objectName = w->objectName(); | - | ||||||||||||||||||||||||
| 69 | hidden = w->isHidden(); | - | ||||||||||||||||||||||||
| 70 | window = w->isWindow(); | - | ||||||||||||||||||||||||
| 71 | if (window)
| 0 | ||||||||||||||||||||||||
| 72 | topLevelRect = w->geometry(); never executed: topLevelRect = w->geometry(); | 0 | ||||||||||||||||||||||||
| 73 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 76 | ** QDockAreaLayoutItem | - | ||||||||||||||||||||||||
| 77 | */ | - | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem) | - | ||||||||||||||||||||||||
| 80 | : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags) | - | ||||||||||||||||||||||||
| 81 | { | - | ||||||||||||||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||
| 84 | QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo) | - | ||||||||||||||||||||||||
| 85 | : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags) | - | ||||||||||||||||||||||||
| 86 | { | - | ||||||||||||||||||||||||
| 87 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem) | - | ||||||||||||||||||||||||
| 90 | : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags) | - | ||||||||||||||||||||||||
| 91 | { | - | ||||||||||||||||||||||||
| 92 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other) | - | ||||||||||||||||||||||||
| 95 | : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos), | - | ||||||||||||||||||||||||
| 96 | size(other.size), flags(other.flags) | - | ||||||||||||||||||||||||
| 97 | { | - | ||||||||||||||||||||||||
| 98 | if (other.subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 99 | subinfo = new QDockAreaLayoutInfo(*other.subinfo); never executed: subinfo = new QDockAreaLayoutInfo(*other.subinfo); | 0 | ||||||||||||||||||||||||
| 100 | else if (other.placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 101 | placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); never executed: placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); | 0 | ||||||||||||||||||||||||
| 102 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | QDockAreaLayoutItem::~QDockAreaLayoutItem() | - | ||||||||||||||||||||||||
| 105 | { | - | ||||||||||||||||||||||||
| 106 | delete subinfo; | - | ||||||||||||||||||||||||
| 107 | delete placeHolderItem; | - | ||||||||||||||||||||||||
| 108 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | bool QDockAreaLayoutItem::skip() const | - | ||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||
| 112 | if (placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 113 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | if (flags & GapItem)
| 0 | ||||||||||||||||||||||||
| 116 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | if (widgetItem != 0)
| 0 | ||||||||||||||||||||||||
| 119 | return widgetItem->isEmpty(); never executed: return widgetItem->isEmpty(); | 0 | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | if (subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 122 | for (int i = 0; i < subinfo->item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 123 | if (!subinfo->item_list.at(i).skip())
| 0 | ||||||||||||||||||||||||
| 124 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 126 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 129 | } | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | QSize QDockAreaLayoutItem::minimumSize() const | - | ||||||||||||||||||||||||
| 132 | { | - | ||||||||||||||||||||||||
| 133 | if (widgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 134 | int left, top, right, bottom; | - | ||||||||||||||||||||||||
| 135 | widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||||||||
| 136 | return widgetItem->minimumSize() + QSize(left+right, top+bottom); never executed: return widgetItem->minimumSize() + QSize(left+right, top+bottom); | 0 | ||||||||||||||||||||||||
| 137 | } | - | ||||||||||||||||||||||||
| 138 | if (subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 139 | return subinfo->minimumSize(); never executed: return subinfo->minimumSize(); | 0 | ||||||||||||||||||||||||
| 140 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 141 | } | - | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | QSize QDockAreaLayoutItem::maximumSize() const | - | ||||||||||||||||||||||||
| 144 | { | - | ||||||||||||||||||||||||
| 145 | if (widgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 146 | int left, top, right, bottom; | - | ||||||||||||||||||||||||
| 147 | widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||||||||
| 148 | return widgetItem->maximumSize()+ QSize(left+right, top+bottom); never executed: return widgetItem->maximumSize()+ QSize(left+right, top+bottom); | 0 | ||||||||||||||||||||||||
| 149 | } | - | ||||||||||||||||||||||||
| 150 | if (subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 151 | return subinfo->maximumSize(); never executed: return subinfo->maximumSize(); | 0 | ||||||||||||||||||||||||
| 152 | return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); never executed: return QSize(((1<<24)-1), ((1<<24)-1)); | 0 | ||||||||||||||||||||||||
| 153 | } | - | ||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const | - | ||||||||||||||||||||||||
| 156 | { | - | ||||||||||||||||||||||||
| 157 | return perp(o, minimumSize()) == perp(o, maximumSize()); never executed: return perp(o, minimumSize()) == perp(o, maximumSize()); | 0 | ||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const | - | ||||||||||||||||||||||||
| 161 | { | - | ||||||||||||||||||||||||
| 162 | if ((flags & GapItem) || placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 163 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 164 | if (widgetItem != 0)
| 0 | ||||||||||||||||||||||||
| 165 | return ((widgetItem->expandingDirections() & o) == o); never executed: return ((widgetItem->expandingDirections() & o) == o); | 0 | ||||||||||||||||||||||||
| 166 | if (subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 167 | return subinfo->expansive(o); never executed: return subinfo->expansive(o); | 0 | ||||||||||||||||||||||||
| 168 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 169 | } | - | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | QSize QDockAreaLayoutItem::sizeHint() const | - | ||||||||||||||||||||||||
| 172 | { | - | ||||||||||||||||||||||||
| 173 | if (placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 174 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 175 | if (widgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 176 | int left, top, right, bottom; | - | ||||||||||||||||||||||||
| 177 | widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||||||||
| 178 | return widgetItem->sizeHint() + QSize(left+right, top+bottom); never executed: return widgetItem->sizeHint() + QSize(left+right, top+bottom); | 0 | ||||||||||||||||||||||||
| 179 | } | - | ||||||||||||||||||||||||
| 180 | if (subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 181 | return subinfo->sizeHint(); never executed: return subinfo->sizeHint(); | 0 | ||||||||||||||||||||||||
| 182 | return QSize(-1, -1); never executed: return QSize(-1, -1); | 0 | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | QDockAreaLayoutItem | - | ||||||||||||||||||||||||
| 186 | &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other) | - | ||||||||||||||||||||||||
| 187 | { | - | ||||||||||||||||||||||||
| 188 | widgetItem = other.widgetItem; | - | ||||||||||||||||||||||||
| 189 | if (other.subinfo == 0)
| 0 | ||||||||||||||||||||||||
| 190 | subinfo = 0; never executed: subinfo = 0; | 0 | ||||||||||||||||||||||||
| 191 | else | - | ||||||||||||||||||||||||
| 192 | subinfo = new QDockAreaLayoutInfo(*other.subinfo); never executed: subinfo = new QDockAreaLayoutInfo(*other.subinfo); | 0 | ||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||
| 194 | delete placeHolderItem; | - | ||||||||||||||||||||||||
| 195 | if (other.placeHolderItem == 0)
| 0 | ||||||||||||||||||||||||
| 196 | placeHolderItem = 0; never executed: placeHolderItem = 0; | 0 | ||||||||||||||||||||||||
| 197 | else | - | ||||||||||||||||||||||||
| 198 | placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); never executed: placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); | 0 | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | pos = other.pos; | - | ||||||||||||||||||||||||
| 201 | size = other.size; | - | ||||||||||||||||||||||||
| 202 | flags = other.flags; | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
| 205 | } | - | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 208 | ** QDockAreaLayoutInfo | - | ||||||||||||||||||||||||
| 209 | */ | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 212 | static quintptr tabId(const QDockAreaLayoutItem &item) | - | ||||||||||||||||||||||||
| 213 | { | - | ||||||||||||||||||||||||
| 214 | if (item.widgetItem == 0)
| 0 | ||||||||||||||||||||||||
| 215 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 216 | return reinterpret_cast<quintptr>(item.widgetItem->widget()); never executed: return reinterpret_cast<quintptr>(item.widgetItem->widget()); | 0 | ||||||||||||||||||||||||
| 217 | } | - | ||||||||||||||||||||||||
| 218 | #endif | - | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | static const int zero = 0; | - | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | QDockAreaLayoutInfo::QDockAreaLayoutInfo() | - | ||||||||||||||||||||||||
| 223 | : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) | - | ||||||||||||||||||||||||
| 224 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 225 | , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) | - | ||||||||||||||||||||||||
| 226 | #endif | - | ||||||||||||||||||||||||
| 227 | { | - | ||||||||||||||||||||||||
| 228 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, | - | ||||||||||||||||||||||||
| 231 | Qt::Orientation _o, int tbshape, | - | ||||||||||||||||||||||||
| 232 | QMainWindow *window) | - | ||||||||||||||||||||||||
| 233 | : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) | - | ||||||||||||||||||||||||
| 234 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 235 | , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) | - | ||||||||||||||||||||||||
| 236 | #endif | - | ||||||||||||||||||||||||
| 237 | { | - | ||||||||||||||||||||||||
| 238 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 239 | Q_UNUSED(tbshape); | - | ||||||||||||||||||||||||
| 240 | #endif | - | ||||||||||||||||||||||||
| 241 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | QSize QDockAreaLayoutInfo::size() const | - | ||||||||||||||||||||||||
| 244 | { | - | ||||||||||||||||||||||||
| 245 | return isEmpty() ? QSize(0, 0) : rect.size(); never executed: return isEmpty() ? QSize(0, 0) : rect.size();
| 0 | ||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | void QDockAreaLayoutInfo::clear() | - | ||||||||||||||||||||||||
| 249 | { | - | ||||||||||||||||||||||||
| 250 | item_list.clear(); | - | ||||||||||||||||||||||||
| 251 | rect = QRect(); | - | ||||||||||||||||||||||||
| 252 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 253 | tabbed = false; | - | ||||||||||||||||||||||||
| 254 | tabBar = 0; | - | ||||||||||||||||||||||||
| 255 | #endif | - | ||||||||||||||||||||||||
| 256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | bool QDockAreaLayoutInfo::isEmpty() const | - | ||||||||||||||||||||||||
| 259 | { | - | ||||||||||||||||||||||||
| 260 | return next(-1) == -1; never executed: return next(-1) == -1; | 0 | ||||||||||||||||||||||||
| 261 | } | - | ||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | QSize QDockAreaLayoutInfo::minimumSize() const | - | ||||||||||||||||||||||||
| 264 | { | - | ||||||||||||||||||||||||
| 265 | if (isEmpty())
| 0 | ||||||||||||||||||||||||
| 266 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||
| 268 | int a = 0, b = 0; | - | ||||||||||||||||||||||||
| 269 | bool first = true; | - | ||||||||||||||||||||||||
| 270 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 271 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 272 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 273 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||
| 275 | QSize min_size = item.minimumSize(); | - | ||||||||||||||||||||||||
| 276 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 277 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 278 | a = qMax(a, pick(o, min_size)); | - | ||||||||||||||||||||||||
| 279 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 280 | #endif | - | ||||||||||||||||||||||||
| 281 | { | - | ||||||||||||||||||||||||
| 282 | if (!first)
| 0 | ||||||||||||||||||||||||
| 283 | a += *sep; never executed: a += *sep; | 0 | ||||||||||||||||||||||||
| 284 | a += pick(o, min_size); | - | ||||||||||||||||||||||||
| 285 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 286 | b = qMax(b, perp(o, min_size)); | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | first = false; | - | ||||||||||||||||||||||||
| 289 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | QSize result; | - | ||||||||||||||||||||||||
| 292 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 293 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 296 | QSize tbm = tabBarMinimumSize(); | - | ||||||||||||||||||||||||
| 297 | if (!tbm.isNull()) {
| 0 | ||||||||||||||||||||||||
| 298 | switch (tabBarShape) { | - | ||||||||||||||||||||||||
| 299 | case QTabBar::RoundedNorth: never executed: case QTabBar::RoundedNorth: | 0 | ||||||||||||||||||||||||
| 300 | case QTabBar::RoundedSouth: never executed: case QTabBar::RoundedSouth: | 0 | ||||||||||||||||||||||||
| 301 | case QTabBar::TriangularNorth: never executed: case QTabBar::TriangularNorth: | 0 | ||||||||||||||||||||||||
| 302 | case QTabBar::TriangularSouth: never executed: case QTabBar::TriangularSouth: | 0 | ||||||||||||||||||||||||
| 303 | result.rheight() += tbm.height(); | - | ||||||||||||||||||||||||
| 304 | result.rwidth() = qMax(tbm.width(), result.width()); | - | ||||||||||||||||||||||||
| 305 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 306 | case QTabBar::RoundedEast: never executed: case QTabBar::RoundedEast: | 0 | ||||||||||||||||||||||||
| 307 | case QTabBar::RoundedWest: never executed: case QTabBar::RoundedWest: | 0 | ||||||||||||||||||||||||
| 308 | case QTabBar::TriangularEast: never executed: case QTabBar::TriangularEast: | 0 | ||||||||||||||||||||||||
| 309 | case QTabBar::TriangularWest: never executed: case QTabBar::TriangularWest: | 0 | ||||||||||||||||||||||||
| 310 | result.rheight() = qMax(tbm.height(), result.height()); | - | ||||||||||||||||||||||||
| 311 | result.rwidth() += tbm.width(); | - | ||||||||||||||||||||||||
| 312 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 313 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 314 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 315 | } | - | ||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||
| 317 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 320 | } | - | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | QSize QDockAreaLayoutInfo::maximumSize() const | - | ||||||||||||||||||||||||
| 323 | { | - | ||||||||||||||||||||||||
| 324 | if (isEmpty())
| 0 | ||||||||||||||||||||||||
| 325 | return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); never executed: return QSize(((1<<24)-1), ((1<<24)-1)); | 0 | ||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||
| 327 | int a = 0, b = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||
| 328 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 329 | if (tabbed)
| 0 | ||||||||||||||||||||||||
| 330 | a = QWIDGETSIZE_MAX; never executed: a = ((1<<24)-1); | 0 | ||||||||||||||||||||||||
| 331 | #endif | - | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | int min_perp = 0; | - | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | bool first = true; | - | ||||||||||||||||||||||||
| 336 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 337 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 338 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 339 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | QSize max_size = item.maximumSize(); | - | ||||||||||||||||||||||||
| 342 | min_perp = qMax(min_perp, perp(o, item.minimumSize())); | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 345 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 346 | a = qMin(a, pick(o, max_size)); | - | ||||||||||||||||||||||||
| 347 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 348 | #endif | - | ||||||||||||||||||||||||
| 349 | { | - | ||||||||||||||||||||||||
| 350 | if (!first)
| 0 | ||||||||||||||||||||||||
| 351 | a += *sep; never executed: a += *sep; | 0 | ||||||||||||||||||||||||
| 352 | a += pick(o, max_size); | - | ||||||||||||||||||||||||
| 353 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 354 | b = qMin(b, perp(o, max_size)); | - | ||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||
| 356 | a = qMin(a, int(QWIDGETSIZE_MAX)); | - | ||||||||||||||||||||||||
| 357 | b = qMin(b, int(QWIDGETSIZE_MAX)); | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | first = false; | - | ||||||||||||||||||||||||
| 360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | b = qMax(b, min_perp); | - | ||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||
| 364 | QSize result; | - | ||||||||||||||||||||||||
| 365 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 366 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 369 | QSize tbh = tabBarSizeHint(); | - | ||||||||||||||||||||||||
| 370 | if (!tbh.isNull()) {
| 0 | ||||||||||||||||||||||||
| 371 | switch (tabBarShape) { | - | ||||||||||||||||||||||||
| 372 | case QTabBar::RoundedNorth: never executed: case QTabBar::RoundedNorth: | 0 | ||||||||||||||||||||||||
| 373 | case QTabBar::RoundedSouth: never executed: case QTabBar::RoundedSouth: | 0 | ||||||||||||||||||||||||
| 374 | result.rheight() += tbh.height(); | - | ||||||||||||||||||||||||
| 375 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 376 | case QTabBar::RoundedEast: never executed: case QTabBar::RoundedEast: | 0 | ||||||||||||||||||||||||
| 377 | case QTabBar::RoundedWest: never executed: case QTabBar::RoundedWest: | 0 | ||||||||||||||||||||||||
| 378 | result.rwidth() += tbh.width(); | - | ||||||||||||||||||||||||
| 379 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 380 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 381 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 382 | } | - | ||||||||||||||||||||||||
| 383 | } | - | ||||||||||||||||||||||||
| 384 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 385 | - | |||||||||||||||||||||||||
| 386 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | QSize QDockAreaLayoutInfo::sizeHint() const | - | ||||||||||||||||||||||||
| 390 | { | - | ||||||||||||||||||||||||
| 391 | if (isEmpty())
| 0 | ||||||||||||||||||||||||
| 392 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | int a = 0, b = 0; | - | ||||||||||||||||||||||||
| 395 | int min_perp = 0; | - | ||||||||||||||||||||||||
| 396 | int max_perp = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||
| 397 | const QDockAreaLayoutItem *previous = 0; | - | ||||||||||||||||||||||||
| 398 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 399 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 400 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 401 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||
| 403 | bool gap = item.flags & QDockAreaLayoutItem::GapItem; | - | ||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||
| 405 | QSize size_hint = item.sizeHint(); | - | ||||||||||||||||||||||||
| 406 | min_perp = qMax(min_perp, perp(o, item.minimumSize())); | - | ||||||||||||||||||||||||
| 407 | max_perp = qMin(max_perp, perp(o, item.maximumSize())); | - | ||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 410 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 411 | a = qMax(a, gap ? item.size : pick(o, size_hint)); | - | ||||||||||||||||||||||||
| 412 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 413 | #endif | - | ||||||||||||||||||||||||
| 414 | { | - | ||||||||||||||||||||||||
| 415 | if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem)
| 0 | ||||||||||||||||||||||||
| 416 | && !previous->hasFixedSize(o)) {
| 0 | ||||||||||||||||||||||||
| 417 | a += *sep; | - | ||||||||||||||||||||||||
| 418 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 419 | a += gap ? item.size : pick(o, size_hint);
| 0 | ||||||||||||||||||||||||
| 420 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 421 | b = qMax(b, perp(o, size_hint)); | - | ||||||||||||||||||||||||
| 422 | - | |||||||||||||||||||||||||
| 423 | previous = &item; | - | ||||||||||||||||||||||||
| 424 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | max_perp = qMax(max_perp, min_perp); | - | ||||||||||||||||||||||||
| 427 | b = qMax(b, min_perp); | - | ||||||||||||||||||||||||
| 428 | b = qMin(b, max_perp); | - | ||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | QSize result; | - | ||||||||||||||||||||||||
| 431 | rpick(o, result) = a; | - | ||||||||||||||||||||||||
| 432 | rperp(o, result) = b; | - | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 435 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 436 | QSize tbh = tabBarSizeHint(); | - | ||||||||||||||||||||||||
| 437 | switch (tabBarShape) { | - | ||||||||||||||||||||||||
| 438 | case QTabBar::RoundedNorth: never executed: case QTabBar::RoundedNorth: | 0 | ||||||||||||||||||||||||
| 439 | case QTabBar::RoundedSouth: never executed: case QTabBar::RoundedSouth: | 0 | ||||||||||||||||||||||||
| 440 | case QTabBar::TriangularNorth: never executed: case QTabBar::TriangularNorth: | 0 | ||||||||||||||||||||||||
| 441 | case QTabBar::TriangularSouth: never executed: case QTabBar::TriangularSouth: | 0 | ||||||||||||||||||||||||
| 442 | result.rheight() += tbh.height(); | - | ||||||||||||||||||||||||
| 443 | result.rwidth() = qMax(tbh.width(), result.width()); | - | ||||||||||||||||||||||||
| 444 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 445 | case QTabBar::RoundedEast: never executed: case QTabBar::RoundedEast: | 0 | ||||||||||||||||||||||||
| 446 | case QTabBar::RoundedWest: never executed: case QTabBar::RoundedWest: | 0 | ||||||||||||||||||||||||
| 447 | case QTabBar::TriangularEast: never executed: case QTabBar::TriangularEast: | 0 | ||||||||||||||||||||||||
| 448 | case QTabBar::TriangularWest: never executed: case QTabBar::TriangularWest: | 0 | ||||||||||||||||||||||||
| 449 | result.rheight() = qMax(tbh.height(), result.height()); | - | ||||||||||||||||||||||||
| 450 | result.rwidth() += tbh.width(); | - | ||||||||||||||||||||||||
| 451 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 452 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 453 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 454 | } | - | ||||||||||||||||||||||||
| 455 | } | - | ||||||||||||||||||||||||
| 456 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 459 | } | - | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | bool QDockAreaLayoutInfo::expansive(Qt::Orientation o) const | - | ||||||||||||||||||||||||
| 462 | { | - | ||||||||||||||||||||||||
| 463 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 464 | if (item_list.at(i).expansive(o))
| 0 | ||||||||||||||||||||||||
| 465 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 466 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 467 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 468 | } | - | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | /* QDockAreaLayoutInfo::maximumSize() doesn't return the real max size. For example, | - | ||||||||||||||||||||||||
| 471 | if the layout is empty, it returns QWIDGETSIZE_MAX. This is so that empty dock areas | - | ||||||||||||||||||||||||
| 472 | don't constrain the size of the QMainWindow, but sometimes we really need to know the | - | ||||||||||||||||||||||||
| 473 | maximum size. Also, these functions take into account widgets that want to keep their | - | ||||||||||||||||||||||||
| 474 | size (f.ex. when they are hidden and then shown, they should not change size). | - | ||||||||||||||||||||||||
| 475 | */ | - | ||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | static int realMinSize(const QDockAreaLayoutInfo &info) | - | ||||||||||||||||||||||||
| 478 | { | - | ||||||||||||||||||||||||
| 479 | int result = 0; | - | ||||||||||||||||||||||||
| 480 | bool first = true; | - | ||||||||||||||||||||||||
| 481 | for (int i = 0; i < info.item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 482 | const QDockAreaLayoutItem &item = info.item_list.at(i); | - | ||||||||||||||||||||||||
| 483 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 484 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | int min = 0; | - | ||||||||||||||||||||||||
| 487 | if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)
| 0 | ||||||||||||||||||||||||
| 488 | min = item.size; never executed: min = item.size; | 0 | ||||||||||||||||||||||||
| 489 | else | - | ||||||||||||||||||||||||
| 490 | min = pick(info.o, item.minimumSize()); never executed: min = pick(info.o, item.minimumSize()); | 0 | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | if (!first)
| 0 | ||||||||||||||||||||||||
| 493 | result += *info.sep; never executed: result += *info.sep; | 0 | ||||||||||||||||||||||||
| 494 | result += min; | - | ||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||
| 496 | first = false; | - | ||||||||||||||||||||||||
| 497 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 500 | } | - | ||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||
| 502 | static int realMaxSize(const QDockAreaLayoutInfo &info) | - | ||||||||||||||||||||||||
| 503 | { | - | ||||||||||||||||||||||||
| 504 | int result = 0; | - | ||||||||||||||||||||||||
| 505 | bool first = true; | - | ||||||||||||||||||||||||
| 506 | for (int i = 0; i < info.item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 507 | const QDockAreaLayoutItem &item = info.item_list.at(i); | - | ||||||||||||||||||||||||
| 508 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 509 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 510 | - | |||||||||||||||||||||||||
| 511 | int max = 0; | - | ||||||||||||||||||||||||
| 512 | if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)
| 0 | ||||||||||||||||||||||||
| 513 | max = item.size; never executed: max = item.size; | 0 | ||||||||||||||||||||||||
| 514 | else | - | ||||||||||||||||||||||||
| 515 | max = pick(info.o, item.maximumSize()); never executed: max = pick(info.o, item.maximumSize()); | 0 | ||||||||||||||||||||||||
| 516 | - | |||||||||||||||||||||||||
| 517 | if (!first)
| 0 | ||||||||||||||||||||||||
| 518 | result += *info.sep; never executed: result += *info.sep; | 0 | ||||||||||||||||||||||||
| 519 | result += max; | - | ||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | if (result >= QWIDGETSIZE_MAX)
| 0 | ||||||||||||||||||||||||
| 522 | return QWIDGETSIZE_MAX; never executed: return ((1<<24)-1); | 0 | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | first = false; | - | ||||||||||||||||||||||||
| 525 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||
| 527 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 528 | } | - | ||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||
| 530 | void QDockAreaLayoutInfo::fitItems() | - | ||||||||||||||||||||||||
| 531 | { | - | ||||||||||||||||||||||||
| 532 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 533 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 534 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 535 | } | - | ||||||||||||||||||||||||
| 536 | #endif | - | ||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | QVector<QLayoutStruct> layout_struct_list(item_list.size()*2); | - | ||||||||||||||||||||||||
| 539 | int j = 0; | - | ||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | int size = pick(o, rect.size()); | - | ||||||||||||||||||||||||
| 542 | int min_size = realMinSize(*this); | - | ||||||||||||||||||||||||
| 543 | int max_size = realMaxSize(*this); | - | ||||||||||||||||||||||||
| 544 | int last_index = -1; | - | ||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||
| 546 | const QDockAreaLayoutItem *previous = 0; | - | ||||||||||||||||||||||||
| 547 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 548 | QDockAreaLayoutItem &item = item_list[i]; | - | ||||||||||||||||||||||||
| 549 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 550 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | bool gap = item.flags & QDockAreaLayoutItem::GapItem; | - | ||||||||||||||||||||||||
| 553 | if (previous && !gap) {
| 0 | ||||||||||||||||||||||||
| 554 | if (!(previous->flags & QDockAreaLayoutItem::GapItem)) {
| 0 | ||||||||||||||||||||||||
| 555 | QLayoutStruct &ls = layout_struct_list[j++]; | - | ||||||||||||||||||||||||
| 556 | ls.init(); | - | ||||||||||||||||||||||||
| 557 | ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;
| 0 | ||||||||||||||||||||||||
| 558 | ls.empty = false; | - | ||||||||||||||||||||||||
| 559 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | if (item.flags & QDockAreaLayoutItem::KeepSize) {
| 0 | ||||||||||||||||||||||||
| 563 | // Check if the item can keep its size, without violating size constraints | - | ||||||||||||||||||||||||
| 564 | // of other items. | - | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | if (size < min_size) {
| 0 | ||||||||||||||||||||||||
| 567 | // There is too little space to keep this widget's size | - | ||||||||||||||||||||||||
| 568 | item.flags &= ~QDockAreaLayoutItem::KeepSize; | - | ||||||||||||||||||||||||
| 569 | min_size -= item.size; | - | ||||||||||||||||||||||||
| 570 | min_size += pick(o, item.minimumSize()); | - | ||||||||||||||||||||||||
| 571 | min_size = qMax(0, min_size); | - | ||||||||||||||||||||||||
| 572 | } else if (size > max_size) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 573 | // There is too much space to keep this widget's size | - | ||||||||||||||||||||||||
| 574 | item.flags &= ~QDockAreaLayoutItem::KeepSize; | - | ||||||||||||||||||||||||
| 575 | max_size -= item.size; | - | ||||||||||||||||||||||||
| 576 | max_size += pick(o, item.maximumSize()); | - | ||||||||||||||||||||||||
| 577 | max_size = qMin<int>(QWIDGETSIZE_MAX, max_size); | - | ||||||||||||||||||||||||
| 578 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 579 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | last_index = j; | - | ||||||||||||||||||||||||
| 582 | QLayoutStruct &ls = layout_struct_list[j++]; | - | ||||||||||||||||||||||||
| 583 | ls.init(); | - | ||||||||||||||||||||||||
| 584 | ls.empty = false; | - | ||||||||||||||||||||||||
| 585 | if (item.flags & QDockAreaLayoutItem::KeepSize) {
| 0 | ||||||||||||||||||||||||
| 586 | ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size; | - | ||||||||||||||||||||||||
| 587 | ls.expansive = false; | - | ||||||||||||||||||||||||
| 588 | ls.stretch = 0; | - | ||||||||||||||||||||||||
| 589 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 590 | ls.maximumSize = pick(o, item.maximumSize()); | - | ||||||||||||||||||||||||
| 591 | ls.expansive = item.expansive(o); | - | ||||||||||||||||||||||||
| 592 | ls.minimumSize = pick(o, item.minimumSize()); | - | ||||||||||||||||||||||||
| 593 | ls.sizeHint = item.size == -1 ? pick(o, item.sizeHint()) : item.size;
| 0 | ||||||||||||||||||||||||
| 594 | ls.stretch = ls.expansive ? ls.sizeHint : 0;
| 0 | ||||||||||||||||||||||||
| 595 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | item.flags &= ~QDockAreaLayoutItem::KeepSize; | - | ||||||||||||||||||||||||
| 598 | previous = &item; | - | ||||||||||||||||||||||||
| 599 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 600 | layout_struct_list.resize(j); | - | ||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | // If there is more space than the widgets can take (due to maximum size constraints), | - | ||||||||||||||||||||||||
| 603 | // we detect it here and stretch the last widget to take up the rest of the space. | - | ||||||||||||||||||||||||
| 604 | if (size > max_size && last_index != -1) {
| 0 | ||||||||||||||||||||||||
| 605 | layout_struct_list[last_index].maximumSize = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||
| 606 | layout_struct_list[last_index].expansive = true; | - | ||||||||||||||||||||||||
| 607 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | qGeomCalc(layout_struct_list, 0, j, pick(o, rect.topLeft()), size, 0); | - | ||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||
| 611 | j = 0; | - | ||||||||||||||||||||||||
| 612 | bool prev_gap = false; | - | ||||||||||||||||||||||||
| 613 | bool first = true; | - | ||||||||||||||||||||||||
| 614 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 615 | QDockAreaLayoutItem &item = item_list[i]; | - | ||||||||||||||||||||||||
| 616 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 617 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||
| 619 | bool gap = item.flags & QDockAreaLayoutItem::GapItem; | - | ||||||||||||||||||||||||
| 620 | if (!first && !gap && !prev_gap)
| 0 | ||||||||||||||||||||||||
| 621 | ++j; never executed: ++j; | 0 | ||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||
| 623 | const QLayoutStruct &ls = layout_struct_list.at(j++); | - | ||||||||||||||||||||||||
| 624 | item.size = ls.size; | - | ||||||||||||||||||||||||
| 625 | item.pos = ls.pos; | - | ||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||
| 627 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 628 | item.subinfo->rect = itemRect(i); | - | ||||||||||||||||||||||||
| 629 | item.subinfo->fitItems(); | - | ||||||||||||||||||||||||
| 630 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | prev_gap = gap; | - | ||||||||||||||||||||||||
| 633 | first = false; | - | ||||||||||||||||||||||||
| 634 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 635 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos, | - | ||||||||||||||||||||||||
| 638 | Qt::Orientation o, | - | ||||||||||||||||||||||||
| 639 | bool nestingEnabled, | - | ||||||||||||||||||||||||
| 640 | QDockAreaLayoutInfo::TabMode tabMode) | - | ||||||||||||||||||||||||
| 641 | { | - | ||||||||||||||||||||||||
| 642 | if (tabMode == QDockAreaLayoutInfo::ForceTabs)
| 0 | ||||||||||||||||||||||||
| 643 | return QInternal::DockCount; never executed: return QInternal::DockCount; | 0 | ||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||
| 645 | QPoint pos = _pos - rect.topLeft(); | - | ||||||||||||||||||||||||
| 646 | - | |||||||||||||||||||||||||
| 647 | int x = pos.x(); | - | ||||||||||||||||||||||||
| 648 | int y = pos.y(); | - | ||||||||||||||||||||||||
| 649 | int w = rect.width(); | - | ||||||||||||||||||||||||
| 650 | int h = rect.height(); | - | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | if (tabMode != QDockAreaLayoutInfo::NoTabs) {
| 0 | ||||||||||||||||||||||||
| 653 | // is it in the center? | - | ||||||||||||||||||||||||
| 654 | if (nestingEnabled) {
| 0 | ||||||||||||||||||||||||
| 655 | /* 2/3 | - | ||||||||||||||||||||||||
| 656 | +--------------+ | - | ||||||||||||||||||||||||
| 657 | | | | - | ||||||||||||||||||||||||
| 658 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 659 | 2/3 | CCCCCCCC | | - | ||||||||||||||||||||||||
| 660 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 661 | | | | - | ||||||||||||||||||||||||
| 662 | +--------------+ */ | - | ||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||
| 664 | QRect center(w/6, h/6, 2*w/3, 2*h/3); | - | ||||||||||||||||||||||||
| 665 | if (center.contains(pos))
| 0 | ||||||||||||||||||||||||
| 666 | return QInternal::DockCount; never executed: return QInternal::DockCount; | 0 | ||||||||||||||||||||||||
| 667 | } else if (o == Qt::Horizontal) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 668 | /* 2/3 | - | ||||||||||||||||||||||||
| 669 | +--------------+ | - | ||||||||||||||||||||||||
| 670 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 671 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 672 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 673 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 674 | | CCCCCCCC | | - | ||||||||||||||||||||||||
| 675 | +--------------+ */ | - | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | if (x > w/6 && x < w*5/6)
| 0 | ||||||||||||||||||||||||
| 678 | return QInternal::DockCount; never executed: return QInternal::DockCount; | 0 | ||||||||||||||||||||||||
| 679 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 680 | /* | - | ||||||||||||||||||||||||
| 681 | +--------------+ | - | ||||||||||||||||||||||||
| 682 | | | | - | ||||||||||||||||||||||||
| 683 | 2/3 |CCCCCCCCCCCCCC| | - | ||||||||||||||||||||||||
| 684 | |CCCCCCCCCCCCCC| | - | ||||||||||||||||||||||||
| 685 | | | | - | ||||||||||||||||||||||||
| 686 | +--------------+ */ | - | ||||||||||||||||||||||||
| 687 | if (y > h/6 && y < 5*h/6)
| 0 | ||||||||||||||||||||||||
| 688 | return QInternal::DockCount; never executed: return QInternal::DockCount; | 0 | ||||||||||||||||||||||||
| 689 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 690 | } | - | ||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||
| 692 | // not in the center. which edge? | - | ||||||||||||||||||||||||
| 693 | if (nestingEnabled) {
| 0 | ||||||||||||||||||||||||
| 694 | if (o == Qt::Horizontal) {
| 0 | ||||||||||||||||||||||||
| 695 | /* 1/3 1/3 1/3 | - | ||||||||||||||||||||||||
| 696 | +------------+ (we've already ruled out the center) | - | ||||||||||||||||||||||||
| 697 | |LLLLTTTTRRRR| | - | ||||||||||||||||||||||||
| 698 | |LLLLTTTTRRRR| | - | ||||||||||||||||||||||||
| 699 | |LLLLBBBBRRRR| | - | ||||||||||||||||||||||||
| 700 | |LLLLBBBBRRRR| | - | ||||||||||||||||||||||||
| 701 | +------------+ */ | - | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | if (x < w/3)
| 0 | ||||||||||||||||||||||||
| 704 | return QInternal::LeftDock; never executed: return QInternal::LeftDock; | 0 | ||||||||||||||||||||||||
| 705 | if (x > 2*w/3)
| 0 | ||||||||||||||||||||||||
| 706 | return QInternal::RightDock; never executed: return QInternal::RightDock; | 0 | ||||||||||||||||||||||||
| 707 | if (y < h/2)
| 0 | ||||||||||||||||||||||||
| 708 | return QInternal::TopDock; never executed: return QInternal::TopDock; | 0 | ||||||||||||||||||||||||
| 709 | return QInternal::BottomDock; never executed: return QInternal::BottomDock; | 0 | ||||||||||||||||||||||||
| 710 | } else { | - | ||||||||||||||||||||||||
| 711 | /* +------------+ (we've already ruled out the center) | - | ||||||||||||||||||||||||
| 712 | 1/3 |TTTTTTTTTTTT| | - | ||||||||||||||||||||||||
| 713 | |LLLLLLRRRRRR| | - | ||||||||||||||||||||||||
| 714 | 1/3 |LLLLLLRRRRRR| | - | ||||||||||||||||||||||||
| 715 | 1/3 |BBBBBBBBBBBB| | - | ||||||||||||||||||||||||
| 716 | +------------+ */ | - | ||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | if (y < h/3)
| 0 | ||||||||||||||||||||||||
| 719 | return QInternal::TopDock; never executed: return QInternal::TopDock; | 0 | ||||||||||||||||||||||||
| 720 | if (y > 2*h/3)
| 0 | ||||||||||||||||||||||||
| 721 | return QInternal::BottomDock; never executed: return QInternal::BottomDock; | 0 | ||||||||||||||||||||||||
| 722 | if (x < w/2)
| 0 | ||||||||||||||||||||||||
| 723 | return QInternal::LeftDock; never executed: return QInternal::LeftDock; | 0 | ||||||||||||||||||||||||
| 724 | return QInternal::RightDock; never executed: return QInternal::RightDock; | 0 | ||||||||||||||||||||||||
| 725 | } | - | ||||||||||||||||||||||||
| 726 | } else { | - | ||||||||||||||||||||||||
| 727 | if (o == Qt::Horizontal) {
| 0 | ||||||||||||||||||||||||
| 728 | return x < w/2 never executed: return x < w/2 ? QInternal::LeftDock : QInternal::RightDock;
| 0 | ||||||||||||||||||||||||
| 729 | ? QInternal::LeftDock never executed: return x < w/2 ? QInternal::LeftDock : QInternal::RightDock; | 0 | ||||||||||||||||||||||||
| 730 | : QInternal::RightDock; never executed: return x < w/2 ? QInternal::LeftDock : QInternal::RightDock; | 0 | ||||||||||||||||||||||||
| 731 | } else { | - | ||||||||||||||||||||||||
| 732 | return y < h/2 never executed: return y < h/2 ? QInternal::TopDock : QInternal::BottomDock;
| 0 | ||||||||||||||||||||||||
| 733 | ? QInternal::TopDock never executed: return y < h/2 ? QInternal::TopDock : QInternal::BottomDock; | 0 | ||||||||||||||||||||||||
| 734 | : QInternal::BottomDock; never executed: return y < h/2 ? QInternal::TopDock : QInternal::BottomDock; | 0 | ||||||||||||||||||||||||
| 735 | } | - | ||||||||||||||||||||||||
| 736 | } | - | ||||||||||||||||||||||||
| 737 | } | - | ||||||||||||||||||||||||
| 738 | - | |||||||||||||||||||||||||
| 739 | QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos, | - | ||||||||||||||||||||||||
| 740 | bool nestingEnabled, TabMode tabMode) const | - | ||||||||||||||||||||||||
| 741 | { | - | ||||||||||||||||||||||||
| 742 | QList<int> result; | - | ||||||||||||||||||||||||
| 743 | QRect item_rect; | - | ||||||||||||||||||||||||
| 744 | int item_index = 0; | - | ||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||
| 746 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 747 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 748 | item_rect = tabContentRect(); | - | ||||||||||||||||||||||||
| 749 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 750 | #endif | - | ||||||||||||||||||||||||
| 751 | { | - | ||||||||||||||||||||||||
| 752 | int pos = pick(o, _pos); | - | ||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | int last = -1; | - | ||||||||||||||||||||||||
| 755 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 756 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 757 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 758 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 759 | - | |||||||||||||||||||||||||
| 760 | last = i; | - | ||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||
| 762 | if (item.pos + item.size < pos)
| 0 | ||||||||||||||||||||||||
| 763 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 764 | - | |||||||||||||||||||||||||
| 765 | if (item.subinfo != 0
| 0 | ||||||||||||||||||||||||
| 766 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 767 | && !item.subinfo->tabbed
| 0 | ||||||||||||||||||||||||
| 768 | #endif | - | ||||||||||||||||||||||||
| 769 | ) { | - | ||||||||||||||||||||||||
| 770 | result = item.subinfo->gapIndex(_pos, nestingEnabled, | - | ||||||||||||||||||||||||
| 771 | tabMode); | - | ||||||||||||||||||||||||
| 772 | result.prepend(i); | - | ||||||||||||||||||||||||
| 773 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 774 | } | - | ||||||||||||||||||||||||
| 775 | - | |||||||||||||||||||||||||
| 776 | item_rect = itemRect(i); | - | ||||||||||||||||||||||||
| 777 | item_index = i; | - | ||||||||||||||||||||||||
| 778 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 779 | } | - | ||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||
| 781 | if (item_rect.isNull()) {
| 0 | ||||||||||||||||||||||||
| 782 | result.append(last + 1); | - | ||||||||||||||||||||||||
| 783 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 784 | } | - | ||||||||||||||||||||||||
| 785 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||
| 787 | Q_ASSERT(!item_rect.isNull()); | - | ||||||||||||||||||||||||
| 788 | - | |||||||||||||||||||||||||
| 789 | QInternal::DockPosition dock_pos | - | ||||||||||||||||||||||||
| 790 | = dockPosHelper(item_rect, _pos, o, nestingEnabled, tabMode); | - | ||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||
| 792 | switch (dock_pos) { | - | ||||||||||||||||||||||||
| 793 | case QInternal::LeftDock: never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 794 | if (o == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
| 795 | result << item_index; never executed: result << item_index; | 0 | ||||||||||||||||||||||||
| 796 | else | - | ||||||||||||||||||||||||
| 797 | result << item_index << 0; // this subinfo doesn't exist yet, but insertGap() never executed: result << item_index << 0; | 0 | ||||||||||||||||||||||||
| 798 | // handles this by inserting it | - | ||||||||||||||||||||||||
| 799 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 800 | case QInternal::RightDock: never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 801 | if (o == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
| 802 | result << item_index + 1; never executed: result << item_index + 1; | 0 | ||||||||||||||||||||||||
| 803 | else | - | ||||||||||||||||||||||||
| 804 | result << item_index << 1; never executed: result << item_index << 1; | 0 | ||||||||||||||||||||||||
| 805 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 806 | case QInternal::TopDock: never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 807 | if (o == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
| 808 | result << item_index << 0; never executed: result << item_index << 0; | 0 | ||||||||||||||||||||||||
| 809 | else | - | ||||||||||||||||||||||||
| 810 | result << item_index; never executed: result << item_index; | 0 | ||||||||||||||||||||||||
| 811 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 812 | case QInternal::BottomDock: never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 813 | if (o == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
| 814 | result << item_index << 1; never executed: result << item_index << 1; | 0 | ||||||||||||||||||||||||
| 815 | else | - | ||||||||||||||||||||||||
| 816 | result << item_index + 1; never executed: result << item_index + 1; | 0 | ||||||||||||||||||||||||
| 817 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 818 | case QInternal::DockCount: never executed: case QInternal::DockCount: | 0 | ||||||||||||||||||||||||
| 819 | result << (-item_index - 1) << 0; // negative item_index means "on top of" | - | ||||||||||||||||||||||||
| 820 | // -item_index - 1, insertGap() | - | ||||||||||||||||||||||||
| 821 | // will insert a tabbed subinfo | - | ||||||||||||||||||||||||
| 822 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 823 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 824 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 825 | } | - | ||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||
| 827 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 828 | } | - | ||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | static inline int shrink(QLayoutStruct &ls, int delta) | - | ||||||||||||||||||||||||
| 831 | { | - | ||||||||||||||||||||||||
| 832 | if (ls.empty)
| 0 | ||||||||||||||||||||||||
| 833 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 834 | int old_size = ls.size; | - | ||||||||||||||||||||||||
| 835 | ls.size = qMax(ls.size - delta, ls.minimumSize); | - | ||||||||||||||||||||||||
| 836 | return old_size - ls.size; never executed: return old_size - ls.size; | 0 | ||||||||||||||||||||||||
| 837 | } | - | ||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||
| 839 | static inline int grow(QLayoutStruct &ls, int delta) | - | ||||||||||||||||||||||||
| 840 | { | - | ||||||||||||||||||||||||
| 841 | if (ls.empty)
| 0 | ||||||||||||||||||||||||
| 842 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 843 | int old_size = ls.size; | - | ||||||||||||||||||||||||
| 844 | ls.size = qMin(ls.size + delta, ls.maximumSize); | - | ||||||||||||||||||||||||
| 845 | return ls.size - old_size; never executed: return ls.size - old_size; | 0 | ||||||||||||||||||||||||
| 846 | } | - | ||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||
| 848 | static int separatorMoveHelper(QVector<QLayoutStruct> &list, int index, int delta, int sep) | - | ||||||||||||||||||||||||
| 849 | { | - | ||||||||||||||||||||||||
| 850 | // adjust sizes | - | ||||||||||||||||||||||||
| 851 | int pos = -1; | - | ||||||||||||||||||||||||
| 852 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 853 | const QLayoutStruct &ls = list.at(i); | - | ||||||||||||||||||||||||
| 854 | if (!ls.empty) {
| 0 | ||||||||||||||||||||||||
| 855 | pos = ls.pos; | - | ||||||||||||||||||||||||
| 856 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 857 | } | - | ||||||||||||||||||||||||
| 858 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 859 | if (pos == -1)
| 0 | ||||||||||||||||||||||||
| 860 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | if (delta > 0) {
| 0 | ||||||||||||||||||||||||
| 863 | int growlimit = 0; | - | ||||||||||||||||||||||||
| 864 | for (int i = 0; i<=index; ++i) {
| 0 | ||||||||||||||||||||||||
| 865 | const QLayoutStruct &ls = list.at(i); | - | ||||||||||||||||||||||||
| 866 | if (ls.empty)
| 0 | ||||||||||||||||||||||||
| 867 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 868 | if (ls.maximumSize == QLAYOUTSIZE_MAX) {
| 0 | ||||||||||||||||||||||||
| 869 | growlimit = QLAYOUTSIZE_MAX; | - | ||||||||||||||||||||||||
| 870 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 871 | } | - | ||||||||||||||||||||||||
| 872 | growlimit += ls.maximumSize - ls.size; | - | ||||||||||||||||||||||||
| 873 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 874 | if (delta > growlimit)
| 0 | ||||||||||||||||||||||||
| 875 | delta = growlimit; never executed: delta = growlimit; | 0 | ||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||
| 877 | int d = 0; | - | ||||||||||||||||||||||||
| 878 | for (int i = index + 1; d < delta && i < list.count(); ++i)
| 0 | ||||||||||||||||||||||||
| 879 | d += shrink(list[i], delta - d); never executed: d += shrink(list[i], delta - d); | 0 | ||||||||||||||||||||||||
| 880 | delta = d; | - | ||||||||||||||||||||||||
| 881 | d = 0; | - | ||||||||||||||||||||||||
| 882 | for (int i = index; d < delta && i >= 0; --i)
| 0 | ||||||||||||||||||||||||
| 883 | d += grow(list[i], delta - d); never executed: d += grow(list[i], delta - d); | 0 | ||||||||||||||||||||||||
| 884 | } else if (delta < 0) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 885 | int growlimit = 0; | - | ||||||||||||||||||||||||
| 886 | for (int i = index + 1; i < list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 887 | const QLayoutStruct &ls = list.at(i); | - | ||||||||||||||||||||||||
| 888 | if (ls.empty)
| 0 | ||||||||||||||||||||||||
| 889 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 890 | if (ls.maximumSize == QLAYOUTSIZE_MAX) {
| 0 | ||||||||||||||||||||||||
| 891 | growlimit = QLAYOUTSIZE_MAX; | - | ||||||||||||||||||||||||
| 892 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 893 | } | - | ||||||||||||||||||||||||
| 894 | growlimit += ls.maximumSize - ls.size; | - | ||||||||||||||||||||||||
| 895 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 896 | if (-delta > growlimit)
| 0 | ||||||||||||||||||||||||
| 897 | delta = -growlimit; never executed: delta = -growlimit; | 0 | ||||||||||||||||||||||||
| 898 | - | |||||||||||||||||||||||||
| 899 | int d = 0; | - | ||||||||||||||||||||||||
| 900 | for (int i = index; d < -delta && i >= 0; --i)
| 0 | ||||||||||||||||||||||||
| 901 | d += shrink(list[i], -delta - d); never executed: d += shrink(list[i], -delta - d); | 0 | ||||||||||||||||||||||||
| 902 | delta = -d; | - | ||||||||||||||||||||||||
| 903 | d = 0; | - | ||||||||||||||||||||||||
| 904 | for (int i = index + 1; d < -delta && i < list.count(); ++i)
| 0 | ||||||||||||||||||||||||
| 905 | d += grow(list[i], -delta - d); never executed: d += grow(list[i], -delta - d); | 0 | ||||||||||||||||||||||||
| 906 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||
| 908 | // adjust positions | - | ||||||||||||||||||||||||
| 909 | bool first = true; | - | ||||||||||||||||||||||||
| 910 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 911 | QLayoutStruct &ls = list[i]; | - | ||||||||||||||||||||||||
| 912 | if (ls.empty) {
| 0 | ||||||||||||||||||||||||
| 913 | ls.pos = pos + (first ? 0 : sep);
| 0 | ||||||||||||||||||||||||
| 914 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 915 | } | - | ||||||||||||||||||||||||
| 916 | if (!first)
| 0 | ||||||||||||||||||||||||
| 917 | pos += sep; never executed: pos += sep; | 0 | ||||||||||||||||||||||||
| 918 | ls.pos = pos; | - | ||||||||||||||||||||||||
| 919 | pos += ls.size; | - | ||||||||||||||||||||||||
| 920 | first = false; | - | ||||||||||||||||||||||||
| 921 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 922 | - | |||||||||||||||||||||||||
| 923 | return delta; never executed: return delta; | 0 | ||||||||||||||||||||||||
| 924 | } | - | ||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||
| 926 | int QDockAreaLayoutInfo::separatorMove(int index, int delta) | - | ||||||||||||||||||||||||
| 927 | { | - | ||||||||||||||||||||||||
| 928 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 929 | Q_ASSERT(!tabbed); | - | ||||||||||||||||||||||||
| 930 | #endif | - | ||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||
| 932 | QVector<QLayoutStruct> list(item_list.size()); | - | ||||||||||||||||||||||||
| 933 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 934 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 935 | QLayoutStruct &ls = list[i]; | - | ||||||||||||||||||||||||
| 936 | Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); | - | ||||||||||||||||||||||||
| 937 | if (item.skip()) {
| 0 | ||||||||||||||||||||||||
| 938 | ls.empty = true; | - | ||||||||||||||||||||||||
| 939 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 940 | const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
| 0 | ||||||||||||||||||||||||
| 941 | ls.empty = false; | - | ||||||||||||||||||||||||
| 942 | ls.pos = item.pos; | - | ||||||||||||||||||||||||
| 943 | ls.size = item.size + separatorSpace; | - | ||||||||||||||||||||||||
| 944 | ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace; | - | ||||||||||||||||||||||||
| 945 | ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace; | - | ||||||||||||||||||||||||
| 946 | - | |||||||||||||||||||||||||
| 947 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 948 | } | - | ||||||||||||||||||||||||
| 949 | - | |||||||||||||||||||||||||
| 950 | //the separator space has been added to the size, so we pass 0 as a parameter | - | ||||||||||||||||||||||||
| 951 | delta = separatorMoveHelper(list, index, delta, 0 /*separator*/); | - | ||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||
| 953 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 954 | QDockAreaLayoutItem &item = item_list[i]; | - | ||||||||||||||||||||||||
| 955 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 956 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 957 | QLayoutStruct &ls = list[i]; | - | ||||||||||||||||||||||||
| 958 | const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
| 0 | ||||||||||||||||||||||||
| 959 | item.size = ls.size - separatorSpace; | - | ||||||||||||||||||||||||
| 960 | item.pos = ls.pos; | - | ||||||||||||||||||||||||
| 961 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 962 | item.subinfo->rect = itemRect(i); | - | ||||||||||||||||||||||||
| 963 | item.subinfo->fitItems(); | - | ||||||||||||||||||||||||
| 964 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 965 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 966 | - | |||||||||||||||||||||||||
| 967 | return delta; never executed: return delta; | 0 | ||||||||||||||||||||||||
| 968 | } | - | ||||||||||||||||||||||||
| 969 | - | |||||||||||||||||||||||||
| 970 | void QDockAreaLayoutInfo::unnest(int index) | - | ||||||||||||||||||||||||
| 971 | { | - | ||||||||||||||||||||||||
| 972 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 973 | if (item.subinfo == 0)
| 0 | ||||||||||||||||||||||||
| 974 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 975 | if (item.subinfo->item_list.count() > 1)
| 0 | ||||||||||||||||||||||||
| 976 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||
| 978 | if (item.subinfo->item_list.count() == 0) {
| 0 | ||||||||||||||||||||||||
| 979 | item_list.removeAt(index); | - | ||||||||||||||||||||||||
| 980 | } else if (item.subinfo->item_list.count() == 1) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 981 | QDockAreaLayoutItem &child = item.subinfo->item_list.first(); | - | ||||||||||||||||||||||||
| 982 | if (child.widgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 983 | item.widgetItem = child.widgetItem; | - | ||||||||||||||||||||||||
| 984 | delete item.subinfo; | - | ||||||||||||||||||||||||
| 985 | item.subinfo = 0; | - | ||||||||||||||||||||||||
| 986 | } else if (child.subinfo != 0) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 987 | QDockAreaLayoutInfo *tmp = item.subinfo; | - | ||||||||||||||||||||||||
| 988 | item.subinfo = child.subinfo; | - | ||||||||||||||||||||||||
| 989 | child.subinfo = 0; | - | ||||||||||||||||||||||||
| 990 | tmp->item_list.clear(); | - | ||||||||||||||||||||||||
| 991 | delete tmp; | - | ||||||||||||||||||||||||
| 992 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 993 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 994 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||
| 996 | void QDockAreaLayoutInfo::remove(const QList<int> &path) | - | ||||||||||||||||||||||||
| 997 | { | - | ||||||||||||||||||||||||
| 998 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1001 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 1002 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1003 | Q_ASSERT(item.subinfo != 0); | - | ||||||||||||||||||||||||
| 1004 | item.subinfo->remove(path.mid(1)); | - | ||||||||||||||||||||||||
| 1005 | unnest(index); | - | ||||||||||||||||||||||||
| 1006 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | int index = path.first(); | - | ||||||||||||||||||||||||
| 1008 | item_list.removeAt(index); | - | ||||||||||||||||||||||||
| 1009 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1010 | } | - | ||||||||||||||||||||||||
| 1011 | - | |||||||||||||||||||||||||
| 1012 | QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1013 | { | - | ||||||||||||||||||||||||
| 1014 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||
| 1016 | int index = path.first(); | - | ||||||||||||||||||||||||
| 1017 | if (index < 0)
| 0 | ||||||||||||||||||||||||
| 1018 | index = -index - 1; never executed: index = -index - 1; | 0 | ||||||||||||||||||||||||
| 1019 | - | |||||||||||||||||||||||||
| 1020 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1021 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1022 | Q_ASSERT(item.subinfo != 0); | - | ||||||||||||||||||||||||
| 1023 | return item.subinfo->plug(path.mid(1)); never executed: return item.subinfo->plug(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 1024 | } | - | ||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1027 | - | |||||||||||||||||||||||||
| 1028 | Q_ASSERT(item.widgetItem != 0); | - | ||||||||||||||||||||||||
| 1029 | Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem); | - | ||||||||||||||||||||||||
| 1030 | item.flags &= ~QDockAreaLayoutItem::GapItem; | - | ||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||
| 1032 | QRect result; | - | ||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||
| 1034 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1035 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 1036 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 1037 | #endif | - | ||||||||||||||||||||||||
| 1038 | { | - | ||||||||||||||||||||||||
| 1039 | int prev = this->prev(index); | - | ||||||||||||||||||||||||
| 1040 | int next = this->next(index); | - | ||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
| 0 | ||||||||||||||||||||||||
| 1043 | item.pos += *sep; | - | ||||||||||||||||||||||||
| 1044 | item.size -= *sep; | - | ||||||||||||||||||||||||
| 1045 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1046 | if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 1047 | item.size -= *sep; never executed: item.size -= *sep; | 0 | ||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | QPoint pos; | - | ||||||||||||||||||||||||
| 1050 | rpick(o, pos) = item.pos; | - | ||||||||||||||||||||||||
| 1051 | rperp(o, pos) = perp(o, rect.topLeft()); | - | ||||||||||||||||||||||||
| 1052 | QSize s; | - | ||||||||||||||||||||||||
| 1053 | rpick(o, s) = item.size; | - | ||||||||||||||||||||||||
| 1054 | rperp(o, s) = perp(o, rect.size()); | - | ||||||||||||||||||||||||
| 1055 | result = QRect(pos, s); | - | ||||||||||||||||||||||||
| 1056 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1057 | - | |||||||||||||||||||||||||
| 1058 | return item.widgetItem; never executed: return item.widgetItem; | 0 | ||||||||||||||||||||||||
| 1059 | } | - | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1062 | { | - | ||||||||||||||||||||||||
| 1063 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||
| 1065 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 1066 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1067 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1068 | Q_ASSERT(item.subinfo != 0); | - | ||||||||||||||||||||||||
| 1069 | return item.subinfo->unplug(path.mid(1)); never executed: return item.subinfo->unplug(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 1070 | } | - | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1073 | int prev = this->prev(index); | - | ||||||||||||||||||||||||
| 1074 | int next = this->next(index); | - | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); | - | ||||||||||||||||||||||||
| 1077 | item.flags |= QDockAreaLayoutItem::GapItem; | - | ||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1080 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 1081 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 1082 | #endif | - | ||||||||||||||||||||||||
| 1083 | { | - | ||||||||||||||||||||||||
| 1084 | if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
| 0 | ||||||||||||||||||||||||
| 1085 | item.pos -= *sep; | - | ||||||||||||||||||||||||
| 1086 | item.size += *sep; | - | ||||||||||||||||||||||||
| 1087 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1088 | if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 1089 | item.size += *sep; never executed: item.size += *sep; | 0 | ||||||||||||||||||||||||
| 1090 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1091 | - | |||||||||||||||||||||||||
| 1092 | return item.widgetItem; never executed: return item.widgetItem; | 0 | ||||||||||||||||||||||||
| 1093 | } | - | ||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||
| 1095 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||
| 1097 | quintptr QDockAreaLayoutInfo::currentTabId() const | - | ||||||||||||||||||||||||
| 1098 | { | - | ||||||||||||||||||||||||
| 1099 | if (!tabbed || tabBar == 0)
| 0 | ||||||||||||||||||||||||
| 1100 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||
| 1102 | int index = tabBar->currentIndex(); | - | ||||||||||||||||||||||||
| 1103 | if (index == -1)
| 0 | ||||||||||||||||||||||||
| 1104 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1105 | - | |||||||||||||||||||||||||
| 1106 | return qvariant_cast<quintptr>(tabBar->tabData(index)); never executed: return qvariant_cast<quintptr>(tabBar->tabData(index)); | 0 | ||||||||||||||||||||||||
| 1107 | } | - | ||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||
| 1109 | void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget) | - | ||||||||||||||||||||||||
| 1110 | { | - | ||||||||||||||||||||||||
| 1111 | setCurrentTabId(reinterpret_cast<quintptr>(widget)); | - | ||||||||||||||||||||||||
| 1112 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1113 | - | |||||||||||||||||||||||||
| 1114 | void QDockAreaLayoutInfo::setCurrentTabId(quintptr id) | - | ||||||||||||||||||||||||
| 1115 | { | - | ||||||||||||||||||||||||
| 1116 | if (!tabbed || tabBar == 0)
| 0 | ||||||||||||||||||||||||
| 1117 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||
| 1119 | for (int i = 0; i < tabBar->count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1120 | if (qvariant_cast<quintptr>(tabBar->tabData(i)) == id) {
| 0 | ||||||||||||||||||||||||
| 1121 | tabBar->setCurrentIndex(i); | - | ||||||||||||||||||||||||
| 1122 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1123 | } | - | ||||||||||||||||||||||||
| 1124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1126 | - | |||||||||||||||||||||||||
| 1127 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1128 | - | |||||||||||||||||||||||||
| 1129 | static QRect dockedGeometry(QWidget *widget) | - | ||||||||||||||||||||||||
| 1130 | { | - | ||||||||||||||||||||||||
| 1131 | int titleHeight = 0; | - | ||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | QDockWidgetLayout *layout | - | ||||||||||||||||||||||||
| 1134 | = qobject_cast<QDockWidgetLayout*>(widget->layout()); | - | ||||||||||||||||||||||||
| 1135 | if(layout != 0 && layout->nativeWindowDeco())
| 0 | ||||||||||||||||||||||||
| 1136 | titleHeight = layout->titleHeight(); never executed: titleHeight = layout->titleHeight(); | 0 | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | QRect result = widget->geometry(); | - | ||||||||||||||||||||||||
| 1139 | result.adjust(0, -titleHeight, 0, 0); | - | ||||||||||||||||||||||||
| 1140 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1141 | } | - | ||||||||||||||||||||||||
| 1142 | - | |||||||||||||||||||||||||
| 1143 | bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) | - | ||||||||||||||||||||||||
| 1144 | { | - | ||||||||||||||||||||||||
| 1145 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | bool insert_tabbed = false; | - | ||||||||||||||||||||||||
| 1148 | int index = path.first(); | - | ||||||||||||||||||||||||
| 1149 | if (index < 0) {
| 0 | ||||||||||||||||||||||||
| 1150 | insert_tabbed = true; | - | ||||||||||||||||||||||||
| 1151 | index = -index - 1; | - | ||||||||||||||||||||||||
| 1152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1153 | - | |||||||||||||||||||||||||
| 1154 | // dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString()); | - | ||||||||||||||||||||||||
| 1155 | - | |||||||||||||||||||||||||
| 1156 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1157 | QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||
| 1159 | if (item.subinfo == 0
| 0 | ||||||||||||||||||||||||
| 1160 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1161 | || (item.subinfo->tabbed && !insert_tabbed)
| 0 | ||||||||||||||||||||||||
| 1162 | #endif | - | ||||||||||||||||||||||||
| 1163 | ) { | - | ||||||||||||||||||||||||
| 1164 | - | |||||||||||||||||||||||||
| 1165 | // this is not yet a nested layout - make it | - | ||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | QDockAreaLayoutInfo *subinfo = item.subinfo; | - | ||||||||||||||||||||||||
| 1168 | QLayoutItem *widgetItem = item.widgetItem; | - | ||||||||||||||||||||||||
| 1169 | QPlaceHolderItem *placeHolderItem = item.placeHolderItem; | - | ||||||||||||||||||||||||
| 1170 | QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
| 0 | ||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||
| 1172 | Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
| 0 | ||||||||||||||||||||||||
| 1173 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1174 | const int tabBarShape = 0; | - | ||||||||||||||||||||||||
| 1175 | #endif | - | ||||||||||||||||||||||||
| 1176 | QDockAreaLayoutInfo *new_info | - | ||||||||||||||||||||||||
| 1177 | = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow); | - | ||||||||||||||||||||||||
| 1178 | - | |||||||||||||||||||||||||
| 1179 | //item become a new top-level | - | ||||||||||||||||||||||||
| 1180 | item.subinfo = new_info; | - | ||||||||||||||||||||||||
| 1181 | item.widgetItem = 0; | - | ||||||||||||||||||||||||
| 1182 | item.placeHolderItem = 0; | - | ||||||||||||||||||||||||
| 1183 | - | |||||||||||||||||||||||||
| 1184 | QDockAreaLayoutItem new_item | - | ||||||||||||||||||||||||
| 1185 | = widgetItem == 0
| 0 | ||||||||||||||||||||||||
| 1186 | ? QDockAreaLayoutItem(subinfo) | - | ||||||||||||||||||||||||
| 1187 | : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);
| 0 | ||||||||||||||||||||||||
| 1188 | new_item.size = pick(opposite, r.size()); | - | ||||||||||||||||||||||||
| 1189 | new_item.pos = pick(opposite, r.topLeft()); | - | ||||||||||||||||||||||||
| 1190 | new_info->item_list.append(new_item); | - | ||||||||||||||||||||||||
| 1191 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1192 | if (insert_tabbed) {
| 0 | ||||||||||||||||||||||||
| 1193 | new_info->tabbed = true; | - | ||||||||||||||||||||||||
| 1194 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1195 | #endif | - | ||||||||||||||||||||||||
| 1196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1197 | - | |||||||||||||||||||||||||
| 1198 | return item.subinfo->insertGap(path.mid(1), dockWidgetItem); never executed: return item.subinfo->insertGap(path.mid(1), dockWidgetItem); | 0 | ||||||||||||||||||||||||
| 1199 | } | - | ||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||
| 1201 | // create the gap item | - | ||||||||||||||||||||||||
| 1202 | QDockAreaLayoutItem gap_item; | - | ||||||||||||||||||||||||
| 1203 | gap_item.flags |= QDockAreaLayoutItem::GapItem; | - | ||||||||||||||||||||||||
| 1204 | gap_item.widgetItem = dockWidgetItem; // so minimumSize(), maximumSize() and | - | ||||||||||||||||||||||||
| 1205 | // sizeHint() will work | - | ||||||||||||||||||||||||
| 1206 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1207 | if (!tabbed)
| 0 | ||||||||||||||||||||||||
| 1208 | #endif | - | ||||||||||||||||||||||||
| 1209 | { | - | ||||||||||||||||||||||||
| 1210 | int prev = this->prev(index); | - | ||||||||||||||||||||||||
| 1211 | int next = this->next(index - 1); | - | ||||||||||||||||||||||||
| 1212 | // find out how much space we have in the layout | - | ||||||||||||||||||||||||
| 1213 | int space = 0; | - | ||||||||||||||||||||||||
| 1214 | if (isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1215 | // I am an empty dock area, therefore I am a top-level dock area. | - | ||||||||||||||||||||||||
| 1216 | switch (dockPos) { | - | ||||||||||||||||||||||||
| 1217 | case QInternal::LeftDock: never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 1218 | case QInternal::RightDock: never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 1219 | if (o == Qt::Vertical) {
| 0 | ||||||||||||||||||||||||
| 1220 | // the "size" is the height of the dock area (remember we are empty) | - | ||||||||||||||||||||||||
| 1221 | space = pick(Qt::Vertical, rect.size()); | - | ||||||||||||||||||||||||
| 1222 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1223 | space = pick(Qt::Horizontal, dockWidgetItem->widget()->size()); | - | ||||||||||||||||||||||||
| 1224 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1225 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1226 | case QInternal::TopDock: never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 1227 | case QInternal::BottomDock: never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 1228 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1229 | if (o == Qt::Horizontal) {
| 0 | ||||||||||||||||||||||||
| 1230 | // the "size" is width of the dock area | - | ||||||||||||||||||||||||
| 1231 | space = pick(Qt::Horizontal, rect.size()); | - | ||||||||||||||||||||||||
| 1232 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1233 | space = pick(Qt::Vertical, dockWidgetItem->widget()->size()); | - | ||||||||||||||||||||||||
| 1234 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1235 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1236 | } | - | ||||||||||||||||||||||||
| 1237 | } else { | - | ||||||||||||||||||||||||
| 1238 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1239 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1240 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1241 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1242 | Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem)); | - | ||||||||||||||||||||||||
| 1243 | space += item.size - pick(o, item.minimumSize()); | - | ||||||||||||||||||||||||
| 1244 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||
| 1247 | // find the actual size of the gap | - | ||||||||||||||||||||||||
| 1248 | int gap_size = 0; | - | ||||||||||||||||||||||||
| 1249 | int sep_size = 0; | - | ||||||||||||||||||||||||
| 1250 | if (isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1251 | gap_size = space; | - | ||||||||||||||||||||||||
| 1252 | sep_size = 0; | - | ||||||||||||||||||||||||
| 1253 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1254 | QRect r = dockedGeometry(dockWidgetItem->widget()); | - | ||||||||||||||||||||||||
| 1255 | gap_size = pick(o, r.size()); | - | ||||||||||||||||||||||||
| 1256 | if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 1257 | sep_size += *sep; never executed: sep_size += *sep; | 0 | ||||||||||||||||||||||||
| 1258 | if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 1259 | sep_size += *sep; never executed: sep_size += *sep; | 0 | ||||||||||||||||||||||||
| 1260 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1261 | if (gap_size + sep_size > space)
| 0 | ||||||||||||||||||||||||
| 1262 | gap_size = pick(o, gap_item.minimumSize()); never executed: gap_size = pick(o, gap_item.minimumSize()); | 0 | ||||||||||||||||||||||||
| 1263 | gap_item.size = gap_size + sep_size; | - | ||||||||||||||||||||||||
| 1264 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1265 | - | |||||||||||||||||||||||||
| 1266 | // finally, insert the gap | - | ||||||||||||||||||||||||
| 1267 | item_list.insert(index, gap_item); | - | ||||||||||||||||||||||||
| 1268 | - | |||||||||||||||||||||||||
| 1269 | // dump(qDebug() << "insertGap() after:" << index << tabIndex, *this, QString()); | - | ||||||||||||||||||||||||
| 1270 | - | |||||||||||||||||||||||||
| 1271 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1272 | } | - | ||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) | - | ||||||||||||||||||||||||
| 1275 | { | - | ||||||||||||||||||||||||
| 1276 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1277 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1278 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1279 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||
| 1281 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1282 | if (tabbed && widget == tabBar)
| 0 | ||||||||||||||||||||||||
| 1283 | return this; never executed: return this; | 0 | ||||||||||||||||||||||||
| 1284 | #endif | - | ||||||||||||||||||||||||
| 1285 | - | |||||||||||||||||||||||||
| 1286 | if (item.widgetItem != 0 && item.widgetItem->widget() == widget)
| 0 | ||||||||||||||||||||||||
| 1287 | return this; never executed: return this; | 0 | ||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||
| 1289 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 1290 | if (QDockAreaLayoutInfo *result = item.subinfo->info(widget))
| 0 | ||||||||||||||||||||||||
| 1291 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1292 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1293 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1294 | - | |||||||||||||||||||||||||
| 1295 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1296 | } | - | ||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||
| 1298 | QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1299 | { | - | ||||||||||||||||||||||||
| 1300 | int index = path.first(); | - | ||||||||||||||||||||||||
| 1301 | if (index < 0)
| 0 | ||||||||||||||||||||||||
| 1302 | index = -index - 1; never executed: index = -index - 1; | 0 | ||||||||||||||||||||||||
| 1303 | if (index >= item_list.count())
| 0 | ||||||||||||||||||||||||
| 1304 | return this; never executed: return this; | 0 | ||||||||||||||||||||||||
| 1305 | if (path.count() == 1 || item_list[index].subinfo == 0)
| 0 | ||||||||||||||||||||||||
| 1306 | return this; never executed: return this; | 0 | ||||||||||||||||||||||||
| 1307 | return item_list[index].subinfo->info(path.mid(1)); never executed: return item_list[index].subinfo->info(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 1308 | } | - | ||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | QRect QDockAreaLayoutInfo::itemRect(int index) const | - | ||||||||||||||||||||||||
| 1311 | { | - | ||||||||||||||||||||||||
| 1312 | const QDockAreaLayoutItem &item = item_list.at(index); | - | ||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||
| 1314 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1315 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | QRect result; | - | ||||||||||||||||||||||||
| 1318 | - | |||||||||||||||||||||||||
| 1319 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1320 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 1321 | if (tabId(item) == currentTabId())
| 0 | ||||||||||||||||||||||||
| 1322 | result = tabContentRect(); never executed: result = tabContentRect(); | 0 | ||||||||||||||||||||||||
| 1323 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 1324 | #endif | - | ||||||||||||||||||||||||
| 1325 | { | - | ||||||||||||||||||||||||
| 1326 | QPoint pos; | - | ||||||||||||||||||||||||
| 1327 | rpick(o, pos) = item.pos; | - | ||||||||||||||||||||||||
| 1328 | rperp(o, pos) = perp(o, rect.topLeft()); | - | ||||||||||||||||||||||||
| 1329 | QSize s; | - | ||||||||||||||||||||||||
| 1330 | rpick(o, s) = item.size; | - | ||||||||||||||||||||||||
| 1331 | rperp(o, s) = perp(o, rect.size()); | - | ||||||||||||||||||||||||
| 1332 | result = QRect(pos, s); | - | ||||||||||||||||||||||||
| 1333 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1334 | - | |||||||||||||||||||||||||
| 1335 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1336 | } | - | ||||||||||||||||||||||||
| 1337 | - | |||||||||||||||||||||||||
| 1338 | QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 1339 | { | - | ||||||||||||||||||||||||
| 1340 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||
| 1342 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 1343 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1344 | const QDockAreaLayoutItem &item = item_list.at(index); | - | ||||||||||||||||||||||||
| 1345 | Q_ASSERT(item.subinfo != 0); | - | ||||||||||||||||||||||||
| 1346 | return item.subinfo->itemRect(path.mid(1)); never executed: return item.subinfo->itemRect(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 1347 | } | - | ||||||||||||||||||||||||
| 1348 | - | |||||||||||||||||||||||||
| 1349 | return itemRect(index); never executed: return itemRect(index); | 0 | ||||||||||||||||||||||||
| 1350 | } | - | ||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | QRect QDockAreaLayoutInfo::separatorRect(int index) const | - | ||||||||||||||||||||||||
| 1353 | { | - | ||||||||||||||||||||||||
| 1354 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1355 | if (tabbed)
| 0 | ||||||||||||||||||||||||
| 1356 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 1357 | #endif | - | ||||||||||||||||||||||||
| 1358 | - | |||||||||||||||||||||||||
| 1359 | const QDockAreaLayoutItem &item = item_list.at(index); | - | ||||||||||||||||||||||||
| 1360 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1361 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 1362 | - | |||||||||||||||||||||||||
| 1363 | QPoint pos = rect.topLeft(); | - | ||||||||||||||||||||||||
| 1364 | rpick(o, pos) = item.pos + item.size; | - | ||||||||||||||||||||||||
| 1365 | QSize s = rect.size(); | - | ||||||||||||||||||||||||
| 1366 | rpick(o, s) = *sep; | - | ||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||
| 1368 | return QRect(pos, s); never executed: return QRect(pos, s); | 0 | ||||||||||||||||||||||||
| 1369 | } | - | ||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||
| 1371 | QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 1372 | { | - | ||||||||||||||||||||||||
| 1373 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||
| 1375 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 1376 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1377 | const QDockAreaLayoutItem &item = item_list.at(index); | - | ||||||||||||||||||||||||
| 1378 | Q_ASSERT(item.subinfo != 0); | - | ||||||||||||||||||||||||
| 1379 | return item.subinfo->separatorRect(path.mid(1)); never executed: return item.subinfo->separatorRect(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 1380 | } | - | ||||||||||||||||||||||||
| 1381 | return separatorRect(index); never executed: return separatorRect(index); | 0 | ||||||||||||||||||||||||
| 1382 | } | - | ||||||||||||||||||||||||
| 1383 | - | |||||||||||||||||||||||||
| 1384 | QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const | - | ||||||||||||||||||||||||
| 1385 | { | - | ||||||||||||||||||||||||
| 1386 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1387 | if (tabbed)
| 0 | ||||||||||||||||||||||||
| 1388 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 1389 | #endif | - | ||||||||||||||||||||||||
| 1390 | - | |||||||||||||||||||||||||
| 1391 | int pos = pick(o, _pos); | - | ||||||||||||||||||||||||
| 1392 | - | |||||||||||||||||||||||||
| 1393 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1394 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1395 | if (item.skip() || (item.flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 1396 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1397 | - | |||||||||||||||||||||||||
| 1398 | if (item.pos + item.size > pos) {
| 0 | ||||||||||||||||||||||||
| 1399 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 1400 | QList<int> result = item.subinfo->findSeparator(_pos); | - | ||||||||||||||||||||||||
| 1401 | if (!result.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1402 | result.prepend(i); | - | ||||||||||||||||||||||||
| 1403 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1404 | } else { | - | ||||||||||||||||||||||||
| 1405 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 1406 | } | - | ||||||||||||||||||||||||
| 1407 | } | - | ||||||||||||||||||||||||
| 1408 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||
| 1410 | int next = this->next(i); | - | ||||||||||||||||||||||||
| 1411 | if (next == -1 || (item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 1412 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1413 | - | |||||||||||||||||||||||||
| 1414 | QRect sepRect = separatorRect(i); | - | ||||||||||||||||||||||||
| 1415 | if (!sepRect.isNull() && *sep == 1)
| 0 | ||||||||||||||||||||||||
| 1416 | sepRect.adjust(-2, -2, 2, 2); never executed: sepRect.adjust(-2, -2, 2, 2); | 0 | ||||||||||||||||||||||||
| 1417 | //we also make sure we don't find a separator that's not there | - | ||||||||||||||||||||||||
| 1418 | if (sepRect.contains(_pos) && !item.hasFixedSize(o)) {
| 0 | ||||||||||||||||||||||||
| 1419 | return QList<int>() << i; never executed: return QList<int>() << i; | 0 | ||||||||||||||||||||||||
| 1420 | } | - | ||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||
| 1422 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1423 | - | |||||||||||||||||||||||||
| 1424 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 1425 | } | - | ||||||||||||||||||||||||
| 1426 | - | |||||||||||||||||||||||||
| 1427 | QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) const | - | ||||||||||||||||||||||||
| 1428 | { | - | ||||||||||||||||||||||||
| 1429 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1430 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1431 | - | |||||||||||||||||||||||||
| 1432 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 1433 | QList<int> result = item.subinfo->indexOfPlaceHolder(objectName); | - | ||||||||||||||||||||||||
| 1434 | if (!result.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1435 | result.prepend(i); | - | ||||||||||||||||||||||||
| 1436 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1437 | } | - | ||||||||||||||||||||||||
| 1438 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1439 | } | - | ||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||
| 1441 | if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) {
| 0 | ||||||||||||||||||||||||
| 1442 | QList<int> result; | - | ||||||||||||||||||||||||
| 1443 | result << i; | - | ||||||||||||||||||||||||
| 1444 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1445 | } | - | ||||||||||||||||||||||||
| 1446 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1447 | - | |||||||||||||||||||||||||
| 1448 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 1449 | } | - | ||||||||||||||||||||||||
| 1450 | - | |||||||||||||||||||||||||
| 1451 | QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const | - | ||||||||||||||||||||||||
| 1452 | { | - | ||||||||||||||||||||||||
| 1453 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1454 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1455 | - | |||||||||||||||||||||||||
| 1456 | if (item.placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 1457 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1458 | - | |||||||||||||||||||||||||
| 1459 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 1460 | QList<int> result = item.subinfo->indexOf(widget); | - | ||||||||||||||||||||||||
| 1461 | if (!result.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1462 | result.prepend(i); | - | ||||||||||||||||||||||||
| 1463 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1464 | } | - | ||||||||||||||||||||||||
| 1465 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1466 | } | - | ||||||||||||||||||||||||
| 1467 | - | |||||||||||||||||||||||||
| 1468 | if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem && item.widgetItem->widget() == widget) {
| 0 | ||||||||||||||||||||||||
| 1469 | QList<int> result; | - | ||||||||||||||||||||||||
| 1470 | result << i; | - | ||||||||||||||||||||||||
| 1471 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1472 | } | - | ||||||||||||||||||||||||
| 1473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||
| 1475 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 1476 | } | - | ||||||||||||||||||||||||
| 1477 | - | |||||||||||||||||||||||||
| 1478 | QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const | - | ||||||||||||||||||||||||
| 1479 | { | - | ||||||||||||||||||||||||
| 1480 | QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); | - | ||||||||||||||||||||||||
| 1481 | Q_ASSERT(result != 0); | - | ||||||||||||||||||||||||
| 1482 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1483 | } | - | ||||||||||||||||||||||||
| 1484 | - | |||||||||||||||||||||||||
| 1485 | bool QDockAreaLayoutInfo::hasFixedSize() const | - | ||||||||||||||||||||||||
| 1486 | { | - | ||||||||||||||||||||||||
| 1487 | return perp(o, minimumSize()) == perp(o, maximumSize()); never executed: return perp(o, minimumSize()) == perp(o, maximumSize()); | 0 | ||||||||||||||||||||||||
| 1488 | } | - | ||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||
| 1490 | - | |||||||||||||||||||||||||
| 1491 | void QDockAreaLayoutInfo::apply(bool animate) | - | ||||||||||||||||||||||||
| 1492 | { | - | ||||||||||||||||||||||||
| 1493 | QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator; | - | ||||||||||||||||||||||||
| 1494 | - | |||||||||||||||||||||||||
| 1495 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1496 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 1497 | QRect tab_rect; | - | ||||||||||||||||||||||||
| 1498 | QSize tbh = tabBarSizeHint(); | - | ||||||||||||||||||||||||
| 1499 | - | |||||||||||||||||||||||||
| 1500 | if (!tbh.isNull()) {
| 0 | ||||||||||||||||||||||||
| 1501 | switch (tabBarShape) { | - | ||||||||||||||||||||||||
| 1502 | case QTabBar::RoundedNorth: never executed: case QTabBar::RoundedNorth: | 0 | ||||||||||||||||||||||||
| 1503 | case QTabBar::TriangularNorth: never executed: case QTabBar::TriangularNorth: | 0 | ||||||||||||||||||||||||
| 1504 | tab_rect = QRect(rect.left(), rect.top(), rect.width(), tbh.height()); | - | ||||||||||||||||||||||||
| 1505 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1506 | case QTabBar::RoundedSouth: never executed: case QTabBar::RoundedSouth: | 0 | ||||||||||||||||||||||||
| 1507 | case QTabBar::TriangularSouth: never executed: case QTabBar::TriangularSouth: | 0 | ||||||||||||||||||||||||
| 1508 | tab_rect = QRect(rect.left(), rect.bottom() - tbh.height() + 1, | - | ||||||||||||||||||||||||
| 1509 | rect.width(), tbh.height()); | - | ||||||||||||||||||||||||
| 1510 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1511 | case QTabBar::RoundedEast: never executed: case QTabBar::RoundedEast: | 0 | ||||||||||||||||||||||||
| 1512 | case QTabBar::TriangularEast: never executed: case QTabBar::TriangularEast: | 0 | ||||||||||||||||||||||||
| 1513 | tab_rect = QRect(rect.right() - tbh.width() + 1, rect.top(), | - | ||||||||||||||||||||||||
| 1514 | tbh.width(), rect.height()); | - | ||||||||||||||||||||||||
| 1515 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1516 | case QTabBar::RoundedWest: never executed: case QTabBar::RoundedWest: | 0 | ||||||||||||||||||||||||
| 1517 | case QTabBar::TriangularWest: never executed: case QTabBar::TriangularWest: | 0 | ||||||||||||||||||||||||
| 1518 | tab_rect = QRect(rect.left(), rect.top(), | - | ||||||||||||||||||||||||
| 1519 | tbh.width(), rect.height()); | - | ||||||||||||||||||||||||
| 1520 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1521 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1522 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1523 | } | - | ||||||||||||||||||||||||
| 1524 | } | - | ||||||||||||||||||||||||
| 1525 | - | |||||||||||||||||||||||||
| 1526 | widgetAnimator.animate(tabBar, tab_rect, animate); | - | ||||||||||||||||||||||||
| 1527 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1528 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1529 | - | |||||||||||||||||||||||||
| 1530 | for (int i = 0; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1531 | QDockAreaLayoutItem &item = item_list[i]; | - | ||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||
| 1533 | if (item.flags & QDockAreaLayoutItem::GapItem)
| 0 | ||||||||||||||||||||||||
| 1534 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1535 | - | |||||||||||||||||||||||||
| 1536 | if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 1537 | item.subinfo->apply(animate); | - | ||||||||||||||||||||||||
| 1538 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1539 | } | - | ||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||
| 1541 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1542 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1543 | - | |||||||||||||||||||||||||
| 1544 | Q_ASSERT(item.widgetItem); | - | ||||||||||||||||||||||||
| 1545 | QRect r = itemRect(i); | - | ||||||||||||||||||||||||
| 1546 | QWidget *w = item.widgetItem->widget(); | - | ||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||
| 1548 | QRect geo = w->geometry(); | - | ||||||||||||||||||||||||
| 1549 | widgetAnimator.animate(w, r, animate); | - | ||||||||||||||||||||||||
| 1550 | if (!w->isHidden() && w->window()->isVisible()) {
| 0 | ||||||||||||||||||||||||
| 1551 | QDockWidget *dw = qobject_cast<QDockWidget*>(w); | - | ||||||||||||||||||||||||
| 1552 | if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
| 0 | ||||||||||||||||||||||||
| 1553 | dw->lower(); | - | ||||||||||||||||||||||||
| 1554 | emit dw->visibilityChanged(false); | - | ||||||||||||||||||||||||
| 1555 | } else if (r.isValid() never executed: end of block
| 0 | ||||||||||||||||||||||||
| 1556 | && (geo.right() < 0 || geo.bottom() < 0)) {
| 0 | ||||||||||||||||||||||||
| 1557 | emit dw->visibilityChanged(true); | - | ||||||||||||||||||||||||
| 1558 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1559 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1561 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1562 | if (*sep == 1)
| 0 | ||||||||||||||||||||||||
| 1563 | updateSeparatorWidgets(); never executed: updateSeparatorWidgets(); | 0 | ||||||||||||||||||||||||
| 1564 | #endif //QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1565 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1566 | - | |||||||||||||||||||||||||
| 1567 | static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over) | - | ||||||||||||||||||||||||
| 1568 | { | - | ||||||||||||||||||||||||
| 1569 | QStyleOption opt(0); | - | ||||||||||||||||||||||||
| 1570 | opt.state = QStyle::State_None; | - | ||||||||||||||||||||||||
| 1571 | if (w->isEnabled())
| 0 | ||||||||||||||||||||||||
| 1572 | opt.state |= QStyle::State_Enabled; never executed: opt.state |= QStyle::State_Enabled; | 0 | ||||||||||||||||||||||||
| 1573 | if (o != Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
| 1574 | opt.state |= QStyle::State_Horizontal; never executed: opt.state |= QStyle::State_Horizontal; | 0 | ||||||||||||||||||||||||
| 1575 | if (mouse_over)
| 0 | ||||||||||||||||||||||||
| 1576 | opt.state |= QStyle::State_MouseOver; never executed: opt.state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
| 1577 | opt.rect = r; | - | ||||||||||||||||||||||||
| 1578 | opt.palette = w->palette(); | - | ||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||
| 1580 | w->style()->drawPrimitive(QStyle::PE_IndicatorDockWidgetResizeHandle, &opt, p, w); | - | ||||||||||||||||||||||||
| 1581 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1582 | - | |||||||||||||||||||||||||
| 1583 | QRegion QDockAreaLayoutInfo::separatorRegion() const | - | ||||||||||||||||||||||||
| 1584 | { | - | ||||||||||||||||||||||||
| 1585 | QRegion result; | - | ||||||||||||||||||||||||
| 1586 | - | |||||||||||||||||||||||||
| 1587 | if (isEmpty())
| 0 | ||||||||||||||||||||||||
| 1588 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1589 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1590 | if (tabbed)
| 0 | ||||||||||||||||||||||||
| 1591 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1592 | #endif | - | ||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||
| 1594 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1595 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1596 | - | |||||||||||||||||||||||||
| 1597 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1598 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1599 | - | |||||||||||||||||||||||||
| 1600 | int next = this->next(i); | - | ||||||||||||||||||||||||
| 1601 | - | |||||||||||||||||||||||||
| 1602 | if (item.subinfo)
| 0 | ||||||||||||||||||||||||
| 1603 | result |= item.subinfo->separatorRegion(); never executed: result |= item.subinfo->separatorRegion(); | 0 | ||||||||||||||||||||||||
| 1604 | - | |||||||||||||||||||||||||
| 1605 | if (next == -1)
| 0 | ||||||||||||||||||||||||
| 1606 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1607 | result |= separatorRect(i); | - | ||||||||||||||||||||||||
| 1608 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1609 | - | |||||||||||||||||||||||||
| 1610 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 1611 | } | - | ||||||||||||||||||||||||
| 1612 | - | |||||||||||||||||||||||||
| 1613 | void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget, | - | ||||||||||||||||||||||||
| 1614 | const QRegion &clip, | - | ||||||||||||||||||||||||
| 1615 | const QPoint &mouse) const | - | ||||||||||||||||||||||||
| 1616 | { | - | ||||||||||||||||||||||||
| 1617 | if (isEmpty())
| 0 | ||||||||||||||||||||||||
| 1618 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1619 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1620 | if (tabbed)
| 0 | ||||||||||||||||||||||||
| 1621 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1622 | #endif | - | ||||||||||||||||||||||||
| 1623 | - | |||||||||||||||||||||||||
| 1624 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1625 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1626 | - | |||||||||||||||||||||||||
| 1627 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 1628 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||
| 1630 | int next = this->next(i); | - | ||||||||||||||||||||||||
| 1631 | if ((item.flags & QDockAreaLayoutItem::GapItem)
| 0 | ||||||||||||||||||||||||
| 1632 | || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
| 0 | ||||||||||||||||||||||||
| 1633 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1634 | - | |||||||||||||||||||||||||
| 1635 | if (item.subinfo) {
| 0 | ||||||||||||||||||||||||
| 1636 | if (clip.contains(item.subinfo->rect))
| 0 | ||||||||||||||||||||||||
| 1637 | item.subinfo->paintSeparators(p, widget, clip, mouse); never executed: item.subinfo->paintSeparators(p, widget, clip, mouse); | 0 | ||||||||||||||||||||||||
| 1638 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1639 | - | |||||||||||||||||||||||||
| 1640 | if (next == -1)
| 0 | ||||||||||||||||||||||||
| 1641 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1642 | QRect r = separatorRect(i); | - | ||||||||||||||||||||||||
| 1643 | if (clip.contains(r) && !item.hasFixedSize(o))
| 0 | ||||||||||||||||||||||||
| 1644 | paintSep(p, widget, r, o, r.contains(mouse)); never executed: paintSep(p, widget, r, o, r.contains(mouse)); | 0 | ||||||||||||||||||||||||
| 1645 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1646 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1647 | - | |||||||||||||||||||||||||
| 1648 | int QDockAreaLayoutInfo::next(int index) const | - | ||||||||||||||||||||||||
| 1649 | { | - | ||||||||||||||||||||||||
| 1650 | for (int i = index + 1; i < item_list.size(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1651 | if (!item_list.at(i).skip())
| 0 | ||||||||||||||||||||||||
| 1652 | return i; never executed: return i; | 0 | ||||||||||||||||||||||||
| 1653 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1654 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1655 | } | - | ||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||
| 1657 | int QDockAreaLayoutInfo::prev(int index) const | - | ||||||||||||||||||||||||
| 1658 | { | - | ||||||||||||||||||||||||
| 1659 | for (int i = index - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
| 1660 | if (!item_list.at(i).skip())
| 0 | ||||||||||||||||||||||||
| 1661 | return i; never executed: return i; | 0 | ||||||||||||||||||||||||
| 1662 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1663 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1664 | } | - | ||||||||||||||||||||||||
| 1665 | - | |||||||||||||||||||||||||
| 1666 | void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) | - | ||||||||||||||||||||||||
| 1667 | { | - | ||||||||||||||||||||||||
| 1668 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1669 | Q_UNUSED(index); | - | ||||||||||||||||||||||||
| 1670 | Q_UNUSED(dockWidgetItem); | - | ||||||||||||||||||||||||
| 1671 | #else | - | ||||||||||||||||||||||||
| 1672 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 1673 | item_list.append(QDockAreaLayoutItem(dockWidgetItem)); | - | ||||||||||||||||||||||||
| 1674 | updateTabBar(); | - | ||||||||||||||||||||||||
| 1675 | setCurrentTab(dockWidgetItem->widget()); | - | ||||||||||||||||||||||||
| 1676 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1677 | QDockAreaLayoutInfo *new_info | - | ||||||||||||||||||||||||
| 1678 | = new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow); | - | ||||||||||||||||||||||||
| 1679 | item_list[index].subinfo = new_info; | - | ||||||||||||||||||||||||
| 1680 | new_info->item_list.append(item_list.at(index).widgetItem); | - | ||||||||||||||||||||||||
| 1681 | item_list[index].widgetItem = 0; | - | ||||||||||||||||||||||||
| 1682 | new_info->item_list.append(dockWidgetItem); | - | ||||||||||||||||||||||||
| 1683 | new_info->tabbed = true; | - | ||||||||||||||||||||||||
| 1684 | new_info->updateTabBar(); | - | ||||||||||||||||||||||||
| 1685 | new_info->setCurrentTab(dockWidgetItem->widget()); | - | ||||||||||||||||||||||||
| 1686 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1687 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1688 | } | - | ||||||||||||||||||||||||
| 1689 | - | |||||||||||||||||||||||||
| 1690 | void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, | - | ||||||||||||||||||||||||
| 1691 | QLayoutItem *dockWidgetItem) | - | ||||||||||||||||||||||||
| 1692 | { | - | ||||||||||||||||||||||||
| 1693 | if (orientation == o) {
| 0 | ||||||||||||||||||||||||
| 1694 | item_list.insert(index + 1, QDockAreaLayoutItem(dockWidgetItem)); | - | ||||||||||||||||||||||||
| 1695 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1696 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1697 | const int tabBarShape = 0; | - | ||||||||||||||||||||||||
| 1698 | #endif | - | ||||||||||||||||||||||||
| 1699 | QDockAreaLayoutInfo *new_info | - | ||||||||||||||||||||||||
| 1700 | = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow); | - | ||||||||||||||||||||||||
| 1701 | item_list[index].subinfo = new_info; | - | ||||||||||||||||||||||||
| 1702 | new_info->item_list.append(item_list.at(index).widgetItem); | - | ||||||||||||||||||||||||
| 1703 | item_list[index].widgetItem = 0; | - | ||||||||||||||||||||||||
| 1704 | new_info->item_list.append(dockWidgetItem); | - | ||||||||||||||||||||||||
| 1705 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1706 | } | - | ||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||
| 1708 | QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) | - | ||||||||||||||||||||||||
| 1709 | { | - | ||||||||||||||||||||||||
| 1710 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 1711 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 1712 | if (path.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 1713 | const QDockAreaLayoutItem &item = item_list[index]; | - | ||||||||||||||||||||||||
| 1714 | Q_ASSERT(item.subinfo != 0); | - | ||||||||||||||||||||||||
| 1715 | return item.subinfo->item(path.mid(1)); never executed: return item.subinfo->item(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 1716 | } | - | ||||||||||||||||||||||||
| 1717 | return item_list[index]; never executed: return item_list[index]; | 0 | ||||||||||||||||||||||||
| 1718 | } | - | ||||||||||||||||||||||||
| 1719 | - | |||||||||||||||||||||||||
| 1720 | QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const | - | ||||||||||||||||||||||||
| 1721 | { | - | ||||||||||||||||||||||||
| 1722 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1723 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1724 | if (item.placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 1725 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1726 | if (item.subinfo) {
| 0 | ||||||||||||||||||||||||
| 1727 | if (QLayoutItem *ret = item.subinfo->itemAt(x, index))
| 0 | ||||||||||||||||||||||||
| 1728 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1729 | } else if (item.widgetItem) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 1730 | if ((*x)++ == index)
| 0 | ||||||||||||||||||||||||
| 1731 | return item.widgetItem; never executed: return item.widgetItem; | 0 | ||||||||||||||||||||||||
| 1732 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1733 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1734 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1735 | } | - | ||||||||||||||||||||||||
| 1736 | - | |||||||||||||||||||||||||
| 1737 | QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) | - | ||||||||||||||||||||||||
| 1738 | { | - | ||||||||||||||||||||||||
| 1739 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1740 | QDockAreaLayoutItem &item = item_list[i]; | - | ||||||||||||||||||||||||
| 1741 | if (item.placeHolderItem != 0)
| 0 | ||||||||||||||||||||||||
| 1742 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1743 | else if (item.subinfo) {
| 0 | ||||||||||||||||||||||||
| 1744 | if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) {
| 0 | ||||||||||||||||||||||||
| 1745 | unnest(i); | - | ||||||||||||||||||||||||
| 1746 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1747 | } | - | ||||||||||||||||||||||||
| 1748 | } else if (item.widgetItem) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 1749 | if ((*x)++ == index) {
| 0 | ||||||||||||||||||||||||
| 1750 | item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget()); | - | ||||||||||||||||||||||||
| 1751 | QLayoutItem *ret = item.widgetItem; | - | ||||||||||||||||||||||||
| 1752 | item.widgetItem = 0; | - | ||||||||||||||||||||||||
| 1753 | if (item.size != -1)
| 0 | ||||||||||||||||||||||||
| 1754 | item.flags |= QDockAreaLayoutItem::KeepSize; never executed: item.flags |= QDockAreaLayoutItem::KeepSize; | 0 | ||||||||||||||||||||||||
| 1755 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 1756 | } | - | ||||||||||||||||||||||||
| 1757 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1758 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1759 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1760 | } | - | ||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||
| 1762 | void QDockAreaLayoutInfo::deleteAllLayoutItems() | - | ||||||||||||||||||||||||
| 1763 | { | - | ||||||||||||||||||||||||
| 1764 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1765 | QDockAreaLayoutItem &item= item_list[i]; | - | ||||||||||||||||||||||||
| 1766 | if (item.subinfo) {
| 0 | ||||||||||||||||||||||||
| 1767 | item.subinfo->deleteAllLayoutItems(); | - | ||||||||||||||||||||||||
| 1768 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1769 | delete item.widgetItem; | - | ||||||||||||||||||||||||
| 1770 | item.widgetItem = 0; | - | ||||||||||||||||||||||||
| 1771 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1772 | } | - | ||||||||||||||||||||||||
| 1773 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1774 | - | |||||||||||||||||||||||||
| 1775 | void QDockAreaLayoutInfo::saveState(QDataStream &stream) const | - | ||||||||||||||||||||||||
| 1776 | { | - | ||||||||||||||||||||||||
| 1777 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1778 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 1779 | stream << (uchar) TabMarker; | - | ||||||||||||||||||||||||
| 1780 | - | |||||||||||||||||||||||||
| 1781 | // write the index in item_list of the widget that's currently on top. | - | ||||||||||||||||||||||||
| 1782 | quintptr id = currentTabId(); | - | ||||||||||||||||||||||||
| 1783 | int index = -1; | - | ||||||||||||||||||||||||
| 1784 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1785 | if (tabId(item_list.at(i)) == id) {
| 0 | ||||||||||||||||||||||||
| 1786 | index = i; | - | ||||||||||||||||||||||||
| 1787 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1788 | } | - | ||||||||||||||||||||||||
| 1789 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1790 | stream << index; | - | ||||||||||||||||||||||||
| 1791 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 1792 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1793 | { | - | ||||||||||||||||||||||||
| 1794 | stream << (uchar) SequenceMarker; | - | ||||||||||||||||||||||||
| 1795 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1796 | - | |||||||||||||||||||||||||
| 1797 | stream << (uchar) o << item_list.count(); | - | ||||||||||||||||||||||||
| 1798 | - | |||||||||||||||||||||||||
| 1799 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 1800 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 1801 | if (item.widgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 1802 | stream << (uchar) WidgetMarker; | - | ||||||||||||||||||||||||
| 1803 | QWidget *w = item.widgetItem->widget(); | - | ||||||||||||||||||||||||
| 1804 | QString name = w->objectName(); | - | ||||||||||||||||||||||||
| 1805 | if (name.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1806 | qWarning("QMainWindow::saveState(): 'objectName' not set for QDockWidget %p '%s;", | - | ||||||||||||||||||||||||
| 1807 | w, qPrintable(w->windowTitle())); | - | ||||||||||||||||||||||||
| 1808 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1809 | stream << name; | - | ||||||||||||||||||||||||
| 1810 | - | |||||||||||||||||||||||||
| 1811 | uchar flags = 0; | - | ||||||||||||||||||||||||
| 1812 | if (!w->isHidden())
| 0 | ||||||||||||||||||||||||
| 1813 | flags |= StateFlagVisible; never executed: flags |= StateFlagVisible; | 0 | ||||||||||||||||||||||||
| 1814 | if (w->isWindow())
| 0 | ||||||||||||||||||||||||
| 1815 | flags |= StateFlagFloating; never executed: flags |= StateFlagFloating; | 0 | ||||||||||||||||||||||||
| 1816 | stream << flags; | - | ||||||||||||||||||||||||
| 1817 | - | |||||||||||||||||||||||||
| 1818 | if (w->isWindow()) {
| 0 | ||||||||||||||||||||||||
| 1819 | const QRect geometry = w->geometry(); | - | ||||||||||||||||||||||||
| 1820 | stream << geometry.x() << geometry.y() << geometry.width() << geometry.height(); | - | ||||||||||||||||||||||||
| 1821 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1822 | stream << item.pos << item.size << pick(o, item.minimumSize()) | - | ||||||||||||||||||||||||
| 1823 | << pick(o, item.maximumSize()); | - | ||||||||||||||||||||||||
| 1824 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1825 | } else if (item.placeHolderItem != 0) {
| 0 | ||||||||||||||||||||||||
| 1826 | stream << (uchar) WidgetMarker; | - | ||||||||||||||||||||||||
| 1827 | stream << item.placeHolderItem->objectName; | - | ||||||||||||||||||||||||
| 1828 | uchar flags = 0; | - | ||||||||||||||||||||||||
| 1829 | if (!item.placeHolderItem->hidden)
| 0 | ||||||||||||||||||||||||
| 1830 | flags |= StateFlagVisible; never executed: flags |= StateFlagVisible; | 0 | ||||||||||||||||||||||||
| 1831 | if (item.placeHolderItem->window)
| 0 | ||||||||||||||||||||||||
| 1832 | flags |= StateFlagFloating; never executed: flags |= StateFlagFloating; | 0 | ||||||||||||||||||||||||
| 1833 | stream << flags; | - | ||||||||||||||||||||||||
| 1834 | if (item.placeHolderItem->window) {
| 0 | ||||||||||||||||||||||||
| 1835 | QRect r = item.placeHolderItem->topLevelRect; | - | ||||||||||||||||||||||||
| 1836 | stream << r.x() << r.y() << r.width() << r.height(); | - | ||||||||||||||||||||||||
| 1837 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1838 | stream << item.pos << item.size << (int)0 << (int)0; | - | ||||||||||||||||||||||||
| 1839 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1840 | } else if (item.subinfo != 0) {
| 0 | ||||||||||||||||||||||||
| 1841 | stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize()); | - | ||||||||||||||||||||||||
| 1842 | item.subinfo->saveState(stream); | - | ||||||||||||||||||||||||
| 1843 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1844 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1845 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1846 | - | |||||||||||||||||||||||||
| 1847 | static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos) | - | ||||||||||||||||||||||||
| 1848 | { | - | ||||||||||||||||||||||||
| 1849 | switch (pos) { | - | ||||||||||||||||||||||||
| 1850 | case QInternal::LeftDock: return Qt::LeftDockWidgetArea; never executed: return Qt::LeftDockWidgetArea;never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 1851 | case QInternal::RightDock: return Qt::RightDockWidgetArea; never executed: return Qt::RightDockWidgetArea;never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 1852 | case QInternal::TopDock: return Qt::TopDockWidgetArea; never executed: return Qt::TopDockWidgetArea;never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 1853 | case QInternal::BottomDock: return Qt::BottomDockWidgetArea; never executed: return Qt::BottomDockWidgetArea;never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 1854 | default: break; never executed: break;never executed: default: | 0 | ||||||||||||||||||||||||
| 1855 | } | - | ||||||||||||||||||||||||
| 1856 | return Qt::NoDockWidgetArea; never executed: return Qt::NoDockWidgetArea; | 0 | ||||||||||||||||||||||||
| 1857 | } | - | ||||||||||||||||||||||||
| 1858 | - | |||||||||||||||||||||||||
| 1859 | bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing) | - | ||||||||||||||||||||||||
| 1860 | { | - | ||||||||||||||||||||||||
| 1861 | uchar marker; | - | ||||||||||||||||||||||||
| 1862 | stream >> marker; | - | ||||||||||||||||||||||||
| 1863 | if (marker != TabMarker && marker != SequenceMarker)
| 0 | ||||||||||||||||||||||||
| 1864 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 1865 | - | |||||||||||||||||||||||||
| 1866 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1867 | tabbed = marker == TabMarker; | - | ||||||||||||||||||||||||
| 1868 | - | |||||||||||||||||||||||||
| 1869 | int index = -1; | - | ||||||||||||||||||||||||
| 1870 | if (tabbed)
| 0 | ||||||||||||||||||||||||
| 1871 | stream >> index; never executed: stream >> index; | 0 | ||||||||||||||||||||||||
| 1872 | #endif | - | ||||||||||||||||||||||||
| 1873 | - | |||||||||||||||||||||||||
| 1874 | uchar orientation; | - | ||||||||||||||||||||||||
| 1875 | stream >> orientation; | - | ||||||||||||||||||||||||
| 1876 | o = static_cast<Qt::Orientation>(orientation); | - | ||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||
| 1878 | int cnt; | - | ||||||||||||||||||||||||
| 1879 | stream >> cnt; | - | ||||||||||||||||||||||||
| 1880 | - | |||||||||||||||||||||||||
| 1881 | for (int i = 0; i < cnt; ++i) {
| 0 | ||||||||||||||||||||||||
| 1882 | uchar nextMarker; | - | ||||||||||||||||||||||||
| 1883 | stream >> nextMarker; | - | ||||||||||||||||||||||||
| 1884 | if (nextMarker == WidgetMarker) {
| 0 | ||||||||||||||||||||||||
| 1885 | QString name; | - | ||||||||||||||||||||||||
| 1886 | uchar flags; | - | ||||||||||||||||||||||||
| 1887 | stream >> name >> flags; | - | ||||||||||||||||||||||||
| 1888 | if (name.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1889 | int dummy; | - | ||||||||||||||||||||||||
| 1890 | stream >> dummy >> dummy >> dummy >> dummy; | - | ||||||||||||||||||||||||
| 1891 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1892 | } | - | ||||||||||||||||||||||||
| 1893 | - | |||||||||||||||||||||||||
| 1894 | QDockWidget *widget = 0; | - | ||||||||||||||||||||||||
| 1895 | for (int j = 0; j < widgets.count(); ++j) {
| 0 | ||||||||||||||||||||||||
| 1896 | if (widgets.at(j)->objectName() == name) {
| 0 | ||||||||||||||||||||||||
| 1897 | widget = widgets.takeAt(j); | - | ||||||||||||||||||||||||
| 1898 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1899 | } | - | ||||||||||||||||||||||||
| 1900 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1901 | - | |||||||||||||||||||||||||
| 1902 | if (widget == 0) {
| 0 | ||||||||||||||||||||||||
| 1903 | QPlaceHolderItem *placeHolder = new QPlaceHolderItem; | - | ||||||||||||||||||||||||
| 1904 | QDockAreaLayoutItem item(placeHolder); | - | ||||||||||||||||||||||||
| 1905 | - | |||||||||||||||||||||||||
| 1906 | placeHolder->objectName = name; | - | ||||||||||||||||||||||||
| 1907 | placeHolder->window = flags & StateFlagFloating; | - | ||||||||||||||||||||||||
| 1908 | placeHolder->hidden = !(flags & StateFlagVisible); | - | ||||||||||||||||||||||||
| 1909 | if (placeHolder->window) {
| 0 | ||||||||||||||||||||||||
| 1910 | int x, y, w, h; | - | ||||||||||||||||||||||||
| 1911 | stream >> x >> y >> w >> h; | - | ||||||||||||||||||||||||
| 1912 | placeHolder->topLevelRect = QRect(x, y, w, h); | - | ||||||||||||||||||||||||
| 1913 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1914 | int dummy; | - | ||||||||||||||||||||||||
| 1915 | stream >> item.pos >> item.size >> dummy >> dummy; | - | ||||||||||||||||||||||||
| 1916 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1917 | if (item.size != -1)
| 0 | ||||||||||||||||||||||||
| 1918 | item.flags |= QDockAreaLayoutItem::KeepSize; never executed: item.flags |= QDockAreaLayoutItem::KeepSize; | 0 | ||||||||||||||||||||||||
| 1919 | if (!testing)
| 0 | ||||||||||||||||||||||||
| 1920 | item_list.append(item); never executed: item_list.append(item); | 0 | ||||||||||||||||||||||||
| 1921 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1922 | QDockAreaLayoutItem item(new QDockWidgetItem(widget)); | - | ||||||||||||||||||||||||
| 1923 | if (flags & StateFlagFloating) {
| 0 | ||||||||||||||||||||||||
| 1924 | bool drawer = false; | - | ||||||||||||||||||||||||
| 1925 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC // drawer support | - | ||||||||||||||||||||||||
| 1926 | extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp | - | ||||||||||||||||||||||||
| 1927 | extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp | - | ||||||||||||||||||||||||
| 1928 | drawer = qt_mac_is_macdrawer(widget); | - | ||||||||||||||||||||||||
| 1929 | #endif | - | ||||||||||||||||||||||||
| 1930 | - | |||||||||||||||||||||||||
| 1931 | if (!testing) {
| 0 | ||||||||||||||||||||||||
| 1932 | widget->hide(); | - | ||||||||||||||||||||||||
| 1933 | if (!drawer)
| 0 | ||||||||||||||||||||||||
| 1934 | widget->setFloating(true); never executed: widget->setFloating(true); | 0 | ||||||||||||||||||||||||
| 1935 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1936 | - | |||||||||||||||||||||||||
| 1937 | int x, y, w, h; | - | ||||||||||||||||||||||||
| 1938 | stream >> x >> y >> w >> h; | - | ||||||||||||||||||||||||
| 1939 | - | |||||||||||||||||||||||||
| 1940 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC // drawer support | - | ||||||||||||||||||||||||
| 1941 | if (drawer) { | - | ||||||||||||||||||||||||
| 1942 | mainWindow->window()->createWinId(); | - | ||||||||||||||||||||||||
| 1943 | widget->window()->createWinId(); | - | ||||||||||||||||||||||||
| 1944 | qt_mac_set_drawer_preferred_edge(widget, toDockWidgetArea(dockPos)); | - | ||||||||||||||||||||||||
| 1945 | } else | - | ||||||||||||||||||||||||
| 1946 | #endif | - | ||||||||||||||||||||||||
| 1947 | if (!testing)
| 0 | ||||||||||||||||||||||||
| 1948 | widget->setGeometry(QDockAreaLayout::constrainedRect(QRect(x, y, w, h), widget)); never executed: widget->setGeometry(QDockAreaLayout::constrainedRect(QRect(x, y, w, h), widget)); | 0 | ||||||||||||||||||||||||
| 1949 | - | |||||||||||||||||||||||||
| 1950 | if (!testing) {
| 0 | ||||||||||||||||||||||||
| 1951 | widget->setVisible(flags & StateFlagVisible); | - | ||||||||||||||||||||||||
| 1952 | item_list.append(item); | - | ||||||||||||||||||||||||
| 1953 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1954 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1955 | int dummy; | - | ||||||||||||||||||||||||
| 1956 | stream >> item.pos >> item.size >> dummy >> dummy; | - | ||||||||||||||||||||||||
| 1957 | if (!testing) {
| 0 | ||||||||||||||||||||||||
| 1958 | item_list.append(item); | - | ||||||||||||||||||||||||
| 1959 | widget->setFloating(false); | - | ||||||||||||||||||||||||
| 1960 | widget->setVisible(flags & StateFlagVisible); | - | ||||||||||||||||||||||||
| 1961 | emit widget->dockLocationChanged(toDockWidgetArea(dockPos)); | - | ||||||||||||||||||||||||
| 1962 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1963 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1964 | if (testing) {
| 0 | ||||||||||||||||||||||||
| 1965 | //was it is not really added to the layout, we need to delete the object here | - | ||||||||||||||||||||||||
| 1966 | delete item.widgetItem; | - | ||||||||||||||||||||||||
| 1967 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1968 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1969 | } else if (nextMarker == SequenceMarker) {
| 0 | ||||||||||||||||||||||||
| 1970 | int dummy; | - | ||||||||||||||||||||||||
| 1971 | #ifdef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1972 | const int tabBarShape = 0; | - | ||||||||||||||||||||||||
| 1973 | #endif | - | ||||||||||||||||||||||||
| 1974 | QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o, | - | ||||||||||||||||||||||||
| 1975 | tabBarShape, mainWindow)); | - | ||||||||||||||||||||||||
| 1976 | stream >> item.pos >> item.size >> dummy >> dummy; | - | ||||||||||||||||||||||||
| 1977 | //we need to make sure the element is in the list so the dock widget can eventually be docked correctly | - | ||||||||||||||||||||||||
| 1978 | if (!testing)
| 0 | ||||||||||||||||||||||||
| 1979 | item_list.append(item); never executed: item_list.append(item); | 0 | ||||||||||||||||||||||||
| 1980 | - | |||||||||||||||||||||||||
| 1981 | //here we need to make sure we change the item in the item_list | - | ||||||||||||||||||||||||
| 1982 | QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
| 0 | ||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||
| 1984 | if (!lastItem.subinfo->restoreState(stream, widgets, testing))
| 0 | ||||||||||||||||||||||||
| 1985 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 1986 | - | |||||||||||||||||||||||||
| 1987 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1988 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 1989 | } | - | ||||||||||||||||||||||||
| 1990 | } | - | ||||||||||||||||||||||||
| 1991 | - | |||||||||||||||||||||||||
| 1992 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1993 | if (!testing && tabbed && index >= 0 && index < item_list.count()) {
| 0 | ||||||||||||||||||||||||
| 1994 | updateTabBar(); | - | ||||||||||||||||||||||||
| 1995 | setCurrentTabId(tabId(item_list.at(index))); | - | ||||||||||||||||||||||||
| 1996 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1997 | if (!testing && *sep == 1)
| 0 | ||||||||||||||||||||||||
| 1998 | updateSeparatorWidgets(); never executed: updateSeparatorWidgets(); | 0 | ||||||||||||||||||||||||
| 1999 | #endif | - | ||||||||||||||||||||||||
| 2000 | - | |||||||||||||||||||||||||
| 2001 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 2002 | } | - | ||||||||||||||||||||||||
| 2003 | - | |||||||||||||||||||||||||
| 2004 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2005 | void QDockAreaLayoutInfo::updateSeparatorWidgets() const | - | ||||||||||||||||||||||||
| 2006 | { | - | ||||||||||||||||||||||||
| 2007 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 2008 | separatorWidgets.clear(); | - | ||||||||||||||||||||||||
| 2009 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2010 | } | - | ||||||||||||||||||||||||
| 2011 | - | |||||||||||||||||||||||||
| 2012 | int j = 0; | - | ||||||||||||||||||||||||
| 2013 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2014 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 2015 | - | |||||||||||||||||||||||||
| 2016 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 2017 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2018 | - | |||||||||||||||||||||||||
| 2019 | int next = this->next(i); | - | ||||||||||||||||||||||||
| 2020 | if ((item.flags & QDockAreaLayoutItem::GapItem)
| 0 | ||||||||||||||||||||||||
| 2021 | || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
| 0 | ||||||||||||||||||||||||
| 2022 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||
| 2024 | if (item.subinfo) {
| 0 | ||||||||||||||||||||||||
| 2025 | item.subinfo->updateSeparatorWidgets(); | - | ||||||||||||||||||||||||
| 2026 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2027 | - | |||||||||||||||||||||||||
| 2028 | if (next == -1)
| 0 | ||||||||||||||||||||||||
| 2029 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | QWidget *sepWidget; | - | ||||||||||||||||||||||||
| 2032 | if (j < separatorWidgets.size() && separatorWidgets.at(j)) {
| 0 | ||||||||||||||||||||||||
| 2033 | sepWidget = separatorWidgets.at(j); | - | ||||||||||||||||||||||||
| 2034 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2035 | sepWidget = mainWindowLayout()->getSeparatorWidget(); | - | ||||||||||||||||||||||||
| 2036 | separatorWidgets.append(sepWidget); | - | ||||||||||||||||||||||||
| 2037 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2038 | j++; | - | ||||||||||||||||||||||||
| 2039 | - | |||||||||||||||||||||||||
| 2040 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||
| 2041 | sepWidget->raise(); | - | ||||||||||||||||||||||||
| 2042 | #endif | - | ||||||||||||||||||||||||
| 2043 | QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2); | - | ||||||||||||||||||||||||
| 2044 | sepWidget->setGeometry(sepRect); | - | ||||||||||||||||||||||||
| 2045 | sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft()))); | - | ||||||||||||||||||||||||
| 2046 | sepWidget->show(); | - | ||||||||||||||||||||||||
| 2047 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2048 | - | |||||||||||||||||||||||||
| 2049 | for (int k = j; k < separatorWidgets.size(); ++k) {
| 0 | ||||||||||||||||||||||||
| 2050 | separatorWidgets[k]->hide(); | - | ||||||||||||||||||||||||
| 2051 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2052 | separatorWidgets.resize(j); | - | ||||||||||||||||||||||||
| 2053 | Q_ASSERT(separatorWidgets.size() == j); | - | ||||||||||||||||||||||||
| 2054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2055 | #endif //QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2056 | - | |||||||||||||||||||||||||
| 2057 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2058 | /*! \internal | - | ||||||||||||||||||||||||
| 2059 | reparent all the widgets contained in this layout portion to the | - | ||||||||||||||||||||||||
| 2060 | specified parent. This is used to reparent dock widgets and tabbars | - | ||||||||||||||||||||||||
| 2061 | to the floating window or the main window | - | ||||||||||||||||||||||||
| 2062 | */ | - | ||||||||||||||||||||||||
| 2063 | void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent) | - | ||||||||||||||||||||||||
| 2064 | { | - | ||||||||||||||||||||||||
| 2065 | if (tabBar)
| 0 | ||||||||||||||||||||||||
| 2066 | tabBar->setParent(parent); never executed: tabBar->setParent(parent); | 0 | ||||||||||||||||||||||||
| 2067 | - | |||||||||||||||||||||||||
| 2068 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2069 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 2070 | if (item.flags & QDockAreaLayoutItem::GapItem)
| 0 | ||||||||||||||||||||||||
| 2071 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2072 | if (item.subinfo)
| 0 | ||||||||||||||||||||||||
| 2073 | item.subinfo->reparentWidgets(parent); never executed: item.subinfo->reparentWidgets(parent); | 0 | ||||||||||||||||||||||||
| 2074 | if (item.widgetItem) {
| 0 | ||||||||||||||||||||||||
| 2075 | QWidget *w = item.widgetItem->widget(); | - | ||||||||||||||||||||||||
| 2076 | if (qobject_cast<QDockWidgetGroupWindow *>(w))
| 0 | ||||||||||||||||||||||||
| 2077 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2078 | if (w->parent() != parent) {
| 0 | ||||||||||||||||||||||||
| 2079 | bool hidden = w->isHidden(); | - | ||||||||||||||||||||||||
| 2080 | w->setParent(parent, w->windowFlags()); | - | ||||||||||||||||||||||||
| 2081 | if (!hidden)
| 0 | ||||||||||||||||||||||||
| 2082 | w->show(); never executed: w->show(); | 0 | ||||||||||||||||||||||||
| 2083 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2084 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2085 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2086 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2087 | - | |||||||||||||||||||||||||
| 2088 | //returns whether the tabbar is visible or not | - | ||||||||||||||||||||||||
| 2089 | bool QDockAreaLayoutInfo::updateTabBar() const | - | ||||||||||||||||||||||||
| 2090 | { | - | ||||||||||||||||||||||||
| 2091 | if (!tabbed)
| 0 | ||||||||||||||||||||||||
| 2092 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 2093 | - | |||||||||||||||||||||||||
| 2094 | QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); | - | ||||||||||||||||||||||||
| 2095 | - | |||||||||||||||||||||||||
| 2096 | if (that->tabBar == 0) {
| 0 | ||||||||||||||||||||||||
| 2097 | that->tabBar = mainWindowLayout()->getTabBar(); | - | ||||||||||||||||||||||||
| 2098 | that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape)); | - | ||||||||||||||||||||||||
| 2099 | that->tabBar->setDrawBase(true); | - | ||||||||||||||||||||||||
| 2100 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2101 | - | |||||||||||||||||||||||||
| 2102 | const QSignalBlocker blocker(tabBar); | - | ||||||||||||||||||||||||
| 2103 | bool gap = false; | - | ||||||||||||||||||||||||
| 2104 | - | |||||||||||||||||||||||||
| 2105 | const quintptr oldCurrentId = currentTabId(); | - | ||||||||||||||||||||||||
| 2106 | - | |||||||||||||||||||||||||
| 2107 | int tab_idx = 0; | - | ||||||||||||||||||||||||
| 2108 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2109 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 2110 | if (item.skip())
| 0 | ||||||||||||||||||||||||
| 2111 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2112 | if (item.flags & QDockAreaLayoutItem::GapItem) {
| 0 | ||||||||||||||||||||||||
| 2113 | gap = true; | - | ||||||||||||||||||||||||
| 2114 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2115 | } | - | ||||||||||||||||||||||||
| 2116 | if (item.widgetItem == 0)
| 0 | ||||||||||||||||||||||||
| 2117 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2118 | - | |||||||||||||||||||||||||
| 2119 | QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget()); | - | ||||||||||||||||||||||||
| 2120 | QString title = dw->d_func()->fixedWindowTitle; | - | ||||||||||||||||||||||||
| 2121 | quintptr id = tabId(item); | - | ||||||||||||||||||||||||
| 2122 | if (tab_idx == tabBar->count()) {
| 0 | ||||||||||||||||||||||||
| 2123 | tabBar->insertTab(tab_idx, title); | - | ||||||||||||||||||||||||
| 2124 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 2125 | tabBar->setTabToolTip(tab_idx, title); | - | ||||||||||||||||||||||||
| 2126 | #endif | - | ||||||||||||||||||||||||
| 2127 | tabBar->setTabData(tab_idx, id); | - | ||||||||||||||||||||||||
| 2128 | } else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) != id) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2129 | if (tab_idx + 1 < tabBar->count()
| 0 | ||||||||||||||||||||||||
| 2130 | && qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) == id)
| 0 | ||||||||||||||||||||||||
| 2131 | tabBar->removeTab(tab_idx); never executed: tabBar->removeTab(tab_idx); | 0 | ||||||||||||||||||||||||
| 2132 | else { | - | ||||||||||||||||||||||||
| 2133 | tabBar->insertTab(tab_idx, title); | - | ||||||||||||||||||||||||
| 2134 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 2135 | tabBar->setTabToolTip(tab_idx, title); | - | ||||||||||||||||||||||||
| 2136 | #endif | - | ||||||||||||||||||||||||
| 2137 | tabBar->setTabData(tab_idx, id); | - | ||||||||||||||||||||||||
| 2138 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2139 | } | - | ||||||||||||||||||||||||
| 2140 | - | |||||||||||||||||||||||||
| 2141 | if (title != tabBar->tabText(tab_idx)) {
| 0 | ||||||||||||||||||||||||
| 2142 | tabBar->setTabText(tab_idx, title); | - | ||||||||||||||||||||||||
| 2143 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 2144 | tabBar->setTabToolTip(tab_idx, title); | - | ||||||||||||||||||||||||
| 2145 | #endif | - | ||||||||||||||||||||||||
| 2146 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2147 | - | |||||||||||||||||||||||||
| 2148 | ++tab_idx; | - | ||||||||||||||||||||||||
| 2149 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2150 | - | |||||||||||||||||||||||||
| 2151 | while (tab_idx < tabBar->count()) {
| 0 | ||||||||||||||||||||||||
| 2152 | tabBar->removeTab(tab_idx); | - | ||||||||||||||||||||||||
| 2153 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2154 | - | |||||||||||||||||||||||||
| 2155 | if (oldCurrentId > 0 && currentTabId() != oldCurrentId)
| 0 | ||||||||||||||||||||||||
| 2156 | that->setCurrentTabId(oldCurrentId); never executed: that->setCurrentTabId(oldCurrentId); | 0 | ||||||||||||||||||||||||
| 2157 | - | |||||||||||||||||||||||||
| 2158 | if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(tabBar->parent()))
| 0 | ||||||||||||||||||||||||
| 2159 | dwgw->adjustFlags(); never executed: dwgw->adjustFlags(); | 0 | ||||||||||||||||||||||||
| 2160 | - | |||||||||||||||||||||||||
| 2161 | //returns if the tabbar is visible or not | - | ||||||||||||||||||||||||
| 2162 | return ( (gap ? 1 : 0) + tabBar->count()) > 1; never executed: return ( (gap ? 1 : 0) + tabBar->count()) > 1;
| 0 | ||||||||||||||||||||||||
| 2163 | } | - | ||||||||||||||||||||||||
| 2164 | - | |||||||||||||||||||||||||
| 2165 | void QDockAreaLayoutInfo::setTabBarShape(int shape) | - | ||||||||||||||||||||||||
| 2166 | { | - | ||||||||||||||||||||||||
| 2167 | if (shape == tabBarShape)
| 0 | ||||||||||||||||||||||||
| 2168 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2169 | tabBarShape = shape; | - | ||||||||||||||||||||||||
| 2170 | if (tabBar != 0)
| 0 | ||||||||||||||||||||||||
| 2171 | tabBar->setShape(static_cast<QTabBar::Shape>(shape)); never executed: tabBar->setShape(static_cast<QTabBar::Shape>(shape)); | 0 | ||||||||||||||||||||||||
| 2172 | - | |||||||||||||||||||||||||
| 2173 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2174 | QDockAreaLayoutItem &item = item_list[i]; | - | ||||||||||||||||||||||||
| 2175 | if (item.subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 2176 | item.subinfo->setTabBarShape(shape); never executed: item.subinfo->setTabBarShape(shape); | 0 | ||||||||||||||||||||||||
| 2177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2179 | - | |||||||||||||||||||||||||
| 2180 | QSize QDockAreaLayoutInfo::tabBarMinimumSize() const | - | ||||||||||||||||||||||||
| 2181 | { | - | ||||||||||||||||||||||||
| 2182 | if (!updateTabBar())
| 0 | ||||||||||||||||||||||||
| 2183 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 2184 | - | |||||||||||||||||||||||||
| 2185 | return tabBar->minimumSizeHint(); never executed: return tabBar->minimumSizeHint(); | 0 | ||||||||||||||||||||||||
| 2186 | } | - | ||||||||||||||||||||||||
| 2187 | - | |||||||||||||||||||||||||
| 2188 | QSize QDockAreaLayoutInfo::tabBarSizeHint() const | - | ||||||||||||||||||||||||
| 2189 | { | - | ||||||||||||||||||||||||
| 2190 | if (!updateTabBar())
| 0 | ||||||||||||||||||||||||
| 2191 | return QSize(0, 0); never executed: return QSize(0, 0); | 0 | ||||||||||||||||||||||||
| 2192 | - | |||||||||||||||||||||||||
| 2193 | return tabBar->sizeHint(); never executed: return tabBar->sizeHint(); | 0 | ||||||||||||||||||||||||
| 2194 | } | - | ||||||||||||||||||||||||
| 2195 | - | |||||||||||||||||||||||||
| 2196 | QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const | - | ||||||||||||||||||||||||
| 2197 | { | - | ||||||||||||||||||||||||
| 2198 | QSet<QTabBar*> result; | - | ||||||||||||||||||||||||
| 2199 | - | |||||||||||||||||||||||||
| 2200 | if (tabbed) {
| 0 | ||||||||||||||||||||||||
| 2201 | updateTabBar(); | - | ||||||||||||||||||||||||
| 2202 | result.insert(tabBar); | - | ||||||||||||||||||||||||
| 2203 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2204 | - | |||||||||||||||||||||||||
| 2205 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2206 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 2207 | if (item.subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 2208 | result += item.subinfo->usedTabBars(); never executed: result += item.subinfo->usedTabBars(); | 0 | ||||||||||||||||||||||||
| 2209 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2210 | - | |||||||||||||||||||||||||
| 2211 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2212 | } | - | ||||||||||||||||||||||||
| 2213 | - | |||||||||||||||||||||||||
| 2214 | // returns a set of all used separator widgets for this dockarelayout info | - | ||||||||||||||||||||||||
| 2215 | // and all subinfos | - | ||||||||||||||||||||||||
| 2216 | QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const | - | ||||||||||||||||||||||||
| 2217 | { | - | ||||||||||||||||||||||||
| 2218 | QSet<QWidget*> result; | - | ||||||||||||||||||||||||
| 2219 | const int numSeparatorWidgets = separatorWidgets.count(); | - | ||||||||||||||||||||||||
| 2220 | result.reserve(numSeparatorWidgets); | - | ||||||||||||||||||||||||
| 2221 | - | |||||||||||||||||||||||||
| 2222 | for (int i = 0; i < numSeparatorWidgets; ++i)
| 0 | ||||||||||||||||||||||||
| 2223 | result << separatorWidgets.at(i); never executed: result << separatorWidgets.at(i); | 0 | ||||||||||||||||||||||||
| 2224 | - | |||||||||||||||||||||||||
| 2225 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2226 | const QDockAreaLayoutItem &item = item_list.at(i); | - | ||||||||||||||||||||||||
| 2227 | if (item.subinfo != 0)
| 0 | ||||||||||||||||||||||||
| 2228 | result += item.subinfo->usedSeparatorWidgets(); never executed: result += item.subinfo->usedSeparatorWidgets(); | 0 | ||||||||||||||||||||||||
| 2229 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2230 | - | |||||||||||||||||||||||||
| 2231 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2232 | } | - | ||||||||||||||||||||||||
| 2233 | - | |||||||||||||||||||||||||
| 2234 | QRect QDockAreaLayoutInfo::tabContentRect() const | - | ||||||||||||||||||||||||
| 2235 | { | - | ||||||||||||||||||||||||
| 2236 | if (!tabbed)
| 0 | ||||||||||||||||||||||||
| 2237 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 2238 | - | |||||||||||||||||||||||||
| 2239 | QRect result = rect; | - | ||||||||||||||||||||||||
| 2240 | QSize tbh = tabBarSizeHint(); | - | ||||||||||||||||||||||||
| 2241 | - | |||||||||||||||||||||||||
| 2242 | if (!tbh.isNull()) {
| 0 | ||||||||||||||||||||||||
| 2243 | switch (tabBarShape) { | - | ||||||||||||||||||||||||
| 2244 | case QTabBar::RoundedNorth: never executed: case QTabBar::RoundedNorth: | 0 | ||||||||||||||||||||||||
| 2245 | case QTabBar::TriangularNorth: never executed: case QTabBar::TriangularNorth: | 0 | ||||||||||||||||||||||||
| 2246 | result.adjust(0, tbh.height(), 0, 0); | - | ||||||||||||||||||||||||
| 2247 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2248 | case QTabBar::RoundedSouth: never executed: case QTabBar::RoundedSouth: | 0 | ||||||||||||||||||||||||
| 2249 | case QTabBar::TriangularSouth: never executed: case QTabBar::TriangularSouth: | 0 | ||||||||||||||||||||||||
| 2250 | result.adjust(0, 0, 0, -tbh.height()); | - | ||||||||||||||||||||||||
| 2251 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2252 | case QTabBar::RoundedEast: never executed: case QTabBar::RoundedEast: | 0 | ||||||||||||||||||||||||
| 2253 | case QTabBar::TriangularEast: never executed: case QTabBar::TriangularEast: | 0 | ||||||||||||||||||||||||
| 2254 | result.adjust(0, 0, -tbh.width(), 0); | - | ||||||||||||||||||||||||
| 2255 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2256 | case QTabBar::RoundedWest: never executed: case QTabBar::RoundedWest: | 0 | ||||||||||||||||||||||||
| 2257 | case QTabBar::TriangularWest: never executed: case QTabBar::TriangularWest: | 0 | ||||||||||||||||||||||||
| 2258 | result.adjust(tbh.width(), 0, 0, 0); | - | ||||||||||||||||||||||||
| 2259 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2260 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 2261 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2262 | } | - | ||||||||||||||||||||||||
| 2263 | } | - | ||||||||||||||||||||||||
| 2264 | - | |||||||||||||||||||||||||
| 2265 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2266 | } | - | ||||||||||||||||||||||||
| 2267 | - | |||||||||||||||||||||||||
| 2268 | int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const | - | ||||||||||||||||||||||||
| 2269 | { | - | ||||||||||||||||||||||||
| 2270 | Q_ASSERT(tabbed && tabBar); | - | ||||||||||||||||||||||||
| 2271 | quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex)); | - | ||||||||||||||||||||||||
| 2272 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 2273 | if (tabId(item_list.at(i)) == data)
| 0 | ||||||||||||||||||||||||
| 2274 | return i; never executed: return i; | 0 | ||||||||||||||||||||||||
| 2275 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2276 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
| 2277 | } | - | ||||||||||||||||||||||||
| 2278 | - | |||||||||||||||||||||||||
| 2279 | void QDockAreaLayoutInfo::moveTab(int from, int to) | - | ||||||||||||||||||||||||
| 2280 | { | - | ||||||||||||||||||||||||
| 2281 | item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to)); | - | ||||||||||||||||||||||||
| 2282 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2283 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2284 | - | |||||||||||||||||||||||||
| 2285 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 2286 | ** QDockAreaLayout | - | ||||||||||||||||||||||||
| 2287 | */ | - | ||||||||||||||||||||||||
| 2288 | - | |||||||||||||||||||||||||
| 2289 | QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) | - | ||||||||||||||||||||||||
| 2290 | { | - | ||||||||||||||||||||||||
| 2291 | mainWindow = win; | - | ||||||||||||||||||||||||
| 2292 | sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win); | - | ||||||||||||||||||||||||
| 2293 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2294 | const int tabShape = QTabBar::RoundedSouth; | - | ||||||||||||||||||||||||
| 2295 | #else | - | ||||||||||||||||||||||||
| 2296 | const int tabShape = 0; | - | ||||||||||||||||||||||||
| 2297 | #endif | - | ||||||||||||||||||||||||
| 2298 | docks[QInternal::LeftDock] | - | ||||||||||||||||||||||||
| 2299 | = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win); | - | ||||||||||||||||||||||||
| 2300 | docks[QInternal::RightDock] | - | ||||||||||||||||||||||||
| 2301 | = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win); | - | ||||||||||||||||||||||||
| 2302 | docks[QInternal::TopDock] | - | ||||||||||||||||||||||||
| 2303 | = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win); | - | ||||||||||||||||||||||||
| 2304 | docks[QInternal::BottomDock] | - | ||||||||||||||||||||||||
| 2305 | = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); | - | ||||||||||||||||||||||||
| 2306 | centralWidgetItem = 0; | - | ||||||||||||||||||||||||
| 2307 | - | |||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||
| 2309 | corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea; | - | ||||||||||||||||||||||||
| 2310 | corners[Qt::TopRightCorner] = Qt::TopDockWidgetArea; | - | ||||||||||||||||||||||||
| 2311 | corners[Qt::BottomLeftCorner] = Qt::BottomDockWidgetArea; | - | ||||||||||||||||||||||||
| 2312 | corners[Qt::BottomRightCorner] = Qt::BottomDockWidgetArea; | - | ||||||||||||||||||||||||
| 2313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2314 | - | |||||||||||||||||||||||||
| 2315 | bool QDockAreaLayout::isValid() const | - | ||||||||||||||||||||||||
| 2316 | { | - | ||||||||||||||||||||||||
| 2317 | return rect.isValid(); never executed: return rect.isValid(); | 0 | ||||||||||||||||||||||||
| 2318 | } | - | ||||||||||||||||||||||||
| 2319 | - | |||||||||||||||||||||||||
| 2320 | void QDockAreaLayout::saveState(QDataStream &stream) const | - | ||||||||||||||||||||||||
| 2321 | { | - | ||||||||||||||||||||||||
| 2322 | stream << (uchar) DockWidgetStateMarker; | - | ||||||||||||||||||||||||
| 2323 | int cnt = 0; | - | ||||||||||||||||||||||||
| 2324 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2325 | if (!docks[i].item_list.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2326 | ++cnt; never executed: ++cnt; | 0 | ||||||||||||||||||||||||
| 2327 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2328 | stream << cnt; | - | ||||||||||||||||||||||||
| 2329 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2330 | if (docks[i].item_list.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2331 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2332 | stream << i << docks[i].rect.size(); | - | ||||||||||||||||||||||||
| 2333 | docks[i].saveState(stream); | - | ||||||||||||||||||||||||
| 2334 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2335 | - | |||||||||||||||||||||||||
| 2336 | stream << centralWidgetRect.size(); | - | ||||||||||||||||||||||||
| 2337 | - | |||||||||||||||||||||||||
| 2338 | for (int i = 0; i < 4; ++i)
| 0 | ||||||||||||||||||||||||
| 2339 | stream << static_cast<int>(corners[i]); never executed: stream << static_cast<int>(corners[i]); | 0 | ||||||||||||||||||||||||
| 2340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2341 | - | |||||||||||||||||||||||||
| 2342 | bool QDockAreaLayout::restoreState(QDataStream &stream, const QList<QDockWidget*> &_dockwidgets, bool testing) | - | ||||||||||||||||||||||||
| 2343 | { | - | ||||||||||||||||||||||||
| 2344 | QList<QDockWidget*> dockwidgets = _dockwidgets; | - | ||||||||||||||||||||||||
| 2345 | - | |||||||||||||||||||||||||
| 2346 | int cnt; | - | ||||||||||||||||||||||||
| 2347 | stream >> cnt; | - | ||||||||||||||||||||||||
| 2348 | for (int i = 0; i < cnt; ++i) {
| 0 | ||||||||||||||||||||||||
| 2349 | int pos; | - | ||||||||||||||||||||||||
| 2350 | stream >> pos; | - | ||||||||||||||||||||||||
| 2351 | QSize size; | - | ||||||||||||||||||||||||
| 2352 | stream >> size; | - | ||||||||||||||||||||||||
| 2353 | if (!testing) {
| 0 | ||||||||||||||||||||||||
| 2354 | docks[pos].rect = QRect(QPoint(0, 0), size); | - | ||||||||||||||||||||||||
| 2355 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2356 | if (!docks[pos].restoreState(stream, dockwidgets, testing)) {
| 0 | ||||||||||||||||||||||||
| 2357 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
| 2358 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 2359 | } | - | ||||||||||||||||||||||||
| 2360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2361 | - | |||||||||||||||||||||||||
| 2362 | QSize size; | - | ||||||||||||||||||||||||
| 2363 | stream >> size; | - | ||||||||||||||||||||||||
| 2364 | centralWidgetRect = QRect(QPoint(0, 0), size); | - | ||||||||||||||||||||||||
| 2365 | - | |||||||||||||||||||||||||
| 2366 | bool ok = stream.status() == QDataStream::Ok; | - | ||||||||||||||||||||||||
| 2367 | - | |||||||||||||||||||||||||
| 2368 | if (ok) {
| 0 | ||||||||||||||||||||||||
| 2369 | int cornerData[4]; | - | ||||||||||||||||||||||||
| 2370 | for (int i = 0; i < 4; ++i)
| 0 | ||||||||||||||||||||||||
| 2371 | stream >> cornerData[i]; never executed: stream >> cornerData[i]; | 0 | ||||||||||||||||||||||||
| 2372 | if (stream.status() == QDataStream::Ok) {
| 0 | ||||||||||||||||||||||||
| 2373 | for (int i = 0; i < 4; ++i)
| 0 | ||||||||||||||||||||||||
| 2374 | corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]); never executed: corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]); | 0 | ||||||||||||||||||||||||
| 2375 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2376 | - | |||||||||||||||||||||||||
| 2377 | if (!testing)
| 0 | ||||||||||||||||||||||||
| 2378 | fallbackToSizeHints = false; never executed: fallbackToSizeHints = false; | 0 | ||||||||||||||||||||||||
| 2379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2380 | - | |||||||||||||||||||||||||
| 2381 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
| 2382 | } | - | ||||||||||||||||||||||||
| 2383 | - | |||||||||||||||||||||||||
| 2384 | QList<int> QDockAreaLayout::indexOfPlaceHolder(const QString &objectName) const | - | ||||||||||||||||||||||||
| 2385 | { | - | ||||||||||||||||||||||||
| 2386 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2387 | QList<int> result = docks[i].indexOfPlaceHolder(objectName); | - | ||||||||||||||||||||||||
| 2388 | if (!result.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2389 | result.prepend(i); | - | ||||||||||||||||||||||||
| 2390 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2391 | } | - | ||||||||||||||||||||||||
| 2392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2393 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 2394 | } | - | ||||||||||||||||||||||||
| 2395 | - | |||||||||||||||||||||||||
| 2396 | QList<int> QDockAreaLayout::indexOf(QWidget *dockWidget) const | - | ||||||||||||||||||||||||
| 2397 | { | - | ||||||||||||||||||||||||
| 2398 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2399 | QList<int> result = docks[i].indexOf(dockWidget); | - | ||||||||||||||||||||||||
| 2400 | if (!result.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2401 | result.prepend(i); | - | ||||||||||||||||||||||||
| 2402 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2403 | } | - | ||||||||||||||||||||||||
| 2404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2405 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 2406 | } | - | ||||||||||||||||||||||||
| 2407 | - | |||||||||||||||||||||||||
| 2408 | QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const | - | ||||||||||||||||||||||||
| 2409 | { | - | ||||||||||||||||||||||||
| 2410 | QMainWindow::DockOptions opts = mainWindow->dockOptions(); | - | ||||||||||||||||||||||||
| 2411 | bool nestingEnabled = opts & QMainWindow::AllowNestedDocks; | - | ||||||||||||||||||||||||
| 2412 | QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs; | - | ||||||||||||||||||||||||
| 2413 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2414 | if (opts & QMainWindow::AllowTabbedDocks
| 0 | ||||||||||||||||||||||||
| 2415 | || opts & QMainWindow::VerticalTabs)
| 0 | ||||||||||||||||||||||||
| 2416 | tabMode = QDockAreaLayoutInfo::AllowTabs; never executed: tabMode = QDockAreaLayoutInfo::AllowTabs; | 0 | ||||||||||||||||||||||||
| 2417 | if (opts & QMainWindow::ForceTabbedDocks)
| 0 | ||||||||||||||||||||||||
| 2418 | tabMode = QDockAreaLayoutInfo::ForceTabs; never executed: tabMode = QDockAreaLayoutInfo::ForceTabs; | 0 | ||||||||||||||||||||||||
| 2419 | - | |||||||||||||||||||||||||
| 2420 | if (tabMode == QDockAreaLayoutInfo::ForceTabs)
| 0 | ||||||||||||||||||||||||
| 2421 | nestingEnabled = false; never executed: nestingEnabled = false; | 0 | ||||||||||||||||||||||||
| 2422 | #endif | - | ||||||||||||||||||||||||
| 2423 | - | |||||||||||||||||||||||||
| 2424 | - | |||||||||||||||||||||||||
| 2425 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2426 | const QDockAreaLayoutInfo &info = docks[i]; | - | ||||||||||||||||||||||||
| 2427 | - | |||||||||||||||||||||||||
| 2428 | if (!info.isEmpty() && info.rect.contains(pos)) {
| 0 | ||||||||||||||||||||||||
| 2429 | QList<int> result | - | ||||||||||||||||||||||||
| 2430 | = docks[i].gapIndex(pos, nestingEnabled, tabMode); | - | ||||||||||||||||||||||||
| 2431 | if (!result.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2432 | result.prepend(i); never executed: result.prepend(i); | 0 | ||||||||||||||||||||||||
| 2433 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2434 | } | - | ||||||||||||||||||||||||
| 2435 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2436 | - | |||||||||||||||||||||||||
| 2437 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2438 | const QDockAreaLayoutInfo &info = docks[i]; | - | ||||||||||||||||||||||||
| 2439 | - | |||||||||||||||||||||||||
| 2440 | if (info.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2441 | QRect r; | - | ||||||||||||||||||||||||
| 2442 | switch (i) { | - | ||||||||||||||||||||||||
| 2443 | case QInternal::LeftDock: never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 2444 | r = QRect(rect.left(), rect.top(), EmptyDropAreaSize, rect.height()); | - | ||||||||||||||||||||||||
| 2445 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2446 | case QInternal::RightDock: never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 2447 | r = QRect(rect.right() - EmptyDropAreaSize, rect.top(), | - | ||||||||||||||||||||||||
| 2448 | EmptyDropAreaSize, rect.height()); | - | ||||||||||||||||||||||||
| 2449 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2450 | case QInternal::TopDock: never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 2451 | r = QRect(rect.left(), rect.top(), rect.width(), EmptyDropAreaSize); | - | ||||||||||||||||||||||||
| 2452 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2453 | case QInternal::BottomDock: never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 2454 | r = QRect(rect.left(), rect.bottom() - EmptyDropAreaSize, | - | ||||||||||||||||||||||||
| 2455 | rect.width(), EmptyDropAreaSize); | - | ||||||||||||||||||||||||
| 2456 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2457 | } | - | ||||||||||||||||||||||||
| 2458 | if (r.contains(pos)) {
| 0 | ||||||||||||||||||||||||
| 2459 | if (opts & QMainWindow::ForceTabbedDocks && !info.item_list.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2460 | //in case of ForceTabbedDocks, we pass -1 in order to force the gap to be tabbed | - | ||||||||||||||||||||||||
| 2461 | //it mustn't be completely empty otherwise it won't work | - | ||||||||||||||||||||||||
| 2462 | return QList<int>() << i << -1 << 0; never executed: return QList<int>() << i << -1 << 0; | 0 | ||||||||||||||||||||||||
| 2463 | } else { | - | ||||||||||||||||||||||||
| 2464 | return QList<int>() << i << 0; never executed: return QList<int>() << i << 0; | 0 | ||||||||||||||||||||||||
| 2465 | } | - | ||||||||||||||||||||||||
| 2466 | } | - | ||||||||||||||||||||||||
| 2467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2468 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2469 | - | |||||||||||||||||||||||||
| 2470 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||||||||
| 2471 | } | - | ||||||||||||||||||||||||
| 2472 | - | |||||||||||||||||||||||||
| 2473 | QList<int> QDockAreaLayout::findSeparator(const QPoint &pos) const | - | ||||||||||||||||||||||||
| 2474 | { | - | ||||||||||||||||||||||||
| 2475 | QList<int> result; | - | ||||||||||||||||||||||||
| 2476 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2477 | const QDockAreaLayoutInfo &info = docks[i]; | - | ||||||||||||||||||||||||
| 2478 | if (info.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2479 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2480 | QRect rect = separatorRect(i); | - | ||||||||||||||||||||||||
| 2481 | if (!rect.isNull() && sep == 1)
| 0 | ||||||||||||||||||||||||
| 2482 | rect.adjust(-2, -2, 2, 2); never executed: rect.adjust(-2, -2, 2, 2); | 0 | ||||||||||||||||||||||||
| 2483 | if (rect.contains(pos) && !info.hasFixedSize()) {
| 0 | ||||||||||||||||||||||||
| 2484 | result << i; | - | ||||||||||||||||||||||||
| 2485 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2486 | } else if (info.rect.contains(pos)) {
| 0 | ||||||||||||||||||||||||
| 2487 | result = docks[i].findSeparator(pos); | - | ||||||||||||||||||||||||
| 2488 | if (!result.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2489 | result.prepend(i); | - | ||||||||||||||||||||||||
| 2490 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2491 | } | - | ||||||||||||||||||||||||
| 2492 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2494 | - | |||||||||||||||||||||||||
| 2495 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2496 | } | - | ||||||||||||||||||||||||
| 2497 | - | |||||||||||||||||||||||||
| 2498 | QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget) | - | ||||||||||||||||||||||||
| 2499 | { | - | ||||||||||||||||||||||||
| 2500 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 2501 | if (QDockAreaLayoutInfo *result = docks[i].info(widget))
| 0 | ||||||||||||||||||||||||
| 2502 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 2503 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2504 | - | |||||||||||||||||||||||||
| 2505 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2506 | } | - | ||||||||||||||||||||||||
| 2507 | - | |||||||||||||||||||||||||
| 2508 | QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) | - | ||||||||||||||||||||||||
| 2509 | { | - | ||||||||||||||||||||||||
| 2510 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2511 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2512 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2513 | - | |||||||||||||||||||||||||
| 2514 | if (path.count() == 1)
| 0 | ||||||||||||||||||||||||
| 2515 | return &docks[index]; never executed: return &docks[index]; | 0 | ||||||||||||||||||||||||
| 2516 | - | |||||||||||||||||||||||||
| 2517 | return docks[index].info(path.mid(1)); never executed: return docks[index].info(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 2518 | } | - | ||||||||||||||||||||||||
| 2519 | - | |||||||||||||||||||||||||
| 2520 | const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 2521 | { | - | ||||||||||||||||||||||||
| 2522 | return const_cast<QDockAreaLayout*>(this)->info(path); never executed: return const_cast<QDockAreaLayout*>(this)->info(path); | 0 | ||||||||||||||||||||||||
| 2523 | } | - | ||||||||||||||||||||||||
| 2524 | - | |||||||||||||||||||||||||
| 2525 | QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path) | - | ||||||||||||||||||||||||
| 2526 | { | - | ||||||||||||||||||||||||
| 2527 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2528 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2529 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2530 | return docks[index].item(path.mid(1)); never executed: return docks[index].item(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 2531 | } | - | ||||||||||||||||||||||||
| 2532 | - | |||||||||||||||||||||||||
| 2533 | QRect QDockAreaLayout::itemRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 2534 | { | - | ||||||||||||||||||||||||
| 2535 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2536 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2537 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2538 | return docks[index].itemRect(path.mid(1)); never executed: return docks[index].itemRect(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 2539 | } | - | ||||||||||||||||||||||||
| 2540 | - | |||||||||||||||||||||||||
| 2541 | QRect QDockAreaLayout::separatorRect(int index) const | - | ||||||||||||||||||||||||
| 2542 | { | - | ||||||||||||||||||||||||
| 2543 | const QDockAreaLayoutInfo &dock = docks[index]; | - | ||||||||||||||||||||||||
| 2544 | if (dock.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2545 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 2546 | QRect r = dock.rect; | - | ||||||||||||||||||||||||
| 2547 | switch (index) { | - | ||||||||||||||||||||||||
| 2548 | case QInternal::LeftDock: never executed: case QInternal::LeftDock: | 0 | ||||||||||||||||||||||||
| 2549 | return QRect(r.right() + 1, r.top(), sep, r.height()); never executed: return QRect(r.right() + 1, r.top(), sep, r.height()); | 0 | ||||||||||||||||||||||||
| 2550 | case QInternal::RightDock: never executed: case QInternal::RightDock: | 0 | ||||||||||||||||||||||||
| 2551 | return QRect(r.left() - sep, r.top(), sep, r.height()); never executed: return QRect(r.left() - sep, r.top(), sep, r.height()); | 0 | ||||||||||||||||||||||||
| 2552 | case QInternal::TopDock: never executed: case QInternal::TopDock: | 0 | ||||||||||||||||||||||||
| 2553 | return QRect(r.left(), r.bottom() + 1, r.width(), sep); never executed: return QRect(r.left(), r.bottom() + 1, r.width(), sep); | 0 | ||||||||||||||||||||||||
| 2554 | case QInternal::BottomDock: never executed: case QInternal::BottomDock: | 0 | ||||||||||||||||||||||||
| 2555 | return QRect(r.left(), r.top() - sep, r.width(), sep); never executed: return QRect(r.left(), r.top() - sep, r.width(), sep); | 0 | ||||||||||||||||||||||||
| 2556 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 2557 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2558 | } | - | ||||||||||||||||||||||||
| 2559 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 2560 | } | - | ||||||||||||||||||||||||
| 2561 | - | |||||||||||||||||||||||||
| 2562 | QRect QDockAreaLayout::separatorRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 2563 | { | - | ||||||||||||||||||||||||
| 2564 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2565 | - | |||||||||||||||||||||||||
| 2566 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2567 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2568 | - | |||||||||||||||||||||||||
| 2569 | if (path.count() == 1)
| 0 | ||||||||||||||||||||||||
| 2570 | return separatorRect(index); never executed: return separatorRect(index); | 0 | ||||||||||||||||||||||||
| 2571 | else | - | ||||||||||||||||||||||||
| 2572 | return docks[index].separatorRect(path.mid(1)); never executed: return docks[index].separatorRect(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 2573 | } | - | ||||||||||||||||||||||||
| 2574 | - | |||||||||||||||||||||||||
| 2575 | bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem) | - | ||||||||||||||||||||||||
| 2576 | { | - | ||||||||||||||||||||||||
| 2577 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2578 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2579 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2580 | return docks[index].insertGap(path.mid(1), dockWidgetItem); never executed: return docks[index].insertGap(path.mid(1), dockWidgetItem); | 0 | ||||||||||||||||||||||||
| 2581 | } | - | ||||||||||||||||||||||||
| 2582 | - | |||||||||||||||||||||||||
| 2583 | QLayoutItem *QDockAreaLayout::plug(const QList<int> &path) | - | ||||||||||||||||||||||||
| 2584 | { | - | ||||||||||||||||||||||||
| 2585 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2586 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2587 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2588 | QLayoutItem *item = docks[index].plug(path.mid(1)); | - | ||||||||||||||||||||||||
| 2589 | docks[index].reparentWidgets(mainWindow); | - | ||||||||||||||||||||||||
| 2590 | return item; never executed: return item; | 0 | ||||||||||||||||||||||||
| 2591 | } | - | ||||||||||||||||||||||||
| 2592 | - | |||||||||||||||||||||||||
| 2593 | QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path) | - | ||||||||||||||||||||||||
| 2594 | { | - | ||||||||||||||||||||||||
| 2595 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2596 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2597 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2598 | return docks[index].unplug(path.mid(1)); never executed: return docks[index].unplug(path.mid(1)); | 0 | ||||||||||||||||||||||||
| 2599 | } | - | ||||||||||||||||||||||||
| 2600 | - | |||||||||||||||||||||||||
| 2601 | void QDockAreaLayout::remove(const QList<int> &path) | - | ||||||||||||||||||||||||
| 2602 | { | - | ||||||||||||||||||||||||
| 2603 | Q_ASSERT(!path.isEmpty()); | - | ||||||||||||||||||||||||
| 2604 | const int index = path.first(); | - | ||||||||||||||||||||||||
| 2605 | Q_ASSERT(index >= 0 && index < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 2606 | docks[index].remove(path.mid(1)); | - | ||||||||||||||||||||||||
| 2607 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2608 | - | |||||||||||||||||||||||||
| 2609 | void QDockAreaLayout::removePlaceHolder(const QString &name) | - | ||||||||||||||||||||||||
| 2610 | { | - | ||||||||||||||||||||||||
| 2611 | QList<int> index = indexOfPlaceHolder(name); | - | ||||||||||||||||||||||||
| 2612 | if (!index.isEmpty())
| 0 | ||||||||||||||||||||||||
| 2613 | remove(index); never executed: remove(index); | 0 | ||||||||||||||||||||||||
| 2614 | foreach (QDockWidgetGroupWindow *dwgw, mainWindow->findChildren<QDockWidgetGroupWindow *>( | - | ||||||||||||||||||||||||
| 2615 | QString(), Qt::FindDirectChildrenOnly)) { | - | ||||||||||||||||||||||||
| 2616 | index = dwgw->layoutInfo()->indexOfPlaceHolder(name); | - | ||||||||||||||||||||||||
| 2617 | if (!index.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2618 | dwgw->layoutInfo()->remove(index); | - | ||||||||||||||||||||||||
| 2619 | dwgw->destroyOrHideIfEmpty(); | - | ||||||||||||||||||||||||
| 2620 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2621 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2622 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2623 | - | |||||||||||||||||||||||||
| 2624 | static never executed: inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); }return qMax(i1, qMax(i2, i3));never executed: return qMax(i1, qMax(i2, i3)); | 0 | ||||||||||||||||||||||||
| 2625 | - | |||||||||||||||||||||||||
| 2626 | void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, | - | ||||||||||||||||||||||||
| 2627 | QVector<QLayoutStruct> *_hor_struct_list) | - | ||||||||||||||||||||||||
| 2628 | { | - | ||||||||||||||||||||||||
| 2629 | QSize center_hint(0, 0); | - | ||||||||||||||||||||||||
| 2630 | QSize center_min(0, 0); | - | ||||||||||||||||||||||||
| 2631 | QSize center_max(0, 0); | - | ||||||||||||||||||||||||
| 2632 | const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
| 0 | ||||||||||||||||||||||||
| 2633 | if (have_central) {
| 0 | ||||||||||||||||||||||||
| 2634 | center_hint = centralWidgetRect.size(); | - | ||||||||||||||||||||||||
| 2635 | if (!center_hint.isValid())
| 0 | ||||||||||||||||||||||||
| 2636 | center_hint = centralWidgetItem->sizeHint(); never executed: center_hint = centralWidgetItem->sizeHint(); | 0 | ||||||||||||||||||||||||
| 2637 | center_min = centralWidgetItem->minimumSize(); | - | ||||||||||||||||||||||||
| 2638 | center_max = centralWidgetItem->maximumSize(); | - | ||||||||||||||||||||||||
| 2639 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2640 | - | |||||||||||||||||||||||||
| 2641 | QRect center_rect = rect; | - | ||||||||||||||||||||||||
| 2642 | if (!docks[QInternal::LeftDock].isEmpty())
| 0 | ||||||||||||||||||||||||
| 2643 | center_rect.setLeft(rect.left() + docks[QInternal::LeftDock].rect.width() + sep); never executed: center_rect.setLeft(rect.left() + docks[QInternal::LeftDock].rect.width() + sep); | 0 | ||||||||||||||||||||||||
| 2644 | if (!docks[QInternal::TopDock].isEmpty())
| 0 | ||||||||||||||||||||||||
| 2645 | center_rect.setTop(rect.top() + docks[QInternal::TopDock].rect.height() + sep); never executed: center_rect.setTop(rect.top() + docks[QInternal::TopDock].rect.height() + sep); | 0 | ||||||||||||||||||||||||
| 2646 | if (!docks[QInternal::RightDock].isEmpty())
| 0 | ||||||||||||||||||||||||
| 2647 | center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep); never executed: center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep); | 0 | ||||||||||||||||||||||||
| 2648 | if (!docks[QInternal::BottomDock].isEmpty())
| 0 | ||||||||||||||||||||||||
| 2649 | center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep); never executed: center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep); | 0 | ||||||||||||||||||||||||
| 2650 | - | |||||||||||||||||||||||||
| 2651 | QSize left_hint = docks[QInternal::LeftDock].size(); | - | ||||||||||||||||||||||||
| 2652 | if (left_hint.isNull() || fallbackToSizeHints)
| 0 | ||||||||||||||||||||||||
| 2653 | left_hint = docks[QInternal::LeftDock].sizeHint(); never executed: left_hint = docks[QInternal::LeftDock].sizeHint(); | 0 | ||||||||||||||||||||||||
| 2654 | QSize left_min = docks[QInternal::LeftDock].minimumSize(); | - | ||||||||||||||||||||||||
| 2655 | QSize left_max = docks[QInternal::LeftDock].maximumSize(); | - | ||||||||||||||||||||||||
| 2656 | left_hint = left_hint.boundedTo(left_max).expandedTo(left_min); | - | ||||||||||||||||||||||||
| 2657 | - | |||||||||||||||||||||||||
| 2658 | QSize right_hint = docks[QInternal::RightDock].size(); | - | ||||||||||||||||||||||||
| 2659 | if (right_hint.isNull() || fallbackToSizeHints)
| 0 | ||||||||||||||||||||||||
| 2660 | right_hint = docks[QInternal::RightDock].sizeHint(); never executed: right_hint = docks[QInternal::RightDock].sizeHint(); | 0 | ||||||||||||||||||||||||
| 2661 | QSize right_min = docks[QInternal::RightDock].minimumSize(); | - | ||||||||||||||||||||||||
| 2662 | QSize right_max = docks[QInternal::RightDock].maximumSize(); | - | ||||||||||||||||||||||||
| 2663 | right_hint = right_hint.boundedTo(right_max).expandedTo(right_min); | - | ||||||||||||||||||||||||
| 2664 | - | |||||||||||||||||||||||||
| 2665 | QSize top_hint = docks[QInternal::TopDock].size(); | - | ||||||||||||||||||||||||
| 2666 | if (top_hint.isNull() || fallbackToSizeHints)
| 0 | ||||||||||||||||||||||||
| 2667 | top_hint = docks[QInternal::TopDock].sizeHint(); never executed: top_hint = docks[QInternal::TopDock].sizeHint(); | 0 | ||||||||||||||||||||||||
| 2668 | QSize top_min = docks[QInternal::TopDock].minimumSize(); | - | ||||||||||||||||||||||||
| 2669 | QSize top_max = docks[QInternal::TopDock].maximumSize(); | - | ||||||||||||||||||||||||
| 2670 | top_hint = top_hint.boundedTo(top_max).expandedTo(top_min); | - | ||||||||||||||||||||||||
| 2671 | - | |||||||||||||||||||||||||
| 2672 | QSize bottom_hint = docks[QInternal::BottomDock].size(); | - | ||||||||||||||||||||||||
| 2673 | if (bottom_hint.isNull() || fallbackToSizeHints)
| 0 | ||||||||||||||||||||||||
| 2674 | bottom_hint = docks[QInternal::BottomDock].sizeHint(); never executed: bottom_hint = docks[QInternal::BottomDock].sizeHint(); | 0 | ||||||||||||||||||||||||
| 2675 | QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); | - | ||||||||||||||||||||||||
| 2676 | QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); | - | ||||||||||||||||||||||||
| 2677 | bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); | - | ||||||||||||||||||||||||
| 2678 | - | |||||||||||||||||||||||||
| 2679 | if (_ver_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2680 | QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list; | - | ||||||||||||||||||||||||
| 2681 | ver_struct_list.resize(3); | - | ||||||||||||||||||||||||
| 2682 | - | |||||||||||||||||||||||||
| 2683 | // top -------------------------------------------------- | - | ||||||||||||||||||||||||
| 2684 | ver_struct_list[0].init(); | - | ||||||||||||||||||||||||
| 2685 | ver_struct_list[0].stretch = 0; | - | ||||||||||||||||||||||||
| 2686 | ver_struct_list[0].sizeHint = top_hint.height(); | - | ||||||||||||||||||||||||
| 2687 | ver_struct_list[0].minimumSize = top_min.height(); | - | ||||||||||||||||||||||||
| 2688 | ver_struct_list[0].maximumSize = top_max.height(); | - | ||||||||||||||||||||||||
| 2689 | ver_struct_list[0].expansive = false; | - | ||||||||||||||||||||||||
| 2690 | ver_struct_list[0].empty = docks[QInternal::TopDock].isEmpty(); | - | ||||||||||||||||||||||||
| 2691 | ver_struct_list[0].pos = docks[QInternal::TopDock].rect.top(); | - | ||||||||||||||||||||||||
| 2692 | ver_struct_list[0].size = docks[QInternal::TopDock].rect.height(); | - | ||||||||||||||||||||||||
| 2693 | - | |||||||||||||||||||||||||
| 2694 | // center -------------------------------------------------- | - | ||||||||||||||||||||||||
| 2695 | ver_struct_list[1].init(); | - | ||||||||||||||||||||||||
| 2696 | ver_struct_list[1].stretch = center_hint.height(); | - | ||||||||||||||||||||||||
| 2697 | - | |||||||||||||||||||||||||
| 2698 | bool tl_significant = corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2699 | || docks[QInternal::TopDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2700 | bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2701 | || docks[QInternal::BottomDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2702 | bool tr_significant = corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2703 | || docks[QInternal::TopDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2704 | bool br_significant = corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2705 | || docks[QInternal::BottomDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2706 | - | |||||||||||||||||||||||||
| 2707 | int left = (tl_significant && bl_significant) ? left_hint.height() : 0;
| 0 | ||||||||||||||||||||||||
| 2708 | int right = (tr_significant && br_significant) ? right_hint.height() : 0;
| 0 | ||||||||||||||||||||||||
| 2709 | ver_struct_list[1].sizeHint = qMax(left, center_hint.height(), right); | - | ||||||||||||||||||||||||
| 2710 | - | |||||||||||||||||||||||||
| 2711 | left = (tl_significant && bl_significant) ? left_min.height() : 0;
| 0 | ||||||||||||||||||||||||
| 2712 | right = (tr_significant && br_significant) ? right_min.height() : 0;
| 0 | ||||||||||||||||||||||||
| 2713 | ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right); | - | ||||||||||||||||||||||||
| 2714 | ver_struct_list[1].maximumSize = center_max.height(); | - | ||||||||||||||||||||||||
| 2715 | ver_struct_list[1].expansive = have_central; | - | ||||||||||||||||||||||||
| 2716 | ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()
| 0 | ||||||||||||||||||||||||
| 2717 | && !have_central
| 0 | ||||||||||||||||||||||||
| 2718 | && docks[QInternal::RightDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2719 | ver_struct_list[1].pos = center_rect.top(); | - | ||||||||||||||||||||||||
| 2720 | ver_struct_list[1].size = center_rect.height(); | - | ||||||||||||||||||||||||
| 2721 | - | |||||||||||||||||||||||||
| 2722 | // bottom -------------------------------------------------- | - | ||||||||||||||||||||||||
| 2723 | ver_struct_list[2].init(); | - | ||||||||||||||||||||||||
| 2724 | ver_struct_list[2].stretch = 0; | - | ||||||||||||||||||||||||
| 2725 | ver_struct_list[2].sizeHint = bottom_hint.height(); | - | ||||||||||||||||||||||||
| 2726 | ver_struct_list[2].minimumSize = bottom_min.height(); | - | ||||||||||||||||||||||||
| 2727 | ver_struct_list[2].maximumSize = bottom_max.height(); | - | ||||||||||||||||||||||||
| 2728 | ver_struct_list[2].expansive = false; | - | ||||||||||||||||||||||||
| 2729 | ver_struct_list[2].empty = docks[QInternal::BottomDock].isEmpty(); | - | ||||||||||||||||||||||||
| 2730 | ver_struct_list[2].pos = docks[QInternal::BottomDock].rect.top(); | - | ||||||||||||||||||||||||
| 2731 | ver_struct_list[2].size = docks[QInternal::BottomDock].rect.height(); | - | ||||||||||||||||||||||||
| 2732 | - | |||||||||||||||||||||||||
| 2733 | for (int i = 0; i < 3; ++i) {
| 0 | ||||||||||||||||||||||||
| 2734 | ver_struct_list[i].sizeHint | - | ||||||||||||||||||||||||
| 2735 | = qMax(ver_struct_list[i].sizeHint, ver_struct_list[i].minimumSize); | - | ||||||||||||||||||||||||
| 2736 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2737 | if (have_central && ver_struct_list[0].empty && ver_struct_list[2].empty)
| 0 | ||||||||||||||||||||||||
| 2738 | ver_struct_list[1].maximumSize = QWIDGETSIZE_MAX; never executed: ver_struct_list[1].maximumSize = ((1<<24)-1); | 0 | ||||||||||||||||||||||||
| 2739 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2740 | - | |||||||||||||||||||||||||
| 2741 | if (_hor_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2742 | QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list; | - | ||||||||||||||||||||||||
| 2743 | hor_struct_list.resize(3); | - | ||||||||||||||||||||||||
| 2744 | - | |||||||||||||||||||||||||
| 2745 | // left -------------------------------------------------- | - | ||||||||||||||||||||||||
| 2746 | hor_struct_list[0].init(); | - | ||||||||||||||||||||||||
| 2747 | hor_struct_list[0].stretch = 0; | - | ||||||||||||||||||||||||
| 2748 | hor_struct_list[0].sizeHint = left_hint.width(); | - | ||||||||||||||||||||||||
| 2749 | hor_struct_list[0].minimumSize = left_min.width(); | - | ||||||||||||||||||||||||
| 2750 | hor_struct_list[0].maximumSize = left_max.width(); | - | ||||||||||||||||||||||||
| 2751 | hor_struct_list[0].expansive = false; | - | ||||||||||||||||||||||||
| 2752 | hor_struct_list[0].empty = docks[QInternal::LeftDock].isEmpty(); | - | ||||||||||||||||||||||||
| 2753 | hor_struct_list[0].pos = docks[QInternal::LeftDock].rect.left(); | - | ||||||||||||||||||||||||
| 2754 | hor_struct_list[0].size = docks[QInternal::LeftDock].rect.width(); | - | ||||||||||||||||||||||||
| 2755 | - | |||||||||||||||||||||||||
| 2756 | // center -------------------------------------------------- | - | ||||||||||||||||||||||||
| 2757 | hor_struct_list[1].init(); | - | ||||||||||||||||||||||||
| 2758 | hor_struct_list[1].stretch = center_hint.width(); | - | ||||||||||||||||||||||||
| 2759 | - | |||||||||||||||||||||||||
| 2760 | bool tl_significant = corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2761 | || docks[QInternal::LeftDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2762 | bool tr_significant = corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2763 | || docks[QInternal::RightDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2764 | bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2765 | || docks[QInternal::LeftDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2766 | bool br_significant = corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 2767 | || docks[QInternal::RightDock].isEmpty();
| 0 | ||||||||||||||||||||||||
| 2768 | - | |||||||||||||||||||||||||
| 2769 | int top = (tl_significant && tr_significant) ? top_hint.width() : 0;
| 0 | ||||||||||||||||||||||||
| 2770 | int bottom = (bl_significant && br_significant) ? bottom_hint.width() : 0;
| 0 | ||||||||||||||||||||||||
| 2771 | hor_struct_list[1].sizeHint = qMax(top, center_hint.width(), bottom); | - | ||||||||||||||||||||||||
| 2772 | - | |||||||||||||||||||||||||
| 2773 | top = (tl_significant && tr_significant) ? top_min.width() : 0;
| 0 | ||||||||||||||||||||||||
| 2774 | bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
| 0 | ||||||||||||||||||||||||
| 2775 | hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom); | - | ||||||||||||||||||||||||
| 2776 | - | |||||||||||||||||||||||||
| 2777 | hor_struct_list[1].maximumSize = center_max.width(); | - | ||||||||||||||||||||||||
| 2778 | hor_struct_list[1].expansive = have_central; | - | ||||||||||||||||||||||||
| 2779 | hor_struct_list[1].empty = !have_central; | - | ||||||||||||||||||||||||
| 2780 | hor_struct_list[1].pos = center_rect.left(); | - | ||||||||||||||||||||||||
| 2781 | hor_struct_list[1].size = center_rect.width(); | - | ||||||||||||||||||||||||
| 2782 | - | |||||||||||||||||||||||||
| 2783 | // right -------------------------------------------------- | - | ||||||||||||||||||||||||
| 2784 | hor_struct_list[2].init(); | - | ||||||||||||||||||||||||
| 2785 | hor_struct_list[2].stretch = 0; | - | ||||||||||||||||||||||||
| 2786 | hor_struct_list[2].sizeHint = right_hint.width(); | - | ||||||||||||||||||||||||
| 2787 | hor_struct_list[2].minimumSize = right_min.width(); | - | ||||||||||||||||||||||||
| 2788 | hor_struct_list[2].maximumSize = right_max.width(); | - | ||||||||||||||||||||||||
| 2789 | hor_struct_list[2].expansive = false; | - | ||||||||||||||||||||||||
| 2790 | hor_struct_list[2].empty = docks[QInternal::RightDock].isEmpty(); | - | ||||||||||||||||||||||||
| 2791 | hor_struct_list[2].pos = docks[QInternal::RightDock].rect.left(); | - | ||||||||||||||||||||||||
| 2792 | hor_struct_list[2].size = docks[QInternal::RightDock].rect.width(); | - | ||||||||||||||||||||||||
| 2793 | - | |||||||||||||||||||||||||
| 2794 | for (int i = 0; i < 3; ++i) {
| 0 | ||||||||||||||||||||||||
| 2795 | hor_struct_list[i].sizeHint | - | ||||||||||||||||||||||||
| 2796 | = qMax(hor_struct_list[i].sizeHint, hor_struct_list[i].minimumSize); | - | ||||||||||||||||||||||||
| 2797 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2798 | if (have_central && hor_struct_list[0].empty && hor_struct_list[2].empty)
| 0 | ||||||||||||||||||||||||
| 2799 | hor_struct_list[1].maximumSize = QWIDGETSIZE_MAX; never executed: hor_struct_list[1].maximumSize = ((1<<24)-1); | 0 | ||||||||||||||||||||||||
| 2800 | - | |||||||||||||||||||||||||
| 2801 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2802 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2803 | - | |||||||||||||||||||||||||
| 2804 | void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, | - | ||||||||||||||||||||||||
| 2805 | QVector<QLayoutStruct> *hor_struct_list) | - | ||||||||||||||||||||||||
| 2806 | { | - | ||||||||||||||||||||||||
| 2807 | - | |||||||||||||||||||||||||
| 2808 | // top --------------------------------------------------- | - | ||||||||||||||||||||||||
| 2809 | - | |||||||||||||||||||||||||
| 2810 | if (!docks[QInternal::TopDock].isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2811 | QRect r = docks[QInternal::TopDock].rect; | - | ||||||||||||||||||||||||
| 2812 | if (hor_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2813 | r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea | - | ||||||||||||||||||||||||
| 2814 | || docks[QInternal::LeftDock].isEmpty() | - | ||||||||||||||||||||||||
| 2815 | ? rect.left() : hor_struct_list->at(1).pos); | - | ||||||||||||||||||||||||
| 2816 | r.setRight(corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea | - | ||||||||||||||||||||||||
| 2817 | || docks[QInternal::RightDock].isEmpty() | - | ||||||||||||||||||||||||
| 2818 | ? rect.right() : hor_struct_list->at(2).pos - sep - 1); | - | ||||||||||||||||||||||||
| 2819 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2820 | if (ver_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2821 | r.setTop(rect.top()); | - | ||||||||||||||||||||||||
| 2822 | r.setBottom(ver_struct_list->at(1).pos - sep - 1); | - | ||||||||||||||||||||||||
| 2823 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2824 | docks[QInternal::TopDock].rect = r; | - | ||||||||||||||||||||||||
| 2825 | docks[QInternal::TopDock].fitItems(); | - | ||||||||||||||||||||||||
| 2826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2827 | - | |||||||||||||||||||||||||
| 2828 | // bottom --------------------------------------------------- | - | ||||||||||||||||||||||||
| 2829 | - | |||||||||||||||||||||||||
| 2830 | if (!docks[QInternal::BottomDock].isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2831 | QRect r = docks[QInternal::BottomDock].rect; | - | ||||||||||||||||||||||||
| 2832 | if (hor_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2833 | r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea | - | ||||||||||||||||||||||||
| 2834 | || docks[QInternal::LeftDock].isEmpty() | - | ||||||||||||||||||||||||
| 2835 | ? rect.left() : hor_struct_list->at(1).pos); | - | ||||||||||||||||||||||||
| 2836 | r.setRight(corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea | - | ||||||||||||||||||||||||
| 2837 | || docks[QInternal::RightDock].isEmpty() | - | ||||||||||||||||||||||||
| 2838 | ? rect.right() : hor_struct_list->at(2).pos - sep - 1); | - | ||||||||||||||||||||||||
| 2839 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2840 | if (ver_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2841 | r.setTop(ver_struct_list->at(2).pos); | - | ||||||||||||||||||||||||
| 2842 | r.setBottom(rect.bottom()); | - | ||||||||||||||||||||||||
| 2843 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2844 | docks[QInternal::BottomDock].rect = r; | - | ||||||||||||||||||||||||
| 2845 | docks[QInternal::BottomDock].fitItems(); | - | ||||||||||||||||||||||||
| 2846 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2847 | - | |||||||||||||||||||||||||
| 2848 | // left --------------------------------------------------- | - | ||||||||||||||||||||||||
| 2849 | - | |||||||||||||||||||||||||
| 2850 | if (!docks[QInternal::LeftDock].isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2851 | QRect r = docks[QInternal::LeftDock].rect; | - | ||||||||||||||||||||||||
| 2852 | if (hor_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2853 | r.setLeft(rect.left()); | - | ||||||||||||||||||||||||
| 2854 | r.setRight(hor_struct_list->at(1).pos - sep - 1); | - | ||||||||||||||||||||||||
| 2855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2856 | if (ver_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2857 | r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea | - | ||||||||||||||||||||||||
| 2858 | || docks[QInternal::TopDock].isEmpty() | - | ||||||||||||||||||||||||
| 2859 | ? rect.top() : ver_struct_list->at(1).pos); | - | ||||||||||||||||||||||||
| 2860 | r.setBottom(corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea | - | ||||||||||||||||||||||||
| 2861 | || docks[QInternal::BottomDock].isEmpty() | - | ||||||||||||||||||||||||
| 2862 | ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1); | - | ||||||||||||||||||||||||
| 2863 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2864 | docks[QInternal::LeftDock].rect = r; | - | ||||||||||||||||||||||||
| 2865 | docks[QInternal::LeftDock].fitItems(); | - | ||||||||||||||||||||||||
| 2866 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2867 | - | |||||||||||||||||||||||||
| 2868 | // right --------------------------------------------------- | - | ||||||||||||||||||||||||
| 2869 | - | |||||||||||||||||||||||||
| 2870 | if (!docks[QInternal::RightDock].isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2871 | QRect r = docks[QInternal::RightDock].rect; | - | ||||||||||||||||||||||||
| 2872 | if (hor_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2873 | r.setLeft(hor_struct_list->at(2).pos); | - | ||||||||||||||||||||||||
| 2874 | r.setRight(rect.right()); | - | ||||||||||||||||||||||||
| 2875 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2876 | if (ver_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2877 | r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea | - | ||||||||||||||||||||||||
| 2878 | || docks[QInternal::TopDock].isEmpty() | - | ||||||||||||||||||||||||
| 2879 | ? rect.top() : ver_struct_list->at(1).pos); | - | ||||||||||||||||||||||||
| 2880 | r.setBottom(corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea | - | ||||||||||||||||||||||||
| 2881 | || docks[QInternal::BottomDock].isEmpty() | - | ||||||||||||||||||||||||
| 2882 | ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1); | - | ||||||||||||||||||||||||
| 2883 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2884 | docks[QInternal::RightDock].rect = r; | - | ||||||||||||||||||||||||
| 2885 | docks[QInternal::RightDock].fitItems(); | - | ||||||||||||||||||||||||
| 2886 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2887 | - | |||||||||||||||||||||||||
| 2888 | // center --------------------------------------------------- | - | ||||||||||||||||||||||||
| 2889 | - | |||||||||||||||||||||||||
| 2890 | if (hor_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2891 | centralWidgetRect.setLeft(hor_struct_list->at(1).pos); | - | ||||||||||||||||||||||||
| 2892 | centralWidgetRect.setWidth(hor_struct_list->at(1).size); | - | ||||||||||||||||||||||||
| 2893 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2894 | if (ver_struct_list != 0) {
| 0 | ||||||||||||||||||||||||
| 2895 | centralWidgetRect.setTop(ver_struct_list->at(1).pos); | - | ||||||||||||||||||||||||
| 2896 | centralWidgetRect.setHeight(ver_struct_list->at(1).size); | - | ||||||||||||||||||||||||
| 2897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2898 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2899 | - | |||||||||||||||||||||||||
| 2900 | void QDockAreaLayout::fitLayout() | - | ||||||||||||||||||||||||
| 2901 | { | - | ||||||||||||||||||||||||
| 2902 | QVector<QLayoutStruct> ver_struct_list(3); | - | ||||||||||||||||||||||||
| 2903 | QVector<QLayoutStruct> hor_struct_list(3); | - | ||||||||||||||||||||||||
| 2904 | getGrid(&ver_struct_list, &hor_struct_list); | - | ||||||||||||||||||||||||
| 2905 | - | |||||||||||||||||||||||||
| 2906 | qGeomCalc(ver_struct_list, 0, 3, rect.top(), rect.height(), sep); | - | ||||||||||||||||||||||||
| 2907 | qGeomCalc(hor_struct_list, 0, 3, rect.left(), rect.width(), sep); | - | ||||||||||||||||||||||||
| 2908 | - | |||||||||||||||||||||||||
| 2909 | setGrid(&ver_struct_list, &hor_struct_list); | - | ||||||||||||||||||||||||
| 2910 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2911 | - | |||||||||||||||||||||||||
| 2912 | void QDockAreaLayout::clear() | - | ||||||||||||||||||||||||
| 2913 | { | - | ||||||||||||||||||||||||
| 2914 | for (int i = 0; i < QInternal::DockCount; ++i)
| 0 | ||||||||||||||||||||||||
| 2915 | docks[i].clear(); never executed: docks[i].clear(); | 0 | ||||||||||||||||||||||||
| 2916 | - | |||||||||||||||||||||||||
| 2917 | rect = QRect(); | - | ||||||||||||||||||||||||
| 2918 | centralWidgetRect = QRect(); | - | ||||||||||||||||||||||||
| 2919 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2920 | - | |||||||||||||||||||||||||
| 2921 | QSize QDockAreaLayout::sizeHint() const | - | ||||||||||||||||||||||||
| 2922 | { | - | ||||||||||||||||||||||||
| 2923 | int left_sep = 0; | - | ||||||||||||||||||||||||
| 2924 | int right_sep = 0; | - | ||||||||||||||||||||||||
| 2925 | int top_sep = 0; | - | ||||||||||||||||||||||||
| 2926 | int bottom_sep = 0; | - | ||||||||||||||||||||||||
| 2927 | - | |||||||||||||||||||||||||
| 2928 | if (centralWidgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 2929 | left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2930 | right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2931 | top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2932 | bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2933 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2934 | - | |||||||||||||||||||||||||
| 2935 | QSize left = docks[QInternal::LeftDock].sizeHint() + QSize(left_sep, 0); | - | ||||||||||||||||||||||||
| 2936 | QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0); | - | ||||||||||||||||||||||||
| 2937 | QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep); | - | ||||||||||||||||||||||||
| 2938 | QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep); | - | ||||||||||||||||||||||||
| 2939 | QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint();
| 0 | ||||||||||||||||||||||||
| 2940 | - | |||||||||||||||||||||||||
| 2941 | int row1 = top.width(); | - | ||||||||||||||||||||||||
| 2942 | int row2 = left.width() + center.width() + right.width(); | - | ||||||||||||||||||||||||
| 2943 | int row3 = bottom.width(); | - | ||||||||||||||||||||||||
| 2944 | int col1 = left.height(); | - | ||||||||||||||||||||||||
| 2945 | int col2 = top.height() + center.height() + bottom.height(); | - | ||||||||||||||||||||||||
| 2946 | int col3 = right.height(); | - | ||||||||||||||||||||||||
| 2947 | - | |||||||||||||||||||||||||
| 2948 | if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 2949 | row1 += left.width(); never executed: row1 += left.width(); | 0 | ||||||||||||||||||||||||
| 2950 | else | - | ||||||||||||||||||||||||
| 2951 | col1 += top.height(); never executed: col1 += top.height(); | 0 | ||||||||||||||||||||||||
| 2952 | - | |||||||||||||||||||||||||
| 2953 | if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 2954 | row1 += right.width(); never executed: row1 += right.width(); | 0 | ||||||||||||||||||||||||
| 2955 | else | - | ||||||||||||||||||||||||
| 2956 | col3 += top.height(); never executed: col3 += top.height(); | 0 | ||||||||||||||||||||||||
| 2957 | - | |||||||||||||||||||||||||
| 2958 | if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 2959 | row3 += left.width(); never executed: row3 += left.width(); | 0 | ||||||||||||||||||||||||
| 2960 | else | - | ||||||||||||||||||||||||
| 2961 | col1 += bottom.height(); never executed: col1 += bottom.height(); | 0 | ||||||||||||||||||||||||
| 2962 | - | |||||||||||||||||||||||||
| 2963 | if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 2964 | row3 += right.width(); never executed: row3 += right.width(); | 0 | ||||||||||||||||||||||||
| 2965 | else | - | ||||||||||||||||||||||||
| 2966 | col3 += bottom.height(); never executed: col3 += bottom.height(); | 0 | ||||||||||||||||||||||||
| 2967 | - | |||||||||||||||||||||||||
| 2968 | return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3)); never executed: return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3)); | 0 | ||||||||||||||||||||||||
| 2969 | } | - | ||||||||||||||||||||||||
| 2970 | - | |||||||||||||||||||||||||
| 2971 | QSize QDockAreaLayout::minimumSize() const | - | ||||||||||||||||||||||||
| 2972 | { | - | ||||||||||||||||||||||||
| 2973 | int left_sep = 0; | - | ||||||||||||||||||||||||
| 2974 | int right_sep = 0; | - | ||||||||||||||||||||||||
| 2975 | int top_sep = 0; | - | ||||||||||||||||||||||||
| 2976 | int bottom_sep = 0; | - | ||||||||||||||||||||||||
| 2977 | - | |||||||||||||||||||||||||
| 2978 | if (centralWidgetItem != 0) {
| 0 | ||||||||||||||||||||||||
| 2979 | left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2980 | right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2981 | top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2982 | bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
| 0 | ||||||||||||||||||||||||
| 2983 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2984 | - | |||||||||||||||||||||||||
| 2985 | QSize left = docks[QInternal::LeftDock].minimumSize() + QSize(left_sep, 0); | - | ||||||||||||||||||||||||
| 2986 | QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0); | - | ||||||||||||||||||||||||
| 2987 | QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep); | - | ||||||||||||||||||||||||
| 2988 | QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep); | - | ||||||||||||||||||||||||
| 2989 | QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize();
| 0 | ||||||||||||||||||||||||
| 2990 | - | |||||||||||||||||||||||||
| 2991 | int row1 = top.width(); | - | ||||||||||||||||||||||||
| 2992 | int row2 = left.width() + center.width() + right.width(); | - | ||||||||||||||||||||||||
| 2993 | int row3 = bottom.width(); | - | ||||||||||||||||||||||||
| 2994 | int col1 = left.height(); | - | ||||||||||||||||||||||||
| 2995 | int col2 = top.height() + center.height() + bottom.height(); | - | ||||||||||||||||||||||||
| 2996 | int col3 = right.height(); | - | ||||||||||||||||||||||||
| 2997 | - | |||||||||||||||||||||||||
| 2998 | if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 2999 | row1 += left.width(); never executed: row1 += left.width(); | 0 | ||||||||||||||||||||||||
| 3000 | else | - | ||||||||||||||||||||||||
| 3001 | col1 += top.height(); never executed: col1 += top.height(); | 0 | ||||||||||||||||||||||||
| 3002 | - | |||||||||||||||||||||||||
| 3003 | if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 3004 | row1 += right.width(); never executed: row1 += right.width(); | 0 | ||||||||||||||||||||||||
| 3005 | else | - | ||||||||||||||||||||||||
| 3006 | col3 += top.height(); never executed: col3 += top.height(); | 0 | ||||||||||||||||||||||||
| 3007 | - | |||||||||||||||||||||||||
| 3008 | if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 3009 | row3 += left.width(); never executed: row3 += left.width(); | 0 | ||||||||||||||||||||||||
| 3010 | else | - | ||||||||||||||||||||||||
| 3011 | col1 += bottom.height(); never executed: col1 += bottom.height(); | 0 | ||||||||||||||||||||||||
| 3012 | - | |||||||||||||||||||||||||
| 3013 | if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)
| 0 | ||||||||||||||||||||||||
| 3014 | row3 += right.width(); never executed: row3 += right.width(); | 0 | ||||||||||||||||||||||||
| 3015 | else | - | ||||||||||||||||||||||||
| 3016 | col3 += bottom.height(); never executed: col3 += bottom.height(); | 0 | ||||||||||||||||||||||||
| 3017 | - | |||||||||||||||||||||||||
| 3018 | return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3)); never executed: return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3)); | 0 | ||||||||||||||||||||||||
| 3019 | } | - | ||||||||||||||||||||||||
| 3020 | - | |||||||||||||||||||||||||
| 3021 | /*! \internal | - | ||||||||||||||||||||||||
| 3022 | Try to fit the given rectangle \a rect on the screen which contains | - | ||||||||||||||||||||||||
| 3023 | the window \a widget. | - | ||||||||||||||||||||||||
| 3024 | Used to compute the geometry of a dragged a dock widget that should | - | ||||||||||||||||||||||||
| 3025 | be shown with \a rect, but needs to be visible on the screen | - | ||||||||||||||||||||||||
| 3026 | */ | - | ||||||||||||||||||||||||
| 3027 | QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget) | - | ||||||||||||||||||||||||
| 3028 | { | - | ||||||||||||||||||||||||
| 3029 | QRect desktop; | - | ||||||||||||||||||||||||
| 3030 | QDesktopWidget *desktopW = QApplication::desktop(); | - | ||||||||||||||||||||||||
| 3031 | if (desktopW->isVirtualDesktop())
| 0 | ||||||||||||||||||||||||
| 3032 | desktop = desktopW->screenGeometry(rect.topLeft()); never executed: desktop = desktopW->screenGeometry(rect.topLeft()); | 0 | ||||||||||||||||||||||||
| 3033 | else | - | ||||||||||||||||||||||||
| 3034 | desktop = desktopW->screenGeometry(widget); never executed: desktop = desktopW->screenGeometry(widget); | 0 | ||||||||||||||||||||||||
| 3035 | - | |||||||||||||||||||||||||
| 3036 | if (desktop.isValid()) {
| 0 | ||||||||||||||||||||||||
| 3037 | rect.setWidth(qMin(rect.width(), desktop.width())); | - | ||||||||||||||||||||||||
| 3038 | rect.setHeight(qMin(rect.height(), desktop.height())); | - | ||||||||||||||||||||||||
| 3039 | rect.moveLeft(qMax(rect.left(), desktop.left())); | - | ||||||||||||||||||||||||
| 3040 | rect.moveTop(qMax(rect.top(), desktop.top())); | - | ||||||||||||||||||||||||
| 3041 | rect.moveRight(qMin(rect.right(), desktop.right())); | - | ||||||||||||||||||||||||
| 3042 | rect.moveBottom(qMin(rect.bottom(), desktop.bottom())); | - | ||||||||||||||||||||||||
| 3043 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3044 | - | |||||||||||||||||||||||||
| 3045 | return rect; never executed: return rect; | 0 | ||||||||||||||||||||||||
| 3046 | } | - | ||||||||||||||||||||||||
| 3047 | - | |||||||||||||||||||||||||
| 3048 | bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) | - | ||||||||||||||||||||||||
| 3049 | { | - | ||||||||||||||||||||||||
| 3050 | QDockAreaLayoutItem *item = 0; | - | ||||||||||||||||||||||||
| 3051 | foreach (QDockWidgetGroupWindow *dwgw, mainWindow->findChildren<QDockWidgetGroupWindow *>( | - | ||||||||||||||||||||||||
| 3052 | QString(), Qt::FindDirectChildrenOnly)) { | - | ||||||||||||||||||||||||
| 3053 | QList<int> index = dwgw->layoutInfo()->indexOfPlaceHolder(dockWidget->objectName()); | - | ||||||||||||||||||||||||
| 3054 | if (!index.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 3055 | dockWidget->setParent(dwgw); | - | ||||||||||||||||||||||||
| 3056 | item = const_cast<QDockAreaLayoutItem *>(&dwgw->layoutInfo()->item(index)); | - | ||||||||||||||||||||||||
| 3057 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3058 | } | - | ||||||||||||||||||||||||
| 3059 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3060 | if (!item) {
| 0 | ||||||||||||||||||||||||
| 3061 | QList<int> index = indexOfPlaceHolder(dockWidget->objectName()); | - | ||||||||||||||||||||||||
| 3062 | if (index.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3063 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 3064 | item = const_cast<QDockAreaLayoutItem *>(&this->item(index)); | - | ||||||||||||||||||||||||
| 3065 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3066 | - | |||||||||||||||||||||||||
| 3067 | QPlaceHolderItem *placeHolder = item->placeHolderItem; | - | ||||||||||||||||||||||||
| 3068 | Q_ASSERT(placeHolder != 0); | - | ||||||||||||||||||||||||
| 3069 | - | |||||||||||||||||||||||||
| 3070 | item->widgetItem = new QDockWidgetItem(dockWidget); | - | ||||||||||||||||||||||||
| 3071 | - | |||||||||||||||||||||||||
| 3072 | if (placeHolder->window) {
| 0 | ||||||||||||||||||||||||
| 3073 | const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget); | - | ||||||||||||||||||||||||
| 3074 | dockWidget->d_func()->setWindowState(true, true, r); | - | ||||||||||||||||||||||||
| 3075 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3076 | dockWidget->setVisible(!placeHolder->hidden); | - | ||||||||||||||||||||||||
| 3077 | #ifdef Q_DEAD_CODE_FROM_QT4_X11 | - | ||||||||||||||||||||||||
| 3078 | if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag | - | ||||||||||||||||||||||||
| 3079 | dockWidget->d_func()->setWindowState(true); | - | ||||||||||||||||||||||||
| 3080 | #endif | - | ||||||||||||||||||||||||
| 3081 | - | |||||||||||||||||||||||||
| 3082 | item->placeHolderItem = 0; | - | ||||||||||||||||||||||||
| 3083 | delete placeHolder; | - | ||||||||||||||||||||||||
| 3084 | - | |||||||||||||||||||||||||
| 3085 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 3086 | } | - | ||||||||||||||||||||||||
| 3087 | - | |||||||||||||||||||||||||
| 3088 | void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget, | - | ||||||||||||||||||||||||
| 3089 | Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 3090 | { | - | ||||||||||||||||||||||||
| 3091 | QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget); | - | ||||||||||||||||||||||||
| 3092 | QDockAreaLayoutInfo &info = docks[pos]; | - | ||||||||||||||||||||||||
| 3093 | if (orientation == info.o || info.item_list.count() <= 1) {
| 0 | ||||||||||||||||||||||||
| 3094 | // empty dock areas, or dock areas containing exactly one widget can have their orientation | - | ||||||||||||||||||||||||
| 3095 | // switched. | - | ||||||||||||||||||||||||
| 3096 | info.o = orientation; | - | ||||||||||||||||||||||||
| 3097 | - | |||||||||||||||||||||||||
| 3098 | QDockAreaLayoutItem new_item(dockWidgetItem); | - | ||||||||||||||||||||||||
| 3099 | info.item_list.append(new_item); | - | ||||||||||||||||||||||||
| 3100 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3101 | if (info.tabbed && !new_item.skip()) {
| 0 | ||||||||||||||||||||||||
| 3102 | info.updateTabBar(); | - | ||||||||||||||||||||||||
| 3103 | info.setCurrentTabId(tabId(new_item)); | - | ||||||||||||||||||||||||
| 3104 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3105 | #endif | - | ||||||||||||||||||||||||
| 3106 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3107 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3108 | int tbshape = info.tabBarShape; | - | ||||||||||||||||||||||||
| 3109 | #else | - | ||||||||||||||||||||||||
| 3110 | int tbshape = 0; | - | ||||||||||||||||||||||||
| 3111 | #endif | - | ||||||||||||||||||||||||
| 3112 | QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow); | - | ||||||||||||||||||||||||
| 3113 | new_info.item_list.append(new QDockAreaLayoutInfo(info)); | - | ||||||||||||||||||||||||
| 3114 | new_info.item_list.append(dockWidgetItem); | - | ||||||||||||||||||||||||
| 3115 | info = new_info; | - | ||||||||||||||||||||||||
| 3116 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3117 | - | |||||||||||||||||||||||||
| 3118 | removePlaceHolder(dockWidget->objectName()); | - | ||||||||||||||||||||||||
| 3119 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3120 | - | |||||||||||||||||||||||||
| 3121 | void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) | - | ||||||||||||||||||||||||
| 3122 | { | - | ||||||||||||||||||||||||
| 3123 | QList<int> path = indexOf(first); | - | ||||||||||||||||||||||||
| 3124 | if (path.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3125 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3126 | - | |||||||||||||||||||||||||
| 3127 | QDockAreaLayoutInfo *info = this->info(path); | - | ||||||||||||||||||||||||
| 3128 | Q_ASSERT(info != 0); | - | ||||||||||||||||||||||||
| 3129 | info->tab(path.last(), new QDockWidgetItem(second)); | - | ||||||||||||||||||||||||
| 3130 | - | |||||||||||||||||||||||||
| 3131 | removePlaceHolder(second->objectName()); | - | ||||||||||||||||||||||||
| 3132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3133 | - | |||||||||||||||||||||||||
| 3134 | void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, | - | ||||||||||||||||||||||||
| 3135 | const QList<int> &sizes, Qt::Orientation o) | - | ||||||||||||||||||||||||
| 3136 | { | - | ||||||||||||||||||||||||
| 3137 | if (docks.count() != sizes.count()) {
| 0 | ||||||||||||||||||||||||
| 3138 | qWarning("QMainWidget::resizeDocks: size of the lists are not the same"); | - | ||||||||||||||||||||||||
| 3139 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3140 | } | - | ||||||||||||||||||||||||
| 3141 | int count = docks.count(); | - | ||||||||||||||||||||||||
| 3142 | fallbackToSizeHints = false; | - | ||||||||||||||||||||||||
| 3143 | for (int i = 0; i < count; ++i) {
| 0 | ||||||||||||||||||||||||
| 3144 | QList<int> path = indexOf(docks[i]); | - | ||||||||||||||||||||||||
| 3145 | if (path.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 3146 | qWarning("QMainWidget::resizeDocks: one QDockWidget is not part of the layout"); | - | ||||||||||||||||||||||||
| 3147 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 3148 | } | - | ||||||||||||||||||||||||
| 3149 | int size = sizes[i]; | - | ||||||||||||||||||||||||
| 3150 | if (size <= 0) {
| 0 | ||||||||||||||||||||||||
| 3151 | qWarning("QMainWidget::resizeDocks: all sizes need to be larger than 0"); | - | ||||||||||||||||||||||||
| 3152 | size = 1; | - | ||||||||||||||||||||||||
| 3153 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3154 | - | |||||||||||||||||||||||||
| 3155 | while (path.size() > 1) {
| 0 | ||||||||||||||||||||||||
| 3156 | QDockAreaLayoutInfo *info = this->info(path); | - | ||||||||||||||||||||||||
| 3157 | if (!info->tabbed && info->o == o) {
| 0 | ||||||||||||||||||||||||
| 3158 | info->item_list[path.last()].size = size; | - | ||||||||||||||||||||||||
| 3159 | int totalSize = 0; | - | ||||||||||||||||||||||||
| 3160 | foreach (const QDockAreaLayoutItem &item, info->item_list) { | - | ||||||||||||||||||||||||
| 3161 | if (!item.skip()) {
| 0 | ||||||||||||||||||||||||
| 3162 | if (totalSize != 0)
| 0 | ||||||||||||||||||||||||
| 3163 | totalSize += sep; never executed: totalSize += sep; | 0 | ||||||||||||||||||||||||
| 3164 | totalSize += item.size == -1 ? pick(o, item.sizeHint()) : item.size;
| 0 | ||||||||||||||||||||||||
| 3165 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3166 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3167 | size = totalSize; | - | ||||||||||||||||||||||||
| 3168 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3169 | path.removeLast(); | - | ||||||||||||||||||||||||
| 3170 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3171 | - | |||||||||||||||||||||||||
| 3172 | const int dockNum = path.first(); | - | ||||||||||||||||||||||||
| 3173 | Q_ASSERT(dockNum < QInternal::DockCount); | - | ||||||||||||||||||||||||
| 3174 | QRect &r = this->docks[dockNum].rect; | - | ||||||||||||||||||||||||
| 3175 | QSize s = r.size(); | - | ||||||||||||||||||||||||
| 3176 | rpick(o, s) = size; | - | ||||||||||||||||||||||||
| 3177 | r.setSize(s); | - | ||||||||||||||||||||||||
| 3178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3179 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3180 | - | |||||||||||||||||||||||||
| 3181 | void QDockAreaLayout::splitDockWidget(QDockWidget *after, | - | ||||||||||||||||||||||||
| 3182 | QDockWidget *dockWidget, | - | ||||||||||||||||||||||||
| 3183 | Qt::Orientation orientation) | - | ||||||||||||||||||||||||
| 3184 | { | - | ||||||||||||||||||||||||
| 3185 | QList<int> path = indexOf(after); | - | ||||||||||||||||||||||||
| 3186 | if (path.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3187 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3188 | - | |||||||||||||||||||||||||
| 3189 | QDockAreaLayoutInfo *info = this->info(path); | - | ||||||||||||||||||||||||
| 3190 | Q_ASSERT(info != 0); | - | ||||||||||||||||||||||||
| 3191 | info->split(path.last(), orientation, new QDockWidgetItem(dockWidget)); | - | ||||||||||||||||||||||||
| 3192 | - | |||||||||||||||||||||||||
| 3193 | removePlaceHolder(dockWidget->objectName()); | - | ||||||||||||||||||||||||
| 3194 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3195 | - | |||||||||||||||||||||||||
| 3196 | void QDockAreaLayout::apply(bool animate) | - | ||||||||||||||||||||||||
| 3197 | { | - | ||||||||||||||||||||||||
| 3198 | QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator; | - | ||||||||||||||||||||||||
| 3199 | - | |||||||||||||||||||||||||
| 3200 | for (int i = 0; i < QInternal::DockCount; ++i)
| 0 | ||||||||||||||||||||||||
| 3201 | docks[i].apply(animate); never executed: docks[i].apply(animate); | 0 | ||||||||||||||||||||||||
| 3202 | if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 3203 | widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, | - | ||||||||||||||||||||||||
| 3204 | animate); | - | ||||||||||||||||||||||||
| 3205 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3206 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3207 | if (sep == 1)
| 0 | ||||||||||||||||||||||||
| 3208 | updateSeparatorWidgets(); never executed: updateSeparatorWidgets(); | 0 | ||||||||||||||||||||||||
| 3209 | #endif //QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3210 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3211 | - | |||||||||||||||||||||||||
| 3212 | void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget, | - | ||||||||||||||||||||||||
| 3213 | const QRegion &clip, | - | ||||||||||||||||||||||||
| 3214 | const QPoint &mouse) const | - | ||||||||||||||||||||||||
| 3215 | { | - | ||||||||||||||||||||||||
| 3216 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3217 | const QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3218 | if (dock.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3219 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 3220 | QRect r = separatorRect(i); | - | ||||||||||||||||||||||||
| 3221 | if (clip.contains(r) && !dock.hasFixedSize()) {
| 0 | ||||||||||||||||||||||||
| 3222 | Qt::Orientation opposite = dock.o == Qt::Horizontal
| 0 | ||||||||||||||||||||||||
| 3223 | ? Qt::Vertical : Qt::Horizontal; | - | ||||||||||||||||||||||||
| 3224 | paintSep(p, widget, r, opposite, r.contains(mouse)); | - | ||||||||||||||||||||||||
| 3225 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3226 | if (clip.contains(dock.rect))
| 0 | ||||||||||||||||||||||||
| 3227 | dock.paintSeparators(p, widget, clip, mouse); never executed: dock.paintSeparators(p, widget, clip, mouse); | 0 | ||||||||||||||||||||||||
| 3228 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3229 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3230 | - | |||||||||||||||||||||||||
| 3231 | QRegion QDockAreaLayout::separatorRegion() const | - | ||||||||||||||||||||||||
| 3232 | { | - | ||||||||||||||||||||||||
| 3233 | QRegion result; | - | ||||||||||||||||||||||||
| 3234 | - | |||||||||||||||||||||||||
| 3235 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3236 | const QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3237 | if (dock.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3238 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 3239 | result |= separatorRect(i); | - | ||||||||||||||||||||||||
| 3240 | result |= dock.separatorRegion(); | - | ||||||||||||||||||||||||
| 3241 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3242 | - | |||||||||||||||||||||||||
| 3243 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 3244 | } | - | ||||||||||||||||||||||||
| 3245 | - | |||||||||||||||||||||||||
| 3246 | int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin, | - | ||||||||||||||||||||||||
| 3247 | const QPoint &dest) | - | ||||||||||||||||||||||||
| 3248 | { | - | ||||||||||||||||||||||||
| 3249 | int delta = 0; | - | ||||||||||||||||||||||||
| 3250 | int index = separator.last(); | - | ||||||||||||||||||||||||
| 3251 | - | |||||||||||||||||||||||||
| 3252 | if (separator.count() > 1) {
| 0 | ||||||||||||||||||||||||
| 3253 | QDockAreaLayoutInfo *info = this->info(separator); | - | ||||||||||||||||||||||||
| 3254 | delta = pick(info->o, dest - origin); | - | ||||||||||||||||||||||||
| 3255 | if (delta != 0)
| 0 | ||||||||||||||||||||||||
| 3256 | delta = info->separatorMove(index, delta); never executed: delta = info->separatorMove(index, delta); | 0 | ||||||||||||||||||||||||
| 3257 | info->apply(false); | - | ||||||||||||||||||||||||
| 3258 | return delta; never executed: return delta; | 0 | ||||||||||||||||||||||||
| 3259 | } | - | ||||||||||||||||||||||||
| 3260 | - | |||||||||||||||||||||||||
| 3261 | QVector<QLayoutStruct> list; | - | ||||||||||||||||||||||||
| 3262 | - | |||||||||||||||||||||||||
| 3263 | if (index == QInternal::LeftDock || index == QInternal::RightDock)
| 0 | ||||||||||||||||||||||||
| 3264 | getGrid(0, &list); never executed: getGrid(0, &list); | 0 | ||||||||||||||||||||||||
| 3265 | else | - | ||||||||||||||||||||||||
| 3266 | getGrid(&list, 0); never executed: getGrid(&list, 0); | 0 | ||||||||||||||||||||||||
| 3267 | - | |||||||||||||||||||||||||
| 3268 | int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock
| 0 | ||||||||||||||||||||||||
| 3269 | ? 0 : 1; | - | ||||||||||||||||||||||||
| 3270 | Qt::Orientation o = index == QInternal::LeftDock || index == QInternal::RightDock
| 0 | ||||||||||||||||||||||||
| 3271 | ? Qt::Horizontal | - | ||||||||||||||||||||||||
| 3272 | : Qt::Vertical; | - | ||||||||||||||||||||||||
| 3273 | - | |||||||||||||||||||||||||
| 3274 | delta = pick(o, dest - origin); | - | ||||||||||||||||||||||||
| 3275 | delta = separatorMoveHelper(list, sep_index, delta, sep); | - | ||||||||||||||||||||||||
| 3276 | - | |||||||||||||||||||||||||
| 3277 | if (index == QInternal::LeftDock || index == QInternal::RightDock)
| 0 | ||||||||||||||||||||||||
| 3278 | setGrid(0, &list); never executed: setGrid(0, &list); | 0 | ||||||||||||||||||||||||
| 3279 | else | - | ||||||||||||||||||||||||
| 3280 | setGrid(&list, 0); never executed: setGrid(&list, 0); | 0 | ||||||||||||||||||||||||
| 3281 | - | |||||||||||||||||||||||||
| 3282 | apply(false); | - | ||||||||||||||||||||||||
| 3283 | - | |||||||||||||||||||||||||
| 3284 | return delta; never executed: return delta; | 0 | ||||||||||||||||||||||||
| 3285 | } | - | ||||||||||||||||||||||||
| 3286 | - | |||||||||||||||||||||||||
| 3287 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3288 | // Sets the correct positions for the separator widgets | - | ||||||||||||||||||||||||
| 3289 | // Allocates new sepearator widgets with getSeparatorWidget | - | ||||||||||||||||||||||||
| 3290 | void QDockAreaLayout::updateSeparatorWidgets() const | - | ||||||||||||||||||||||||
| 3291 | { | - | ||||||||||||||||||||||||
| 3292 | int j = 0; | - | ||||||||||||||||||||||||
| 3293 | - | |||||||||||||||||||||||||
| 3294 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3295 | const QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3296 | if (dock.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3297 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 3298 | - | |||||||||||||||||||||||||
| 3299 | QWidget *sepWidget; | - | ||||||||||||||||||||||||
| 3300 | if (j < separatorWidgets.size()) {
| 0 | ||||||||||||||||||||||||
| 3301 | sepWidget = separatorWidgets.at(j); | - | ||||||||||||||||||||||||
| 3302 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3303 | sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget(); | - | ||||||||||||||||||||||||
| 3304 | separatorWidgets.append(sepWidget); | - | ||||||||||||||||||||||||
| 3305 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3306 | j++; | - | ||||||||||||||||||||||||
| 3307 | - | |||||||||||||||||||||||||
| 3308 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||
| 3309 | sepWidget->raise(); | - | ||||||||||||||||||||||||
| 3310 | #endif | - | ||||||||||||||||||||||||
| 3311 | QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2); | - | ||||||||||||||||||||||||
| 3312 | sepWidget->setGeometry(sepRect); | - | ||||||||||||||||||||||||
| 3313 | sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft()))); | - | ||||||||||||||||||||||||
| 3314 | sepWidget->show(); | - | ||||||||||||||||||||||||
| 3315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3316 | for (int i = j; i < separatorWidgets.size(); ++i)
| 0 | ||||||||||||||||||||||||
| 3317 | separatorWidgets.at(i)->hide(); never executed: separatorWidgets.at(i)->hide(); | 0 | ||||||||||||||||||||||||
| 3318 | - | |||||||||||||||||||||||||
| 3319 | separatorWidgets.resize(j); | - | ||||||||||||||||||||||||
| 3320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3321 | #endif //QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3322 | - | |||||||||||||||||||||||||
| 3323 | QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const | - | ||||||||||||||||||||||||
| 3324 | { | - | ||||||||||||||||||||||||
| 3325 | Q_ASSERT(x != 0); | - | ||||||||||||||||||||||||
| 3326 | - | |||||||||||||||||||||||||
| 3327 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3328 | const QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3329 | if (QLayoutItem *ret = dock.itemAt(x, index))
| 0 | ||||||||||||||||||||||||
| 3330 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 3331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3332 | - | |||||||||||||||||||||||||
| 3333 | if (centralWidgetItem && (*x)++ == index)
| 0 | ||||||||||||||||||||||||
| 3334 | return centralWidgetItem; never executed: return centralWidgetItem; | 0 | ||||||||||||||||||||||||
| 3335 | - | |||||||||||||||||||||||||
| 3336 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 3337 | } | - | ||||||||||||||||||||||||
| 3338 | - | |||||||||||||||||||||||||
| 3339 | QLayoutItem *QDockAreaLayout::takeAt(int *x, int index) | - | ||||||||||||||||||||||||
| 3340 | { | - | ||||||||||||||||||||||||
| 3341 | Q_ASSERT(x != 0); | - | ||||||||||||||||||||||||
| 3342 | - | |||||||||||||||||||||||||
| 3343 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3344 | QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3345 | if (QLayoutItem *ret = dock.takeAt(x, index))
| 0 | ||||||||||||||||||||||||
| 3346 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 3347 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3348 | - | |||||||||||||||||||||||||
| 3349 | if (centralWidgetItem && (*x)++ == index) {
| 0 | ||||||||||||||||||||||||
| 3350 | QLayoutItem *ret = centralWidgetItem; | - | ||||||||||||||||||||||||
| 3351 | centralWidgetItem = 0; | - | ||||||||||||||||||||||||
| 3352 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 3353 | } | - | ||||||||||||||||||||||||
| 3354 | - | |||||||||||||||||||||||||
| 3355 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 3356 | } | - | ||||||||||||||||||||||||
| 3357 | - | |||||||||||||||||||||||||
| 3358 | void QDockAreaLayout::deleteAllLayoutItems() | - | ||||||||||||||||||||||||
| 3359 | { | - | ||||||||||||||||||||||||
| 3360 | for (int i = 0; i < QInternal::DockCount; ++i)
| 0 | ||||||||||||||||||||||||
| 3361 | docks[i].deleteAllLayoutItems(); never executed: docks[i].deleteAllLayoutItems(); | 0 | ||||||||||||||||||||||||
| 3362 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3363 | - | |||||||||||||||||||||||||
| 3364 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3365 | QSet<QTabBar*> QDockAreaLayout::usedTabBars() const | - | ||||||||||||||||||||||||
| 3366 | { | - | ||||||||||||||||||||||||
| 3367 | QSet<QTabBar*> result; | - | ||||||||||||||||||||||||
| 3368 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3369 | const QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3370 | result += dock.usedTabBars(); | - | ||||||||||||||||||||||||
| 3371 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3372 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 3373 | } | - | ||||||||||||||||||||||||
| 3374 | - | |||||||||||||||||||||||||
| 3375 | // Returns the set of all used separator widgets | - | ||||||||||||||||||||||||
| 3376 | QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const | - | ||||||||||||||||||||||||
| 3377 | { | - | ||||||||||||||||||||||||
| 3378 | QSet<QWidget*> result; | - | ||||||||||||||||||||||||
| 3379 | const int numSeparators = separatorWidgets.count(); | - | ||||||||||||||||||||||||
| 3380 | result.reserve(numSeparators); | - | ||||||||||||||||||||||||
| 3381 | for (int i = 0; i < numSeparators; ++i)
| 0 | ||||||||||||||||||||||||
| 3382 | result << separatorWidgets.at(i); never executed: result << separatorWidgets.at(i); | 0 | ||||||||||||||||||||||||
| 3383 | for (int i = 0; i < QInternal::DockCount; ++i) {
| 0 | ||||||||||||||||||||||||
| 3384 | const QDockAreaLayoutInfo &dock = docks[i]; | - | ||||||||||||||||||||||||
| 3385 | result += dock.usedSeparatorWidgets(); | - | ||||||||||||||||||||||||
| 3386 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3387 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 3388 | } | - | ||||||||||||||||||||||||
| 3389 | #endif | - | ||||||||||||||||||||||||
| 3390 | - | |||||||||||||||||||||||||
| 3391 | QRect QDockAreaLayout::gapRect(const QList<int> &path) const | - | ||||||||||||||||||||||||
| 3392 | { | - | ||||||||||||||||||||||||
| 3393 | const QDockAreaLayoutInfo *info = this->info(path); | - | ||||||||||||||||||||||||
| 3394 | if (info == 0)
| 0 | ||||||||||||||||||||||||
| 3395 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 3396 | const QList<QDockAreaLayoutItem> &item_list = info->item_list; | - | ||||||||||||||||||||||||
| 3397 | Qt::Orientation o = info->o; | - | ||||||||||||||||||||||||
| 3398 | int index = path.last(); | - | ||||||||||||||||||||||||
| 3399 | if (index < 0 || index >= item_list.count())
| 0 | ||||||||||||||||||||||||
| 3400 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 3401 | const QDockAreaLayoutItem &item = item_list.at(index); | - | ||||||||||||||||||||||||
| 3402 | if (!(item.flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 3403 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
| 3404 | - | |||||||||||||||||||||||||
| 3405 | QRect result; | - | ||||||||||||||||||||||||
| 3406 | - | |||||||||||||||||||||||||
| 3407 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 3408 | if (info->tabbed) {
| 0 | ||||||||||||||||||||||||
| 3409 | result = info->tabContentRect(); | - | ||||||||||||||||||||||||
| 3410 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 3411 | #endif | - | ||||||||||||||||||||||||
| 3412 | { | - | ||||||||||||||||||||||||
| 3413 | int pos = item.pos; | - | ||||||||||||||||||||||||
| 3414 | int size = item.size; | - | ||||||||||||||||||||||||
| 3415 | - | |||||||||||||||||||||||||
| 3416 | int prev = info->prev(index); | - | ||||||||||||||||||||||||
| 3417 | int next = info->next(index); | - | ||||||||||||||||||||||||
| 3418 | - | |||||||||||||||||||||||||
| 3419 | if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
| 0 | ||||||||||||||||||||||||
| 3420 | pos += sep; | - | ||||||||||||||||||||||||
| 3421 | size -= sep; | - | ||||||||||||||||||||||||
| 3422 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3423 | if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
| 0 | ||||||||||||||||||||||||
| 3424 | size -= sep; never executed: size -= sep; | 0 | ||||||||||||||||||||||||
| 3425 | - | |||||||||||||||||||||||||
| 3426 | QPoint p; | - | ||||||||||||||||||||||||
| 3427 | rpick(o, p) = pos; | - | ||||||||||||||||||||||||
| 3428 | rperp(o, p) = perp(o, info->rect.topLeft()); | - | ||||||||||||||||||||||||
| 3429 | QSize s; | - | ||||||||||||||||||||||||
| 3430 | rpick(o, s) = size; | - | ||||||||||||||||||||||||
| 3431 | rperp(o, s) = perp(o, info->rect.size()); | - | ||||||||||||||||||||||||
| 3432 | - | |||||||||||||||||||||||||
| 3433 | result = QRect(p, s); | - | ||||||||||||||||||||||||
| 3434 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3435 | - | |||||||||||||||||||||||||
| 3436 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 3437 | } | - | ||||||||||||||||||||||||
| 3438 | - | |||||||||||||||||||||||||
| 3439 | void QDockAreaLayout::keepSize(QDockWidget *w) | - | ||||||||||||||||||||||||
| 3440 | { | - | ||||||||||||||||||||||||
| 3441 | QList<int> path = indexOf(w); | - | ||||||||||||||||||||||||
| 3442 | if (path.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3443 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3444 | QDockAreaLayoutItem &item = this->item(path); | - | ||||||||||||||||||||||||
| 3445 | if (item.size != -1)
| 0 | ||||||||||||||||||||||||
| 3446 | item.flags |= QDockAreaLayoutItem::KeepSize; never executed: item.flags |= QDockAreaLayoutItem::KeepSize; | 0 | ||||||||||||||||||||||||
| 3447 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3448 | - | |||||||||||||||||||||||||
| 3449 | void QDockAreaLayout::styleChangedEvent() | - | ||||||||||||||||||||||||
| 3450 | { | - | ||||||||||||||||||||||||
| 3451 | sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow); | - | ||||||||||||||||||||||||
| 3452 | if (isValid())
| 0 | ||||||||||||||||||||||||
| 3453 | fitLayout(); never executed: fitLayout(); | 0 | ||||||||||||||||||||||||
| 3454 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3455 | - | |||||||||||||||||||||||||
| 3456 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| 3457 | - | |||||||||||||||||||||||||
| 3458 | #endif // QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |