Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicswidget_p.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
29 | ** | - | ||||||||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
31 | ** | - | ||||||||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | #include "qglobal.h" | - | ||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | #include <QtCore/qdebug.h> | - | ||||||||||||||||||||||||
39 | #include <QtCore/qnumeric.h> | - | ||||||||||||||||||||||||
40 | #include "qgraphicswidget_p.h" | - | ||||||||||||||||||||||||
41 | #include "qgraphicslayoutitem_p.h" | - | ||||||||||||||||||||||||
42 | #include "qgraphicslayout.h" | - | ||||||||||||||||||||||||
43 | #include "qgraphicsscene_p.h" | - | ||||||||||||||||||||||||
44 | #include <QtWidgets/qapplication.h> | - | ||||||||||||||||||||||||
45 | #include <QtWidgets/qgraphicsscene.h> | - | ||||||||||||||||||||||||
46 | #include <QtWidgets/qstyleoption.h> | - | ||||||||||||||||||||||||
47 | #include <QtWidgets/QStyleOptionTitleBar> | - | ||||||||||||||||||||||||
48 | #include <QtWidgets/QGraphicsSceneMouseEvent> | - | ||||||||||||||||||||||||
49 | #if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
50 | # include <private/qmacstyle_mac_p.h> | - | ||||||||||||||||||||||||
51 | #endif | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags) | - | ||||||||||||||||||||||||
56 | { | - | ||||||||||||||||||||||||
57 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||
59 | attributes = 0; | - | ||||||||||||||||||||||||
60 | isWidget = 1; // QGraphicsItem::isWidget() returns true. | - | ||||||||||||||||||||||||
61 | focusNext = focusPrev = q; | - | ||||||||||||||||||||||||
62 | focusPolicy = Qt::NoFocus; | - | ||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||
64 | adjustWindowFlags(&wFlags); | - | ||||||||||||||||||||||||
65 | windowFlags = wFlags; | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | q->setParentItem(parentItem); | - | ||||||||||||||||||||||||
68 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType)); | - | ||||||||||||||||||||||||
69 | q->setGraphicsItem(q); | - | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | resolveLayoutDirection(); | - | ||||||||||||||||||||||||
72 | q->unsetWindowFrameMargins(); | - | ||||||||||||||||||||||||
73 | flags |= QGraphicsItem::ItemUsesExtendedStyleOption; | - | ||||||||||||||||||||||||
74 | flags |= QGraphicsItem::ItemSendsGeometryChanges; | - | ||||||||||||||||||||||||
75 | if (windowFlags & Qt::Window)
| 0 | ||||||||||||||||||||||||
76 | flags |= QGraphicsItem::ItemIsPanel; never executed: flags |= QGraphicsItem::ItemIsPanel; | 0 | ||||||||||||||||||||||||
77 | } never executed: end of block | 0 | ||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const | - | ||||||||||||||||||||||||
80 | { | - | ||||||||||||||||||||||||
81 | Q_Q(const QGraphicsWidget); | - | ||||||||||||||||||||||||
82 | int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); | - | ||||||||||||||||||||||||
83 | return (qreal)height; never executed: return (qreal)height; | 0 | ||||||||||||||||||||||||
84 | } | - | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | /*! | - | ||||||||||||||||||||||||
87 | \internal | - | ||||||||||||||||||||||||
88 | */ | - | ||||||||||||||||||||||||
89 | QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate() | - | ||||||||||||||||||||||||
90 | { | - | ||||||||||||||||||||||||
91 | // Remove any lazily allocated data | - | ||||||||||||||||||||||||
92 | delete[] margins; | - | ||||||||||||||||||||||||
93 | delete[] windowFrameMargins; | - | ||||||||||||||||||||||||
94 | delete windowData; | - | ||||||||||||||||||||||||
95 | } never executed: end of block | 0 | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | /*! | - | ||||||||||||||||||||||||
98 | \internal | - | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | Ensures that margins is allocated. | - | ||||||||||||||||||||||||
101 | This function must be called before any dereferencing. | - | ||||||||||||||||||||||||
102 | */ | - | ||||||||||||||||||||||||
103 | void QGraphicsWidgetPrivate::ensureMargins() const | - | ||||||||||||||||||||||||
104 | { | - | ||||||||||||||||||||||||
105 | if (!margins) {
| 0 | ||||||||||||||||||||||||
106 | margins = new qreal[4]; | - | ||||||||||||||||||||||||
107 | for (int i = 0; i < 4; ++i)
| 0 | ||||||||||||||||||||||||
108 | margins[i] = 0; never executed: margins[i] = 0; | 0 | ||||||||||||||||||||||||
109 | } never executed: end of block | 0 | ||||||||||||||||||||||||
110 | } never executed: end of block | 0 | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | /*! | - | ||||||||||||||||||||||||
113 | \internal | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | Ensures that windowFrameMargins is allocated. | - | ||||||||||||||||||||||||
116 | This function must be called before any dereferencing. | - | ||||||||||||||||||||||||
117 | */ | - | ||||||||||||||||||||||||
118 | void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const | - | ||||||||||||||||||||||||
119 | { | - | ||||||||||||||||||||||||
120 | if (!windowFrameMargins) {
| 0 | ||||||||||||||||||||||||
121 | windowFrameMargins = new qreal[4]; | - | ||||||||||||||||||||||||
122 | for (int i = 0; i < 4; ++i)
| 0 | ||||||||||||||||||||||||
123 | windowFrameMargins[i] = 0; never executed: windowFrameMargins[i] = 0; | 0 | ||||||||||||||||||||||||
124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | /*! | - | ||||||||||||||||||||||||
128 | \internal | - | ||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | Ensures that windowData is allocated. | - | ||||||||||||||||||||||||
131 | This function must be called before any dereferencing. | - | ||||||||||||||||||||||||
132 | */ | - | ||||||||||||||||||||||||
133 | void QGraphicsWidgetPrivate::ensureWindowData() | - | ||||||||||||||||||||||||
134 | { | - | ||||||||||||||||||||||||
135 | if (!windowData)
| 0 | ||||||||||||||||||||||||
136 | windowData = new WindowData; never executed: windowData = new WindowData; | 0 | ||||||||||||||||||||||||
137 | } never executed: end of block | 0 | ||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette) | - | ||||||||||||||||||||||||
140 | { | - | ||||||||||||||||||||||||
141 | if (this->palette == palette && this->palette.resolve() == palette.resolve())
| 0 | ||||||||||||||||||||||||
142 | return; never executed: return; | 0 | ||||||||||||||||||||||||
143 | updatePalette(palette); | - | ||||||||||||||||||||||||
144 | } never executed: end of block | 0 | ||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | void QGraphicsWidgetPrivate::resolvePalette(uint inheritedMask) | - | ||||||||||||||||||||||||
147 | { | - | ||||||||||||||||||||||||
148 | inheritedPaletteResolveMask = inheritedMask; | - | ||||||||||||||||||||||||
149 | QPalette naturalPalette = naturalWidgetPalette(); | - | ||||||||||||||||||||||||
150 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - | ||||||||||||||||||||||||
151 | updatePalette(resolvedPalette); | - | ||||||||||||||||||||||||
152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette) | - | ||||||||||||||||||||||||
155 | { | - | ||||||||||||||||||||||||
156 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
157 | // Update local palette setting. | - | ||||||||||||||||||||||||
158 | this->palette = palette; | - | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | // Calculate new mask. | - | ||||||||||||||||||||||||
161 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||
162 | inheritedPaletteResolveMask = 0; never executed: inheritedPaletteResolveMask = 0; | 0 | ||||||||||||||||||||||||
163 | int mask = palette.resolve() | inheritedPaletteResolveMask; | - | ||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||
165 | // Propagate to children. | - | ||||||||||||||||||||||||
166 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||
167 | QGraphicsItem *item = children.at(i); | - | ||||||||||||||||||||||||
168 | if (item->isWidget()) {
| 0 | ||||||||||||||||||||||||
169 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
170 | if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||
171 | w->d_func()->resolvePalette(mask); never executed: w->d_func()->resolvePalette(mask); | 0 | ||||||||||||||||||||||||
172 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
173 | item->d_ptr->resolvePalette(mask); | - | ||||||||||||||||||||||||
174 | } never executed: end of block | 0 | ||||||||||||||||||||||||
175 | } | - | ||||||||||||||||||||||||
176 | - | |||||||||||||||||||||||||
177 | // Notify change. | - | ||||||||||||||||||||||||
178 | QEvent event(QEvent::PaletteChange); | - | ||||||||||||||||||||||||
179 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
180 | } never executed: end of block | 0 | ||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||
182 | void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||
183 | { | - | ||||||||||||||||||||||||
184 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
185 | if ((direction == Qt::RightToLeft) == (testAttribute(Qt::WA_RightToLeft)))
| 0 | ||||||||||||||||||||||||
186 | return; never executed: return; | 0 | ||||||||||||||||||||||||
187 | q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft)); | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | // Propagate this change to all children. | - | ||||||||||||||||||||||||
190 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||
191 | QGraphicsItem *item = children.at(i); | - | ||||||||||||||||||||||||
192 | if (item->isWidget()) {
| 0 | ||||||||||||||||||||||||
193 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
194 | if (widget->parentWidget() && !widget->testAttribute(Qt::WA_SetLayoutDirection))
| 0 | ||||||||||||||||||||||||
195 | widget->d_func()->setLayoutDirection_helper(direction); never executed: widget->d_func()->setLayoutDirection_helper(direction); | 0 | ||||||||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
197 | } never executed: end of block | 0 | ||||||||||||||||||||||||
198 | - | |||||||||||||||||||||||||
199 | // Send the notification event to this widget item. | - | ||||||||||||||||||||||||
200 | QEvent e(QEvent::LayoutDirectionChange); | - | ||||||||||||||||||||||||
201 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||
202 | } never executed: end of block | 0 | ||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | void QGraphicsWidgetPrivate::resolveLayoutDirection() | - | ||||||||||||||||||||||||
205 | { | - | ||||||||||||||||||||||||
206 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
207 | if (q->testAttribute(Qt::WA_SetLayoutDirection)) {
| 0 | ||||||||||||||||||||||||
208 | return; never executed: return; | 0 | ||||||||||||||||||||||||
209 | } | - | ||||||||||||||||||||||||
210 | if (QGraphicsWidget *parentWidget = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||
211 | setLayoutDirection_helper(parentWidget->layoutDirection()); | - | ||||||||||||||||||||||||
212 | } else if (scene) { never executed: end of block
| 0 | ||||||||||||||||||||||||
213 | // ### shouldn't the scene have a layoutdirection really? how does | - | ||||||||||||||||||||||||
214 | // ### QGraphicsWidget get changes from QApplication::layoutDirection? | - | ||||||||||||||||||||||||
215 | setLayoutDirection_helper(QApplication::layoutDirection()); | - | ||||||||||||||||||||||||
216 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
217 | setLayoutDirection_helper(QApplication::layoutDirection()); | - | ||||||||||||||||||||||||
218 | } never executed: end of block | 0 | ||||||||||||||||||||||||
219 | } | - | ||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||
221 | QPalette QGraphicsWidgetPrivate::naturalWidgetPalette() const | - | ||||||||||||||||||||||||
222 | { | - | ||||||||||||||||||||||||
223 | Q_Q(const QGraphicsWidget); | - | ||||||||||||||||||||||||
224 | QPalette palette; | - | ||||||||||||||||||||||||
225 | if (QGraphicsWidget *parent = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||
226 | palette = parent->palette(); | - | ||||||||||||||||||||||||
227 | } else if (scene) { never executed: end of block
| 0 | ||||||||||||||||||||||||
228 | palette = scene->palette(); | - | ||||||||||||||||||||||||
229 | } never executed: end of block | 0 | ||||||||||||||||||||||||
230 | palette.resolve(0); | - | ||||||||||||||||||||||||
231 | return palette; never executed: return palette; | 0 | ||||||||||||||||||||||||
232 | } | - | ||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||
234 | void QGraphicsWidgetPrivate::setFont_helper(const QFont &font) | - | ||||||||||||||||||||||||
235 | { | - | ||||||||||||||||||||||||
236 | if (this->font == font && this->font.resolve() == font.resolve())
| 0 | ||||||||||||||||||||||||
237 | return; never executed: return; | 0 | ||||||||||||||||||||||||
238 | updateFont(font); | - | ||||||||||||||||||||||||
239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||
241 | void QGraphicsWidgetPrivate::resolveFont(uint inheritedMask) | - | ||||||||||||||||||||||||
242 | { | - | ||||||||||||||||||||||||
243 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
244 | inheritedFontResolveMask = inheritedMask; | - | ||||||||||||||||||||||||
245 | if (QGraphicsWidget *p = q->parentWidget())
| 0 | ||||||||||||||||||||||||
246 | inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask; never executed: inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask; | 0 | ||||||||||||||||||||||||
247 | QFont naturalFont = naturalWidgetFont(); | - | ||||||||||||||||||||||||
248 | QFont resolvedFont = font.resolve(naturalFont); | - | ||||||||||||||||||||||||
249 | updateFont(resolvedFont); | - | ||||||||||||||||||||||||
250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||
252 | void QGraphicsWidgetPrivate::updateFont(const QFont &font) | - | ||||||||||||||||||||||||
253 | { | - | ||||||||||||||||||||||||
254 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
255 | // Update the local font setting. | - | ||||||||||||||||||||||||
256 | this->font = font; | - | ||||||||||||||||||||||||
257 | - | |||||||||||||||||||||||||
258 | // Calculate new mask. | - | ||||||||||||||||||||||||
259 | if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||
260 | inheritedFontResolveMask = 0; never executed: inheritedFontResolveMask = 0; | 0 | ||||||||||||||||||||||||
261 | int mask = font.resolve() | inheritedFontResolveMask; | - | ||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | // Propagate to children. | - | ||||||||||||||||||||||||
264 | for (int i = 0; i < children.size(); ++i) {
| 0 | ||||||||||||||||||||||||
265 | QGraphicsItem *item = children.at(i); | - | ||||||||||||||||||||||||
266 | if (item->isWidget()) {
| 0 | ||||||||||||||||||||||||
267 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
268 | if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||
269 | w->d_func()->resolveFont(mask); never executed: w->d_func()->resolveFont(mask); | 0 | ||||||||||||||||||||||||
270 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
271 | item->d_ptr->resolveFont(mask); | - | ||||||||||||||||||||||||
272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
273 | } | - | ||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | if (!polished)
| 0 | ||||||||||||||||||||||||
276 | return; never executed: return; | 0 | ||||||||||||||||||||||||
277 | // Notify change. | - | ||||||||||||||||||||||||
278 | QEvent event(QEvent::FontChange); | - | ||||||||||||||||||||||||
279 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
280 | } never executed: end of block | 0 | ||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | QFont QGraphicsWidgetPrivate::naturalWidgetFont() const | - | ||||||||||||||||||||||||
283 | { | - | ||||||||||||||||||||||||
284 | Q_Q(const QGraphicsWidget); | - | ||||||||||||||||||||||||
285 | QFont naturalFont; // ### no application font support | - | ||||||||||||||||||||||||
286 | if (QGraphicsWidget *parent = q->parentWidget()) {
| 0 | ||||||||||||||||||||||||
287 | naturalFont = parent->font(); | - | ||||||||||||||||||||||||
288 | } else if (scene) { never executed: end of block
| 0 | ||||||||||||||||||||||||
289 | naturalFont = scene->font(); | - | ||||||||||||||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
291 | naturalFont.resolve(0); | - | ||||||||||||||||||||||||
292 | return naturalFont; never executed: return naturalFont; | 0 | ||||||||||||||||||||||||
293 | } | - | ||||||||||||||||||||||||
294 | - | |||||||||||||||||||||||||
295 | void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *option) | - | ||||||||||||||||||||||||
296 | { | - | ||||||||||||||||||||||||
297 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
298 | ensureWindowData(); | - | ||||||||||||||||||||||||
299 | q->initStyleOption(option); | - | ||||||||||||||||||||||||
300 | option->rect.setHeight(titleBarHeight(*option)); | - | ||||||||||||||||||||||||
301 | option->titleBarFlags = windowFlags; | - | ||||||||||||||||||||||||
302 | option->subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu; | - | ||||||||||||||||||||||||
303 | option->activeSubControls = windowData->hoveredSubControl; | - | ||||||||||||||||||||||||
304 | bool isActive = q->isActiveWindow(); | - | ||||||||||||||||||||||||
305 | if (isActive) {
| 0 | ||||||||||||||||||||||||
306 | option->state |= QStyle::State_Active; | - | ||||||||||||||||||||||||
307 | option->titleBarState = Qt::WindowActive; | - | ||||||||||||||||||||||||
308 | option->titleBarState |= QStyle::State_Active; | - | ||||||||||||||||||||||||
309 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
310 | option->state &= ~QStyle::State_Active; | - | ||||||||||||||||||||||||
311 | option->titleBarState = Qt::WindowNoState; | - | ||||||||||||||||||||||||
312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
313 | QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar"); | - | ||||||||||||||||||||||||
314 | QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0); | - | ||||||||||||||||||||||||
315 | option->text = QFontMetrics(windowTitleFont).elidedText( | - | ||||||||||||||||||||||||
316 | windowData->windowTitle, Qt::ElideRight, textRect.width()); | - | ||||||||||||||||||||||||
317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
318 | - | |||||||||||||||||||||||||
319 | void QGraphicsWidgetPrivate::adjustWindowFlags(Qt::WindowFlags *flags) | - | ||||||||||||||||||||||||
320 | { | - | ||||||||||||||||||||||||
321 | bool customize = (*flags & (Qt::CustomizeWindowHint | - | ||||||||||||||||||||||||
322 | | Qt::FramelessWindowHint | - | ||||||||||||||||||||||||
323 | | Qt::WindowTitleHint | - | ||||||||||||||||||||||||
324 | | Qt::WindowSystemMenuHint | - | ||||||||||||||||||||||||
325 | | Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||||||||
326 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||||||||
327 | | Qt::WindowContextHelpButtonHint)); | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | uint type = (*flags & Qt::WindowType_Mask); | - | ||||||||||||||||||||||||
330 | if (customize)
| 0 | ||||||||||||||||||||||||
331 | ; never executed: ; | 0 | ||||||||||||||||||||||||
332 | else if (type == Qt::Dialog || type == Qt::Sheet)
| 0 | ||||||||||||||||||||||||
333 | *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint; | 0 | ||||||||||||||||||||||||
334 | else if (type == Qt::Tool)
| 0 | ||||||||||||||||||||||||
335 | *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; | 0 | ||||||||||||||||||||||||
336 | else if (type == Qt::Window || type == Qt::SubWindow)
| 0 | ||||||||||||||||||||||||
337 | *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; | 0 | ||||||||||||||||||||||||
338 | | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; | 0 | ||||||||||||||||||||||||
339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | void QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
342 | { | - | ||||||||||||||||||||||||
343 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
344 | ensureWindowData(); | - | ||||||||||||||||||||||||
345 | if (windowData->grabbedSection != Qt::NoSection) {
| 0 | ||||||||||||||||||||||||
346 | if (windowData->grabbedSection == Qt::TitleBarArea) {
| 0 | ||||||||||||||||||||||||
347 | windowData->buttonSunken = false; | - | ||||||||||||||||||||||||
348 | QStyleOptionTitleBar bar; | - | ||||||||||||||||||||||||
349 | initStyleOptionTitleBar(&bar); | - | ||||||||||||||||||||||||
350 | // make sure that the coordinates (rect and pos) we send to the style are positive. | - | ||||||||||||||||||||||||
351 | bar.rect = q->windowFrameRect().toRect(); | - | ||||||||||||||||||||||||
352 | bar.rect.moveTo(0,0); | - | ||||||||||||||||||||||||
353 | bar.rect.setHeight(q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar)); | - | ||||||||||||||||||||||||
354 | QPointF pos = event->pos(); | - | ||||||||||||||||||||||||
355 | if (windowFrameMargins) {
| 0 | ||||||||||||||||||||||||
356 | pos.rx() += windowFrameMargins[Left]; | - | ||||||||||||||||||||||||
357 | pos.ry() += windowFrameMargins[Top]; | - | ||||||||||||||||||||||||
358 | } never executed: end of block | 0 | ||||||||||||||||||||||||
359 | bar.subControls = QStyle::SC_TitleBarCloseButton; | - | ||||||||||||||||||||||||
360 | if (q->style()->subControlRect(QStyle::CC_TitleBar, &bar,
| 0 | ||||||||||||||||||||||||
361 | QStyle::SC_TitleBarCloseButton,
| 0 | ||||||||||||||||||||||||
362 | event->widget()).contains(pos.toPoint())) {
| 0 | ||||||||||||||||||||||||
363 | q->close(); | - | ||||||||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||||||||
365 | } never executed: end of block | 0 | ||||||||||||||||||||||||
366 | if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->buttons()))
| 0 | ||||||||||||||||||||||||
367 | windowData->grabbedSection = Qt::NoSection; never executed: windowData->grabbedSection = Qt::NoSection; | 0 | ||||||||||||||||||||||||
368 | event->accept(); | - | ||||||||||||||||||||||||
369 | } never executed: end of block | 0 | ||||||||||||||||||||||||
370 | } never executed: end of block | 0 | ||||||||||||||||||||||||
371 | - | |||||||||||||||||||||||||
372 | void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
373 | { | - | ||||||||||||||||||||||||
374 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
375 | if (event->button() != Qt::LeftButton)
| 0 | ||||||||||||||||||||||||
376 | return; never executed: return; | 0 | ||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | ensureWindowData(); | - | ||||||||||||||||||||||||
379 | windowData->startGeometry = q->geometry(); | - | ||||||||||||||||||||||||
380 | windowData->grabbedSection = q->windowFrameSectionAt(event->pos()); | - | ||||||||||||||||||||||||
381 | ensureWindowData(); | - | ||||||||||||||||||||||||
382 | if (windowData->grabbedSection == Qt::TitleBarArea
| 0 | ||||||||||||||||||||||||
383 | && windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton) {
| 0 | ||||||||||||||||||||||||
384 | windowData->buttonSunken = true; | - | ||||||||||||||||||||||||
385 | q->update(); | - | ||||||||||||||||||||||||
386 | } never executed: end of block | 0 | ||||||||||||||||||||||||
387 | event->setAccepted(windowData->grabbedSection != Qt::NoSection); | - | ||||||||||||||||||||||||
388 | } never executed: end of block | 0 | ||||||||||||||||||||||||
389 | - | |||||||||||||||||||||||||
390 | /*! | - | ||||||||||||||||||||||||
391 | Used to calculate the | - | ||||||||||||||||||||||||
392 | Precondition: | - | ||||||||||||||||||||||||
393 | \a widget should support either hfw or wfh | - | ||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||
395 | If \a heightForWidth is set to false, this function will query the width for height | - | ||||||||||||||||||||||||
396 | instead. \a width will then be interpreted as height, \a minh and \a maxh will be interpreted | - | ||||||||||||||||||||||||
397 | as minimum width and maximum width. | - | ||||||||||||||||||||||||
398 | */ | - | ||||||||||||||||||||||||
399 | static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh, | - | ||||||||||||||||||||||||
400 | const QGraphicsWidget *widget, | - | ||||||||||||||||||||||||
401 | bool heightForWidth = true) | - | ||||||||||||||||||||||||
402 | { | - | ||||||||||||||||||||||||
403 | qreal minimumHeightForWidth = -1; | - | ||||||||||||||||||||||||
404 | const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth(); | - | ||||||||||||||||||||||||
405 | if (hasHFW == heightForWidth) {
| 0 | ||||||||||||||||||||||||
406 | minimumHeightForWidth = hasHFW
| 0 | ||||||||||||||||||||||||
407 | ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height() | - | ||||||||||||||||||||||||
408 | : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); //"width" is here height! | - | ||||||||||||||||||||||||
409 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
410 | // widthForHeight | - | ||||||||||||||||||||||||
411 | const qreal constraint = width; | - | ||||||||||||||||||||||||
412 | while (maxh - minh > 0.1) {
| 0 | ||||||||||||||||||||||||
413 | qreal middle = minh + (maxh - minh)/2; | - | ||||||||||||||||||||||||
414 | // ### really bad, if we are a widget with a layout it will call | - | ||||||||||||||||||||||||
415 | // layout->effectiveSizeHint(Qt::MiniumumSize), which again will call | - | ||||||||||||||||||||||||
416 | // sizeHint three times because of how the cache works | - | ||||||||||||||||||||||||
417 | qreal hfw = hasHFW
| 0 | ||||||||||||||||||||||||
418 | ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height() | - | ||||||||||||||||||||||||
419 | : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width(); | - | ||||||||||||||||||||||||
420 | if (hfw > constraint) {
| 0 | ||||||||||||||||||||||||
421 | minh = middle; | - | ||||||||||||||||||||||||
422 | } else if (hfw <= constraint) { never executed: end of block
| 0 | ||||||||||||||||||||||||
423 | maxh = middle; | - | ||||||||||||||||||||||||
424 | } never executed: end of block | 0 | ||||||||||||||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||||||||||||||
426 | minimumHeightForWidth = maxh; | - | ||||||||||||||||||||||||
427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
428 | return minimumHeightForWidth; never executed: return minimumHeightForWidth; | 0 | ||||||||||||||||||||||||
429 | } | - | ||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw, | - | ||||||||||||||||||||||||
432 | const QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
433 | { | - | ||||||||||||||||||||||||
434 | return minimumHeightForWidth(height, minw, maxw, widget, false); never executed: return minimumHeightForWidth(height, minw, maxw, widget, false); | 0 | ||||||||||||||||||||||||
435 | } | - | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | static QSizeF closestAcceptableSize(const QSizeF &proposed, | - | ||||||||||||||||||||||||
438 | const QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
439 | { | - | ||||||||||||||||||||||||
440 | const QSizeF current = widget->size(); | - | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | qreal minw = proposed.width(); | - | ||||||||||||||||||||||||
443 | qreal maxw = current.width(); | - | ||||||||||||||||||||||||
444 | qreal minh = proposed.height(); | - | ||||||||||||||||||||||||
445 | qreal maxh = current.height(); | - | ||||||||||||||||||||||||
446 | - | |||||||||||||||||||||||||
447 | qreal middlew = maxw; | - | ||||||||||||||||||||||||
448 | qreal middleh = maxh; | - | ||||||||||||||||||||||||
449 | qreal min_hfw; | - | ||||||||||||||||||||||||
450 | min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget); | - | ||||||||||||||||||||||||
451 | - | |||||||||||||||||||||||||
452 | do { | - | ||||||||||||||||||||||||
453 | if (maxw - minw < 0.1) {
| 0 | ||||||||||||||||||||||||
454 | // we still haven't found anything, cut off binary search | - | ||||||||||||||||||||||||
455 | minw = maxw; | - | ||||||||||||||||||||||||
456 | minh = maxh; | - | ||||||||||||||||||||||||
457 | } never executed: end of block | 0 | ||||||||||||||||||||||||
458 | middlew = minw + (maxw - minw)/2.0; | - | ||||||||||||||||||||||||
459 | middleh = minh + (maxh - minh)/2.0; | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget); | - | ||||||||||||||||||||||||
462 | - | |||||||||||||||||||||||||
463 | if (min_hfw > middleh) {
| 0 | ||||||||||||||||||||||||
464 | minw = middlew; | - | ||||||||||||||||||||||||
465 | minh = middleh; | - | ||||||||||||||||||||||||
466 | } else if (min_hfw <= middleh) { never executed: end of block
| 0 | ||||||||||||||||||||||||
467 | maxw = middlew; | - | ||||||||||||||||||||||||
468 | maxh = middleh; | - | ||||||||||||||||||||||||
469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
470 | } while (maxw != minw); never executed: end of block
| 0 | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget); | - | ||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | QSizeF result; | - | ||||||||||||||||||||||||
475 | if (min_hfw < maxh) {
| 0 | ||||||||||||||||||||||||
476 | result = QSizeF(middlew, min_hfw); | - | ||||||||||||||||||||||||
477 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
478 | // Needed because of the cut-off we do above. | - | ||||||||||||||||||||||||
479 | result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh); | - | ||||||||||||||||||||||||
480 | } never executed: end of block | 0 | ||||||||||||||||||||||||
481 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
482 | } | - | ||||||||||||||||||||||||
483 | - | |||||||||||||||||||||||||
484 | static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry, | - | ||||||||||||||||||||||||
485 | QRectF *rect, Qt::WindowFrameSection section, | - | ||||||||||||||||||||||||
486 | const QSizeF &min, const QSizeF &max, | - | ||||||||||||||||||||||||
487 | const QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
488 | { | - | ||||||||||||||||||||||||
489 | const QRectF proposedRect = *rect; | - | ||||||||||||||||||||||||
490 | qreal width = qBound(min.width(), proposedRect.width(), max.width()); | - | ||||||||||||||||||||||||
491 | qreal height = qBound(min.height(), proposedRect.height(), max.height()); | - | ||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||
493 | const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth(); | - | ||||||||||||||||||||||||
494 | const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight(); | - | ||||||||||||||||||||||||
495 | - | |||||||||||||||||||||||||
496 | const bool widthChanged = proposedRect.width() != widget->size().width(); | - | ||||||||||||||||||||||||
497 | const bool heightChanged = proposedRect.height() != widget->size().height(); | - | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | if (hasHFW || hasWFH) {
| 0 | ||||||||||||||||||||||||
500 | if (widthChanged || heightChanged) {
| 0 | ||||||||||||||||||||||||
501 | qreal minExtent; | - | ||||||||||||||||||||||||
502 | qreal maxExtent; | - | ||||||||||||||||||||||||
503 | qreal constraint; | - | ||||||||||||||||||||||||
504 | qreal proposed; | - | ||||||||||||||||||||||||
505 | if (hasHFW) {
| 0 | ||||||||||||||||||||||||
506 | minExtent = min.height(); | - | ||||||||||||||||||||||||
507 | maxExtent = max.height(); | - | ||||||||||||||||||||||||
508 | constraint = width; | - | ||||||||||||||||||||||||
509 | proposed = proposedRect.height(); | - | ||||||||||||||||||||||||
510 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
511 | // width for height | - | ||||||||||||||||||||||||
512 | minExtent = min.width(); | - | ||||||||||||||||||||||||
513 | maxExtent = max.width(); | - | ||||||||||||||||||||||||
514 | constraint = height; | - | ||||||||||||||||||||||||
515 | proposed = proposedRect.width(); | - | ||||||||||||||||||||||||
516 | } never executed: end of block | 0 | ||||||||||||||||||||||||
517 | if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed) {
| 0 | ||||||||||||||||||||||||
518 | QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget); | - | ||||||||||||||||||||||||
519 | width = effectiveSize.width(); | - | ||||||||||||||||||||||||
520 | height = effectiveSize.height(); | - | ||||||||||||||||||||||||
521 | } never executed: end of block | 0 | ||||||||||||||||||||||||
522 | } never executed: end of block | 0 | ||||||||||||||||||||||||
523 | } never executed: end of block | 0 | ||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||
525 | switch (section) { | - | ||||||||||||||||||||||||
526 | case Qt::LeftSection: never executed: case Qt::LeftSection: | 0 | ||||||||||||||||||||||||
527 | rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(), | - | ||||||||||||||||||||||||
528 | qRound(width), startGeometry.height()); | - | ||||||||||||||||||||||||
529 | break; never executed: break; | 0 | ||||||||||||||||||||||||
530 | case Qt::TopLeftSection: never executed: case Qt::TopLeftSection: | 0 | ||||||||||||||||||||||||
531 | rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height), | - | ||||||||||||||||||||||||
532 | qRound(width), qRound(height)); | - | ||||||||||||||||||||||||
533 | break; never executed: break; | 0 | ||||||||||||||||||||||||
534 | case Qt::TopSection: never executed: case Qt::TopSection: | 0 | ||||||||||||||||||||||||
535 | rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height), | - | ||||||||||||||||||||||||
536 | startGeometry.width(), qRound(height)); | - | ||||||||||||||||||||||||
537 | break; never executed: break; | 0 | ||||||||||||||||||||||||
538 | case Qt::TopRightSection: never executed: case Qt::TopRightSection: | 0 | ||||||||||||||||||||||||
539 | rect->setTop(rect->bottom() - qRound(height)); | - | ||||||||||||||||||||||||
540 | rect->setWidth(qRound(width)); | - | ||||||||||||||||||||||||
541 | break; never executed: break; | 0 | ||||||||||||||||||||||||
542 | case Qt::RightSection: never executed: case Qt::RightSection: | 0 | ||||||||||||||||||||||||
543 | rect->setWidth(qRound(width)); | - | ||||||||||||||||||||||||
544 | break; never executed: break; | 0 | ||||||||||||||||||||||||
545 | case Qt::BottomRightSection: never executed: case Qt::BottomRightSection: | 0 | ||||||||||||||||||||||||
546 | rect->setWidth(qRound(width)); | - | ||||||||||||||||||||||||
547 | rect->setHeight(qRound(height)); | - | ||||||||||||||||||||||||
548 | break; never executed: break; | 0 | ||||||||||||||||||||||||
549 | case Qt::BottomSection: never executed: case Qt::BottomSection: | 0 | ||||||||||||||||||||||||
550 | rect->setHeight(qRound(height)); | - | ||||||||||||||||||||||||
551 | break; never executed: break; | 0 | ||||||||||||||||||||||||
552 | case Qt::BottomLeftSection: never executed: case Qt::BottomLeftSection: | 0 | ||||||||||||||||||||||||
553 | rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(), | - | ||||||||||||||||||||||||
554 | qRound(width), qRound(height)); | - | ||||||||||||||||||||||||
555 | break; never executed: break; | 0 | ||||||||||||||||||||||||
556 | default: never executed: default: | 0 | ||||||||||||||||||||||||
557 | break; never executed: break; | 0 | ||||||||||||||||||||||||
558 | } | - | ||||||||||||||||||||||||
559 | } | - | ||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
562 | { | - | ||||||||||||||||||||||||
563 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
564 | ensureWindowData(); | - | ||||||||||||||||||||||||
565 | if (!(event->buttons() & Qt::LeftButton) || windowData->hoveredSubControl != QStyle::SC_TitleBarLabel)
| 0 | ||||||||||||||||||||||||
566 | return; never executed: return; | 0 | ||||||||||||||||||||||||
567 | - | |||||||||||||||||||||||||
568 | QLineF delta(q->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)), event->pos()); | - | ||||||||||||||||||||||||
569 | QLineF parentDelta(q->mapToParent(delta.p1()), q->mapToParent(delta.p2())); | - | ||||||||||||||||||||||||
570 | QLineF parentXDelta(q->mapToParent(QPointF(delta.p1().x(), 0)), q->mapToParent(QPointF(delta.p2().x(), 0))); | - | ||||||||||||||||||||||||
571 | QLineF parentYDelta(q->mapToParent(QPointF(0, delta.p1().y())), q->mapToParent(QPointF(0, delta.p2().y()))); | - | ||||||||||||||||||||||||
572 | - | |||||||||||||||||||||||||
573 | QRectF newGeometry; | - | ||||||||||||||||||||||||
574 | switch (windowData->grabbedSection) { | - | ||||||||||||||||||||||||
575 | case Qt::LeftSection: never executed: case Qt::LeftSection: | 0 | ||||||||||||||||||||||||
576 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
577 | + QPointF(parentXDelta.dx(), parentXDelta.dy()), | - | ||||||||||||||||||||||||
578 | windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
579 | break; never executed: break; | 0 | ||||||||||||||||||||||||
580 | case Qt::TopLeftSection: never executed: case Qt::TopLeftSection: | 0 | ||||||||||||||||||||||||
581 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
582 | + QPointF(parentDelta.dx(), parentDelta.dy()), | - | ||||||||||||||||||||||||
583 | windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
584 | break; never executed: break; | 0 | ||||||||||||||||||||||||
585 | case Qt::TopSection: never executed: case Qt::TopSection: | 0 | ||||||||||||||||||||||||
586 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
587 | + QPointF(parentYDelta.dx(), parentYDelta.dy()), | - | ||||||||||||||||||||||||
588 | windowData->startGeometry.size() - QSizeF(0, delta.dy())); | - | ||||||||||||||||||||||||
589 | break; never executed: break; | 0 | ||||||||||||||||||||||||
590 | case Qt::TopRightSection: never executed: case Qt::TopRightSection: | 0 | ||||||||||||||||||||||||
591 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
592 | + QPointF(parentYDelta.dx(), parentYDelta.dy()), | - | ||||||||||||||||||||||||
593 | windowData->startGeometry.size() - QSizeF(-delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
594 | break; never executed: break; | 0 | ||||||||||||||||||||||||
595 | case Qt::RightSection: never executed: case Qt::RightSection: | 0 | ||||||||||||||||||||||||
596 | newGeometry = QRectF(windowData->startGeometry.topLeft(), | - | ||||||||||||||||||||||||
597 | windowData->startGeometry.size() + QSizeF(delta.dx(), 0)); | - | ||||||||||||||||||||||||
598 | break; never executed: break; | 0 | ||||||||||||||||||||||||
599 | case Qt::BottomRightSection: never executed: case Qt::BottomRightSection: | 0 | ||||||||||||||||||||||||
600 | newGeometry = QRectF(windowData->startGeometry.topLeft(), | - | ||||||||||||||||||||||||
601 | windowData->startGeometry.size() + QSizeF(delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
602 | break; never executed: break; | 0 | ||||||||||||||||||||||||
603 | case Qt::BottomSection: never executed: case Qt::BottomSection: | 0 | ||||||||||||||||||||||||
604 | newGeometry = QRectF(windowData->startGeometry.topLeft(), | - | ||||||||||||||||||||||||
605 | windowData->startGeometry.size() + QSizeF(0, delta.dy())); | - | ||||||||||||||||||||||||
606 | break; never executed: break; | 0 | ||||||||||||||||||||||||
607 | case Qt::BottomLeftSection: never executed: case Qt::BottomLeftSection: | 0 | ||||||||||||||||||||||||
608 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
609 | + QPointF(parentXDelta.dx(), parentXDelta.dy()), | - | ||||||||||||||||||||||||
610 | windowData->startGeometry.size() - QSizeF(delta.dx(), -delta.dy())); | - | ||||||||||||||||||||||||
611 | break; never executed: break; | 0 | ||||||||||||||||||||||||
612 | case Qt::TitleBarArea: never executed: case Qt::TitleBarArea: | 0 | ||||||||||||||||||||||||
613 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
614 | + QPointF(parentDelta.dx(), parentDelta.dy()), | - | ||||||||||||||||||||||||
615 | windowData->startGeometry.size()); | - | ||||||||||||||||||||||||
616 | break; never executed: break; | 0 | ||||||||||||||||||||||||
617 | case Qt::NoSection: never executed: case Qt::NoSection: | 0 | ||||||||||||||||||||||||
618 | break; never executed: break; | 0 | ||||||||||||||||||||||||
619 | } | - | ||||||||||||||||||||||||
620 | - | |||||||||||||||||||||||||
621 | if (windowData->grabbedSection != Qt::NoSection) {
| 0 | ||||||||||||||||||||||||
622 | _q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry, | - | ||||||||||||||||||||||||
623 | windowData->grabbedSection, | - | ||||||||||||||||||||||||
624 | q->effectiveSizeHint(Qt::MinimumSize), | - | ||||||||||||||||||||||||
625 | q->effectiveSizeHint(Qt::MaximumSize), | - | ||||||||||||||||||||||||
626 | q); | - | ||||||||||||||||||||||||
627 | q->setGeometry(newGeometry); | - | ||||||||||||||||||||||||
628 | } never executed: end of block | 0 | ||||||||||||||||||||||||
629 | } never executed: end of block | 0 | ||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event) | - | ||||||||||||||||||||||||
632 | { | - | ||||||||||||||||||||||||
633 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
634 | if (!hasDecoration())
| 0 | ||||||||||||||||||||||||
635 | return; never executed: return; | 0 | ||||||||||||||||||||||||
636 | - | |||||||||||||||||||||||||
637 | ensureWindowData(); | - | ||||||||||||||||||||||||
638 | - | |||||||||||||||||||||||||
639 | if (q->rect().contains(event->pos())) {
| 0 | ||||||||||||||||||||||||
640 | if (windowData->buttonMouseOver || windowData->hoveredSubControl != QStyle::SC_None)
| 0 | ||||||||||||||||||||||||
641 | windowFrameHoverLeaveEvent(event); never executed: windowFrameHoverLeaveEvent(event); | 0 | ||||||||||||||||||||||||
642 | return; never executed: return; | 0 | ||||||||||||||||||||||||
643 | } | - | ||||||||||||||||||||||||
644 | - | |||||||||||||||||||||||||
645 | bool wasMouseOver = windowData->buttonMouseOver; | - | ||||||||||||||||||||||||
646 | QRect oldButtonRect = windowData->buttonRect; | - | ||||||||||||||||||||||||
647 | windowData->buttonRect = QRect(); | - | ||||||||||||||||||||||||
648 | windowData->buttonMouseOver = false; | - | ||||||||||||||||||||||||
649 | QPointF pos = event->pos(); | - | ||||||||||||||||||||||||
650 | QStyleOptionTitleBar bar; | - | ||||||||||||||||||||||||
651 | // make sure that the coordinates (rect and pos) we send to the style are positive. | - | ||||||||||||||||||||||||
652 | if (windowFrameMargins) {
| 0 | ||||||||||||||||||||||||
653 | pos.rx() += windowFrameMargins[Left]; | - | ||||||||||||||||||||||||
654 | pos.ry() += windowFrameMargins[Top]; | - | ||||||||||||||||||||||||
655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
656 | initStyleOptionTitleBar(&bar); | - | ||||||||||||||||||||||||
657 | bar.rect = q->windowFrameRect().toRect(); | - | ||||||||||||||||||||||||
658 | bar.rect.moveTo(0,0); | - | ||||||||||||||||||||||||
659 | bar.rect.setHeight(int(titleBarHeight(bar))); | - | ||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | Qt::CursorShape cursorShape = Qt::ArrowCursor; | - | ||||||||||||||||||||||||
662 | bool needsSetCursorCall = true; | - | ||||||||||||||||||||||||
663 | switch (q->windowFrameSectionAt(event->pos())) { | - | ||||||||||||||||||||||||
664 | case Qt::TopLeftSection: never executed: case Qt::TopLeftSection: | 0 | ||||||||||||||||||||||||
665 | case Qt::BottomRightSection: never executed: case Qt::BottomRightSection: | 0 | ||||||||||||||||||||||||
666 | cursorShape = Qt::SizeFDiagCursor; | - | ||||||||||||||||||||||||
667 | break; never executed: break; | 0 | ||||||||||||||||||||||||
668 | case Qt::TopRightSection: never executed: case Qt::TopRightSection: | 0 | ||||||||||||||||||||||||
669 | case Qt::BottomLeftSection: never executed: case Qt::BottomLeftSection: | 0 | ||||||||||||||||||||||||
670 | cursorShape = Qt::SizeBDiagCursor; | - | ||||||||||||||||||||||||
671 | break; never executed: break; | 0 | ||||||||||||||||||||||||
672 | case Qt::LeftSection: never executed: case Qt::LeftSection: | 0 | ||||||||||||||||||||||||
673 | case Qt::RightSection: never executed: case Qt::RightSection: | 0 | ||||||||||||||||||||||||
674 | cursorShape = Qt::SizeHorCursor; | - | ||||||||||||||||||||||||
675 | break; never executed: break; | 0 | ||||||||||||||||||||||||
676 | case Qt::TopSection: never executed: case Qt::TopSection: | 0 | ||||||||||||||||||||||||
677 | case Qt::BottomSection: never executed: case Qt::BottomSection: | 0 | ||||||||||||||||||||||||
678 | cursorShape = Qt::SizeVerCursor; | - | ||||||||||||||||||||||||
679 | break; never executed: break; | 0 | ||||||||||||||||||||||||
680 | case Qt::TitleBarArea: never executed: case Qt::TitleBarArea: | 0 | ||||||||||||||||||||||||
681 | windowData->buttonRect = q->style()->subControlRect( | - | ||||||||||||||||||||||||
682 | QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0); | - | ||||||||||||||||||||||||
683 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||
684 | // On mac we should hover if we are in the 'area' of the buttons | - | ||||||||||||||||||||||||
685 | windowData->buttonRect |= q->style()->subControlRect( | - | ||||||||||||||||||||||||
686 | QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarMinButton, 0); | - | ||||||||||||||||||||||||
687 | windowData->buttonRect |= q->style()->subControlRect( | - | ||||||||||||||||||||||||
688 | QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarMaxButton, 0); | - | ||||||||||||||||||||||||
689 | #endif | - | ||||||||||||||||||||||||
690 | if (windowData->buttonRect.contains(pos.toPoint()))
| 0 | ||||||||||||||||||||||||
691 | windowData->buttonMouseOver = true; never executed: windowData->buttonMouseOver = true; | 0 | ||||||||||||||||||||||||
692 | event->ignore(); | - | ||||||||||||||||||||||||
693 | break; never executed: break; | 0 | ||||||||||||||||||||||||
694 | default: never executed: default: | 0 | ||||||||||||||||||||||||
695 | needsSetCursorCall = false; | - | ||||||||||||||||||||||||
696 | event->ignore(); | - | ||||||||||||||||||||||||
697 | } never executed: end of block | 0 | ||||||||||||||||||||||||
698 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||
699 | if (needsSetCursorCall)
| 0 | ||||||||||||||||||||||||
700 | q->setCursor(cursorShape); never executed: q->setCursor(cursorShape); | 0 | ||||||||||||||||||||||||
701 | #endif | - | ||||||||||||||||||||||||
702 | // update buttons if we hover over them | - | ||||||||||||||||||||||||
703 | windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0); | - | ||||||||||||||||||||||||
704 | if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton)
| 0 | ||||||||||||||||||||||||
705 | windowData->hoveredSubControl = QStyle::SC_TitleBarLabel; never executed: windowData->hoveredSubControl = QStyle::SC_TitleBarLabel; | 0 | ||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||
707 | if (windowData->buttonMouseOver != wasMouseOver) {
| 0 | ||||||||||||||||||||||||
708 | if (!oldButtonRect.isNull())
| 0 | ||||||||||||||||||||||||
709 | q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft())); never executed: q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft())); | 0 | ||||||||||||||||||||||||
710 | if (!windowData->buttonRect.isNull())
| 0 | ||||||||||||||||||||||||
711 | q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft())); never executed: q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft())); | 0 | ||||||||||||||||||||||||
712 | } never executed: end of block | 0 | ||||||||||||||||||||||||
713 | } never executed: end of block | 0 | ||||||||||||||||||||||||
714 | - | |||||||||||||||||||||||||
715 | void QGraphicsWidgetPrivate::windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event) | - | ||||||||||||||||||||||||
716 | { | - | ||||||||||||||||||||||||
717 | Q_UNUSED(event); | - | ||||||||||||||||||||||||
718 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
719 | if (hasDecoration()) {
| 0 | ||||||||||||||||||||||||
720 | // ### restore the cursor, don't override it | - | ||||||||||||||||||||||||
721 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||
722 | q->unsetCursor(); | - | ||||||||||||||||||||||||
723 | #endif | - | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | ensureWindowData(); | - | ||||||||||||||||||||||||
726 | - | |||||||||||||||||||||||||
727 | bool needsUpdate = false; | - | ||||||||||||||||||||||||
728 | if (windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton
| 0 | ||||||||||||||||||||||||
729 | || windowData->buttonMouseOver)
| 0 | ||||||||||||||||||||||||
730 | needsUpdate = true; never executed: needsUpdate = true; | 0 | ||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | // update the hover state (of buttons etc...) | - | ||||||||||||||||||||||||
733 | windowData->hoveredSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
734 | windowData->buttonMouseOver = false; | - | ||||||||||||||||||||||||
735 | windowData->buttonRect = QRect(); | - | ||||||||||||||||||||||||
736 | if (needsUpdate)
| 0 | ||||||||||||||||||||||||
737 | q->update(windowData->buttonRect); never executed: q->update(windowData->buttonRect); | 0 | ||||||||||||||||||||||||
738 | } never executed: end of block | 0 | ||||||||||||||||||||||||
739 | } never executed: end of block | 0 | ||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||
741 | bool QGraphicsWidgetPrivate::hasDecoration() const | - | ||||||||||||||||||||||||
742 | { | - | ||||||||||||||||||||||||
743 | return (windowFlags & Qt::Window) && (windowFlags & Qt::WindowTitleHint); never executed: return (windowFlags & Qt::Window) && (windowFlags & Qt::WindowTitleHint);
| 0 | ||||||||||||||||||||||||
744 | } | - | ||||||||||||||||||||||||
745 | - | |||||||||||||||||||||||||
746 | /** | - | ||||||||||||||||||||||||
747 | * is called after a reparent has taken place to fix up the focus chain(s) | - | ||||||||||||||||||||||||
748 | */ | - | ||||||||||||||||||||||||
749 | void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene) | - | ||||||||||||||||||||||||
750 | { | - | ||||||||||||||||||||||||
751 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
752 | Q_ASSERT(focusNext && focusPrev); | - | ||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||
754 | if (q_ptr->isPanel()) {
| 0 | ||||||||||||||||||||||||
755 | // panels are never a part of their parent's or ancestors' focus | - | ||||||||||||||||||||||||
756 | // chains. so reparenting a panel is easy; there's nothing to | - | ||||||||||||||||||||||||
757 | // do. | - | ||||||||||||||||||||||||
758 | return; never executed: return; | 0 | ||||||||||||||||||||||||
759 | } | - | ||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | // we're not a panel, so find the first widget in the focus chain | - | ||||||||||||||||||||||||
762 | // (this), and the last (this, or the last widget that is still | - | ||||||||||||||||||||||||
763 | // a descendent of this). also find the widgets that currently / | - | ||||||||||||||||||||||||
764 | // before reparenting point to this widgets' focus chain. | - | ||||||||||||||||||||||||
765 | QGraphicsWidget *focusFirst = q; | - | ||||||||||||||||||||||||
766 | QGraphicsWidget *focusBefore = focusPrev; | - | ||||||||||||||||||||||||
767 | QGraphicsWidget *focusLast = focusFirst; | - | ||||||||||||||||||||||||
768 | QGraphicsWidget *focusAfter = focusNext; | - | ||||||||||||||||||||||||
769 | do { | - | ||||||||||||||||||||||||
770 | if (!q->isAncestorOf(focusAfter))
| 0 | ||||||||||||||||||||||||
771 | break; never executed: break; | 0 | ||||||||||||||||||||||||
772 | focusLast = focusAfter; | - | ||||||||||||||||||||||||
773 | } while ((focusAfter = focusAfter->d_func()->focusNext)); never executed: end of block
| 0 | ||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | if (!parent && oldScene && oldScene != newScene && oldScene->d_func()->tabFocusFirst == q) {
| 0 | ||||||||||||||||||||||||
776 | // detach from old scene's top level focus chain. | - | ||||||||||||||||||||||||
777 | oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : 0;
| 0 | ||||||||||||||||||||||||
778 | } never executed: end of block | 0 | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | // detach from current focus chain; skip this widget subtree. | - | ||||||||||||||||||||||||
781 | focusBefore->d_func()->focusNext = focusAfter; | - | ||||||||||||||||||||||||
782 | focusAfter->d_func()->focusPrev = focusBefore; | - | ||||||||||||||||||||||||
783 | - | |||||||||||||||||||||||||
784 | if (newParent) {
| 0 | ||||||||||||||||||||||||
785 | // attach to new parent's focus chain as the last element | - | ||||||||||||||||||||||||
786 | // in its chain. | - | ||||||||||||||||||||||||
787 | QGraphicsWidget *newFocusFirst = newParent; | - | ||||||||||||||||||||||||
788 | QGraphicsWidget *newFocusLast = newFocusFirst; | - | ||||||||||||||||||||||||
789 | QGraphicsWidget *newFocusAfter = newFocusFirst->d_func()->focusNext; | - | ||||||||||||||||||||||||
790 | do { | - | ||||||||||||||||||||||||
791 | if (!newParent->isAncestorOf(newFocusAfter))
| 0 | ||||||||||||||||||||||||
792 | break; never executed: break; | 0 | ||||||||||||||||||||||||
793 | newFocusLast = newFocusAfter; | - | ||||||||||||||||||||||||
794 | } while ((newFocusAfter = newFocusAfter->d_func()->focusNext)); never executed: end of block
| 0 | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | newFocusLast->d_func()->focusNext = q; | - | ||||||||||||||||||||||||
797 | focusLast->d_func()->focusNext = newFocusAfter; | - | ||||||||||||||||||||||||
798 | newFocusAfter->d_func()->focusPrev = focusLast; | - | ||||||||||||||||||||||||
799 | focusPrev = newFocusLast; | - | ||||||||||||||||||||||||
800 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
801 | // no new parent, so just link up our own prev->last widgets. | - | ||||||||||||||||||||||||
802 | focusPrev = focusLast; | - | ||||||||||||||||||||||||
803 | focusLast->d_func()->focusNext = q; | - | ||||||||||||||||||||||||
804 | } never executed: end of block | 0 | ||||||||||||||||||||||||
805 | } | - | ||||||||||||||||||||||||
806 | - | |||||||||||||||||||||||||
807 | void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l) | - | ||||||||||||||||||||||||
808 | { | - | ||||||||||||||||||||||||
809 | delete (this->layout); | - | ||||||||||||||||||||||||
810 | layout = l; | - | ||||||||||||||||||||||||
811 | if (!l) {
| 0 | ||||||||||||||||||||||||
812 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
813 | q->updateGeometry(); | - | ||||||||||||||||||||||||
814 | } never executed: end of block | 0 | ||||||||||||||||||||||||
815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
816 | - | |||||||||||||||||||||||||
817 | qreal QGraphicsWidgetPrivate::width() const | - | ||||||||||||||||||||||||
818 | { | - | ||||||||||||||||||||||||
819 | Q_Q(const QGraphicsWidget); | - | ||||||||||||||||||||||||
820 | return q->geometry().width(); never executed: return q->geometry().width(); | 0 | ||||||||||||||||||||||||
821 | } | - | ||||||||||||||||||||||||
822 | - | |||||||||||||||||||||||||
823 | void QGraphicsWidgetPrivate::setWidth(qreal w) | - | ||||||||||||||||||||||||
824 | { | - | ||||||||||||||||||||||||
825 | if (qIsNaN(w))
| 0 | ||||||||||||||||||||||||
826 | return; never executed: return; | 0 | ||||||||||||||||||||||||
827 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
828 | if (q->geometry().width() == w)
| 0 | ||||||||||||||||||||||||
829 | return; never executed: return; | 0 | ||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||
831 | q->setGeometry(QRectF(q->x(), q->y(), w, height())); | - | ||||||||||||||||||||||||
832 | } never executed: end of block | 0 | ||||||||||||||||||||||||
833 | - | |||||||||||||||||||||||||
834 | void QGraphicsWidgetPrivate::resetWidth() | - | ||||||||||||||||||||||||
835 | { | - | ||||||||||||||||||||||||
836 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
837 | q->setGeometry(QRectF(q->x(), q->y(), 0, height())); | - | ||||||||||||||||||||||||
838 | } never executed: end of block | 0 | ||||||||||||||||||||||||
839 | - | |||||||||||||||||||||||||
840 | qreal QGraphicsWidgetPrivate::height() const | - | ||||||||||||||||||||||||
841 | { | - | ||||||||||||||||||||||||
842 | Q_Q(const QGraphicsWidget); | - | ||||||||||||||||||||||||
843 | return q->geometry().height(); never executed: return q->geometry().height(); | 0 | ||||||||||||||||||||||||
844 | } | - | ||||||||||||||||||||||||
845 | - | |||||||||||||||||||||||||
846 | void QGraphicsWidgetPrivate::setHeight(qreal h) | - | ||||||||||||||||||||||||
847 | { | - | ||||||||||||||||||||||||
848 | if (qIsNaN(h))
| 0 | ||||||||||||||||||||||||
849 | return; never executed: return; | 0 | ||||||||||||||||||||||||
850 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
851 | if (q->geometry().height() == h)
| 0 | ||||||||||||||||||||||||
852 | return; never executed: return; | 0 | ||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||
854 | q->setGeometry(QRectF(q->x(), q->y(), width(), h)); | - | ||||||||||||||||||||||||
855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | void QGraphicsWidgetPrivate::resetHeight() | - | ||||||||||||||||||||||||
858 | { | - | ||||||||||||||||||||||||
859 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
860 | q->setGeometry(QRectF(q->x(), q->y(), width(), 0)); | - | ||||||||||||||||||||||||
861 | } never executed: end of block | 0 | ||||||||||||||||||||||||
862 | - | |||||||||||||||||||||||||
863 | void QGraphicsWidgetPrivate::setGeometryFromSetPos() | - | ||||||||||||||||||||||||
864 | { | - | ||||||||||||||||||||||||
865 | if (inSetGeometry)
| 0 | ||||||||||||||||||||||||
866 | return; never executed: return; | 0 | ||||||||||||||||||||||||
867 | Q_Q(QGraphicsWidget); | - | ||||||||||||||||||||||||
868 | inSetPos = 1; | - | ||||||||||||||||||||||||
869 | // Ensure setGeometry is called (avoid recursion when setPos is | - | ||||||||||||||||||||||||
870 | // called from within setGeometry). | - | ||||||||||||||||||||||||
871 | q->setGeometry(QRectF(pos, q->size())); | - | ||||||||||||||||||||||||
872 | inSetPos = 0 ; | - | ||||||||||||||||||||||||
873 | } never executed: end of block | 0 | ||||||||||||||||||||||||
874 | - | |||||||||||||||||||||||||
875 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
876 | - | |||||||||||||||||||||||||
877 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |