annotate src/gui/layouts/flow_layout.cc @ 253:b3549da699a6

*: ooooh! stupid big commit! oops
author Paper <paper@paper.us.eu.org>
date Tue, 06 Feb 2024 16:56:32 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
253
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
1 /*
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
2 * Copyright (C) 2016 The Qt Company Ltd.
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
3 * Contact: https://www.qt.io/licensing/
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
4 *
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
5 * This file is part of the QtCore module of the Qt Toolkit.
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
6 *
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
7 * "Redistribution and use in source and binary forms, with or without
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
8 * modification, are permitted provided that the following conditions are
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
9 * met:
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
10 * * Redistributions of source code must retain the above copyright
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer.
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
12 * * Redistributions in binary form must reproduce the above copyright
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
14 * the documentation and/or other materials provided with the
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
15 * distribution.
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
16 * * Neither the name of The Qt Company Ltd nor the names of its
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
17 * contributors may be used to endorse or promote products derived
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
18 * from this software without specific prior written permission.
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
19 *
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
31 */
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
32 #include "gui/layouts/flow_layout.h"
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
33
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
34 #include <QWidget>
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
35
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
36 #include <algorithm>
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
37
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
38 FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
39 : QLayout(parent), _horiz_space(hSpacing), _vert_space(vSpacing) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
40 setContentsMargins(margin, margin, margin, margin);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
41 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
42
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
43 FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
44 : _horiz_space(hSpacing), _vert_space(vSpacing) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
45 setContentsMargins(margin, margin, margin, margin);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
46 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
47
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
48 FlowLayout::~FlowLayout() {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
49 while (count())
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
50 delete takeAt(0);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
51 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
52
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
53 void FlowLayout::addItem(QLayoutItem *item) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
54 item_list.append(item);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
55 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
56
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
57 int FlowLayout::horizontalSpacing() const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
58 return (_horiz_space >= 0) ? _horiz_space : smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
59 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
60
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
61 int FlowLayout::verticalSpacing() const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
62 return (_vert_space >= 0) ? _vert_space : smartSpacing(QStyle::PM_LayoutVerticalSpacing);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
63 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
64
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
65 int FlowLayout::count() const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
66 return item_list.size();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
67 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
68
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
69 QLayoutItem* FlowLayout::itemAt(int index) const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
70 return item_list.value(index);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
71 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
72
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
73 QLayoutItem* FlowLayout::takeAt(int index) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
74 return (index >= 0 && index < item_list.size()) ? item_list.takeAt(index) : nullptr;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
75 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
76
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
77 Qt::Orientations FlowLayout::expandingDirections() const
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
78 {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
79 return {};
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
80 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
81
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
82 bool FlowLayout::hasHeightForWidth() const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
83 return true;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
84 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
85
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
86 int FlowLayout::heightForWidth(int width) const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
87 return doLayout(QRect(0, 0, width, 0), true);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
88 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
89
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
90 void FlowLayout::setGeometry(const QRect &rect) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
91 QLayout::setGeometry(rect);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
92 doLayout(rect, false);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
93 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
94
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
95 QSize FlowLayout::sizeHint() const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
96 return minimumSize();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
97 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
98
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
99 QSize FlowLayout::minimumSize() const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
100 QSize size;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
101 for (QLayoutItem* item : item_list)
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
102 size = size.expandedTo(item->minimumSize());
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
103
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
104 const QMargins margins = contentsMargins();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
105 size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
106 return size;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
107 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
108
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
109 int FlowLayout::doLayout(const QRect &rect, bool test) const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
110 int left, top, right, bottom;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
111 getContentsMargins(&left, &top, &right, &bottom);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
112 QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
113
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
114 int x = effectiveRect.x();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
115 int y = effectiveRect.y();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
116 int line_height = 0;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
117
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
118 for (QLayoutItem* item : item_list) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
119 const QWidget* wid = item->widget();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
120 int horiz_space = horizontalSpacing();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
121 if (horiz_space == -1)
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
122 horiz_space = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
123
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
124 int vert_space = verticalSpacing();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
125 if (vert_space == -1)
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
126 vert_space = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
127
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
128 int next_x = x + item->sizeHint().width() + horiz_space;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
129 if ((next_x - horiz_space > effectiveRect.right()) && (line_height > 0)) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
130 x = effectiveRect.x();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
131 y = y + line_height + vert_space;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
132 next_x = x + item->sizeHint().width() + horiz_space;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
133 line_height = 0;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
134 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
135
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
136 if (!test)
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
137 item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
138
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
139 x = next_x;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
140 line_height = std::max(line_height, item->sizeHint().height());
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
141 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
142
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
143 return y + line_height - rect.y() + bottom;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
144 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
145
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
146 int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
147 QObject *parent = this->parent();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
148 if (!parent) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
149 return -1;
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
150 } else if (parent->isWidgetType()) {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
151 QWidget *pw = static_cast<QWidget *>(parent);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
152 return pw->style()->pixelMetric(pm, nullptr, pw);
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
153 } else {
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
154 return static_cast<QLayout *>(parent)->spacing();
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
155 }
b3549da699a6 *: ooooh! stupid big commit!
Paper <paper@paper.us.eu.org>
parents:
diff changeset
156 }