| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmdiarea.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | - | |||||||||||||
| 12 | using namespace QMdi; | - | ||||||||||||
| 13 | - | |||||||||||||
| 14 | - | |||||||||||||
| 15 | static bool sanityCheck(const QMdiSubWindow * const child, const char *where) | - | ||||||||||||
| 16 | { | - | ||||||||||||
| 17 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||
| 18 | const char error[] = "null pointer"; | - | ||||||||||||
| 19 | ((!(false)) ? qt_assert_x(where, error,__FILE__,184189) : qt_noop()); | - | ||||||||||||
| 20 | QMessageLogger(__FILE__, 185190, __PRETTY_FUNCTION__).warning("%s:%s", where, error); | - | ||||||||||||
| 21 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 22 | } | - | ||||||||||||
| 23 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 24 | } | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | static bool sanityCheck(const QList<QWidget *> &widgets, const int index, const char *where) | - | ||||||||||||
| 27 | { | - | ||||||||||||
| 28 | if (__builtin_expect(!!(
| 0 | ||||||||||||
| 29 | const char error[] = "index out of range"; | - | ||||||||||||
| 30 | ((!(false)) ? qt_assert_x(where, error,__FILE__,195200) : qt_noop()); | - | ||||||||||||
| 31 | QMessageLogger(__FILE__, 196201, __PRETTY_FUNCTION__).warning("%s:%s", where, error); | - | ||||||||||||
| 32 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 33 | } | - | ||||||||||||
| 34 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||
| 35 | const char error[] = "null pointer"; | - | ||||||||||||
| 36 | ((!(false)) ? qt_assert_x(where, error,__FILE__,201206) : qt_noop()); | - | ||||||||||||
| 37 | QMessageLogger(__FILE__, 202207, __PRETTY_FUNCTION__).warning("%s:%s", where, error); | - | ||||||||||||
| 38 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 39 | } | - | ||||||||||||
| 40 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 41 | } | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | static void setIndex(int *index, int candidate, int min, int max, bool isIncreasing) | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | if (!index) | - | ||||||||||||
| 46 | return; | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | if (isIncreasing) { | - | ||||||||||||
| 49 | if (candidate > max) | - | ||||||||||||
| 50 | *index = min; | - | ||||||||||||
| 51 | else | - | ||||||||||||
| 52 | *index = qMax(candidate, min); | - | ||||||||||||
| 53 | } else { | - | ||||||||||||
| 54 | if (candidate < min) | - | ||||||||||||
| 55 | *index = max; | - | ||||||||||||
| 56 | else | - | ||||||||||||
| 57 | *index = qMin(candidate, max); | - | ||||||||||||
| 58 | } | - | ||||||||||||
| 59 | ((!(*index >= min && *index <= max)) ? qt_assert("*index >= min && *index <= max",__FILE__,224229) : qt_noop()); | - | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | static inline bool useScrollBar(const QRect &childrenRect, const QSize &maxViewportSize, | - | ||||||||||||
| 63 | Qt::Orientation orientation) | - | ||||||||||||
| 64 | { | - | ||||||||||||
| 65 | if (orientation == Qt::Horizontal) | - | ||||||||||||
| 66 | return childrenRect.width() > maxViewportSize.width() | - | ||||||||||||
| 67 | || childrenRect.left() < 0 | - | ||||||||||||
| 68 | || childrenRect.right() >= maxViewportSize.width(); | - | ||||||||||||
| 69 | else | - | ||||||||||||
| 70 | return childrenRect.height() > maxViewportSize.height() | - | ||||||||||||
| 71 | || childrenRect.top() < 0 | - | ||||||||||||
| 72 | || childrenRect.bottom() >= maxViewportSize.height(); | - | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | - | |||||||||||||
| 76 | static inline QMdiArea *mdiAreaParent(QWidget *widget) | - | ||||||||||||
| 77 | { | - | ||||||||||||
| 78 | if (!widget) | - | ||||||||||||
| 79 | return 0; | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | QWidget *parent = widget->parentWidget(); | - | ||||||||||||
| 82 | while (parent) { | - | ||||||||||||
| 83 | if (QMdiArea *area = qobject_cast<QMdiArea *>(parent)) | - | ||||||||||||
| 84 | return area; | - | ||||||||||||
| 85 | parent = parent->parentWidget(); | - | ||||||||||||
| 86 | } | - | ||||||||||||
| 87 | return 0; | - | ||||||||||||
| 88 | } | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | - | |||||||||||||
| 91 | static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWidget::TabPosition position) | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | const bool rounded = (shape == QTabWidget::Rounded); | - | ||||||||||||
| 94 | if (position == QTabWidget::North) | - | ||||||||||||
| 95 | return rounded ? QTabBar::RoundedNorth : QTabBar::TriangularNorth; | - | ||||||||||||
| 96 | if (position == QTabWidget::South) | - | ||||||||||||
| 97 | return rounded ? QTabBar::RoundedSouth : QTabBar::TriangularSouth; | - | ||||||||||||
| 98 | if (position == QTabWidget::East) | - | ||||||||||||
| 99 | return rounded ? QTabBar::RoundedEast : QTabBar::TriangularEast; | - | ||||||||||||
| 100 | if (position == QTabWidget::West) | - | ||||||||||||
| 101 | return rounded ? QTabBar::RoundedWest : QTabBar::TriangularWest; | - | ||||||||||||
| 102 | return QTabBar::RoundedNorth; | - | ||||||||||||
| 103 | } | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | - | |||||||||||||
| 106 | static inline QString tabTextFor(QMdiSubWindow *subWindow) | - | ||||||||||||
| 107 | { | - | ||||||||||||
| 108 | if (!subWindow) | - | ||||||||||||
| 109 | return QString(); | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | QString title = subWindow->windowTitle(); | - | ||||||||||||
| 112 | if (subWindow->isWindowModified()) { | - | ||||||||||||
| 113 | title.replace(QLatin1String("[*]"), QLatin1String("*")); | - | ||||||||||||
| 114 | } else { | - | ||||||||||||
| 115 | extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); | - | ||||||||||||
| 116 | title = qt_setWindowTitle_helperHelper(title, subWindow); | - | ||||||||||||
| 117 | } | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | return title.isEmpty() ? QMdiArea::tr("(Untitled)") : title; | - | ||||||||||||
| 120 | } | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | void RegularTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | if (widgets.isEmpty()) | - | ||||||||||||
| 128 | return; | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | const int n = widgets.size(); | - | ||||||||||||
| 131 | const int ncols = qMax(qCeil(qSqrt(qreal(n))), 1); | - | ||||||||||||
| 132 | const int nrows = qMax((n % ncols) ? (n / ncols + 1) : (n / ncols), 1); | - | ||||||||||||
| 133 | const int nspecial = (n % ncols) ? (ncols - n % ncols) : 0; | - | ||||||||||||
| 134 | const int dx = domain.width() / ncols; | - | ||||||||||||
| 135 | const int dy = domain.height() / nrows; | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | int i = 0; | - | ||||||||||||
| 138 | for (int row = 0; row < nrows; ++row) { | - | ||||||||||||
| 139 | const int y1 = int(row * (dy + 1)); | - | ||||||||||||
| 140 | for (int col = 0; col < ncols; ++col) { | - | ||||||||||||
| 141 | if (row == 1 && col < nspecial) | - | ||||||||||||
| 142 | continue; | - | ||||||||||||
| 143 | const int x1 = int(col * (dx + 1)); | - | ||||||||||||
| 144 | int x2 = int(x1 + dx); | - | ||||||||||||
| 145 | int y2 = int(y1 + dy); | - | ||||||||||||
| 146 | if (row == 0 && col < nspecial) { | - | ||||||||||||
| 147 | y2 *= 2; | - | ||||||||||||
| 148 | if (nrows != 2) | - | ||||||||||||
| 149 | y2 += 1; | - | ||||||||||||
| 150 | else | - | ||||||||||||
| 151 | y2 = domain.bottom(); | - | ||||||||||||
| 152 | } | - | ||||||||||||
| 153 | if (col == ncols - 1 && x2 != domain.right()) | - | ||||||||||||
| 154 | x2 = domain.right(); | - | ||||||||||||
| 155 | if (row == nrows - 1 && y2 != domain.bottom()) | - | ||||||||||||
| 156 | y2 = domain.bottom(); | - | ||||||||||||
| 157 | if (!sanityCheck(widgets, i, "RegularTiler")) | - | ||||||||||||
| 158 | continue; | - | ||||||||||||
| 159 | QWidget *widget = widgets.at(i++); | - | ||||||||||||
| 160 | QRect newGeometry = QRect(QPoint(x1, y1), QPoint(x2, y2)); | - | ||||||||||||
| 161 | widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry)); | - | ||||||||||||
| 162 | } | - | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | } | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| 167 | - | |||||||||||||
| 168 | - | |||||||||||||
| 169 | void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) const | - | ||||||||||||
| 170 | { | - | ||||||||||||
| 171 | if (widgets.isEmpty()) | - | ||||||||||||
| 172 | return; | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | - | |||||||||||||
| 175 | const int topOffset = 0; | - | ||||||||||||
| 176 | const int bottomOffset = 50; | - | ||||||||||||
| 177 | const int leftOffset = 0; | - | ||||||||||||
| 178 | const int rightOffset = 100; | - | ||||||||||||
| 179 | const int dx = 10; | - | ||||||||||||
| 180 | - | |||||||||||||
| 181 | QStyleOptionTitleBar options; | - | ||||||||||||
| 182 | options.initFrom(widgets.at(0)); | - | ||||||||||||
| 183 | int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0)); | - | ||||||||||||
| 184 | const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); | - | ||||||||||||
| 185 | const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1) | - | ||||||||||||
| 186 | + widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, 0, widgets.at(0)); | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | const int n = widgets.size(); | - | ||||||||||||
| 189 | const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1); | - | ||||||||||||
| 190 | const int ncols = qMax(n / nrows + ((n % nrows) ? 1 : 0), 1); | - | ||||||||||||
| 191 | const int dcol = (domain.width() - (leftOffset + rightOffset)) / ncols; | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | int i = 0; | - | ||||||||||||
| 194 | for (int row = 0; row < nrows; ++row) { | - | ||||||||||||
| 195 | for (int col = 0; col < ncols; ++col) { | - | ||||||||||||
| 196 | const int x = leftOffset + row * dx + col * dcol; | - | ||||||||||||
| 197 | const int y = topOffset + row * dy; | - | ||||||||||||
| 198 | if (!sanityCheck(widgets, i, "SimpleCascader")) | - | ||||||||||||
| 199 | continue; | - | ||||||||||||
| 200 | QWidget *widget = widgets.at(i++); | - | ||||||||||||
| 201 | QRect newGeometry = QRect(QPoint(x, y), widget->sizeHint()); | - | ||||||||||||
| 202 | widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry)); | - | ||||||||||||
| 203 | if (i == n) | - | ||||||||||||
| 204 | return; | - | ||||||||||||
| 205 | } | - | ||||||||||||
| 206 | } | - | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | - | |||||||||||||
| 210 | - | |||||||||||||
| 211 | - | |||||||||||||
| 212 | void IconTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const | - | ||||||||||||
| 213 | { | - | ||||||||||||
| 214 | if (widgets.isEmpty()
| 0 | ||||||||||||
| 215 | return; never executed: return; | 0 | ||||||||||||
| 216 | - | |||||||||||||
| 217 | const int n = widgets.size(); | - | ||||||||||||
| 218 | const int width = qMax(widgets.at(0)->width();(), 1); | - | ||||||||||||
| 219 | const int height = widgets.at(0)->height(); | - | ||||||||||||
| 220 | const int ncols = qMax(domain.width() / width, 1); | - | ||||||||||||
| 221 | const int nrows = n / ncols + ((
| 0 | ||||||||||||
| 222 | - | |||||||||||||
| 223 | int i = 0; | - | ||||||||||||
| 224 | for (int row = 0; row < nrows
| 0 | ||||||||||||
| 225 | for (int col = 0; col < ncols
| 0 | ||||||||||||
| 226 | const int x = col * width; | - | ||||||||||||
| 227 | const int y = domain.height() - height - row * height; | - | ||||||||||||
| 228 | if (!sanityCheck(widgets, i, "IconTiler")
| 0 | ||||||||||||
| 229 | continue; never executed: continue; | 0 | ||||||||||||
| 230 | QWidget *widget = widgets.at(i++); | - | ||||||||||||
| 231 | QPoint newPos(x, y); | - | ||||||||||||
| 232 | QRect newGeometry = QRect(newPos.x(), newPos.y(), widget->width(), widget->height()); | - | ||||||||||||
| 233 | widget->setGeometry(QStyle::visualRect(widget->layoutDirection(), domain, newGeometry)); | - | ||||||||||||
| 234 | if (i == n
| 0 | ||||||||||||
| 235 | return; never executed: return; | 0 | ||||||||||||
| 236 | } never executed: end of block | 0 | ||||||||||||
| 237 | } never executed: end of block | 0 | ||||||||||||
| 238 | } never executed: end of block | 0 | ||||||||||||
| 239 | - | |||||||||||||
| 240 | - | |||||||||||||
| 241 | - | |||||||||||||
| 242 | - | |||||||||||||
| 243 | - | |||||||||||||
| 244 | int MinOverlapPlacer::accumulatedOverlap(const QRect &source, const QVector<QRect> &rects) | - | ||||||||||||
| 245 | { | - | ||||||||||||
| 246 | int accOverlap = 0; | - | ||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(rects)>::type> _container_((rects)); _container_.control && _container_.i != _container_.e; | ||||||||||||||
| 247 | ++_container_.i, _container_.control ^= 1)for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0: rects) { | - | ||||||||||||
| 248 | QRect intersection = source.intersected(rect); | - | ||||||||||||
| 249 | accOverlap += intersection.width() * intersection.height(); | - | ||||||||||||
| 250 | } never executed: end of block | 0 | ||||||||||||
| 251 | return never executed: accOverlap;return accOverlap;never executed: return accOverlap; | 0 | ||||||||||||
| 252 | } | - | ||||||||||||
| 253 | - | |||||||||||||
| 254 | - | |||||||||||||
| 255 | - | |||||||||||||
| 256 | - | |||||||||||||
| 257 | - | |||||||||||||
| 258 | - | |||||||||||||
| 259 | - | |||||||||||||
| 260 | QRect MinOverlapPlacer::findMinOverlapRect(const QVector<QRect> &source, const QVector<QRect> &rects) | - | ||||||||||||
| 261 | { | - | ||||||||||||
| 262 | int minAccOverlap = -1; | - | ||||||||||||
| 263 | QRect minAccOverlapRect; | - | ||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(source)>::type> _container_((source)); _container_.control && _container_.i != _container_.e; | ||||||||||||||
| 264 | ++_container_.i, _container_.control ^= 1)for (const QRect &srcRect = *_container_.i; _container_.control; _container_.control = 0: source) { | - | ||||||||||||
| 265 | const int accOverlap = accumulatedOverlap(srcRect, rects); | - | ||||||||||||
| 266 | if (accOverlap < minAccOverlap
| 0 | ||||||||||||
| 267 | minAccOverlap = accOverlap; | - | ||||||||||||
| 268 | minAccOverlapRect = srcRect; | - | ||||||||||||
| 269 | } never executed: end of block | 0 | ||||||||||||
| 270 | } never executed: end of block | 0 | ||||||||||||
| 271 | return never executed: minAccOverlapRect;return minAccOverlapRect;never executed: return minAccOverlapRect; | 0 | ||||||||||||
| 272 | } | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | - | |||||||||||||
| 275 | - | |||||||||||||
| 276 | - | |||||||||||||
| 277 | - | |||||||||||||
| 278 | QVector<QRect> MinOverlapPlacer::getCandidatePlacements(const QSize &size, const QVector<QRect> &rects, | - | ||||||||||||
| 279 | const QRect &domain) | - | ||||||||||||
| 280 | { | - | ||||||||||||
| 281 | QVector<QRect> result; | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | QVector<int> xlist; | - | ||||||||||||
| 284 | xlist.reserve(2 + rects.size()); | - | ||||||||||||
| 285 | xlist << domain.left() << domain.right() - size.width() + 1; | - | ||||||||||||
| 286 | - | |||||||||||||
| 287 | QVector<int> ylist; | - | ||||||||||||
| 288 | ylist.reserve(2 + rects.size()); | - | ||||||||||||
| 289 | ylist << domain.top(); | - | ||||||||||||
| 290 | if (domain.bottom() - size.height() + 1 >= 0
| 0 | ||||||||||||
| 291 | ylist << domain.bottom() - size.height() + 1; never executed: ylist << domain.bottom() - size.height() + 1; | 0 | ||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(rects)>::type> _container_((rects)); _container_.control && _container_.i != _container_.e never executed: ylist << domain.bottom() - size.height() + 1;never executed: ;ylist << domain.bottom() - size.height() + 1;never executed: ylist << domain.bottom() - size.height() + 1; | ||||||||||||||
| 292 | - | |||||||||||||
| 293 | ++_container_.i, _container_.control ^= 1)for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0: rects) { | - | ||||||||||||
| 294 | xlist << rect.right() + 1; | - | ||||||||||||
| 295 | ylist << rect.bottom() + 1; | - | ||||||||||||
| 296 | } never executed: end of block | 0 | ||||||||||||
| 297 | - | |||||||||||||
| 298 | std::sort(xlist.begin(), xlist.end()); | - | ||||||||||||
| 299 | xlist.erase(std::unique(xlist.begin(), xlist.end()), xlist.end()); | - | ||||||||||||
| 300 | - | |||||||||||||
| 301 | std::sort(ylist.begin(), ylist.end()); | - | ||||||||||||
| 302 | ylist.erase(std::unique(ylist.begin(), ylist.end()), ylist.end()); | - | ||||||||||||
| 303 | - | |||||||||||||
| 304 | result.reserve(ylist.size() * xlist.size()); | - | ||||||||||||
| 305 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(ylist)>::type> _container_((ylist)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (int y = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 306 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(xlist)>::type> _container_((xlist)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (int x = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 307 | result << QRect(QPoint(x, y), size); never executed: result << QRect(QPoint(x, y), size); | 0 | ||||||||||||
| 308 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||
| 309 | } | - | ||||||||||||
| 310 | - | |||||||||||||
| 311 | - | |||||||||||||
| 312 | - | |||||||||||||
| 313 | - | |||||||||||||
| 314 | - | |||||||||||||
| 315 | - | |||||||||||||
| 316 | QVector<QRect> MinOverlapPlacer::findNonInsiders(const QRect &domain, QVector<QRect> &source) | - | ||||||||||||
| 317 | { | - | ||||||||||||
| 318 | const auto containedInDomain = | - | ||||||||||||
| 319 | [domain](const QRect &srcRect) { return never executed: return domain.contains(srcRect);never executed: domain.contains(srcRect);return domain.contains(srcRect);never executed: };return domain.contains(srcRect); | 0 | ||||||||||||
| 320 | - | |||||||||||||
| 321 | const auto firstOut = std::stable_partition(source.begin(), source.end(), containedInDomain); | - | ||||||||||||
| 322 | - | |||||||||||||
| 323 | QVector<QRect> result; | - | ||||||||||||
| 324 | result.reserve(source.size()); | - | ||||||||||||
| QMutableVectorIterator<QRect> it(sourceend() - firstOut); | ||||||||||||||
| 325 | whilestd::copy(it.hasNext()) { | - | ||||||||||||
| const QRect srcRect = it.next(); | ||||||||||||||
| if (!domainfirstOut, source.containsend(), std::back_inserter(srcRect)) {result<< srcRect; | ||||||||||||||
| it)); | ||||||||||||||
| 326 | - | |||||||||||||
| 327 | source.remove(); | - | ||||||||||||
| } | ||||||||||||||
| }erase(firstOut, source.end()); | ||||||||||||||
| 328 | - | |||||||||||||
| 329 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||
| 330 | } | - | ||||||||||||
| 331 | - | |||||||||||||
| 332 | - | |||||||||||||
| 333 | - | |||||||||||||
| 334 | - | |||||||||||||
| 335 | - | |||||||||||||
| 336 | - | |||||||||||||
| 337 | QVector<QRect> MinOverlapPlacer::findMaxOverlappers(const QRect &domain, const QVector<QRect> &source) | - | ||||||||||||
| 338 | { | - | ||||||||||||
| 339 | QVector<QRect> result; | - | ||||||||||||
| 340 | result.reserve(source.size()); | - | ||||||||||||
| 341 | - | |||||||||||||
| 342 | int maxOverlap = -1; | - | ||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(source)>::type> _container_((source)); _container_.control && _container_.i != _container_.e; | ||||||||||||||
| 343 | ++_container_.i, _container_.control ^= 1)for (const QRect &srcRect = *_container_.i; _container_.control; _container_.control = 0: source) { | - | ||||||||||||
| 344 | QRect intersection = domain.intersected(srcRect); | - | ||||||||||||
| 345 | const int overlap = intersection.width() * intersection.height(); | - | ||||||||||||
| 346 | if (overlap >= maxOverlap
| 0 | ||||||||||||
| 347 | if (overlap > maxOverlap
| 0 | ||||||||||||
| 348 | maxOverlap = overlap; | - | ||||||||||||
| 349 | result.clear(); | - | ||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||
| 351 | result << srcRect; | - | ||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||
| 353 | } never executed: end of block | 0 | ||||||||||||
| 354 | - | |||||||||||||
| 355 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||
| 356 | } | - | ||||||||||||
| 357 | - | |||||||||||||
| 358 | - | |||||||||||||
| 359 | - | |||||||||||||
| 360 | - | |||||||||||||
| 361 | - | |||||||||||||
| 362 | - | |||||||||||||
| 363 | - | |||||||||||||
| 364 | QPoint MinOverlapPlacer::findBestPlacement(const QRect &domain, const QVector<QRect> &rects, | - | ||||||||||||
| 365 | QVector<QRect> &source) | - | ||||||||||||
| 366 | { | - | ||||||||||||
| 367 | const QVector<QRect> nonInsiders = findNonInsiders(domain, source); | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | if (!source.empty()) | - | ||||||||||||
| 370 | return findMinOverlapRect(source, rects).topLeft(); | - | ||||||||||||
| 371 | - | |||||||||||||
| 372 | QVector<QRect> maxOverlappers = findMaxOverlappers(domain, nonInsiders); | - | ||||||||||||
| 373 | return findMinOverlapRect(maxOverlappers, rects).topLeft(); | - | ||||||||||||
| 374 | } | - | ||||||||||||
| 375 | QPoint MinOverlapPlacer::place(const QSize &size, const QVector<QRect> &rects, | - | ||||||||||||
| 376 | const QRect &domain) const | - | ||||||||||||
| 377 | { | - | ||||||||||||
| 378 | if (size.isEmpty()
| 0 | ||||||||||||
| 379 | return never executed: QPoint();return QPoint();never executed: return QPoint(); | 0 | ||||||||||||
| 380 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(rects)>::type> _container_((rects)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0: rects) { | - | ||||||||||||
| 381 | if (!rect.isValid()
| 0 | ||||||||||||
| 382 | return never executed: QPoint();return QPoint();never executed: return QPoint(); | 0 | ||||||||||||
| 383 | } never executed: end of block | 0 | ||||||||||||
| 384 | - | |||||||||||||
| 385 | QVector<QRect> candidates = getCandidatePlacements(size, rects, domain); | - | ||||||||||||
| 386 | return never executed: findBestPlacement(domain, rects, candidates);return findBestPlacement(domain, rects, candidates);never executed: return findBestPlacement(domain, rects, candidates); | 0 | ||||||||||||
| 387 | } | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | - | |||||||||||||
| 390 | class QMdiAreaTabBar : public QTabBar | - | ||||||||||||
| 391 | { | - | ||||||||||||
| 392 | public: | - | ||||||||||||
| 393 | QMdiAreaTabBar(QWidget *parent) : QTabBar(parent) {} | - | ||||||||||||
| 394 | - | |||||||||||||
| 395 | protected: | - | ||||||||||||
| 396 | void mousePressEvent(QMouseEvent *event) override; | - | ||||||||||||
| 397 | - | |||||||||||||
| 398 | void contextMenuEvent(QContextMenuEvent *event) override; | - | ||||||||||||
| 399 | - | |||||||||||||
| 400 | - | |||||||||||||
| 401 | private: | - | ||||||||||||
| 402 | QMdiSubWindow *subWindowFromIndex(int index) const; | - | ||||||||||||
| 403 | }; | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | - | |||||||||||||
| 406 | - | |||||||||||||
| 407 | - | |||||||||||||
| 408 | void QMdiAreaTabBar::mousePressEvent(QMouseEvent *event) | - | ||||||||||||
| 409 | { | - | ||||||||||||
| 410 | if (event->button() != Qt::MidButton) { | - | ||||||||||||
| 411 | QTabBar::mousePressEvent(event); | - | ||||||||||||
| 412 | return; | - | ||||||||||||
| 413 | } | - | ||||||||||||
| 414 | - | |||||||||||||
| 415 | QMdiSubWindow *subWindow = subWindowFromIndex(tabAt(event->pos())); | - | ||||||||||||
| 416 | if (!subWindow) { | - | ||||||||||||
| 417 | event->ignore(); | - | ||||||||||||
| 418 | return; | - | ||||||||||||
| 419 | } | - | ||||||||||||
| 420 | - | |||||||||||||
| 421 | subWindow->close(); | - | ||||||||||||
| 422 | } | - | ||||||||||||
| 423 | - | |||||||||||||
| 424 | - | |||||||||||||
| 425 | - | |||||||||||||
| 426 | - | |||||||||||||
| 427 | - | |||||||||||||
| 428 | void QMdiAreaTabBar::contextMenuEvent(QContextMenuEvent *event) | - | ||||||||||||
| 429 | { | - | ||||||||||||
| 430 | QPointer<QMdiSubWindow> subWindow = subWindowFromIndex(tabAt(event->pos())); | - | ||||||||||||
| 431 | if (!subWindow || subWindow->isHidden()) { | - | ||||||||||||
| 432 | event->ignore(); | - | ||||||||||||
| 433 | return; | - | ||||||||||||
| 434 | } | - | ||||||||||||
| 435 | - | |||||||||||||
| 436 | - | |||||||||||||
| 437 | QMdiSubWindowPrivate *subWindowPrivate = subWindow->d_func(); | - | ||||||||||||
| 438 | if (!subWindowPrivate->systemMenu) { | - | ||||||||||||
| 439 | event->ignore(); | - | ||||||||||||
| 440 | return; | - | ||||||||||||
| 441 | } | - | ||||||||||||
| 442 | - | |||||||||||||
| 443 | QMdiSubWindow *currentSubWindow = subWindowFromIndex(currentIndex()); | - | ||||||||||||
| 444 | ((!(currentSubWindow)) ? qt_assert("currentSubWindow",__FILE__,618622) : qt_noop()); | - | ||||||||||||
| 445 | - | |||||||||||||
| 446 | - | |||||||||||||
| 447 | - | |||||||||||||
| 448 | if (currentSubWindow->isMaximized()) { | - | ||||||||||||
| 449 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::MoveAction, false); | - | ||||||||||||
| 450 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::ResizeAction, false); | - | ||||||||||||
| 451 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::MinimizeAction, false); | - | ||||||||||||
| 452 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::MaximizeAction, false); | - | ||||||||||||
| 453 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::RestoreAction, false); | - | ||||||||||||
| 454 | subWindowPrivate->setVisible(QMdiSubWindowPrivate::StayOnTopAction, false); | - | ||||||||||||
| 455 | } | - | ||||||||||||
| 456 | - | |||||||||||||
| 457 | - | |||||||||||||
| 458 | subWindowPrivate->systemMenu->exec(event->globalPos()); | - | ||||||||||||
| 459 | if (!subWindow) | - | ||||||||||||
| 460 | return; | - | ||||||||||||
| 461 | - | |||||||||||||
| 462 | - | |||||||||||||
| 463 | subWindowPrivate->updateActions(); | - | ||||||||||||
| 464 | - | |||||||||||||
| 465 | } | - | ||||||||||||
| 466 | - | |||||||||||||
| 467 | - | |||||||||||||
| 468 | - | |||||||||||||
| 469 | - | |||||||||||||
| 470 | - | |||||||||||||
| 471 | QMdiSubWindow *QMdiAreaTabBar::subWindowFromIndex(int index) const | - | ||||||||||||
| 472 | { | - | ||||||||||||
| 473 | if (index < 0 || index >= count()) | - | ||||||||||||
| 474 | return 0; | - | ||||||||||||
| 475 | - | |||||||||||||
| 476 | QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parentWidget()); | - | ||||||||||||
| 477 | ((!(mdiArea)) ? qt_assert("mdiArea",__FILE__,651655) : qt_noop()); | - | ||||||||||||
| 478 | - | |||||||||||||
| 479 | const QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList(); | - | ||||||||||||
| 480 | ((!(index < subWindows.size())) ? qt_assert("index < subWindows.size()",__FILE__,654658) : qt_noop()); | - | ||||||||||||
| 481 | - | |||||||||||||
| 482 | QMdiSubWindow *subWindow = mdiArea->subWindowList().at(index); | - | ||||||||||||
| 483 | ((!(subWindow)) ? qt_assert("subWindow",__FILE__,657661) : qt_noop()); | - | ||||||||||||
| 484 | - | |||||||||||||
| 485 | return subWindow; | - | ||||||||||||
| 486 | } | - | ||||||||||||
| 487 | - | |||||||||||||
| 488 | - | |||||||||||||
| 489 | - | |||||||||||||
| 490 | - | |||||||||||||
| 491 | - | |||||||||||||
| 492 | QMdiAreaPrivate::QMdiAreaPrivate() | - | ||||||||||||
| 493 | : cascader(0), | - | ||||||||||||
| 494 | regularTiler(0), | - | ||||||||||||
| 495 | iconTiler(0), | - | ||||||||||||
| 496 | placer(0), | - | ||||||||||||
| 497 | - | |||||||||||||
| 498 | rubberBand(0), | - | ||||||||||||
| 499 | - | |||||||||||||
| 500 | - | |||||||||||||
| 501 | tabBar(0), | - | ||||||||||||
| 502 | - | |||||||||||||
| 503 | activationOrder(QMdiArea::CreationOrder), | - | ||||||||||||
| 504 | viewMode(QMdiArea::SubWindowView), | - | ||||||||||||
| 505 | - | |||||||||||||
| 506 | documentMode(false), | - | ||||||||||||
| 507 | tabsClosable(false), | - | ||||||||||||
| 508 | tabsMovable(false), | - | ||||||||||||
| 509 | - | |||||||||||||
| 510 | - | |||||||||||||
| 511 | tabShape(QTabWidget::Rounded), | - | ||||||||||||
| 512 | tabPosition(QTabWidget::North), | - | ||||||||||||
| 513 | - | |||||||||||||
| 514 | ignoreGeometryChange(false), | - | ||||||||||||
| 515 | ignoreWindowStateChange(false), | - | ||||||||||||
| 516 | isActivated(false), | - | ||||||||||||
| 517 | isSubWindowsTiled(false), | - | ||||||||||||
| 518 | showActiveWindowMaximized(false), | - | ||||||||||||
| 519 | tileCalledFromResizeEvent(false), | - | ||||||||||||
| 520 | updatesDisabledByUs(false), | - | ||||||||||||
| 521 | inViewModeChange(false), | - | ||||||||||||
| 522 | indexToNextWindow(-1), | - | ||||||||||||
| 523 | indexToPreviousWindow(-1), | - | ||||||||||||
| 524 | indexToHighlighted(-1), | - | ||||||||||||
| 525 | indexToLastActiveTab(-1), | - | ||||||||||||
| 526 | resizeTimerId(-1), | - | ||||||||||||
| 527 | tabToPreviousTimerId(-1) | - | ||||||||||||
| 528 | { | - | ||||||||||||
| 529 | } | - | ||||||||||||
| 530 | - | |||||||||||||
| 531 | - | |||||||||||||
| 532 | - | |||||||||||||
| 533 | - | |||||||||||||
| 534 | void QMdiAreaPrivate::_q_deactivateAllWindows(QMdiSubWindow *aboutToActivate) | - | ||||||||||||
| 535 | { | - | ||||||||||||
| 536 | if (ignoreWindowStateChange) | - | ||||||||||||
| 537 | return; | - | ||||||||||||
| 538 | - | |||||||||||||
| 539 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 540 | if (!aboutToActivate) | - | ||||||||||||
| 541 | aboutToBecomeActive = qobject_cast<QMdiSubWindow *>(q->sender()); | - | ||||||||||||
| 542 | else | - | ||||||||||||
| 543 | aboutToBecomeActive = aboutToActivate; | - | ||||||||||||
| 544 | ((!(aboutToBecomeActive)) ? qt_assert("aboutToBecomeActive",__FILE__,718722) : qt_noop()); | - | ||||||||||||
| 545 | - | |||||||||||||
| 546 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(childWindows)>::type> _container_((childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 547 | if (!sanityCheck(child, "QMdiArea::deactivateAllWindows") || aboutToBecomeActive == child) | - | ||||||||||||
| 548 | continue; | - | ||||||||||||
| 549 | - | |||||||||||||
| 550 | ignoreWindowStateChange = true; | - | ||||||||||||
| 551 | if(!(options & QMdiArea::DontMaximizeSubWindowOnActivation) && !showActiveWindowMaximized) | - | ||||||||||||
| 552 | showActiveWindowMaximized = child->isMaximized() && child->isVisible(); | - | ||||||||||||
| 553 | if (showActiveWindowMaximized && child->isMaximized()) { | - | ||||||||||||
| 554 | if (q->updatesEnabled()) { | - | ||||||||||||
| 555 | updatesDisabledByUs = true; | - | ||||||||||||
| 556 | q->setUpdatesEnabled(false); | - | ||||||||||||
| 557 | } | - | ||||||||||||
| 558 | child->showNormal(); | - | ||||||||||||
| 559 | } | - | ||||||||||||
| 560 | if (child->isMinimized() && !child->isShaded() && !windowStaysOnTop(child)) | - | ||||||||||||
| 561 | child->lower(); | - | ||||||||||||
| 562 | ignoreWindowStateChange = false; | - | ||||||||||||
| 563 | child->d_func()->setActive(false); | - | ||||||||||||
| 564 | } | - | ||||||||||||
| 565 | } | - | ||||||||||||
| 566 | - | |||||||||||||
| 567 | - | |||||||||||||
| 568 | - | |||||||||||||
| 569 | - | |||||||||||||
| 570 | void QMdiAreaPrivate::_q_processWindowStateChanged(Qt::WindowStates oldState, | - | ||||||||||||
| 571 | Qt::WindowStates newState) | - | ||||||||||||
| 572 | { | - | ||||||||||||
| 573 | if (ignoreWindowStateChange) | - | ||||||||||||
| 574 | return; | - | ||||||||||||
| 575 | - | |||||||||||||
| 576 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 577 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(q->sender()); | - | ||||||||||||
| 578 | if (!child) | - | ||||||||||||
| 579 | return; | - | ||||||||||||
| 580 | - | |||||||||||||
| 581 | - | |||||||||||||
| 582 | if (!(oldState & Qt::WindowActive) && (newState & Qt::WindowActive)) | - | ||||||||||||
| 583 | emitWindowActivated(child); | - | ||||||||||||
| 584 | - | |||||||||||||
| 585 | else if ((oldState & Qt::WindowActive) && !(newState & Qt::WindowActive)) | - | ||||||||||||
| 586 | resetActiveWindow(child); | - | ||||||||||||
| 587 | - | |||||||||||||
| 588 | - | |||||||||||||
| 589 | if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized)) { | - | ||||||||||||
| 590 | isSubWindowsTiled = false; | - | ||||||||||||
| 591 | arrangeMinimizedSubWindows(); | - | ||||||||||||
| 592 | - | |||||||||||||
| 593 | } else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized)) { | - | ||||||||||||
| 594 | internalRaise(child); | - | ||||||||||||
| 595 | - | |||||||||||||
| 596 | } else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized))) { | - | ||||||||||||
| 597 | internalRaise(child); | - | ||||||||||||
| 598 | if (oldState & Qt::WindowMinimized) | - | ||||||||||||
| 599 | arrangeMinimizedSubWindows(); | - | ||||||||||||
| 600 | } | - | ||||||||||||
| 601 | } | - | ||||||||||||
| 602 | - | |||||||||||||
| 603 | void QMdiAreaPrivate::_q_currentTabChanged(int index) | - | ||||||||||||
| 604 | { | - | ||||||||||||
| 605 | - | |||||||||||||
| 606 | - | |||||||||||||
| 607 | - | |||||||||||||
| 608 | if (!tabBar || index < 0) | - | ||||||||||||
| 609 | return; | - | ||||||||||||
| 610 | - | |||||||||||||
| 611 | - | |||||||||||||
| 612 | if (indexToLastActiveTab >= 0 && indexToLastActiveTab < tabBar->count() | - | ||||||||||||
| 613 | && indexToLastActiveTab < childWindows.count()) { | - | ||||||||||||
| 614 | QMdiSubWindow *lastActive = childWindows.at(indexToLastActiveTab); | - | ||||||||||||
| 615 | if (lastActive && lastActive->isHidden()) | - | ||||||||||||
| 616 | tabBar->setTabEnabled(indexToLastActiveTab, false); | - | ||||||||||||
| 617 | } | - | ||||||||||||
| 618 | - | |||||||||||||
| 619 | indexToLastActiveTab = index; | - | ||||||||||||
| 620 | ((!(childWindows.size() > index)) ? qt_assert("childWindows.size() > index",__FILE__,794798) : qt_noop()); | - | ||||||||||||
| 621 | QMdiSubWindow *subWindow = childWindows.at(index); | - | ||||||||||||
| 622 | ((!(subWindow)) ? qt_assert("subWindow",__FILE__,796800) : qt_noop()); | - | ||||||||||||
| 623 | activateWindow(subWindow); | - | ||||||||||||
| 624 | - | |||||||||||||
| 625 | } | - | ||||||||||||
| 626 | - | |||||||||||||
| 627 | void QMdiAreaPrivate::_q_closeTab(int index) | - | ||||||||||||
| 628 | { | - | ||||||||||||
| 629 | - | |||||||||||||
| 630 | - | |||||||||||||
| 631 | - | |||||||||||||
| 632 | QMdiSubWindow *subWindow = childWindows.at(index); | - | ||||||||||||
| 633 | ((!(subWindow)) ? qt_assert("subWindow",__FILE__,807811) : qt_noop()); | - | ||||||||||||
| 634 | subWindow->close(); | - | ||||||||||||
| 635 | - | |||||||||||||
| 636 | } | - | ||||||||||||
| 637 | - | |||||||||||||
| 638 | void QMdiAreaPrivate::_q_moveTab(int from, int to) | - | ||||||||||||
| 639 | { | - | ||||||||||||
| 640 | - | |||||||||||||
| 641 | - | |||||||||||||
| 642 | - | |||||||||||||
| 643 | - | |||||||||||||
| 644 | childWindows.move(from, to); | - | ||||||||||||
| 645 | - | |||||||||||||
| 646 | } | - | ||||||||||||
| 647 | - | |||||||||||||
| 648 | - | |||||||||||||
| 649 | - | |||||||||||||
| 650 | - | |||||||||||||
| 651 | void QMdiAreaPrivate::appendChild(QMdiSubWindow *child) | - | ||||||||||||
| 652 | { | - | ||||||||||||
| 653 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 654 | ((!(child && childWindows.indexOf(child) == -1)) ? qt_assert("child && childWindows.indexOf(child) == -1",__FILE__,828832) : qt_noop()); | - | ||||||||||||
| 655 | - | |||||||||||||
| 656 | if (child->parent() != viewport) | - | ||||||||||||
| 657 | child->setParent(viewport, child->windowFlags()); | - | ||||||||||||
| 658 | childWindows.append(QPointer<QMdiSubWindow>(child)); | - | ||||||||||||
| 659 | - | |||||||||||||
| 660 | if (!child->testAttribute(Qt::WA_Resized) && q->isVisible()) { | - | ||||||||||||
| 661 | QSize newSize(child->sizeHint().boundedTo(viewport->size())); | - | ||||||||||||
| 662 | child->resize(newSize.expandedTo(qSmartMinSize(child))); | - | ||||||||||||
| 663 | } | - | ||||||||||||
| 664 | - | |||||||||||||
| 665 | if (!placer) | - | ||||||||||||
| 666 | placer = new MinOverlapPlacer; | - | ||||||||||||
| 667 | place(placer, child); | - | ||||||||||||
| 668 | - | |||||||||||||
| 669 | if (hbarpolicy != Qt::ScrollBarAlwaysOff) | - | ||||||||||||
| 670 | child->setOption(QMdiSubWindow::AllowOutsideAreaHorizontally, true); | - | ||||||||||||
| 671 | else | - | ||||||||||||
| 672 | child->setOption(QMdiSubWindow::AllowOutsideAreaHorizontally, false); | - | ||||||||||||
| 673 | - | |||||||||||||
| 674 | if (vbarpolicy != Qt::ScrollBarAlwaysOff) | - | ||||||||||||
| 675 | child->setOption(QMdiSubWindow::AllowOutsideAreaVertically, true); | - | ||||||||||||
| 676 | else | - | ||||||||||||
| 677 | child->setOption(QMdiSubWindow::AllowOutsideAreaVertically, false); | - | ||||||||||||
| 678 | - | |||||||||||||
| 679 | internalRaise(child); | - | ||||||||||||
| 680 | indicesToActivatedChildren.prepend(childWindows.size() - 1); | - | ||||||||||||
| 681 | ((!(indicesToActivatedChildren.size() == childWindows.size())) ? qt_assert("indicesToActivatedChildren.size() == childWindows.size()",__FILE__,855859) : qt_noop()); | - | ||||||||||||
| 682 | - | |||||||||||||
| 683 | - | |||||||||||||
| 684 | if (tabBar) { | - | ||||||||||||
| 685 | tabBar->addTab(child->windowIcon(), tabTextFor(child)); | - | ||||||||||||
| 686 | updateTabBarGeometry(); | - | ||||||||||||
| 687 | if (childWindows.count() == 1 && !(options & QMdiArea::DontMaximizeSubWindowOnActivation)) | - | ||||||||||||
| 688 | showActiveWindowMaximized = true; | - | ||||||||||||
| 689 | } | - | ||||||||||||
| 690 | - | |||||||||||||
| 691 | - | |||||||||||||
| 692 | if (!(child->windowFlags() & Qt::SubWindow)) | - | ||||||||||||
| 693 | child->setWindowFlags(Qt::SubWindow); | - | ||||||||||||
| 694 | child->installEventFilter(q); | - | ||||||||||||
| 695 | - | |||||||||||||
| 696 | QObject::connect(child, qFlagLocation("2""aboutToActivate()" "\0" __FILE__ ":" "870""874"), q, qFlagLocation("1""_q_deactivateAllWindows()" "\0" __FILE__ ":" "870""874")); | - | ||||||||||||
| 697 | QObject::connect(child, qFlagLocation("2""windowStateChanged(Qt::WindowStates,Qt::WindowStates)" "\0" __FILE__ ":" "871""875"), | - | ||||||||||||
| 698 | q, qFlagLocation("1""_q_processWindowStateChanged(Qt::WindowStates,Qt::WindowStates)" "\0" __FILE__ ":" "872""876")); | - | ||||||||||||
| 699 | } | - | ||||||||||||
| 700 | - | |||||||||||||
| 701 | - | |||||||||||||
| 702 | - | |||||||||||||
| 703 | - | |||||||||||||
| 704 | void QMdiAreaPrivate::place(Placer *placer, QMdiSubWindow *child) | - | ||||||||||||
| 705 | { | - | ||||||||||||
| 706 | if (!placer || !child) | - | ||||||||||||
| 707 | return; | - | ||||||||||||
| 708 | - | |||||||||||||
| 709 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 710 | if (!q->isVisible()) { | - | ||||||||||||
| 711 | - | |||||||||||||
| 712 | - | |||||||||||||
| 713 | - | |||||||||||||
| 714 | pendingPlacements.append(child); | - | ||||||||||||
| 715 | return; | - | ||||||||||||
| 716 | } | - | ||||||||||||
| 717 | - | |||||||||||||
| 718 | QVector<QRect> rects; | - | ||||||||||||
| 719 | rects.reserve(childWindows.size()); | - | ||||||||||||
| 720 | QRect parentRect = q->rect(); | - | ||||||||||||
| 721 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(childWindows)>::type> _container_((childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *window = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 722 | if (!sanityCheck(window, "QMdiArea::place") || window == child || !window->isVisibleTo(q) | - | ||||||||||||
| 723 | || !window->testAttribute(Qt::WA_Moved)) { | - | ||||||||||||
| 724 | continue; | - | ||||||||||||
| 725 | } | - | ||||||||||||
| 726 | QRect occupiedGeometry; | - | ||||||||||||
| 727 | if (window->isMaximized()) { | - | ||||||||||||
| 728 | occupiedGeometry = QRect(window->d_func()->oldGeometry.topLeft(), | - | ||||||||||||
| 729 | window->d_func()->restoreSize); | - | ||||||||||||
| 730 | } else { | - | ||||||||||||
| 731 | occupiedGeometry = window->geometry(); | - | ||||||||||||
| 732 | } | - | ||||||||||||
| 733 | rects.append(QStyle::visualRect(child->layoutDirection(), parentRect, occupiedGeometry)); | - | ||||||||||||
| 734 | } | - | ||||||||||||
| 735 | QPoint newPos = placer->place(child->size(), rects, parentRect); | - | ||||||||||||
| 736 | QRect newGeometry = QRect(newPos.x(), newPos.y(), child->width(), child->height()); | - | ||||||||||||
| 737 | child->setGeometry(QStyle::visualRect(child->layoutDirection(), parentRect, newGeometry)); | - | ||||||||||||
| 738 | } | - | ||||||||||||
| 739 | - | |||||||||||||
| 740 | - | |||||||||||||
| 741 | - | |||||||||||||
| 742 | - | |||||||||||||
| 743 | void QMdiAreaPrivate::rearrange(Rearranger *rearranger) | - | ||||||||||||
| 744 | { | - | ||||||||||||
| 745 | if (!rearranger
| 0 | ||||||||||||
| 746 | return; never executed: return; | 0 | ||||||||||||
| 747 | - | |||||||||||||
| 748 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 749 | if (!q->isVisible()
| 0 | ||||||||||||
| 750 | - | |||||||||||||
| 751 | int index = pendingRearrangements.indexOf(rearranger); | - | ||||||||||||
| 752 | if (index != -1
| 0 | ||||||||||||
| 753 | pendingRearrangements.move(index, pendingRearrangements.size() - 1); never executed: pendingRearrangements.move(index, pendingRearrangements.size() - 1); | 0 | ||||||||||||
| 754 | else | - | ||||||||||||
| 755 | pendingRearrangements.append(rearranger); never executed: pendingRearrangements.append(rearranger); | 0 | ||||||||||||
| 756 | return; never executed: return; | 0 | ||||||||||||
| 757 | } | - | ||||||||||||
| 758 | - | |||||||||||||
| 759 | QList<QWidget *> widgets; | - | ||||||||||||
| 760 | const bool reverseList = rearranger->type() == Rearranger::RegularTiler; | - | ||||||||||||
| 761 | const QList<QMdiSubWindow *> subWindows = subWindowList(activationOrder, reverseList); | - | ||||||||||||
| 762 | QSize minSubWindowSize; | - | ||||||||||||
| 763 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(subWindows)>::type> _container_((subWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 764 | if (!sanityCheck(child, "QMdiArea::rearrange")
| 0 | ||||||||||||
| 765 | continue; never executed: continue; | 0 | ||||||||||||
| 766 | if (rearranger->type() == Rearranger::IconTiler
| 0 | ||||||||||||
| 767 | if (child->isMinimized()
| 0 | ||||||||||||
| 768 | widgets.append(child); never executed: widgets.append(child); | 0 | ||||||||||||
| 769 | } never executed: else {end of block | 0 | ||||||||||||
| 770 | if (child->isMinimized()
| 0 | ||||||||||||
| 771 | continue; never executed: continue; | 0 | ||||||||||||
| 772 | if (child->isMaximized()
| 0 | ||||||||||||
| 773 | child->showNormal(); never executed: child->showNormal(); | 0 | ||||||||||||
| 774 | minSubWindowSize = minSubWindowSize.expandedTo(child->minimumSize()) | - | ||||||||||||
| 775 | .expandedTo(child->d_func()->internalMinimumSize); | - | ||||||||||||
| 776 | widgets.append(child); | - | ||||||||||||
| 777 | } never executed: end of block | 0 | ||||||||||||
| 778 | } | - | ||||||||||||
| 779 | - | |||||||||||||
| 780 | if (active
| 0 | ||||||||||||
| 781 | - | |||||||||||||
| 782 | - | |||||||||||||
| 783 | int indexToActive = widgets.indexOf((QWidget *)active); | - | ||||||||||||
| 784 | if (indexToActive > 0
| 0 | ||||||||||||
| 785 | widgets.move(indexToActive, 0); never executed: widgets.move(indexToActive, 0); | 0 | ||||||||||||
| 786 | } never executed: end of block | 0 | ||||||||||||
| 787 | - | |||||||||||||
| 788 | QRect domain = viewport->rect(); | - | ||||||||||||
| 789 | if (rearranger->type() == Rearranger::RegularTiler
| 0 | ||||||||||||
| 790 | domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); never executed: domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); | 0 | ||||||||||||
| 791 | - | |||||||||||||
| 792 | rearranger->rearrange(widgets, domain); | - | ||||||||||||
| 793 | - | |||||||||||||
| 794 | if (rearranger->type() == Rearranger::RegularTiler
| 0 | ||||||||||||
| 795 | isSubWindowsTiled = true; | - | ||||||||||||
| 796 | updateScrollBars(); | - | ||||||||||||
| 797 | } never executed: else if (rearranger->type() == Rearranger::SimpleCascaderend of block
| 0 | ||||||||||||
| 798 | isSubWindowsTiled = false; | - | ||||||||||||
| 799 | } never executed: end of block | 0 | ||||||||||||
| 800 | } never executed: end of block | 0 | ||||||||||||
| 801 | - | |||||||||||||
| 802 | - | |||||||||||||
| 803 | - | |||||||||||||
| 804 | - | |||||||||||||
| 805 | - | |||||||||||||
| 806 | - | |||||||||||||
| 807 | void QMdiAreaPrivate::arrangeMinimizedSubWindows() | - | ||||||||||||
| 808 | { | - | ||||||||||||
| 809 | if (!iconTiler) | - | ||||||||||||
| 810 | iconTiler = new IconTiler; | - | ||||||||||||
| 811 | rearrange(iconTiler); | - | ||||||||||||
| 812 | } | - | ||||||||||||
| 813 | - | |||||||||||||
| 814 | - | |||||||||||||
| 815 | - | |||||||||||||
| 816 | - | |||||||||||||
| 817 | void QMdiAreaPrivate::activateWindow(QMdiSubWindow *child) | - | ||||||||||||
| 818 | { | - | ||||||||||||
| 819 | if (childWindows.isEmpty()) { | - | ||||||||||||
| 820 | ((!(!child)) ? qt_assert("!child",__FILE__,994998) : qt_noop()); | - | ||||||||||||
| 821 | ((!(!active)) ? qt_assert("!active",__FILE__,995999) : qt_noop()); | - | ||||||||||||
| 822 | return; | - | ||||||||||||
| 823 | } | - | ||||||||||||
| 824 | - | |||||||||||||
| 825 | if (!child) { | - | ||||||||||||
| 826 | if (active) { | - | ||||||||||||
| 827 | ((!(active->d_func()->isActive)) ? qt_assert("active->d_func()->isActive",__FILE__,10011005) : qt_noop()); | - | ||||||||||||
| 828 | active->d_func()->setActive(false); | - | ||||||||||||
| 829 | resetActiveWindow(); | - | ||||||||||||
| 830 | } | - | ||||||||||||
| 831 | return; | - | ||||||||||||
| 832 | } | - | ||||||||||||
| 833 | - | |||||||||||||
| 834 | if (child->isHidden() || child == active) | - | ||||||||||||
| 835 | return; | - | ||||||||||||
| 836 | child->d_func()->setActive(true); | - | ||||||||||||
| 837 | } | - | ||||||||||||
| 838 | - | |||||||||||||
| 839 | - | |||||||||||||
| 840 | - | |||||||||||||
| 841 | - | |||||||||||||
| 842 | void QMdiAreaPrivate::activateCurrentWindow() | - | ||||||||||||
| 843 | { | - | ||||||||||||
| 844 | QMdiSubWindow *current = q_func()->currentSubWindow(); | - | ||||||||||||
| 845 | if (current && !isExplicitlyDeactivated(current)) { | - | ||||||||||||
| 846 | current->d_func()->activationEnabled = true; | - | ||||||||||||
| 847 | current->d_func()->setActive(true, false); | - | ||||||||||||
| 848 | } | - | ||||||||||||
| 849 | } | - | ||||||||||||
| 850 | - | |||||||||||||
| 851 | void QMdiAreaPrivate::activateHighlightedWindow() | - | ||||||||||||
| 852 | { | - | ||||||||||||
| 853 | if (indexToHighlighted < 0) | - | ||||||||||||
| 854 | return; | - | ||||||||||||
| 855 | - | |||||||||||||
| 856 | ((!(indexToHighlighted < childWindows.size())) ? qt_assert("indexToHighlighted < childWindows.size()",__FILE__,10301034) : qt_noop()); | - | ||||||||||||
| 857 | if (tabToPreviousTimerId != -1) | - | ||||||||||||
| 858 | activateWindow(nextVisibleSubWindow(-1, QMdiArea::ActivationHistoryOrder)); | - | ||||||||||||
| 859 | else | - | ||||||||||||
| 860 | activateWindow(childWindows.at(indexToHighlighted)); | - | ||||||||||||
| 861 | - | |||||||||||||
| 862 | hideRubberBand(); | - | ||||||||||||
| 863 | - | |||||||||||||
| 864 | } | - | ||||||||||||
| 865 | - | |||||||||||||
| 866 | - | |||||||||||||
| 867 | - | |||||||||||||
| 868 | - | |||||||||||||
| 869 | void QMdiAreaPrivate::emitWindowActivated(QMdiSubWindow *activeWindow) | - | ||||||||||||
| 870 | { | - | ||||||||||||
| 871 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 872 | ((!(activeWindow)) ? qt_assert("activeWindow",__FILE__,10461050) : qt_noop()); | - | ||||||||||||
| 873 | if (activeWindow == active) | - | ||||||||||||
| 874 | return; | - | ||||||||||||
| 875 | ((!(activeWindow->d_func()->isActive)) ? qt_assert("activeWindow->d_func()->isActive",__FILE__,10491053) : qt_noop()); | - | ||||||||||||
| 876 | - | |||||||||||||
| 877 | if (!aboutToBecomeActive) | - | ||||||||||||
| 878 | _q_deactivateAllWindows(activeWindow); | - | ||||||||||||
| 879 | ((!(aboutToBecomeActive)) ? qt_assert("aboutToBecomeActive",__FILE__,10531057) : qt_noop()); | - | ||||||||||||
| 880 | - | |||||||||||||
| 881 | - | |||||||||||||
| 882 | - | |||||||||||||
| 883 | if (showActiveWindowMaximized) { | - | ||||||||||||
| 884 | if (!activeWindow->isMaximized()) | - | ||||||||||||
| 885 | activeWindow->showMaximized(); | - | ||||||||||||
| 886 | showActiveWindowMaximized = false; | - | ||||||||||||
| 887 | } | - | ||||||||||||
| 888 | - | |||||||||||||
| 889 | - | |||||||||||||
| 890 | const int indexToActiveWindow = childWindows.indexOf(activeWindow); | - | ||||||||||||
| 891 | ((!(indexToActiveWindow != -1)) ? qt_assert("indexToActiveWindow != -1",__FILE__,10651069) : qt_noop()); | - | ||||||||||||
| 892 | const int index = indicesToActivatedChildren.indexOf(indexToActiveWindow); | - | ||||||||||||
| 893 | ((!(index != -1)) ? qt_assert("index != -1",__FILE__,10671071) : qt_noop()); | - | ||||||||||||
| 894 | indicesToActivatedChildren.move(index, 0); | - | ||||||||||||
| 895 | internalRaise(activeWindow); | - | ||||||||||||
| 896 | - | |||||||||||||
| 897 | if (updatesDisabledByUs) { | - | ||||||||||||
| 898 | q->setUpdatesEnabled(true); | - | ||||||||||||
| 899 | updatesDisabledByUs = false; | - | ||||||||||||
| 900 | } | - | ||||||||||||
| 901 | - | |||||||||||||
| 902 | ((!(aboutToBecomeActive == activeWindow)) ? qt_assert("aboutToBecomeActive == activeWindow",__FILE__,10761080) : qt_noop()); | - | ||||||||||||
| 903 | active = activeWindow; | - | ||||||||||||
| 904 | aboutToBecomeActive = 0; | - | ||||||||||||
| 905 | ((!(active->d_func()->isActive)) ? qt_assert("active->d_func()->isActive",__FILE__,10791083) : qt_noop()); | - | ||||||||||||
| 906 | - | |||||||||||||
| 907 | - | |||||||||||||
| 908 | if (tabBar && tabBar->currentIndex() != indexToActiveWindow) | - | ||||||||||||
| 909 | tabBar->setCurrentIndex(indexToActiveWindow); | - | ||||||||||||
| 910 | - | |||||||||||||
| 911 | - | |||||||||||||
| 912 | if (active->isMaximized() && scrollBarsEnabled()) | - | ||||||||||||
| 913 | updateScrollBars(); | - | ||||||||||||
| 914 | - | |||||||||||||
| 915 | q->subWindowActivated(active); | - | ||||||||||||
| 916 | } | - | ||||||||||||
| 917 | - | |||||||||||||
| 918 | - | |||||||||||||
| 919 | - | |||||||||||||
| 920 | - | |||||||||||||
| 921 | void QMdiAreaPrivate::resetActiveWindow(QMdiSubWindow *deactivatedWindow) | - | ||||||||||||
| 922 | { | - | ||||||||||||
| 923 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 924 | if (deactivatedWindow) { | - | ||||||||||||
| 925 | if (deactivatedWindow != active) | - | ||||||||||||
| 926 | return; | - | ||||||||||||
| 927 | active = 0; | - | ||||||||||||
| 928 | if ((aboutToBecomeActive || isActivated || lastWindowAboutToBeDestroyed()) | - | ||||||||||||
| 929 | && !isExplicitlyDeactivated(deactivatedWindow) && !q->window()->isMinimized()) { | - | ||||||||||||
| 930 | return; | - | ||||||||||||
| 931 | } | - | ||||||||||||
| 932 | q->subWindowActivated(0); | - | ||||||||||||
| 933 | return; | - | ||||||||||||
| 934 | } | - | ||||||||||||
| 935 | - | |||||||||||||
| 936 | if (aboutToBecomeActive) | - | ||||||||||||
| 937 | return; | - | ||||||||||||
| 938 | - | |||||||||||||
| 939 | active = 0; | - | ||||||||||||
| 940 | q->subWindowActivated(0); | - | ||||||||||||
| 941 | } | - | ||||||||||||
| 942 | - | |||||||||||||
| 943 | - | |||||||||||||
| 944 | - | |||||||||||||
| 945 | - | |||||||||||||
| 946 | void QMdiAreaPrivate::updateActiveWindow(int removedIndex, bool activeRemoved) | - | ||||||||||||
| 947 | { | - | ||||||||||||
| 948 | ((!(indicesToActivatedChildren.size() == childWindows.size())) ? qt_assert("indicesToActivatedChildren.size() == childWindows.size()",__FILE__,11221126) : qt_noop()); | - | ||||||||||||
| 949 | - | |||||||||||||
| 950 | - | |||||||||||||
| 951 | if (tabBar && removedIndex >= 0) { | - | ||||||||||||
| 952 | const QSignalBlocker blocker(tabBar); | - | ||||||||||||
| 953 | tabBar->removeTab(removedIndex); | - | ||||||||||||
| 954 | updateTabBarGeometry(); | - | ||||||||||||
| 955 | } | - | ||||||||||||
| 956 | - | |||||||||||||
| 957 | - | |||||||||||||
| 958 | if (childWindows.isEmpty()) { | - | ||||||||||||
| 959 | showActiveWindowMaximized = false; | - | ||||||||||||
| 960 | resetActiveWindow(); | - | ||||||||||||
| 961 | return; | - | ||||||||||||
| 962 | } | - | ||||||||||||
| 963 | - | |||||||||||||
| 964 | if (indexToHighlighted >= 0) { | - | ||||||||||||
| 965 | - | |||||||||||||
| 966 | - | |||||||||||||
| 967 | if (indexToHighlighted == removedIndex) | - | ||||||||||||
| 968 | hideRubberBand(); | - | ||||||||||||
| 969 | else | - | ||||||||||||
| 970 | - | |||||||||||||
| 971 | - | |||||||||||||
| 972 | if (indexToHighlighted > removedIndex) | - | ||||||||||||
| 973 | --indexToHighlighted; | - | ||||||||||||
| 974 | } | - | ||||||||||||
| 975 | - | |||||||||||||
| 976 | - | |||||||||||||
| 977 | for (int i = 0; i < indicesToActivatedChildren.size(); ++i) { | - | ||||||||||||
| 978 | int *index = &indicesToActivatedChildren[i]; | - | ||||||||||||
| 979 | if (*index > removedIndex) | - | ||||||||||||
| 980 | --*index; | - | ||||||||||||
| 981 | } | - | ||||||||||||
| 982 | - | |||||||||||||
| 983 | if (!activeRemoved) | - | ||||||||||||
| 984 | return; | - | ||||||||||||
| 985 | - | |||||||||||||
| 986 | - | |||||||||||||
| 987 | QMdiSubWindow *next = nextVisibleSubWindow(0, activationOrder, removedIndex); | - | ||||||||||||
| 988 | if (next) | - | ||||||||||||
| 989 | activateWindow(next); | - | ||||||||||||
| 990 | } | - | ||||||||||||
| 991 | - | |||||||||||||
| 992 | - | |||||||||||||
| 993 | - | |||||||||||||
| 994 | - | |||||||||||||
| 995 | void QMdiAreaPrivate::updateScrollBars() | - | ||||||||||||
| 996 | { | - | ||||||||||||
| 997 | if (ignoreGeometryChange || !scrollBarsEnabled()) | - | ||||||||||||
| 998 | return; | - | ||||||||||||
| 999 | - | |||||||||||||
| 1000 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 1001 | QSize maxSize = q->maximumViewportSize(); | - | ||||||||||||
| 1002 | QSize hbarExtent = hbar->sizeHint(); | - | ||||||||||||
| 1003 | QSize vbarExtent = vbar->sizeHint(); | - | ||||||||||||
| 1004 | - | |||||||||||||
| 1005 | if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) { | - | ||||||||||||
| 1006 | const int doubleFrameWidth = frameWidth * 2; | - | ||||||||||||
| 1007 | if (hbarpolicy == Qt::ScrollBarAlwaysOn) | - | ||||||||||||
| 1008 | maxSize.rheight() -= doubleFrameWidth; | - | ||||||||||||
| 1009 | if (vbarpolicy == Qt::ScrollBarAlwaysOn) | - | ||||||||||||
| 1010 | maxSize.rwidth() -= doubleFrameWidth; | - | ||||||||||||
| 1011 | hbarExtent.rheight() += doubleFrameWidth; | - | ||||||||||||
| 1012 | vbarExtent.rwidth() += doubleFrameWidth; | - | ||||||||||||
| 1013 | } | - | ||||||||||||
| 1014 | - | |||||||||||||
| 1015 | const QRect childrenRect = active && active->isMaximized() | - | ||||||||||||
| 1016 | ? active->geometry() : viewport->childrenRect(); | - | ||||||||||||
| 1017 | bool useHorizontalScrollBar = useScrollBar(childrenRect, maxSize, Qt::Horizontal); | - | ||||||||||||
| 1018 | bool useVerticalScrollBar = useScrollBar(childrenRect, maxSize, Qt::Vertical); | - | ||||||||||||
| 1019 | - | |||||||||||||
| 1020 | if (useHorizontalScrollBar && !useVerticalScrollBar) { | - | ||||||||||||
| 1021 | const QSize max = maxSize - QSize(0, hbarExtent.height()); | - | ||||||||||||
| 1022 | useVerticalScrollBar = useScrollBar(childrenRect, max, Qt::Vertical); | - | ||||||||||||
| 1023 | } | - | ||||||||||||
| 1024 | - | |||||||||||||
| 1025 | if (useVerticalScrollBar && !useHorizontalScrollBar) { | - | ||||||||||||
| 1026 | const QSize max = maxSize - QSize(vbarExtent.width(), 0); | - | ||||||||||||
| 1027 | useHorizontalScrollBar = useScrollBar(childrenRect, max, Qt::Horizontal); | - | ||||||||||||
| 1028 | } | - | ||||||||||||
| 1029 | - | |||||||||||||
| 1030 | if (useHorizontalScrollBar && hbarpolicy != Qt::ScrollBarAlwaysOn) | - | ||||||||||||
| 1031 | maxSize.rheight() -= hbarExtent.height(); | - | ||||||||||||
| 1032 | if (useVerticalScrollBar && vbarpolicy != Qt::ScrollBarAlwaysOn) | - | ||||||||||||
| 1033 | maxSize.rwidth() -= vbarExtent.width(); | - | ||||||||||||
| 1034 | - | |||||||||||||
| 1035 | QRect viewportRect(QPoint(0, 0), maxSize); | - | ||||||||||||
| 1036 | const int startX = q->isLeftToRight() ? childrenRect.left() : viewportRect.right() | - | ||||||||||||
| 1037 | - childrenRect.right(); | - | ||||||||||||
| 1038 | - | |||||||||||||
| 1039 | - | |||||||||||||
| 1040 | if (isSubWindowsTiled && hbar->value() != 0) | - | ||||||||||||
| 1041 | hbar->setValue(0); | - | ||||||||||||
| 1042 | const int xOffset = startX + hbar->value(); | - | ||||||||||||
| 1043 | hbar->setRange(qMin(0, xOffset), | - | ||||||||||||
| 1044 | qMax(0, xOffset + childrenRect.width() - viewportRect.width())); | - | ||||||||||||
| 1045 | hbar->setPageStep(childrenRect.width()); | - | ||||||||||||
| 1046 | hbar->setSingleStep(childrenRect.width() / 20); | - | ||||||||||||
| 1047 | - | |||||||||||||
| 1048 | - | |||||||||||||
| 1049 | if (isSubWindowsTiled && vbar->value() != 0) | - | ||||||||||||
| 1050 | vbar->setValue(0); | - | ||||||||||||
| 1051 | const int yOffset = childrenRect.top() + vbar->value(); | - | ||||||||||||
| 1052 | vbar->setRange(qMin(0, yOffset), | - | ||||||||||||
| 1053 | qMax(0, yOffset + childrenRect.height() - viewportRect.height())); | - | ||||||||||||
| 1054 | vbar->setPageStep(childrenRect.height()); | - | ||||||||||||
| 1055 | vbar->setSingleStep(childrenRect.height() / 20); | - | ||||||||||||
| 1056 | } | - | ||||||||||||
| 1057 | - | |||||||||||||
| 1058 | - | |||||||||||||
| 1059 | - | |||||||||||||
| 1060 | - | |||||||||||||
| 1061 | void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const | - | ||||||||||||
| 1062 | { | - | ||||||||||||
| 1063 | if (!sanityCheck(mdiChild, "QMdiArea::internalRaise")
| 0 | ||||||||||||
| 1064 | return; never executed: return; | 0 | ||||||||||||
| 1065 | - | |||||||||||||
| 1066 | QMdiSubWindow *stackUnderChild = 0; | - | ||||||||||||
| 1067 | if (!windowStaysOnTop(mdiChild)
| 0 | ||||||||||||
| 1068 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(viewport->const auto children ())>::type> _container_((= viewport->children())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||
| 1069 | for (QObject *object = *_container_.i; _container_.control; _container_.control = 0: children) { | - | ||||||||||||
| 1070 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object); | - | ||||||||||||
| 1071 | if (!child
| 0 | ||||||||||||
| 1072 | continue; never executed: continue; | 0 | ||||||||||||
| 1073 | if (!child->isHidden()
| 0 | ||||||||||||
| 1074 | if (stackUnderChild
| 0 | ||||||||||||
| 1075 | child->stackUnder(stackUnderChild); never executed: child->stackUnder(stackUnderChild); | 0 | ||||||||||||
| 1076 | else | - | ||||||||||||
| 1077 | child->raise(); never executed: child->raise(); | 0 | ||||||||||||
| 1078 | stackUnderChild = child; | - | ||||||||||||
| 1079 | } never executed: end of block | 0 | ||||||||||||
| 1080 | } never executed: end of block | 0 | ||||||||||||
| 1081 | } never executed: end of block | 0 | ||||||||||||
| 1082 | - | |||||||||||||
| 1083 | if (stackUnderChild
| 0 | ||||||||||||
| 1084 | mdiChild->stackUnder(stackUnderChild); never executed: mdiChild->stackUnder(stackUnderChild); | 0 | ||||||||||||
| 1085 | else | - | ||||||||||||
| 1086 | mdiChild->raise(); never executed: mdiChild->raise(); | 0 | ||||||||||||
| 1087 | } | - | ||||||||||||
| 1088 | - | |||||||||||||
| 1089 | QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount) | - | ||||||||||||
| 1090 | { | - | ||||||||||||
| 1091 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 1092 | if (!minSubWindowSize.isValid() || subWindowCount <= 0) | - | ||||||||||||
| 1093 | return viewport->rect(); | - | ||||||||||||
| 1094 | - | |||||||||||||
| 1095 | - | |||||||||||||
| 1096 | const int columns = qMax(qCeil(qSqrt(qreal(subWindowCount))), 1); | - | ||||||||||||
| 1097 | const int rows = qMax((subWindowCount % columns) ? (subWindowCount / columns + 1) | - | ||||||||||||
| 1098 | : (subWindowCount / columns), 1); | - | ||||||||||||
| 1099 | const int minWidth = minSubWindowSize.width() * columns; | - | ||||||||||||
| 1100 | const int minHeight = minSubWindowSize.height() * rows; | - | ||||||||||||
| 1101 | - | |||||||||||||
| 1102 | - | |||||||||||||
| 1103 | - | |||||||||||||
| 1104 | if (!tileCalledFromResizeEvent) { | - | ||||||||||||
| 1105 | QWidget *topLevel = q; | - | ||||||||||||
| 1106 | - | |||||||||||||
| 1107 | while (topLevel && !topLevel->isWindow() && topLevel->windowType() != Qt::SubWindow) | - | ||||||||||||
| 1108 | topLevel = topLevel->parentWidget(); | - | ||||||||||||
| 1109 | - | |||||||||||||
| 1110 | int minAreaWidth = minWidth + left + right + 2; | - | ||||||||||||
| 1111 | int minAreaHeight = minHeight + top + bottom + 2; | - | ||||||||||||
| 1112 | if (hbar->isVisible()) | - | ||||||||||||
| 1113 | minAreaHeight += hbar->height(); | - | ||||||||||||
| 1114 | if (vbar->isVisible()) | - | ||||||||||||
| 1115 | minAreaWidth += vbar->width(); | - | ||||||||||||
| 1116 | if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) { | - | ||||||||||||
| 1117 | const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q); | - | ||||||||||||
| 1118 | minAreaWidth += 2 * frame; | - | ||||||||||||
| 1119 | minAreaHeight += 2 * frame; | - | ||||||||||||
| 1120 | } | - | ||||||||||||
| 1121 | const QSize diff = QSize(minAreaWidth, minAreaHeight).expandedTo(q->size()) - q->size(); | - | ||||||||||||
| 1122 | topLevel->resize(topLevel->size() + diff); | - | ||||||||||||
| 1123 | } | - | ||||||||||||
| 1124 | - | |||||||||||||
| 1125 | QRect domain = viewport->rect(); | - | ||||||||||||
| 1126 | - | |||||||||||||
| 1127 | - | |||||||||||||
| 1128 | if (domain.width() < minWidth) { | - | ||||||||||||
| 1129 | domain.setWidth(minWidth); | - | ||||||||||||
| 1130 | if (hbarpolicy == Qt::ScrollBarAlwaysOff) | - | ||||||||||||
| 1131 | q->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); | - | ||||||||||||
| 1132 | else | - | ||||||||||||
| 1133 | hbar->setValue(0); | - | ||||||||||||
| 1134 | } | - | ||||||||||||
| 1135 | - | |||||||||||||
| 1136 | if (domain.height() < minHeight) { | - | ||||||||||||
| 1137 | domain.setHeight(minHeight); | - | ||||||||||||
| 1138 | if (vbarpolicy == Qt::ScrollBarAlwaysOff) | - | ||||||||||||
| 1139 | q->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); | - | ||||||||||||
| 1140 | else | - | ||||||||||||
| 1141 | vbar->setValue(0); | - | ||||||||||||
| 1142 | } | - | ||||||||||||
| 1143 | return domain; | - | ||||||||||||
| 1144 | } | - | ||||||||||||
| 1145 | - | |||||||||||||
| 1146 | - | |||||||||||||
| 1147 | - | |||||||||||||
| 1148 | - | |||||||||||||
| 1149 | bool QMdiAreaPrivate::scrollBarsEnabled() const | - | ||||||||||||
| 1150 | { | - | ||||||||||||
| 1151 | return hbarpolicy != Qt::ScrollBarAlwaysOff || vbarpolicy != Qt::ScrollBarAlwaysOff; | - | ||||||||||||
| 1152 | } | - | ||||||||||||
| 1153 | - | |||||||||||||
| 1154 | - | |||||||||||||
| 1155 | - | |||||||||||||
| 1156 | - | |||||||||||||
| 1157 | bool QMdiAreaPrivate::lastWindowAboutToBeDestroyed() const | - | ||||||||||||
| 1158 | { | - | ||||||||||||
| 1159 | if (childWindows.count() != 1) | - | ||||||||||||
| 1160 | return false; | - | ||||||||||||
| 1161 | - | |||||||||||||
| 1162 | QMdiSubWindow *last = childWindows.at(0); | - | ||||||||||||
| 1163 | if (!last) | - | ||||||||||||
| 1164 | return true; | - | ||||||||||||
| 1165 | - | |||||||||||||
| 1166 | if (!last->testAttribute(Qt::WA_DeleteOnClose)) | - | ||||||||||||
| 1167 | return false; | - | ||||||||||||
| 1168 | - | |||||||||||||
| 1169 | return last->d_func()->data.is_closing; | - | ||||||||||||
| 1170 | } | - | ||||||||||||
| 1171 | - | |||||||||||||
| 1172 | - | |||||||||||||
| 1173 | - | |||||||||||||
| 1174 | - | |||||||||||||
| 1175 | void QMdiAreaPrivate::setChildActivationEnabled(bool enable, bool onlyNextActivationEvent) const | - | ||||||||||||
| 1176 | { | - | ||||||||||||
| 1177 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(childWindows)>::type> _container_((childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *subWindow = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 1178 | if (!subWindow || !subWindow->isVisible()) | - | ||||||||||||
| 1179 | continue; | - | ||||||||||||
| 1180 | if (onlyNextActivationEvent) | - | ||||||||||||
| 1181 | subWindow->d_func()->ignoreNextActivationEvent = !enable; | - | ||||||||||||
| 1182 | else | - | ||||||||||||
| 1183 | subWindow->d_func()->activationEnabled = enable; | - | ||||||||||||
| 1184 | } | - | ||||||||||||
| 1185 | } | - | ||||||||||||
| 1186 | - | |||||||||||||
| 1187 | - | |||||||||||||
| 1188 | - | |||||||||||||
| 1189 | - | |||||||||||||
| 1190 | - | |||||||||||||
| 1191 | void QMdiAreaPrivate::scrollBarPolicyChanged(Qt::Orientation orientation, Qt::ScrollBarPolicy policy) | - | ||||||||||||
| 1192 | { | - | ||||||||||||
| 1193 | if (childWindows.isEmpty()) | - | ||||||||||||
| 1194 | return; | - | ||||||||||||
| 1195 | - | |||||||||||||
| 1196 | const QMdiSubWindow::SubWindowOption option = orientation == Qt::Horizontal ? | - | ||||||||||||
| 1197 | QMdiSubWindow::AllowOutsideAreaHorizontally : QMdiSubWindow::AllowOutsideAreaVertically; | - | ||||||||||||
| 1198 | const bool enable = policy != Qt::ScrollBarAlwaysOff; | - | ||||||||||||
| 1199 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(childWindows)>::type> _container_((childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 1200 | if (!sanityCheck(child, "QMdiArea::scrollBarPolicyChanged")) | - | ||||||||||||
| 1201 | continue; | - | ||||||||||||
| 1202 | child->setOption(option, enable); | - | ||||||||||||
| 1203 | } | - | ||||||||||||
| 1204 | updateScrollBars(); | - | ||||||||||||
| 1205 | } | - | ||||||||||||
| 1206 | - | |||||||||||||
| 1207 | QList<QMdiSubWindow*> | - | ||||||||||||
| 1208 | QMdiAreaPrivate::subWindowList(QMdiArea::WindowOrder order, bool reversed) const | - | ||||||||||||
| 1209 | { | - | ||||||||||||
| 1210 | QList<QMdiSubWindow *> list; | - | ||||||||||||
| 1211 | if (childWindows.isEmpty()
| 0 | ||||||||||||
| 1212 | return never executed: list;return list;never executed: return list; | 0 | ||||||||||||
| 1213 | - | |||||||||||||
| 1214 | if (order == QMdiArea::CreationOrder
| 0 | ||||||||||||
| 1215 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(childWindows)>::type> _container_((childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 1216 | if (!child
| 0 | ||||||||||||
| 1217 | continue; never executed: continue; | 0 | ||||||||||||
| 1218 | if (!reversed
| 0 | ||||||||||||
| 1219 | list.append(child); never executed: list.append(child); | 0 | ||||||||||||
| 1220 | else | - | ||||||||||||
| 1221 | list.prepend(child); never executed: list.prepend(child); | 0 | ||||||||||||
| 1222 | } | - | ||||||||||||
| 1223 | } never executed: else if (order == QMdiArea::StackingOrderend of block
| 0 | ||||||||||||
| 1224 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(viewport->children())>::type> _container_((viewport->children())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QObject *object = *_container_.i; _container_.control; _container_.control = 0): viewport->children()) { | - | ||||||||||||
| 1225 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(object); | - | ||||||||||||
| 1226 | if (!child
| 0 | ||||||||||||
| 1227 | continue; never executed: continue; | 0 | ||||||||||||
| 1228 | if (!reversed
| 0 | ||||||||||||
| 1229 | list.append(child); never executed: list.append(child); | 0 | ||||||||||||
| 1230 | else | - | ||||||||||||
| 1231 | list.prepend(child); never executed: list.prepend(child); | 0 | ||||||||||||
| 1232 | } | - | ||||||||||||
| 1233 | } never executed: else {end of block | 0 | ||||||||||||
| 1234 | ((!(indicesToActivatedChildren.size() == childWindows.size())) ? qt_assert("indicesToActivatedChildren.size() == childWindows.size()",__FILE__,14071412) : qt_noop()); | - | ||||||||||||
| 1235 | for (int i = indicesToActivatedChildren.count() - 1; i >= 0
| 0 | ||||||||||||
| 1236 | QMdiSubWindow *child = childWindows.at(indicesToActivatedChildren.at(i)); | - | ||||||||||||
| 1237 | if (!child
| 0 | ||||||||||||
| 1238 | continue; never executed: continue; | 0 | ||||||||||||
| 1239 | if (!reversed
| 0 | ||||||||||||
| 1240 | list.append(child); never executed: list.append(child); | 0 | ||||||||||||
| 1241 | else | - | ||||||||||||
| 1242 | list.prepend(child); never executed: list.prepend(child); | 0 | ||||||||||||
| 1243 | } | - | ||||||||||||
| 1244 | } never executed: end of block | 0 | ||||||||||||
| 1245 | return never executed: list;return list;never executed: return list; | 0 | ||||||||||||
| 1246 | } | - | ||||||||||||
| 1247 | - | |||||||||||||
| 1248 | - | |||||||||||||
| 1249 | - | |||||||||||||
| 1250 | - | |||||||||||||
| 1251 | void QMdiAreaPrivate::disconnectSubWindow(QObject *subWindow) | - | ||||||||||||
| 1252 | { | - | ||||||||||||
| 1253 | if (!subWindow) | - | ||||||||||||
| 1254 | return; | - | ||||||||||||
| 1255 | - | |||||||||||||
| 1256 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 1257 | QObject::disconnect(subWindow, 0, q, 0); | - | ||||||||||||
| 1258 | subWindow->removeEventFilter(q); | - | ||||||||||||
| 1259 | } | - | ||||||||||||
| 1260 | - | |||||||||||||
| 1261 | - | |||||||||||||
| 1262 | - | |||||||||||||
| 1263 | - | |||||||||||||
| 1264 | QMdiSubWindow *QMdiAreaPrivate::nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder order, | - | ||||||||||||
| 1265 | int removedIndex, int fromIndex) const | - | ||||||||||||
| 1266 | { | - | ||||||||||||
| 1267 | if (childWindows.isEmpty()) | - | ||||||||||||
| 1268 | return 0; | - | ||||||||||||
| 1269 | - | |||||||||||||
| 1270 | const QMdiArea * const q = q_func(); | - | ||||||||||||
| 1271 | const QList<QMdiSubWindow *> subWindows = q->subWindowList(order); | - | ||||||||||||
| 1272 | QMdiSubWindow *current = 0; | - | ||||||||||||
| 1273 | - | |||||||||||||
| 1274 | if (removedIndex < 0) { | - | ||||||||||||
| 1275 | if (fromIndex >= 0 && fromIndex < subWindows.size()) | - | ||||||||||||
| 1276 | current = childWindows.at(fromIndex); | - | ||||||||||||
| 1277 | else | - | ||||||||||||
| 1278 | current = q->currentSubWindow(); | - | ||||||||||||
| 1279 | } | - | ||||||||||||
| 1280 | - | |||||||||||||
| 1281 | - | |||||||||||||
| 1282 | - | |||||||||||||
| 1283 | if (!current) { | - | ||||||||||||
| 1284 | if (removedIndex >= 0 && order == QMdiArea::CreationOrder) { | - | ||||||||||||
| 1285 | int candidateIndex = -1; | - | ||||||||||||
| 1286 | setIndex(&candidateIndex, removedIndex, 0, subWindows.size() - 1, true); | - | ||||||||||||
| 1287 | current = childWindows.at(candidateIndex); | - | ||||||||||||
| 1288 | } else { | - | ||||||||||||
| 1289 | current = subWindows.back(); | - | ||||||||||||
| 1290 | } | - | ||||||||||||
| 1291 | } | - | ||||||||||||
| 1292 | ((!(current)) ? qt_assert("current",__FILE__,14651470) : qt_noop()); | - | ||||||||||||
| 1293 | - | |||||||||||||
| 1294 | - | |||||||||||||
| 1295 | const int indexToCurrent = subWindows.indexOf(current); | - | ||||||||||||
| 1296 | const bool increasing = increaseFactor > 0; | - | ||||||||||||
| 1297 | - | |||||||||||||
| 1298 | - | |||||||||||||
| 1299 | int index = -1; | - | ||||||||||||
| 1300 | setIndex(&index, indexToCurrent + increaseFactor, 0, subWindows.size() - 1, increasing); | - | ||||||||||||
| 1301 | ((!(index != -1)) ? qt_assert("index != -1",__FILE__,14741479) : qt_noop()); | - | ||||||||||||
| 1302 | - | |||||||||||||
| 1303 | - | |||||||||||||
| 1304 | while (subWindows.at(index)->isHidden()) { | - | ||||||||||||
| 1305 | setIndex(&index, index + increaseFactor, 0, subWindows.size() - 1, increasing); | - | ||||||||||||
| 1306 | if (index == indexToCurrent) | - | ||||||||||||
| 1307 | break; | - | ||||||||||||
| 1308 | } | - | ||||||||||||
| 1309 | - | |||||||||||||
| 1310 | if (!subWindows.at(index)->isHidden()) | - | ||||||||||||
| 1311 | return subWindows.at(index); | - | ||||||||||||
| 1312 | return 0; | - | ||||||||||||
| 1313 | } | - | ||||||||||||
| 1314 | - | |||||||||||||
| 1315 | - | |||||||||||||
| 1316 | - | |||||||||||||
| 1317 | - | |||||||||||||
| 1318 | void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) | - | ||||||||||||
| 1319 | { | - | ||||||||||||
| 1320 | if (childWindows.size() == 1) | - | ||||||||||||
| 1321 | return; | - | ||||||||||||
| 1322 | - | |||||||||||||
| 1323 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 1324 | - | |||||||||||||
| 1325 | if (indexToHighlighted < 0) { | - | ||||||||||||
| 1326 | QMdiSubWindow *current = q->currentSubWindow(); | - | ||||||||||||
| 1327 | if (!current) | - | ||||||||||||
| 1328 | return; | - | ||||||||||||
| 1329 | indexToHighlighted = childWindows.indexOf(current); | - | ||||||||||||
| 1330 | } | - | ||||||||||||
| 1331 | - | |||||||||||||
| 1332 | ((!(indexToHighlighted >= 0)) ? qt_assert("indexToHighlighted >= 0",__FILE__,15051510) : qt_noop()); | - | ||||||||||||
| 1333 | ((!(indexToHighlighted < childWindows.size())) ? qt_assert("indexToHighlighted < childWindows.size()",__FILE__,15061511) : qt_noop()); | - | ||||||||||||
| 1334 | - | |||||||||||||
| 1335 | QMdiSubWindow *highlight = nextVisibleSubWindow(increaseFactor, activationOrder, -1, indexToHighlighted); | - | ||||||||||||
| 1336 | if (!highlight) | - | ||||||||||||
| 1337 | return; | - | ||||||||||||
| 1338 | - | |||||||||||||
| 1339 | - | |||||||||||||
| 1340 | if (!rubberBand) { | - | ||||||||||||
| 1341 | rubberBand = new QRubberBand(QRubberBand::Rectangle, q); | - | ||||||||||||
| 1342 | - | |||||||||||||
| 1343 | rubberBand->setObjectName(QLatin1String("qt_rubberband")); | - | ||||||||||||
| 1344 | rubberBand->setWindowFlags(rubberBand->windowFlags() | Qt::WindowStaysOnTopHint); | - | ||||||||||||
| 1345 | } | - | ||||||||||||
| 1346 | - | |||||||||||||
| 1347 | - | |||||||||||||
| 1348 | - | |||||||||||||
| 1349 | - | |||||||||||||
| 1350 | if (tabToPreviousTimerId == -1) | - | ||||||||||||
| 1351 | showRubberBandFor(highlight); | - | ||||||||||||
| 1352 | - | |||||||||||||
| 1353 | - | |||||||||||||
| 1354 | indexToHighlighted = childWindows.indexOf(highlight); | - | ||||||||||||
| 1355 | ((!(indexToHighlighted >= 0)) ? qt_assert("indexToHighlighted >= 0",__FILE__,15281533) : qt_noop()); | - | ||||||||||||
| 1356 | } | - | ||||||||||||
| 1357 | - | |||||||||||||
| 1358 | void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) | - | ||||||||||||
| 1359 | { | - | ||||||||||||
| 1360 | if (!subWindow || !rubberBand) | - | ||||||||||||
| 1361 | return; | - | ||||||||||||
| 1362 | - | |||||||||||||
| 1363 | if (viewMode == QMdiArea::TabbedView) | - | ||||||||||||
| 1364 | rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow))); | - | ||||||||||||
| 1365 | else | - | ||||||||||||
| 1366 | rubberBand->setGeometry(subWindow->geometry()); | - | ||||||||||||
| 1367 | - | |||||||||||||
| 1368 | rubberBand->raise(); | - | ||||||||||||
| 1369 | rubberBand->show(); | - | ||||||||||||
| 1370 | } | - | ||||||||||||
| 1371 | - | |||||||||||||
| 1372 | - | |||||||||||||
| 1373 | - | |||||||||||||
| 1374 | - | |||||||||||||
| 1375 | - | |||||||||||||
| 1376 | void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode) | - | ||||||||||||
| 1377 | { | - | ||||||||||||
| 1378 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 1379 | if (viewMode == mode || inViewModeChange) | - | ||||||||||||
| 1380 | return; | - | ||||||||||||
| 1381 | - | |||||||||||||
| 1382 | - | |||||||||||||
| 1383 | inViewModeChange = true; | - | ||||||||||||
| 1384 | - | |||||||||||||
| 1385 | - | |||||||||||||
| 1386 | if (mode == QMdiArea::TabbedView) { | - | ||||||||||||
| 1387 | ((!(!tabBar)) ? qt_assert("!tabBar",__FILE__,15601565) : qt_noop()); | - | ||||||||||||
| 1388 | tabBar = new QMdiAreaTabBar(q); | - | ||||||||||||
| 1389 | tabBar->setDocumentMode(documentMode); | - | ||||||||||||
| 1390 | tabBar->setTabsClosable(tabsClosable); | - | ||||||||||||
| 1391 | tabBar->setMovable(tabsMovable); | - | ||||||||||||
| 1392 | - | |||||||||||||
| 1393 | tabBar->setShape(tabBarShapeFrom(tabShape, tabPosition)); | - | ||||||||||||
| 1394 | - | |||||||||||||
| 1395 | - | |||||||||||||
| 1396 | isSubWindowsTiled = false; | - | ||||||||||||
| 1397 | - | |||||||||||||
| 1398 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(childWindows)>::type> _container_((childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *subWindow = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||
| 1399 | tabBar->addTab(subWindow->windowIcon(), tabTextFor(subWindow)); | - | ||||||||||||
| 1400 | - | |||||||||||||
| 1401 | QMdiSubWindow *current = q->currentSubWindow(); | - | ||||||||||||
| 1402 | if (current) { | - | ||||||||||||
| 1403 | tabBar->setCurrentIndex(childWindows.indexOf(current)); | - | ||||||||||||
| 1404 | - | |||||||||||||
| 1405 | if (current->isMaximized()) | - | ||||||||||||
| 1406 | current->showNormal(); | - | ||||||||||||
| 1407 | - | |||||||||||||
| 1408 | viewMode = mode; | - | ||||||||||||
| 1409 | - | |||||||||||||
| 1410 | - | |||||||||||||
| 1411 | if (!q->testOption(QMdiArea::DontMaximizeSubWindowOnActivation)) { | - | ||||||||||||
| 1412 | current->showMaximized(); | - | ||||||||||||
| 1413 | } | - | ||||||||||||
| 1414 | } else { | - | ||||||||||||
| 1415 | viewMode = mode; | - | ||||||||||||
| 1416 | } | - | ||||||||||||
| 1417 | - | |||||||||||||
| 1418 | if (q->isVisible()) | - | ||||||||||||
| 1419 | tabBar->show(); | - | ||||||||||||
| 1420 | updateTabBarGeometry(); | - | ||||||||||||
| 1421 | - | |||||||||||||
| 1422 | QObject::connect(tabBar, qFlagLocation("2""currentChanged(int)" "\0" __FILE__ ":" "1595""1600"), q, qFlagLocation("1""_q_currentTabChanged(int)" "\0" __FILE__ ":" "1595""1600")); | - | ||||||||||||
| 1423 | QObject::connect(tabBar, qFlagLocation("2""tabCloseRequested(int)" "\0" __FILE__ ":" "1596""1601"), q, qFlagLocation("1""_q_closeTab(int)" "\0" __FILE__ ":" "1596""1601")); | - | ||||||||||||
| 1424 | QObject::connect(tabBar, qFlagLocation("2""tabMoved(int,int)" "\0" __FILE__ ":" "1597""1602"), q, qFlagLocation("1""_q_moveTab(int,int)" "\0" __FILE__ ":" "1597""1602")); | - | ||||||||||||
| 1425 | } else | - | ||||||||||||
| 1426 | - | |||||||||||||
| 1427 | { | - | ||||||||||||
| 1428 | - | |||||||||||||
| 1429 | delete tabBar; | - | ||||||||||||
| 1430 | tabBar = 0; | - | ||||||||||||
| 1431 | - | |||||||||||||
| 1432 | - | |||||||||||||
| 1433 | viewMode = mode; | - | ||||||||||||
| 1434 | q->setViewportMargins(0, 0, 0, 0); | - | ||||||||||||
| 1435 | indexToLastActiveTab = -1; | - | ||||||||||||
| 1436 | - | |||||||||||||
| 1437 | QMdiSubWindow *current = q->currentSubWindow(); | - | ||||||||||||
| 1438 | if (current && current->isMaximized()) | - | ||||||||||||
| 1439 | current->showNormal(); | - | ||||||||||||
| 1440 | } | - | ||||||||||||
| 1441 | - | |||||||||||||
| 1442 | ((!(viewMode == mode)) ? qt_assert("viewMode == mode",__FILE__,16151620) : qt_noop()); | - | ||||||||||||
| 1443 | inViewModeChange = false; | - | ||||||||||||
| 1444 | } | - | ||||||||||||
| 1445 | - | |||||||||||||
| 1446 | - | |||||||||||||
| 1447 | - | |||||||||||||
| 1448 | - | |||||||||||||
| 1449 | - | |||||||||||||
| 1450 | void QMdiAreaPrivate::updateTabBarGeometry() | - | ||||||||||||
| 1451 | { | - | ||||||||||||
| 1452 | if (!tabBar) | - | ||||||||||||
| 1453 | return; | - | ||||||||||||
| 1454 | - | |||||||||||||
| 1455 | QMdiArea * const q = q_func(); | - | ||||||||||||
| 1456 | - | |||||||||||||
| 1457 | ((!(tabBarShapeFrom(tabShape, tabPosition) == tabBar->shape())) ? qt_assert("tabBarShapeFrom(tabShape, tabPosition) == tabBar->shape()",__FILE__,16301635) : qt_noop()); | - | ||||||||||||
| 1458 | - | |||||||||||||
| 1459 | const QSize tabBarSizeHint = tabBar->sizeHint(); | - | ||||||||||||
| 1460 | - | |||||||||||||
| 1461 | int areaHeight = q->height(); | - | ||||||||||||
| 1462 | if (hbar && hbar->isVisible()) | - | ||||||||||||
| 1463 | areaHeight -= hbar->height(); | - | ||||||||||||
| 1464 | - | |||||||||||||
| 1465 | int areaWidth = q->width(); | - | ||||||||||||
| 1466 | if (vbar && vbar->isVisible()) | - | ||||||||||||
| 1467 | areaWidth -= vbar->width(); | - | ||||||||||||
| 1468 | - | |||||||||||||
| 1469 | QRect tabBarRect; | - | ||||||||||||
| 1470 | - | |||||||||||||
| 1471 | switch (tabPosition) { | - | ||||||||||||
| 1472 | case QTabWidget::North: | - | ||||||||||||
| 1473 | q->setViewportMargins(0, tabBarSizeHint.height(), 0, 0); | - | ||||||||||||
| 1474 | tabBarRect = QRect(0, 0, areaWidth, tabBarSizeHint.height()); | - | ||||||||||||
| 1475 | break; | - | ||||||||||||
| 1476 | case QTabWidget::South: | - | ||||||||||||
| 1477 | q->setViewportMargins(0, 0, 0, tabBarSizeHint.height()); | - | ||||||||||||
| 1478 | tabBarRect = QRect(0, areaHeight - tabBarSizeHint.height(), areaWidth, tabBarSizeHint.height()); | - | ||||||||||||
| 1479 | break; | - | ||||||||||||
| 1480 | case QTabWidget::East: | - | ||||||||||||
| 1481 | if (q->layoutDirection() == Qt::LeftToRight) | - | ||||||||||||
| 1482 | q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0); | - | ||||||||||||
| 1483 | else | - | ||||||||||||
| 1484 | q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0); | - | ||||||||||||
| 1485 | tabBarRect = QRect(areaWidth - tabBarSizeHint.width(), 0, tabBarSizeHint.width(), areaHeight); | - | ||||||||||||
| 1486 | break; | - | ||||||||||||
| 1487 | case QTabWidget::West: | - | ||||||||||||
| 1488 | if (q->layoutDirection() == Qt::LeftToRight) | - | ||||||||||||
| 1489 | q->setViewportMargins(tabBarSizeHint.width(), 0, 0, 0); | - | ||||||||||||
| 1490 | else | - | ||||||||||||
| 1491 | q->setViewportMargins(0, 0, tabBarSizeHint.width(), 0); | - | ||||||||||||
| 1492 | tabBarRect = QRect(0, 0, tabBarSizeHint.width(), areaHeight); | - | ||||||||||||
| 1493 | break; | - | ||||||||||||
| 1494 | default: | - | ||||||||||||
| 1495 | break; | - | ||||||||||||
| 1496 | } | - | ||||||||||||
| 1497 | - | |||||||||||||
| 1498 | - | |||||||||||||
| 1499 | tabBar->setGeometry(QStyle::visualRect(q->layoutDirection(), q->contentsRect(), tabBarRect)); | - | ||||||||||||
| 1500 | } | - | ||||||||||||
| 1501 | - | |||||||||||||
| 1502 | - | |||||||||||||
| 1503 | - | |||||||||||||
| 1504 | - | |||||||||||||
| 1505 | void QMdiAreaPrivate::refreshTabBar() | - | ||||||||||||
| 1506 | { | - | ||||||||||||
| 1507 | if (!tabBar) | - | ||||||||||||
| 1508 | return; | - | ||||||||||||
| 1509 | - | |||||||||||||
| 1510 | tabBar->setDocumentMode(documentMode); | - | ||||||||||||
| 1511 | tabBar->setTabsClosable(tabsClosable); | - | ||||||||||||
| 1512 | tabBar->setMovable(tabsMovable); | - | ||||||||||||
| 1513 | - | |||||||||||||
| 1514 | tabBar->setShape(tabBarShapeFrom(tabShape, tabPosition)); | - | ||||||||||||
| 1515 | - | |||||||||||||
| 1516 | updateTabBarGeometry(); | - | ||||||||||||
| 1517 | } | - | ||||||||||||
| 1518 | - | |||||||||||||
| 1519 | - | |||||||||||||
| 1520 | - | |||||||||||||
| 1521 | - | |||||||||||||
| 1522 | - | |||||||||||||
| 1523 | - | |||||||||||||
| 1524 | QMdiArea::QMdiArea(QWidget *parent) | - | ||||||||||||
| 1525 | : QAbstractScrollArea(*new QMdiAreaPrivate, parent) | - | ||||||||||||
| 1526 | { | - | ||||||||||||
| 1527 | setBackground(palette().brush(QPalette::Dark)); | - | ||||||||||||
| 1528 | setFrameStyle(QFrame::NoFrame); | - | ||||||||||||
| 1529 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - | ||||||||||||
| 1530 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | - | ||||||||||||
| 1531 | setViewport(0); | - | ||||||||||||
| 1532 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||
| 1533 | QApplication::instance()->installEventFilter(this); | - | ||||||||||||
| 1534 | } | - | ||||||||||||
| 1535 | - | |||||||||||||
| 1536 | - | |||||||||||||
| 1537 | - | |||||||||||||
| 1538 | - | |||||||||||||
| 1539 | QMdiArea::~QMdiArea() | - | ||||||||||||
| 1540 | { | - | ||||||||||||
| 1541 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1542 | delete d->cascader; | - | ||||||||||||
| 1543 | d->cascader = 0; | - | ||||||||||||
| 1544 | - | |||||||||||||
| 1545 | delete d->regularTiler; | - | ||||||||||||
| 1546 | d->regularTiler = 0; | - | ||||||||||||
| 1547 | - | |||||||||||||
| 1548 | delete d->iconTiler; | - | ||||||||||||
| 1549 | d->iconTiler = 0; | - | ||||||||||||
| 1550 | - | |||||||||||||
| 1551 | delete d->placer; | - | ||||||||||||
| 1552 | d->placer = 0; | - | ||||||||||||
| 1553 | } | - | ||||||||||||
| 1554 | - | |||||||||||||
| 1555 | - | |||||||||||||
| 1556 | - | |||||||||||||
| 1557 | - | |||||||||||||
| 1558 | QSize QMdiArea::sizeHint() const | - | ||||||||||||
| 1559 | { | - | ||||||||||||
| 1560 | - | |||||||||||||
| 1561 | - | |||||||||||||
| 1562 | int nestedCount = 0; | - | ||||||||||||
| 1563 | QWidget *widget = this->parentWidget(); | - | ||||||||||||
| 1564 | while (widget
| 0 | ||||||||||||
| 1565 | if (qobject_cast<QMdiArea *>(widget)
| 0 | ||||||||||||
| 1566 | ++ never executed: nestedCount;++nestedCount;never executed: ++nestedCount; | 0 | ||||||||||||
| 1567 | widget = widget->parentWidget(); | - | ||||||||||||
| 1568 | } never executed: end of block | 0 | ||||||||||||
| 1569 | const int scaleFactor = 3 * (nestedCount + 1); | - | ||||||||||||
| 1570 | - | |||||||||||||
| 1571 | QSize desktopSize = QApplication::desktop()->size(); | - | ||||||||||||
| 1572 | QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor); | - | ||||||||||||
| 1573 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d_func()->childWindows)>::type> _container_((d_func()->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0: d_func()->childWindows) { | - | ||||||||||||
| 1574 | if (!sanityCheck(child, "QMdiArea::sizeHint")
| 0 | ||||||||||||
| 1575 | continue; never executed: continue; | 0 | ||||||||||||
| 1576 | size = size.expandedTo(child->sizeHint()); | - | ||||||||||||
| 1577 | } never executed: end of block | 0 | ||||||||||||
| 1578 | return never executed: size.expandedTo(QApplication::globalStrut());return size.expandedTo(QApplication::globalStrut());never executed: return size.expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||
| 1579 | } | - | ||||||||||||
| 1580 | - | |||||||||||||
| 1581 | - | |||||||||||||
| 1582 | - | |||||||||||||
| 1583 | - | |||||||||||||
| 1584 | QSize QMdiArea::minimumSizeHint() const | - | ||||||||||||
| 1585 | { | - | ||||||||||||
| 1586 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1587 | QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this), | - | ||||||||||||
| 1588 | style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, this)); | - | ||||||||||||
| 1589 | size = size.expandedTo(QAbstractScrollArea::minimumSizeHint()); | - | ||||||||||||
| 1590 | if (!d->scrollBarsEnabled()
| 0 | ||||||||||||
| 1591 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->childWindows)>::type> _container_((d->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0: d->childWindows) { | - | ||||||||||||
| 1592 | if (!sanityCheck(child, "QMdiArea::sizeHint")
| 0 | ||||||||||||
| 1593 | continue; never executed: continue; | 0 | ||||||||||||
| 1594 | size = size.expandedTo(child->minimumSizeHint()); | - | ||||||||||||
| 1595 | } never executed: end of block | 0 | ||||||||||||
| 1596 | } never executed: end of block | 0 | ||||||||||||
| 1597 | return never executed: size.expandedTo(QApplication::globalStrut());return size.expandedTo(QApplication::globalStrut());never executed: return size.expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||
| 1598 | } | - | ||||||||||||
| 1599 | QMdiSubWindow *QMdiArea::currentSubWindow() const | - | ||||||||||||
| 1600 | { | - | ||||||||||||
| 1601 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1602 | if (d->childWindows.isEmpty()) | - | ||||||||||||
| 1603 | return 0; | - | ||||||||||||
| 1604 | - | |||||||||||||
| 1605 | if (d->active) | - | ||||||||||||
| 1606 | return d->active; | - | ||||||||||||
| 1607 | - | |||||||||||||
| 1608 | if (d->isActivated && !window()->isMinimized()) | - | ||||||||||||
| 1609 | return 0; | - | ||||||||||||
| 1610 | - | |||||||||||||
| 1611 | ((!(d->indicesToActivatedChildren.count() > 0)) ? qt_assert("d->indicesToActivatedChildren.count() > 0",__FILE__,17941799) : qt_noop()); | - | ||||||||||||
| 1612 | int index = d->indicesToActivatedChildren.at(0); | - | ||||||||||||
| 1613 | ((!(index >= 0 && index < d->childWindows.size())) ? qt_assert("index >= 0 && index < d->childWindows.size()",__FILE__,17961801) : qt_noop()); | - | ||||||||||||
| 1614 | QMdiSubWindow *current = d->childWindows.at(index); | - | ||||||||||||
| 1615 | ((!(current)) ? qt_assert("current",__FILE__,17981803) : qt_noop()); | - | ||||||||||||
| 1616 | return current; | - | ||||||||||||
| 1617 | } | - | ||||||||||||
| 1618 | QMdiSubWindow *QMdiArea::activeSubWindow() const | - | ||||||||||||
| 1619 | { | - | ||||||||||||
| 1620 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1621 | return d->active; | - | ||||||||||||
| 1622 | } | - | ||||||||||||
| 1623 | - | |||||||||||||
| 1624 | - | |||||||||||||
| 1625 | - | |||||||||||||
| 1626 | - | |||||||||||||
| 1627 | - | |||||||||||||
| 1628 | - | |||||||||||||
| 1629 | - | |||||||||||||
| 1630 | void QMdiArea::setActiveSubWindow(QMdiSubWindow *window) | - | ||||||||||||
| 1631 | { | - | ||||||||||||
| 1632 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1633 | if (!window
| 0 | ||||||||||||
| 1634 | d->activateWindow(0); | - | ||||||||||||
| 1635 | return; never executed: return; | 0 | ||||||||||||
| 1636 | } | - | ||||||||||||
| 1637 | - | |||||||||||||
| 1638 | if (__builtin_expect(!!(
| 0 | ||||||||||||
| 1639 | QMessageLogger(__FILE__, 18351840, __PRETTY_FUNCTION__).warning("QMdiArea::setActiveSubWindow: workspace is empty"); | - | ||||||||||||
| 1640 | return; never executed: return; | 0 | ||||||||||||
| 1641 | } | - | ||||||||||||
| 1642 | - | |||||||||||||
| 1643 | if (__builtin_expect(!!(
| 0 | ||||||||||||
| 1644 | QMessageLogger(__FILE__, 18401845, __PRETTY_FUNCTION__).warning("QMdiArea::setActiveSubWindow: window is not inside workspace"); | - | ||||||||||||
| 1645 | return; never executed: return; | 0 | ||||||||||||
| 1646 | } | - | ||||||||||||
| 1647 | - | |||||||||||||
| 1648 | d->activateWindow(window); | - | ||||||||||||
| 1649 | } never executed: end of block | 0 | ||||||||||||
| 1650 | - | |||||||||||||
| 1651 | - | |||||||||||||
| 1652 | - | |||||||||||||
| 1653 | - | |||||||||||||
| 1654 | - | |||||||||||||
| 1655 | - | |||||||||||||
| 1656 | void QMdiArea::closeActiveSubWindow() | - | ||||||||||||
| 1657 | { | - | ||||||||||||
| 1658 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1659 | if (d->active) | - | ||||||||||||
| 1660 | d->active->close(); | - | ||||||||||||
| 1661 | } | - | ||||||||||||
| 1662 | QList<QMdiSubWindow *> QMdiArea::subWindowList(WindowOrder order) const | - | ||||||||||||
| 1663 | { | - | ||||||||||||
| 1664 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1665 | return d->subWindowList(order, false); | - | ||||||||||||
| 1666 | } | - | ||||||||||||
| 1667 | void QMdiArea::closeAllSubWindows() | - | ||||||||||||
| 1668 | { | - | ||||||||||||
| 1669 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1670 | if (d->childWindows.isEmpty()) | - | ||||||||||||
| 1671 | return; | - | ||||||||||||
| 1672 | - | |||||||||||||
| 1673 | d->isSubWindowsTiled = false; | - | ||||||||||||
| 1674 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->childWindows)>::type> _container_((d->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 1675 | if (!sanityCheck(child, "QMdiArea::closeAllSubWindows")) | - | ||||||||||||
| 1676 | continue; | - | ||||||||||||
| 1677 | child->close(); | - | ||||||||||||
| 1678 | } | - | ||||||||||||
| 1679 | - | |||||||||||||
| 1680 | d->updateScrollBars(); | - | ||||||||||||
| 1681 | } | - | ||||||||||||
| 1682 | void QMdiArea::activateNextSubWindow() | - | ||||||||||||
| 1683 | { | - | ||||||||||||
| 1684 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1685 | if (d->childWindows.isEmpty()) | - | ||||||||||||
| 1686 | return; | - | ||||||||||||
| 1687 | - | |||||||||||||
| 1688 | QMdiSubWindow *next = d->nextVisibleSubWindow(1, d->activationOrder); | - | ||||||||||||
| 1689 | if (next) | - | ||||||||||||
| 1690 | d->activateWindow(next); | - | ||||||||||||
| 1691 | } | - | ||||||||||||
| 1692 | void QMdiArea::activatePreviousSubWindow() | - | ||||||||||||
| 1693 | { | - | ||||||||||||
| 1694 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1695 | if (d->childWindows.isEmpty()) | - | ||||||||||||
| 1696 | return; | - | ||||||||||||
| 1697 | - | |||||||||||||
| 1698 | QMdiSubWindow *previous = d->nextVisibleSubWindow(-1, d->activationOrder); | - | ||||||||||||
| 1699 | if (previous) | - | ||||||||||||
| 1700 | d->activateWindow(previous); | - | ||||||||||||
| 1701 | } | - | ||||||||||||
| 1702 | QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFlags) | - | ||||||||||||
| 1703 | { | - | ||||||||||||
| 1704 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||
| 1705 | QMessageLogger(__FILE__, 19641969, __PRETTY_FUNCTION__).warning("QMdiArea::addSubWindow: null pointer to widget"); | - | ||||||||||||
| 1706 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 1707 | } | - | ||||||||||||
| 1708 | - | |||||||||||||
| 1709 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1710 | - | |||||||||||||
| 1711 | QWidget *childFocus = widget->focusWidget(); | - | ||||||||||||
| 1712 | QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(widget); | - | ||||||||||||
| 1713 | - | |||||||||||||
| 1714 | - | |||||||||||||
| 1715 | if (child
| 0 | ||||||||||||
| 1716 | if (__builtin_expect(!!(
| 0 | ||||||||||||
| 1717 | QMessageLogger(__FILE__, 19761981, __PRETTY_FUNCTION__).warning("QMdiArea::addSubWindow: window is already added"); | - | ||||||||||||
| 1718 | return never executed: child;return child;never executed: return child; | 0 | ||||||||||||
| 1719 | } | - | ||||||||||||
| 1720 | child->setParent(viewport(), windowFlags ? windowFlags : child->windowFlags()); | - | ||||||||||||
| 1721 | - | |||||||||||||
| 1722 | } never executed: else {end of block | 0 | ||||||||||||
| 1723 | child = new QMdiSubWindow(viewport(), windowFlags); | - | ||||||||||||
| 1724 | child->setAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||
| 1725 | child->setWidget(widget); | - | ||||||||||||
| 1726 | ((!(child->testAttribute(Qt::WA_DeleteOnClose))) ? qt_assert("child->testAttribute(Qt::WA_DeleteOnClose)",__FILE__,19851990) : qt_noop()); | - | ||||||||||||
| 1727 | } never executed: end of block | 0 | ||||||||||||
| 1728 | - | |||||||||||||
| 1729 | if (childFocus
| 0 | ||||||||||||
| 1730 | childFocus->setFocus(); never executed: childFocus->setFocus(); | 0 | ||||||||||||
| 1731 | d->appendChild(child); | - | ||||||||||||
| 1732 | return never executed: child;return child;never executed: return child; | 0 | ||||||||||||
| 1733 | } | - | ||||||||||||
| 1734 | void QMdiArea::removeSubWindow(QWidget *widget) | - | ||||||||||||
| 1735 | { | - | ||||||||||||
| 1736 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||
| 1737 | QMessageLogger(__FILE__, 20072012, __PRETTY_FUNCTION__).warning("QMdiArea::removeSubWindow: null pointer to widget"); | - | ||||||||||||
| 1738 | return; never executed: return; | 0 | ||||||||||||
| 1739 | } | - | ||||||||||||
| 1740 | - | |||||||||||||
| 1741 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1742 | if (d->childWindows.isEmpty()
| 0 | ||||||||||||
| 1743 | return; never executed: return; | 0 | ||||||||||||
| 1744 | - | |||||||||||||
| 1745 | if (QMdiSubWindow *child = qobject_cast<QMdiSubWindow *>(widget)
| 0 | ||||||||||||
| 1746 | int index = d->childWindows.indexOf(child); | - | ||||||||||||
| 1747 | if (__builtin_expect(!!(
| 0 | ||||||||||||
| 1748 | QMessageLogger(__FILE__, 20182023, __PRETTY_FUNCTION__).warning("QMdiArea::removeSubWindow: window is not inside workspace"); | - | ||||||||||||
| 1749 | return; never executed: return; | 0 | ||||||||||||
| 1750 | } | - | ||||||||||||
| 1751 | d->disconnectSubWindow(child); | - | ||||||||||||
| 1752 | d->childWindows.removeAll(child); | - | ||||||||||||
| 1753 | d->indicesToActivatedChildren.removeAll(index); | - | ||||||||||||
| 1754 | d->updateActiveWindow(index, d->active == child); | - | ||||||||||||
| 1755 | child->setParent(0); | - | ||||||||||||
| 1756 | return; never executed: return; | 0 | ||||||||||||
| 1757 | } | - | ||||||||||||
| 1758 | - | |||||||||||||
| 1759 | bool found = false; | - | ||||||||||||
| 1760 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->childWindows)>::type> _container_((d->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 1761 | if (!sanityCheck(child, "QMdiArea::removeSubWindow")
| 0 | ||||||||||||
| 1762 | continue; never executed: continue; | 0 | ||||||||||||
| 1763 | if (child->widget() == widget
| 0 | ||||||||||||
| 1764 | child->setWidget(0); | - | ||||||||||||
| 1765 | ((!(!child->widget())) ? qt_assert("!child->widget()",__FILE__,20352040) : qt_noop()); | - | ||||||||||||
| 1766 | found = true; | - | ||||||||||||
| 1767 | break; never executed: break; | 0 | ||||||||||||
| 1768 | } | - | ||||||||||||
| 1769 | } never executed: end of block | 0 | ||||||||||||
| 1770 | - | |||||||||||||
| 1771 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||
| 1772 | QMessageLogger(__FILE__, 20422047, __PRETTY_FUNCTION__).warning("QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea"); never executed: QMessageLogger(__FILE__, 2047, __PRETTY_FUNCTION__).warning("QMdiArea::removeSubWindow: widget is not child of any window inside QMdiArea"); | 0 | ||||||||||||
| 1773 | } never executed: end of block | 0 | ||||||||||||
| 1774 | QBrush QMdiArea::background() const | - | ||||||||||||
| 1775 | { | - | ||||||||||||
| 1776 | return d_func()->background; | - | ||||||||||||
| 1777 | } | - | ||||||||||||
| 1778 | - | |||||||||||||
| 1779 | void QMdiArea::setBackground(const QBrush &brush) | - | ||||||||||||
| 1780 | { | - | ||||||||||||
| 1781 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1782 | if (d->background != brush) { | - | ||||||||||||
| 1783 | d->background = brush; | - | ||||||||||||
| 1784 | d->viewport->setAttribute(Qt::WA_OpaquePaintEvent, brush.isOpaque()); | - | ||||||||||||
| 1785 | d->viewport->update(); | - | ||||||||||||
| 1786 | } | - | ||||||||||||
| 1787 | } | - | ||||||||||||
| 1788 | QMdiArea::WindowOrder QMdiArea::activationOrder() const | - | ||||||||||||
| 1789 | { | - | ||||||||||||
| 1790 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1791 | return d->activationOrder; | - | ||||||||||||
| 1792 | } | - | ||||||||||||
| 1793 | - | |||||||||||||
| 1794 | void QMdiArea::setActivationOrder(WindowOrder order) | - | ||||||||||||
| 1795 | { | - | ||||||||||||
| 1796 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1797 | if (order != d->activationOrder) | - | ||||||||||||
| 1798 | d->activationOrder = order; | - | ||||||||||||
| 1799 | } | - | ||||||||||||
| 1800 | - | |||||||||||||
| 1801 | - | |||||||||||||
| 1802 | - | |||||||||||||
| 1803 | - | |||||||||||||
| 1804 | - | |||||||||||||
| 1805 | - | |||||||||||||
| 1806 | - | |||||||||||||
| 1807 | void QMdiArea::setOption(AreaOption option, bool on) | - | ||||||||||||
| 1808 | { | - | ||||||||||||
| 1809 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1810 | if (on && !(d->options & option))d->options|= option; | - | ||||||||||||
| else if (!on &&.setFlag(d->options & option)) | ||||||||||||||
| d->options &= ~option;, on); | ||||||||||||||
| 1811 | } never executed: end of block | 0 | ||||||||||||
| 1812 | - | |||||||||||||
| 1813 | - | |||||||||||||
| 1814 | - | |||||||||||||
| 1815 | - | |||||||||||||
| 1816 | - | |||||||||||||
| 1817 | - | |||||||||||||
| 1818 | bool QMdiArea::testOption(AreaOption option) const | - | ||||||||||||
| 1819 | { | - | ||||||||||||
| 1820 | return d_func()->options & option; | - | ||||||||||||
| 1821 | } | - | ||||||||||||
| 1822 | QMdiArea::ViewMode QMdiArea::viewMode() const | - | ||||||||||||
| 1823 | { | - | ||||||||||||
| 1824 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1825 | return d->viewMode; | - | ||||||||||||
| 1826 | } | - | ||||||||||||
| 1827 | - | |||||||||||||
| 1828 | void QMdiArea::setViewMode(ViewMode mode) | - | ||||||||||||
| 1829 | { | - | ||||||||||||
| 1830 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1831 | d->setViewMode(mode); | - | ||||||||||||
| 1832 | } | - | ||||||||||||
| 1833 | bool QMdiArea::documentMode() const | - | ||||||||||||
| 1834 | { | - | ||||||||||||
| 1835 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1836 | return d->documentMode; | - | ||||||||||||
| 1837 | } | - | ||||||||||||
| 1838 | - | |||||||||||||
| 1839 | void QMdiArea::setDocumentMode(bool enabled) | - | ||||||||||||
| 1840 | { | - | ||||||||||||
| 1841 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1842 | if (d->documentMode == enabled) | - | ||||||||||||
| 1843 | return; | - | ||||||||||||
| 1844 | - | |||||||||||||
| 1845 | d->documentMode = enabled; | - | ||||||||||||
| 1846 | d->refreshTabBar(); | - | ||||||||||||
| 1847 | } | - | ||||||||||||
| 1848 | bool QMdiArea::tabsClosable() const | - | ||||||||||||
| 1849 | { | - | ||||||||||||
| 1850 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1851 | return d->tabsClosable; | - | ||||||||||||
| 1852 | } | - | ||||||||||||
| 1853 | - | |||||||||||||
| 1854 | void QMdiArea::setTabsClosable(bool closable) | - | ||||||||||||
| 1855 | { | - | ||||||||||||
| 1856 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1857 | if (d->tabsClosable == closable) | - | ||||||||||||
| 1858 | return; | - | ||||||||||||
| 1859 | - | |||||||||||||
| 1860 | d->tabsClosable = closable; | - | ||||||||||||
| 1861 | d->refreshTabBar(); | - | ||||||||||||
| 1862 | } | - | ||||||||||||
| 1863 | bool QMdiArea::tabsMovable() const | - | ||||||||||||
| 1864 | { | - | ||||||||||||
| 1865 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1866 | return d->tabsMovable; | - | ||||||||||||
| 1867 | } | - | ||||||||||||
| 1868 | - | |||||||||||||
| 1869 | void QMdiArea::setTabsMovable(bool movable) | - | ||||||||||||
| 1870 | { | - | ||||||||||||
| 1871 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1872 | if (d->tabsMovable == movable) | - | ||||||||||||
| 1873 | return; | - | ||||||||||||
| 1874 | - | |||||||||||||
| 1875 | d->tabsMovable = movable; | - | ||||||||||||
| 1876 | d->refreshTabBar(); | - | ||||||||||||
| 1877 | } | - | ||||||||||||
| 1878 | QTabWidget::TabShape QMdiArea::tabShape() const | - | ||||||||||||
| 1879 | { | - | ||||||||||||
| 1880 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1881 | return d->tabShape; | - | ||||||||||||
| 1882 | } | - | ||||||||||||
| 1883 | - | |||||||||||||
| 1884 | void QMdiArea::setTabShape(QTabWidget::TabShape shape) | - | ||||||||||||
| 1885 | { | - | ||||||||||||
| 1886 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1887 | if (d->tabShape == shape) | - | ||||||||||||
| 1888 | return; | - | ||||||||||||
| 1889 | - | |||||||||||||
| 1890 | d->tabShape = shape; | - | ||||||||||||
| 1891 | d->refreshTabBar(); | - | ||||||||||||
| 1892 | } | - | ||||||||||||
| 1893 | QTabWidget::TabPosition QMdiArea::tabPosition() const | - | ||||||||||||
| 1894 | { | - | ||||||||||||
| 1895 | const QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1896 | return d->tabPosition; | - | ||||||||||||
| 1897 | } | - | ||||||||||||
| 1898 | - | |||||||||||||
| 1899 | void QMdiArea::setTabPosition(QTabWidget::TabPosition position) | - | ||||||||||||
| 1900 | { | - | ||||||||||||
| 1901 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1902 | if (d->tabPosition == position) | - | ||||||||||||
| 1903 | return; | - | ||||||||||||
| 1904 | - | |||||||||||||
| 1905 | d->tabPosition = position; | - | ||||||||||||
| 1906 | d->refreshTabBar(); | - | ||||||||||||
| 1907 | } | - | ||||||||||||
| 1908 | - | |||||||||||||
| 1909 | - | |||||||||||||
| 1910 | - | |||||||||||||
| 1911 | - | |||||||||||||
| 1912 | - | |||||||||||||
| 1913 | void QMdiArea::childEvent(QChildEvent *childEvent) | - | ||||||||||||
| 1914 | { | - | ||||||||||||
| 1915 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1916 | if (childEvent->type() == QEvent::ChildPolished) { | - | ||||||||||||
| 1917 | if (QMdiSubWindow *mdiChild = qobject_cast<QMdiSubWindow *>(childEvent->child())) { | - | ||||||||||||
| 1918 | if (d->childWindows.indexOf(mdiChild) == -1) | - | ||||||||||||
| 1919 | d->appendChild(mdiChild); | - | ||||||||||||
| 1920 | } | - | ||||||||||||
| 1921 | } | - | ||||||||||||
| 1922 | } | - | ||||||||||||
| 1923 | - | |||||||||||||
| 1924 | - | |||||||||||||
| 1925 | - | |||||||||||||
| 1926 | - | |||||||||||||
| 1927 | void QMdiArea::resizeEvent(QResizeEvent *resizeEvent) | - | ||||||||||||
| 1928 | { | - | ||||||||||||
| 1929 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1930 | if (d->childWindows.isEmpty()) { | - | ||||||||||||
| 1931 | resizeEvent->ignore(); | - | ||||||||||||
| 1932 | return; | - | ||||||||||||
| 1933 | } | - | ||||||||||||
| 1934 | - | |||||||||||||
| 1935 | - | |||||||||||||
| 1936 | d->updateTabBarGeometry(); | - | ||||||||||||
| 1937 | - | |||||||||||||
| 1938 | - | |||||||||||||
| 1939 | - | |||||||||||||
| 1940 | - | |||||||||||||
| 1941 | - | |||||||||||||
| 1942 | if (d->isSubWindowsTiled) { | - | ||||||||||||
| 1943 | d->tileCalledFromResizeEvent = true; | - | ||||||||||||
| 1944 | tileSubWindows(); | - | ||||||||||||
| 1945 | d->tileCalledFromResizeEvent = false; | - | ||||||||||||
| 1946 | d->isSubWindowsTiled = true; | - | ||||||||||||
| 1947 | d->startResizeTimer(); | - | ||||||||||||
| 1948 | - | |||||||||||||
| 1949 | return; | - | ||||||||||||
| 1950 | } | - | ||||||||||||
| 1951 | - | |||||||||||||
| 1952 | - | |||||||||||||
| 1953 | bool hasMaximizedSubWindow = false; | - | ||||||||||||
| 1954 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->childWindows)>::type> _container_((d->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 1955 | if (sanityCheck(child, "QMdiArea::resizeEvent") && child->isMaximized() | - | ||||||||||||
| 1956 | && child->size() != resizeEvent->size()) { | - | ||||||||||||
| 1957 | child->resize(resizeEvent->size()); | - | ||||||||||||
| 1958 | if (!hasMaximizedSubWindow) | - | ||||||||||||
| 1959 | hasMaximizedSubWindow = true; | - | ||||||||||||
| 1960 | } | - | ||||||||||||
| 1961 | } | - | ||||||||||||
| 1962 | - | |||||||||||||
| 1963 | d->updateScrollBars(); | - | ||||||||||||
| 1964 | - | |||||||||||||
| 1965 | - | |||||||||||||
| 1966 | - | |||||||||||||
| 1967 | - | |||||||||||||
| 1968 | if (hasMaximizedSubWindow) | - | ||||||||||||
| 1969 | d->startResizeTimer(); | - | ||||||||||||
| 1970 | else | - | ||||||||||||
| 1971 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||
| 1972 | } | - | ||||||||||||
| 1973 | - | |||||||||||||
| 1974 | - | |||||||||||||
| 1975 | - | |||||||||||||
| 1976 | - | |||||||||||||
| 1977 | void QMdiArea::timerEvent(QTimerEvent *timerEvent) | - | ||||||||||||
| 1978 | { | - | ||||||||||||
| 1979 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 1980 | if (timerEvent->timerId() == d->resizeTimerId) { | - | ||||||||||||
| 1981 | killTimer(d->resizeTimerId); | - | ||||||||||||
| 1982 | d->resizeTimerId = -1; | - | ||||||||||||
| 1983 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||
| 1984 | } else if (timerEvent->timerId() == d->tabToPreviousTimerId) { | - | ||||||||||||
| 1985 | killTimer(d->tabToPreviousTimerId); | - | ||||||||||||
| 1986 | d->tabToPreviousTimerId = -1; | - | ||||||||||||
| 1987 | if (d->indexToHighlighted < 0) | - | ||||||||||||
| 1988 | return; | - | ||||||||||||
| 1989 | - | |||||||||||||
| 1990 | - | |||||||||||||
| 1991 | ((!(d->indexToHighlighted < d->childWindows.size())) ? qt_assert("d->indexToHighlighted < d->childWindows.size()",__FILE__,23512353) : qt_noop()); | - | ||||||||||||
| 1992 | ((!(d->rubberBand)) ? qt_assert("d->rubberBand",__FILE__,23522354) : qt_noop()); | - | ||||||||||||
| 1993 | d->showRubberBandFor(d->childWindows.at(d->indexToHighlighted)); | - | ||||||||||||
| 1994 | - | |||||||||||||
| 1995 | } | - | ||||||||||||
| 1996 | } | - | ||||||||||||
| 1997 | - | |||||||||||||
| 1998 | - | |||||||||||||
| 1999 | - | |||||||||||||
| 2000 | - | |||||||||||||
| 2001 | void QMdiArea::showEvent(QShowEvent *showEvent) | - | ||||||||||||
| 2002 | { | - | ||||||||||||
| 2003 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2004 | if (!d->pendingRearrangements.isEmpty()) { | - | ||||||||||||
| 2005 | bool skipPlacement = false; | - | ||||||||||||
| 2006 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->pendingRearrangements)>::type> _container_((d->pendingRearrangements)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (Rearranger *rearranger = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 2007 | - | |||||||||||||
| 2008 | - | |||||||||||||
| 2009 | if (rearranger->type() != Rearranger::IconTiler && !skipPlacement) | - | ||||||||||||
| 2010 | skipPlacement = true; | - | ||||||||||||
| 2011 | d->rearrange(rearranger); | - | ||||||||||||
| 2012 | } | - | ||||||||||||
| 2013 | d->pendingRearrangements.clear(); | - | ||||||||||||
| 2014 | - | |||||||||||||
| 2015 | if (skipPlacement && !d->pendingPlacements.isEmpty()) | - | ||||||||||||
| 2016 | d->pendingPlacements.clear(); | - | ||||||||||||
| 2017 | } | - | ||||||||||||
| 2018 | - | |||||||||||||
| 2019 | if (!d->pendingPlacements.isEmpty()) { | - | ||||||||||||
| 2020 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->pendingPlacements)>::type> _container_((d->pendingPlacements)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *window = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 2021 | if (!window) | - | ||||||||||||
| 2022 | continue; | - | ||||||||||||
| 2023 | if (!window->testAttribute(Qt::WA_Resized)) { | - | ||||||||||||
| 2024 | QSize newSize(window->sizeHint().boundedTo(viewport()->size())); | - | ||||||||||||
| 2025 | window->resize(newSize.expandedTo(qSmartMinSize(window))); | - | ||||||||||||
| 2026 | } | - | ||||||||||||
| 2027 | if (!window->testAttribute(Qt::WA_Moved) && !window->isMinimized() | - | ||||||||||||
| 2028 | && !window->isMaximized()) { | - | ||||||||||||
| 2029 | d->place(d->placer, window); | - | ||||||||||||
| 2030 | } | - | ||||||||||||
| 2031 | } | - | ||||||||||||
| 2032 | d->pendingPlacements.clear(); | - | ||||||||||||
| 2033 | } | - | ||||||||||||
| 2034 | - | |||||||||||||
| 2035 | d->setChildActivationEnabled(true); | - | ||||||||||||
| 2036 | d->activateCurrentWindow(); | - | ||||||||||||
| 2037 | - | |||||||||||||
| 2038 | QAbstractScrollArea::showEvent(showEvent); | - | ||||||||||||
| 2039 | } | - | ||||||||||||
| 2040 | - | |||||||||||||
| 2041 | - | |||||||||||||
| 2042 | - | |||||||||||||
| 2043 | - | |||||||||||||
| 2044 | bool QMdiArea::viewportEvent(QEvent *event) | - | ||||||||||||
| 2045 | { | - | ||||||||||||
| 2046 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2047 | switch (event->type()) { | - | ||||||||||||
| 2048 | case QEvent::ChildRemoved: { | - | ||||||||||||
| 2049 | d->isSubWindowsTiled = false; | - | ||||||||||||
| 2050 | QObject *removedChild = static_cast<QChildEvent *>(event)->child(); | - | ||||||||||||
| 2051 | for (int i = 0; i < d->childWindows.size(); ++i) { | - | ||||||||||||
| 2052 | QObject *child = d->childWindows.at(i); | - | ||||||||||||
| 2053 | if (!child || child == removedChild || !child->parent() | - | ||||||||||||
| 2054 | || child->parent() != viewport()) { | - | ||||||||||||
| 2055 | if (!testOption(DontMaximizeSubWindowOnActivation)) { | - | ||||||||||||
| 2056 | - | |||||||||||||
| 2057 | - | |||||||||||||
| 2058 | QWidget *mdiChild = qobject_cast<QWidget *>(removedChild); | - | ||||||||||||
| 2059 | if (mdiChild && mdiChild->isMaximized()) | - | ||||||||||||
| 2060 | d->showActiveWindowMaximized = true; | - | ||||||||||||
| 2061 | } | - | ||||||||||||
| 2062 | d->disconnectSubWindow(child); | - | ||||||||||||
| 2063 | const bool activeRemoved = i == d->indicesToActivatedChildren.at(0); | - | ||||||||||||
| 2064 | d->childWindows.removeAt(i); | - | ||||||||||||
| 2065 | d->indicesToActivatedChildren.removeAll(i); | - | ||||||||||||
| 2066 | d->updateActiveWindow(i, activeRemoved); | - | ||||||||||||
| 2067 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||
| 2068 | break; | - | ||||||||||||
| 2069 | } | - | ||||||||||||
| 2070 | } | - | ||||||||||||
| 2071 | d->updateScrollBars(); | - | ||||||||||||
| 2072 | break; | - | ||||||||||||
| 2073 | } | - | ||||||||||||
| 2074 | case QEvent::Destroy: | - | ||||||||||||
| 2075 | d->isSubWindowsTiled = false; | - | ||||||||||||
| 2076 | d->resetActiveWindow(); | - | ||||||||||||
| 2077 | d->childWindows.clear(); | - | ||||||||||||
| 2078 | QMessageLogger(__FILE__, 24382440, __PRETTY_FUNCTION__).warning("QMdiArea: Deleting the view port is undefined, use setViewport instead."); | - | ||||||||||||
| 2079 | break; | - | ||||||||||||
| 2080 | default: | - | ||||||||||||
| 2081 | break; | - | ||||||||||||
| 2082 | } | - | ||||||||||||
| 2083 | return QAbstractScrollArea::viewportEvent(event); | - | ||||||||||||
| 2084 | } | - | ||||||||||||
| 2085 | - | |||||||||||||
| 2086 | - | |||||||||||||
| 2087 | - | |||||||||||||
| 2088 | - | |||||||||||||
| 2089 | void QMdiArea::scrollContentsBy(int dx, int dy) | - | ||||||||||||
| 2090 | { | - | ||||||||||||
| 2091 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2092 | const bool wasSubWindowsTiled = d->isSubWindowsTiled; | - | ||||||||||||
| 2093 | d->ignoreGeometryChange = true; | - | ||||||||||||
| 2094 | viewport()->scroll(isLeftToRight() ? dx : -dx, dy); | - | ||||||||||||
| 2095 | d->arrangeMinimizedSubWindows(); | - | ||||||||||||
| 2096 | d->ignoreGeometryChange = false; | - | ||||||||||||
| 2097 | if (wasSubWindowsTiled) | - | ||||||||||||
| 2098 | d->isSubWindowsTiled = true; | - | ||||||||||||
| 2099 | } | - | ||||||||||||
| 2100 | - | |||||||||||||
| 2101 | - | |||||||||||||
| 2102 | - | |||||||||||||
| 2103 | - | |||||||||||||
| 2104 | - | |||||||||||||
| 2105 | - | |||||||||||||
| 2106 | void QMdiArea::tileSubWindows() | - | ||||||||||||
| 2107 | { | - | ||||||||||||
| 2108 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2109 | if (!d->regularTiler) | - | ||||||||||||
| 2110 | d->regularTiler = new RegularTiler; | - | ||||||||||||
| 2111 | d->rearrange(d->regularTiler); | - | ||||||||||||
| 2112 | } | - | ||||||||||||
| 2113 | - | |||||||||||||
| 2114 | - | |||||||||||||
| 2115 | - | |||||||||||||
| 2116 | - | |||||||||||||
| 2117 | - | |||||||||||||
| 2118 | - | |||||||||||||
| 2119 | void QMdiArea::cascadeSubWindows() | - | ||||||||||||
| 2120 | { | - | ||||||||||||
| 2121 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2122 | if (!d->cascader) | - | ||||||||||||
| 2123 | d->cascader = new SimpleCascader; | - | ||||||||||||
| 2124 | d->rearrange(d->cascader); | - | ||||||||||||
| 2125 | } | - | ||||||||||||
| 2126 | - | |||||||||||||
| 2127 | - | |||||||||||||
| 2128 | - | |||||||||||||
| 2129 | - | |||||||||||||
| 2130 | bool QMdiArea::event(QEvent *event) | - | ||||||||||||
| 2131 | { | - | ||||||||||||
| 2132 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2133 | switch (event->type()) { | - | ||||||||||||
| 2134 | - | |||||||||||||
| 2135 | - | |||||||||||||
| 2136 | - | |||||||||||||
| 2137 | - | |||||||||||||
| 2138 | - | |||||||||||||
| 2139 | - | |||||||||||||
| 2140 | - | |||||||||||||
| 2141 | case QEvent::WindowActivate: { | - | ||||||||||||
| 2142 | d->isActivated = true; | - | ||||||||||||
| 2143 | if (d->childWindows.isEmpty()) | - | ||||||||||||
| 2144 | break; | - | ||||||||||||
| 2145 | if (!d->active) | - | ||||||||||||
| 2146 | d->activateCurrentWindow(); | - | ||||||||||||
| 2147 | d->setChildActivationEnabled(false, true); | - | ||||||||||||
| 2148 | break; | - | ||||||||||||
| 2149 | } | - | ||||||||||||
| 2150 | case QEvent::WindowDeactivate: | - | ||||||||||||
| 2151 | d->isActivated = false; | - | ||||||||||||
| 2152 | d->setChildActivationEnabled(false, true); | - | ||||||||||||
| 2153 | break; | - | ||||||||||||
| 2154 | case QEvent::StyleChange: | - | ||||||||||||
| 2155 | - | |||||||||||||
| 2156 | - | |||||||||||||
| 2157 | - | |||||||||||||
| 2158 | if (d->isSubWindowsTiled) { | - | ||||||||||||
| 2159 | tileSubWindows(); | - | ||||||||||||
| 2160 | d->isSubWindowsTiled = true; | - | ||||||||||||
| 2161 | } | - | ||||||||||||
| 2162 | break; | - | ||||||||||||
| 2163 | case QEvent::WindowIconChange: | - | ||||||||||||
| 2164 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->childWindows)>::type> _container_((d->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *window = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 2165 | if (sanityCheck(window, "QMdiArea::WindowIconChange")) | - | ||||||||||||
| 2166 | QApplication::sendEvent(window, event); | - | ||||||||||||
| 2167 | } | - | ||||||||||||
| 2168 | break; | - | ||||||||||||
| 2169 | case QEvent::Hide: | - | ||||||||||||
| 2170 | d->setActive(d->active, false, false); | - | ||||||||||||
| 2171 | d->setChildActivationEnabled(false); | - | ||||||||||||
| 2172 | break; | - | ||||||||||||
| 2173 | - | |||||||||||||
| 2174 | case QEvent::LayoutDirectionChange: | - | ||||||||||||
| 2175 | d->updateTabBarGeometry(); | - | ||||||||||||
| 2176 | break; | - | ||||||||||||
| 2177 | - | |||||||||||||
| 2178 | default: | - | ||||||||||||
| 2179 | break; | - | ||||||||||||
| 2180 | } | - | ||||||||||||
| 2181 | return QAbstractScrollArea::event(event); | - | ||||||||||||
| 2182 | } | - | ||||||||||||
| 2183 | - | |||||||||||||
| 2184 | - | |||||||||||||
| 2185 | - | |||||||||||||
| 2186 | - | |||||||||||||
| 2187 | bool QMdiArea::eventFilter(QObject *object, QEvent *event) | - | ||||||||||||
| 2188 | { | - | ||||||||||||
| 2189 | if (!object) | - | ||||||||||||
| 2190 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2191 | - | |||||||||||||
| 2192 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2193 | - | |||||||||||||
| 2194 | if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { | - | ||||||||||||
| 2195 | - | |||||||||||||
| 2196 | QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); | - | ||||||||||||
| 2197 | - | |||||||||||||
| 2198 | - | |||||||||||||
| 2199 | - | |||||||||||||
| 2200 | - | |||||||||||||
| 2201 | if (!(keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() != Qt::Key_Control) | - | ||||||||||||
| 2202 | - | |||||||||||||
| 2203 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2204 | - | |||||||||||||
| 2205 | - | |||||||||||||
| 2206 | QMdiArea *area = mdiAreaParent(static_cast<QWidget *>(object)); | - | ||||||||||||
| 2207 | if (!area) | - | ||||||||||||
| 2208 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2209 | - | |||||||||||||
| 2210 | const bool keyPress = (event->type() == QEvent::KeyPress); | - | ||||||||||||
| 2211 | - | |||||||||||||
| 2212 | - | |||||||||||||
| 2213 | - | |||||||||||||
| 2214 | - | |||||||||||||
| 2215 | - | |||||||||||||
| 2216 | switch (keyEvent->key()) { | - | ||||||||||||
| 2217 | - | |||||||||||||
| 2218 | - | |||||||||||||
| 2219 | - | |||||||||||||
| 2220 | case Qt::Key_Control: | - | ||||||||||||
| 2221 | - | |||||||||||||
| 2222 | if (keyPress) | - | ||||||||||||
| 2223 | area->d_func()->startTabToPreviousTimer(); | - | ||||||||||||
| 2224 | else | - | ||||||||||||
| 2225 | area->d_func()->activateHighlightedWindow(); | - | ||||||||||||
| 2226 | break; | - | ||||||||||||
| 2227 | case Qt::Key_Tab: | - | ||||||||||||
| 2228 | case Qt::Key_Backtab: | - | ||||||||||||
| 2229 | if (keyPress) | - | ||||||||||||
| 2230 | area->d_func()->highlightNextSubWindow(keyEvent->key() == Qt::Key_Tab ? 1 : -1); | - | ||||||||||||
| 2231 | return true; | - | ||||||||||||
| 2232 | - | |||||||||||||
| 2233 | case Qt::Key_Escape: | - | ||||||||||||
| 2234 | area->d_func()->hideRubberBand(); | - | ||||||||||||
| 2235 | break; | - | ||||||||||||
| 2236 | - | |||||||||||||
| 2237 | default: | - | ||||||||||||
| 2238 | break; | - | ||||||||||||
| 2239 | } | - | ||||||||||||
| 2240 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2241 | } | - | ||||||||||||
| 2242 | - | |||||||||||||
| 2243 | QMdiSubWindow *subWindow = qobject_cast<QMdiSubWindow *>(object); | - | ||||||||||||
| 2244 | - | |||||||||||||
| 2245 | if (!subWindow) { | - | ||||||||||||
| 2246 | - | |||||||||||||
| 2247 | if (event->type() == QEvent::ApplicationActivate && !d->active | - | ||||||||||||
| 2248 | && isVisible() && !window()->isMinimized()) { | - | ||||||||||||
| 2249 | d->activateCurrentWindow(); | - | ||||||||||||
| 2250 | } else if (event->type() == QEvent::ApplicationDeactivate && d->active) { | - | ||||||||||||
| 2251 | d->setActive(d->active, false, false); | - | ||||||||||||
| 2252 | } | - | ||||||||||||
| 2253 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2254 | } | - | ||||||||||||
| 2255 | - | |||||||||||||
| 2256 | if (subWindow->mdiArea() != this) | - | ||||||||||||
| 2257 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2258 | - | |||||||||||||
| 2259 | - | |||||||||||||
| 2260 | switch (event->type()) { | - | ||||||||||||
| 2261 | case QEvent::Move: | - | ||||||||||||
| 2262 | case QEvent::Resize: | - | ||||||||||||
| 2263 | if (d->tileCalledFromResizeEvent) | - | ||||||||||||
| 2264 | break; | - | ||||||||||||
| 2265 | d->updateScrollBars(); | - | ||||||||||||
| 2266 | if (!subWindow->isMinimized()) | - | ||||||||||||
| 2267 | d->isSubWindowsTiled = false; | - | ||||||||||||
| 2268 | break; | - | ||||||||||||
| 2269 | case QEvent::Show: | - | ||||||||||||
| 2270 | - | |||||||||||||
| 2271 | if (d->tabBar) { | - | ||||||||||||
| 2272 | const int tabIndex = d->childWindows.indexOf(subWindow); | - | ||||||||||||
| 2273 | if (!d->tabBar->isTabEnabled(tabIndex)) | - | ||||||||||||
| 2274 | d->tabBar->setTabEnabled(tabIndex, true); | - | ||||||||||||
| 2275 | } | - | ||||||||||||
| 2276 | - | |||||||||||||
| 2277 | - | |||||||||||||
| 2278 | case QEvent::Hide: | - | ||||||||||||
| 2279 | d->isSubWindowsTiled = false; | - | ||||||||||||
| 2280 | break; | - | ||||||||||||
| 2281 | - | |||||||||||||
| 2282 | case QEvent::Close: | - | ||||||||||||
| 2283 | if (d->childWindows.indexOf(subWindow) == d->indexToHighlighted) | - | ||||||||||||
| 2284 | d->hideRubberBand(); | - | ||||||||||||
| 2285 | break; | - | ||||||||||||
| 2286 | - | |||||||||||||
| 2287 | - | |||||||||||||
| 2288 | case QEvent::WindowTitleChange: | - | ||||||||||||
| 2289 | case QEvent::ModifiedChange: | - | ||||||||||||
| 2290 | if (d->tabBar) | - | ||||||||||||
| 2291 | d->tabBar->setTabText(d->childWindows.indexOf(subWindow), tabTextFor(subWindow)); | - | ||||||||||||
| 2292 | break; | - | ||||||||||||
| 2293 | case QEvent::WindowIconChange: | - | ||||||||||||
| 2294 | if (d->tabBar) | - | ||||||||||||
| 2295 | d->tabBar->setTabIcon(d->childWindows.indexOf(subWindow), subWindow->windowIcon()); | - | ||||||||||||
| 2296 | break; | - | ||||||||||||
| 2297 | - | |||||||||||||
| 2298 | default: | - | ||||||||||||
| 2299 | break; | - | ||||||||||||
| 2300 | } | - | ||||||||||||
| 2301 | return QAbstractScrollArea::eventFilter(object, event); | - | ||||||||||||
| 2302 | } | - | ||||||||||||
| 2303 | - | |||||||||||||
| 2304 | - | |||||||||||||
| 2305 | - | |||||||||||||
| 2306 | - | |||||||||||||
| 2307 | void QMdiArea::paintEvent(QPaintEvent *paintEvent) | - | ||||||||||||
| 2308 | { | - | ||||||||||||
| 2309 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2310 | QPainter painter(d->viewport); | - | ||||||||||||
| 2311 | const QVector<QRect> &exposedRects = paintEvent->region().rects(); | - | ||||||||||||
| 2312 | for (int i = 0; i < exposedRects.size(); ++i) | - | ||||||||||||
| 2313 | painter.fillRect(exposedRects.at(i), d->background); | - | ||||||||||||
| 2314 | } | - | ||||||||||||
| 2315 | void QMdiArea::setupViewport(QWidget *viewport) | - | ||||||||||||
| 2316 | { | - | ||||||||||||
| 2317 | QMdiAreaPrivate * const d = d_func(); | - | ||||||||||||
| 2318 | if (viewport) | - | ||||||||||||
| 2319 | viewport->setAttribute(Qt::WA_OpaquePaintEvent, d->background.isOpaque()); | - | ||||||||||||
| 2320 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->childWindows)>::type> _container_((d->childWindows)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QMdiSubWindow *child = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||
| 2321 | if (!sanityCheck(child, "QMdiArea::setupViewport")) | - | ||||||||||||
| 2322 | continue; | - | ||||||||||||
| 2323 | child->setParent(viewport, child->windowFlags()); | - | ||||||||||||
| 2324 | } | - | ||||||||||||
| 2325 | } | - | ||||||||||||
| 2326 | - | |||||||||||||
| 2327 | - | |||||||||||||
| 2328 | - | |||||||||||||
| Switch to Source code | Preprocessed file |