Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicswidget_p.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags) | - | ||||||||||||||||||||||||
11 | { | - | ||||||||||||||||||||||||
12 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | attributes = 0; | - | ||||||||||||||||||||||||
15 | isWidget = 1; | - | ||||||||||||||||||||||||
16 | focusNext = focusPrev = q; | - | ||||||||||||||||||||||||
17 | focusPolicy = Qt::NoFocus; | - | ||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||
19 | adjustWindowFlags(&wFlags); | - | ||||||||||||||||||||||||
20 | windowFlags = wFlags; | - | ||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||
22 | q->setParentItem(parentItem); | - | ||||||||||||||||||||||||
23 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType)); | - | ||||||||||||||||||||||||
24 | q->setGraphicsItem(q); | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | resolveLayoutDirection(); | - | ||||||||||||||||||||||||
27 | q->unsetWindowFrameMargins(); | - | ||||||||||||||||||||||||
28 | flags |= QGraphicsItem::ItemUsesExtendedStyleOption; | - | ||||||||||||||||||||||||
29 | flags |= QGraphicsItem::ItemSendsGeometryChanges; | - | ||||||||||||||||||||||||
30 | if (windowFlags & Qt::Window
| 0 | ||||||||||||||||||||||||
31 | flags |= QGraphicsItem::ItemIsPanel; never executed: flags |= QGraphicsItem::ItemIsPanel; | 0 | ||||||||||||||||||||||||
32 | } never executed: end of block | 0 | ||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const | - | ||||||||||||||||||||||||
35 | { | - | ||||||||||||||||||||||||
36 | const QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
37 | int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); | - | ||||||||||||||||||||||||
38 | return never executed: (qreal)height;return (qreal)height; never executed: return (qreal)height; | 0 | ||||||||||||||||||||||||
39 | } | - | ||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate() | - | ||||||||||||||||||||||||
45 | { | - | ||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||
47 | delete[] margins; | - | ||||||||||||||||||||||||
48 | delete[] windowFrameMargins; | - | ||||||||||||||||||||||||
49 | delete windowData; | - | ||||||||||||||||||||||||
50 | } never executed: end of block | 0 | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | void QGraphicsWidgetPrivate::ensureMargins() const | - | ||||||||||||||||||||||||
59 | { | - | ||||||||||||||||||||||||
60 | if (!margins
| 0 | ||||||||||||||||||||||||
61 | margins = new qreal[4]; | - | ||||||||||||||||||||||||
62 | for (int i = 0; i < 4
| 0 | ||||||||||||||||||||||||
63 | margins[i] = 0; never executed: margins[i] = 0; | 0 | ||||||||||||||||||||||||
64 | } never executed: end of block | 0 | ||||||||||||||||||||||||
65 | } never executed: end of block | 0 | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const | - | ||||||||||||||||||||||||
74 | { | - | ||||||||||||||||||||||||
75 | if (!windowFrameMargins
| 0 | ||||||||||||||||||||||||
76 | windowFrameMargins = new qreal[4]; | - | ||||||||||||||||||||||||
77 | for (int i = 0; i < 4
| 0 | ||||||||||||||||||||||||
78 | windowFrameMargins[i] = 0; never executed: windowFrameMargins[i] = 0; | 0 | ||||||||||||||||||||||||
79 | } never executed: end of block | 0 | ||||||||||||||||||||||||
80 | } never executed: end of block | 0 | ||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | - | |||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | void QGraphicsWidgetPrivate::ensureWindowData() | - | ||||||||||||||||||||||||
89 | { | - | ||||||||||||||||||||||||
90 | if (!windowData
| 0 | ||||||||||||||||||||||||
91 | windowData = new WindowData; never executed: windowData = new WindowData; | 0 | ||||||||||||||||||||||||
92 | } never executed: end of block | 0 | ||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||
94 | void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette) | - | ||||||||||||||||||||||||
95 | { | - | ||||||||||||||||||||||||
96 | if (this->palette == palette
| 0 | ||||||||||||||||||||||||
97 | return; never executed: return; | 0 | ||||||||||||||||||||||||
98 | updatePalette(palette); | - | ||||||||||||||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||
101 | void QGraphicsWidgetPrivate::resolvePalette(uint inheritedMask) | - | ||||||||||||||||||||||||
102 | { | - | ||||||||||||||||||||||||
103 | inheritedPaletteResolveMask = inheritedMask; | - | ||||||||||||||||||||||||
104 | QPalette naturalPalette = naturalWidgetPalette(); | - | ||||||||||||||||||||||||
105 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - | ||||||||||||||||||||||||
106 | updatePalette(resolvedPalette); | - | ||||||||||||||||||||||||
107 | } never executed: end of block | 0 | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette) | - | ||||||||||||||||||||||||
110 | { | - | ||||||||||||||||||||||||
111 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | this->palette = palette; | - | ||||||||||||||||||||||||
114 | - | |||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||
116 | if (q->isWindow()
| 0 | ||||||||||||||||||||||||
117 | inheritedPaletteResolveMask = 0; never executed: inheritedPaletteResolveMask = 0; | 0 | ||||||||||||||||||||||||
118 | int mask = palette.resolve() | inheritedPaletteResolveMask; | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | for (int i = 0; i < children.size()
| 0 | ||||||||||||||||||||||||
122 | QGraphicsItem *item = children.at(i); | - | ||||||||||||||||||||||||
123 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
124 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
125 | if (!w->isWindow()
| 0 | ||||||||||||||||||||||||
126 | w->d_func()->resolvePalette(mask); never executed: w->d_func()->resolvePalette(mask); | 0 | ||||||||||||||||||||||||
127 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
128 | item->d_ptr->resolvePalette(mask); | - | ||||||||||||||||||||||||
129 | } never executed: end of block | 0 | ||||||||||||||||||||||||
130 | } | - | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||
133 | QEvent event(QEvent::PaletteChange); | - | ||||||||||||||||||||||||
134 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
135 | } never executed: end of block | 0 | ||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||
137 | void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) | - | ||||||||||||||||||||||||
138 | { | - | ||||||||||||||||||||||||
139 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
140 | if ((
| 0 | ||||||||||||||||||||||||
141 | return; never executed: return; | 0 | ||||||||||||||||||||||||
142 | q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft)); | - | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | for (int i = 0; i < children.size()
| 0 | ||||||||||||||||||||||||
146 | QGraphicsItem *item = children.at(i); | - | ||||||||||||||||||||||||
147 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
148 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
149 | if (widget->parentWidget()
| 0 | ||||||||||||||||||||||||
150 | widget->d_func()->setLayoutDirection_helper(direction); never executed: widget->d_func()->setLayoutDirection_helper(direction); | 0 | ||||||||||||||||||||||||
151 | } never executed: end of block | 0 | ||||||||||||||||||||||||
152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | QEvent e(QEvent::LayoutDirectionChange); | - | ||||||||||||||||||||||||
156 | QApplication::sendEvent(q, &e); | - | ||||||||||||||||||||||||
157 | } never executed: end of block | 0 | ||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | void QGraphicsWidgetPrivate::resolveLayoutDirection() | - | ||||||||||||||||||||||||
160 | { | - | ||||||||||||||||||||||||
161 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
162 | if (q->testAttribute(Qt::WA_SetLayoutDirection)
| 0 | ||||||||||||||||||||||||
163 | return; never executed: return; | 0 | ||||||||||||||||||||||||
164 | } | - | ||||||||||||||||||||||||
165 | if (QGraphicsWidget *parentWidget = q->parentWidget()
| 0 | ||||||||||||||||||||||||
166 | setLayoutDirection_helper(parentWidget->layoutDirection()); | - | ||||||||||||||||||||||||
167 | } never executed: else if (sceneend of block
| 0 | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||
170 | setLayoutDirection_helper(QApplication::layoutDirection()); | - | ||||||||||||||||||||||||
171 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
172 | setLayoutDirection_helper(QApplication::layoutDirection()); | - | ||||||||||||||||||||||||
173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
174 | } | - | ||||||||||||||||||||||||
175 | - | |||||||||||||||||||||||||
176 | QPalette QGraphicsWidgetPrivate::naturalWidgetPalette() const | - | ||||||||||||||||||||||||
177 | { | - | ||||||||||||||||||||||||
178 | const QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
179 | QPalette palette; | - | ||||||||||||||||||||||||
180 | if (QGraphicsWidget *parent = q->parentWidget()
| 0 | ||||||||||||||||||||||||
181 | palette = parent->palette(); | - | ||||||||||||||||||||||||
182 | } never executed: else if (sceneend of block
| 0 | ||||||||||||||||||||||||
183 | palette = scene->palette(); | - | ||||||||||||||||||||||||
184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
185 | palette.resolve(0); | - | ||||||||||||||||||||||||
186 | return never executed: palette;return palette; never executed: return palette; | 0 | ||||||||||||||||||||||||
187 | } | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | void QGraphicsWidgetPrivate::setFont_helper(const QFont &font) | - | ||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||
191 | if (this->font == font
| 0 | ||||||||||||||||||||||||
192 | return; never executed: return; | 0 | ||||||||||||||||||||||||
193 | updateFont(font); | - | ||||||||||||||||||||||||
194 | } never executed: end of block | 0 | ||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | void QGraphicsWidgetPrivate::resolveFont(uint inheritedMask) | - | ||||||||||||||||||||||||
197 | { | - | ||||||||||||||||||||||||
198 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
199 | inheritedFontResolveMask = inheritedMask; | - | ||||||||||||||||||||||||
200 | if (QGraphicsWidget *p = q->parentWidget()
| 0 | ||||||||||||||||||||||||
201 | inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask; never executed: inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask; | 0 | ||||||||||||||||||||||||
202 | QFont naturalFont = naturalWidgetFont(); | - | ||||||||||||||||||||||||
203 | QFont resolvedFont = font.resolve(naturalFont); | - | ||||||||||||||||||||||||
204 | updateFont(resolvedFont); | - | ||||||||||||||||||||||||
205 | } never executed: end of block | 0 | ||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | void QGraphicsWidgetPrivate::updateFont(const QFont &font) | - | ||||||||||||||||||||||||
208 | { | - | ||||||||||||||||||||||||
209 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | this->font = font; | - | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | if (q->isWindow()
| 0 | ||||||||||||||||||||||||
215 | inheritedFontResolveMask = 0; never executed: inheritedFontResolveMask = 0; | 0 | ||||||||||||||||||||||||
216 | int mask = font.resolve() | inheritedFontResolveMask; | - | ||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | for (int i = 0; i < children.size()
| 0 | ||||||||||||||||||||||||
220 | QGraphicsItem *item = children.at(i); | - | ||||||||||||||||||||||||
221 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
222 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
223 | if (!w->isWindow()
| 0 | ||||||||||||||||||||||||
224 | w->d_func()->resolveFont(mask); never executed: w->d_func()->resolveFont(mask); | 0 | ||||||||||||||||||||||||
225 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
226 | item->d_ptr->resolveFont(mask); | - | ||||||||||||||||||||||||
227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
228 | } | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | if (!polished
| 0 | ||||||||||||||||||||||||
231 | return; never executed: return; | 0 | ||||||||||||||||||||||||
232 | - | |||||||||||||||||||||||||
233 | QEvent event(QEvent::FontChange); | - | ||||||||||||||||||||||||
234 | QApplication::sendEvent(q, &event); | - | ||||||||||||||||||||||||
235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | QFont QGraphicsWidgetPrivate::naturalWidgetFont() const | - | ||||||||||||||||||||||||
238 | { | - | ||||||||||||||||||||||||
239 | const QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
240 | QFont naturalFont; | - | ||||||||||||||||||||||||
241 | if (QGraphicsWidget *parent = q->parentWidget()
| 0 | ||||||||||||||||||||||||
242 | naturalFont = parent->font(); | - | ||||||||||||||||||||||||
243 | } never executed: else if (sceneend of block
| 0 | ||||||||||||||||||||||||
244 | naturalFont = scene->font(); | - | ||||||||||||||||||||||||
245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
246 | naturalFont.resolve(0); | - | ||||||||||||||||||||||||
247 | return never executed: naturalFont;return naturalFont; never executed: return naturalFont; | 0 | ||||||||||||||||||||||||
248 | } | - | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *option) | - | ||||||||||||||||||||||||
251 | { | - | ||||||||||||||||||||||||
252 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
253 | ensureWindowData(); | - | ||||||||||||||||||||||||
254 | q->initStyleOption(option); | - | ||||||||||||||||||||||||
255 | option->rect.setHeight(titleBarHeight(*option)); | - | ||||||||||||||||||||||||
256 | option->titleBarFlags = windowFlags; | - | ||||||||||||||||||||||||
257 | option->subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu; | - | ||||||||||||||||||||||||
258 | option->activeSubControls = windowData->hoveredSubControl; | - | ||||||||||||||||||||||||
259 | bool isActive = q->isActiveWindow(); | - | ||||||||||||||||||||||||
260 | if (isActive
| 0 | ||||||||||||||||||||||||
261 | option->state |= QStyle::State_Active; | - | ||||||||||||||||||||||||
262 | option->titleBarState = Qt::WindowActive; | - | ||||||||||||||||||||||||
263 | option->titleBarState |= QStyle::State_Active; | - | ||||||||||||||||||||||||
264 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
265 | option->state &= ~QStyle::State_Active; | - | ||||||||||||||||||||||||
266 | option->titleBarState = Qt::WindowNoState; | - | ||||||||||||||||||||||||
267 | } never executed: end of block | 0 | ||||||||||||||||||||||||
268 | QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar"); | - | ||||||||||||||||||||||||
269 | QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0); | - | ||||||||||||||||||||||||
270 | option->text = QFontMetrics(windowTitleFont).elidedText( | - | ||||||||||||||||||||||||
271 | windowData->windowTitle, Qt::ElideRight, textRect.width()); | - | ||||||||||||||||||||||||
272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | void QGraphicsWidgetPrivate::adjustWindowFlags(Qt::WindowFlags *flags) | - | ||||||||||||||||||||||||
275 | { | - | ||||||||||||||||||||||||
276 | bool customize = (*flags & (Qt::CustomizeWindowHint | - | ||||||||||||||||||||||||
277 | | Qt::FramelessWindowHint | - | ||||||||||||||||||||||||
278 | | Qt::WindowTitleHint | - | ||||||||||||||||||||||||
279 | | Qt::WindowSystemMenuHint | - | ||||||||||||||||||||||||
280 | | Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||||||||
281 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||||||||
282 | | Qt::WindowContextHelpButtonHint)); | - | ||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||
284 | uint type = (*flags & Qt::WindowType_Mask); | - | ||||||||||||||||||||||||
285 | if (customize
| 0 | ||||||||||||||||||||||||
286 | ; never executed: ; | 0 | ||||||||||||||||||||||||
287 | else if (type == Qt::Dialog
| 0 | ||||||||||||||||||||||||
288 | * never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint;*flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint; | 0 | ||||||||||||||||||||||||
289 | else if (type == Qt::Tool
| 0 | ||||||||||||||||||||||||
290 | * never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint;*flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; | 0 | ||||||||||||||||||||||||
291 | else if (type == Qt::Window
| 0 | ||||||||||||||||||||||||
292 | * never executed: flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint*flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; | 0 | ||||||||||||||||||||||||
293 | | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; never executed: *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint; | 0 | ||||||||||||||||||||||||
294 | } never executed: end of block | 0 | ||||||||||||||||||||||||
295 | - | |||||||||||||||||||||||||
296 | void QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
297 | { | - | ||||||||||||||||||||||||
298 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
299 | ensureWindowData(); | - | ||||||||||||||||||||||||
300 | if (windowData->grabbedSection != Qt::NoSection
| 0 | ||||||||||||||||||||||||
301 | if (windowData->grabbedSection == Qt::TitleBarArea
| 0 | ||||||||||||||||||||||||
302 | windowData->buttonSunken = false; | - | ||||||||||||||||||||||||
303 | QStyleOptionTitleBar bar; | - | ||||||||||||||||||||||||
304 | initStyleOptionTitleBar(&bar); | - | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | bar.rect = q->windowFrameRect().toRect(); | - | ||||||||||||||||||||||||
307 | bar.rect.moveTo(0,0); | - | ||||||||||||||||||||||||
308 | bar.rect.setHeight(q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar)); | - | ||||||||||||||||||||||||
309 | QPointF pos = event->pos(); | - | ||||||||||||||||||||||||
310 | if (windowFrameMargins
| 0 | ||||||||||||||||||||||||
311 | pos.rx() += windowFrameMargins[Left]; | - | ||||||||||||||||||||||||
312 | pos.ry() += windowFrameMargins[Top]; | - | ||||||||||||||||||||||||
313 | } never executed: end of block | 0 | ||||||||||||||||||||||||
314 | bar.subControls = QStyle::SC_TitleBarCloseButton; | - | ||||||||||||||||||||||||
315 | if (q->style()->subControlRect(QStyle::CC_TitleBar, &bar,
| 0 | ||||||||||||||||||||||||
316 | QStyle::SC_TitleBarCloseButton,
| 0 | ||||||||||||||||||||||||
317 | event->widget()).contains(pos.toPoint())
| 0 | ||||||||||||||||||||||||
318 | q->close(); | - | ||||||||||||||||||||||||
319 | } never executed: end of block | 0 | ||||||||||||||||||||||||
320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
321 | if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->buttons())
| 0 | ||||||||||||||||||||||||
322 | windowData->grabbedSection = Qt::NoSection; never executed: windowData->grabbedSection = Qt::NoSection; | 0 | ||||||||||||||||||||||||
323 | event->accept(); | - | ||||||||||||||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||||||||||||||
325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
328 | { | - | ||||||||||||||||||||||||
329 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
330 | if (event->button() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
331 | return; never executed: return; | 0 | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | ensureWindowData(); | - | ||||||||||||||||||||||||
334 | windowData->startGeometry = q->geometry(); | - | ||||||||||||||||||||||||
335 | windowData->grabbedSection = q->windowFrameSectionAt(event->pos()); | - | ||||||||||||||||||||||||
336 | ensureWindowData(); | - | ||||||||||||||||||||||||
337 | if (windowData->grabbedSection == Qt::TitleBarArea
| 0 | ||||||||||||||||||||||||
338 | && windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton
| 0 | ||||||||||||||||||||||||
339 | windowData->buttonSunken = true; | - | ||||||||||||||||||||||||
340 | q->update(); | - | ||||||||||||||||||||||||
341 | } never executed: end of block | 0 | ||||||||||||||||||||||||
342 | event->setAccepted(windowData->grabbedSection != Qt::NoSection); | - | ||||||||||||||||||||||||
343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
344 | static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh, | - | ||||||||||||||||||||||||
345 | const QGraphicsWidget *widget, | - | ||||||||||||||||||||||||
346 | bool heightForWidth = true) | - | ||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||
348 | qreal minimumHeightForWidth = -1; | - | ||||||||||||||||||||||||
349 | const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth(); | - | ||||||||||||||||||||||||
350 | if (hasHFW == heightForWidth
| 0 | ||||||||||||||||||||||||
351 | minimumHeightForWidth = hasHFW
| 0 | ||||||||||||||||||||||||
352 | ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height() | - | ||||||||||||||||||||||||
353 | : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); | - | ||||||||||||||||||||||||
354 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
355 | - | |||||||||||||||||||||||||
356 | const qreal constraint = width; | - | ||||||||||||||||||||||||
357 | while (maxh - minh > 0.1
| 0 | ||||||||||||||||||||||||
358 | qreal middle = minh + (maxh - minh)/2; | - | ||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||
362 | qreal hfw = hasHFW
| 0 | ||||||||||||||||||||||||
363 | ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height() | - | ||||||||||||||||||||||||
364 | : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width(); | - | ||||||||||||||||||||||||
365 | if (hfw > constraint
| 0 | ||||||||||||||||||||||||
366 | minh = middle; | - | ||||||||||||||||||||||||
367 | } never executed: else if (hfw <= constraintend of block
| 0 | ||||||||||||||||||||||||
368 | maxh = middle; | - | ||||||||||||||||||||||||
369 | } never executed: end of block | 0 | ||||||||||||||||||||||||
370 | } never executed: end of block | 0 | ||||||||||||||||||||||||
371 | minimumHeightForWidth = maxh; | - | ||||||||||||||||||||||||
372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
373 | return never executed: minimumHeightForWidth;return minimumHeightForWidth; never executed: return minimumHeightForWidth; | 0 | ||||||||||||||||||||||||
374 | } | - | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw, | - | ||||||||||||||||||||||||
377 | const QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
378 | { | - | ||||||||||||||||||||||||
379 | return never executed: minimumHeightForWidth(height, minw, maxw, widget, false);return minimumHeightForWidth(height, minw, maxw, widget, false); never executed: return minimumHeightForWidth(height, minw, maxw, widget, false); | 0 | ||||||||||||||||||||||||
380 | } | - | ||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | static QSizeF closestAcceptableSize(const QSizeF &proposed, | - | ||||||||||||||||||||||||
383 | const QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
384 | { | - | ||||||||||||||||||||||||
385 | const QSizeF current = widget->size(); | - | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | qreal minw = proposed.width(); | - | ||||||||||||||||||||||||
388 | qreal maxw = current.width(); | - | ||||||||||||||||||||||||
389 | qreal minh = proposed.height(); | - | ||||||||||||||||||||||||
390 | qreal maxh = current.height(); | - | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | qreal middlew = maxw; | - | ||||||||||||||||||||||||
393 | qreal middleh = maxh; | - | ||||||||||||||||||||||||
394 | qreal min_hfw; | - | ||||||||||||||||||||||||
395 | min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget); | - | ||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||
397 | do { | - | ||||||||||||||||||||||||
398 | if (maxw - minw < 0.1
| 0 | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | minw = maxw; | - | ||||||||||||||||||||||||
401 | minh = maxh; | - | ||||||||||||||||||||||||
402 | } never executed: end of block | 0 | ||||||||||||||||||||||||
403 | middlew = minw + (maxw - minw)/2.0; | - | ||||||||||||||||||||||||
404 | middleh = minh + (maxh - minh)/2.0; | - | ||||||||||||||||||||||||
405 | - | |||||||||||||||||||||||||
406 | min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget); | - | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | if (min_hfw > middleh
| 0 | ||||||||||||||||||||||||
409 | minw = middlew; | - | ||||||||||||||||||||||||
410 | minh = middleh; | - | ||||||||||||||||||||||||
411 | } never executed: else if (min_hfw <= middlehend of block
| 0 | ||||||||||||||||||||||||
412 | maxw = middlew; | - | ||||||||||||||||||||||||
413 | maxh = middleh; | - | ||||||||||||||||||||||||
414 | } never executed: end of block | 0 | ||||||||||||||||||||||||
415 | } never executed: while (maxw != minwend of block
| 0 | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget); | - | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | QSizeF result; | - | ||||||||||||||||||||||||
420 | if (min_hfw < maxh
| 0 | ||||||||||||||||||||||||
421 | result = QSizeF(middlew, min_hfw); | - | ||||||||||||||||||||||||
422 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh); | - | ||||||||||||||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||||||||||||||
426 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||
427 | } | - | ||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||
429 | static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry, | - | ||||||||||||||||||||||||
430 | QRectF *rect, Qt::WindowFrameSection section, | - | ||||||||||||||||||||||||
431 | const QSizeF &min, const QSizeF &max, | - | ||||||||||||||||||||||||
432 | const QGraphicsWidget *widget) | - | ||||||||||||||||||||||||
433 | { | - | ||||||||||||||||||||||||
434 | const QRectF proposedRect = *rect; | - | ||||||||||||||||||||||||
435 | qreal width = qBound(min.width(), proposedRect.width(), max.width()); | - | ||||||||||||||||||||||||
436 | qreal height = qBound(min.height(), proposedRect.height(), max.height()); | - | ||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth(); | - | ||||||||||||||||||||||||
439 | const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight(); | - | ||||||||||||||||||||||||
440 | - | |||||||||||||||||||||||||
441 | const bool widthChanged = proposedRect.width() != widget->size().width(); | - | ||||||||||||||||||||||||
442 | const bool heightChanged = proposedRect.height() != widget->size().height(); | - | ||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | if (hasHFW
| 0 | ||||||||||||||||||||||||
445 | if (widthChanged
| 0 | ||||||||||||||||||||||||
446 | qreal minExtent; | - | ||||||||||||||||||||||||
447 | qreal maxExtent; | - | ||||||||||||||||||||||||
448 | qreal constraint; | - | ||||||||||||||||||||||||
449 | qreal proposed; | - | ||||||||||||||||||||||||
450 | if (hasHFW
| 0 | ||||||||||||||||||||||||
451 | minExtent = min.height(); | - | ||||||||||||||||||||||||
452 | maxExtent = max.height(); | - | ||||||||||||||||||||||||
453 | constraint = width; | - | ||||||||||||||||||||||||
454 | proposed = proposedRect.height(); | - | ||||||||||||||||||||||||
455 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
456 | - | |||||||||||||||||||||||||
457 | minExtent = min.width(); | - | ||||||||||||||||||||||||
458 | maxExtent = max.width(); | - | ||||||||||||||||||||||||
459 | constraint = height; | - | ||||||||||||||||||||||||
460 | proposed = proposedRect.width(); | - | ||||||||||||||||||||||||
461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
462 | if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed
| 0 | ||||||||||||||||||||||||
463 | QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget); | - | ||||||||||||||||||||||||
464 | width = effectiveSize.width(); | - | ||||||||||||||||||||||||
465 | height = effectiveSize.height(); | - | ||||||||||||||||||||||||
466 | } never executed: end of block | 0 | ||||||||||||||||||||||||
467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
468 | } never executed: end of block | 0 | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | switch (section) { | - | ||||||||||||||||||||||||
471 | case never executed: Qt::LeftSection:case Qt::LeftSection: never executed: case Qt::LeftSection: | 0 | ||||||||||||||||||||||||
472 | rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(), | - | ||||||||||||||||||||||||
473 | qRound(width), startGeometry.height()); | - | ||||||||||||||||||||||||
474 | break; never executed: break; | 0 | ||||||||||||||||||||||||
475 | case never executed: Qt::TopLeftSection:case Qt::TopLeftSection: never executed: case Qt::TopLeftSection: | 0 | ||||||||||||||||||||||||
476 | rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height), | - | ||||||||||||||||||||||||
477 | qRound(width), qRound(height)); | - | ||||||||||||||||||||||||
478 | break; never executed: break; | 0 | ||||||||||||||||||||||||
479 | case never executed: Qt::TopSection:case Qt::TopSection: never executed: case Qt::TopSection: | 0 | ||||||||||||||||||||||||
480 | rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height), | - | ||||||||||||||||||||||||
481 | startGeometry.width(), qRound(height)); | - | ||||||||||||||||||||||||
482 | break; never executed: break; | 0 | ||||||||||||||||||||||||
483 | case never executed: Qt::TopRightSection:case Qt::TopRightSection: never executed: case Qt::TopRightSection: | 0 | ||||||||||||||||||||||||
484 | rect->setTop(rect->bottom() - qRound(height)); | - | ||||||||||||||||||||||||
485 | rect->setWidth(qRound(width)); | - | ||||||||||||||||||||||||
486 | break; never executed: break; | 0 | ||||||||||||||||||||||||
487 | case never executed: Qt::RightSection:case Qt::RightSection: never executed: case Qt::RightSection: | 0 | ||||||||||||||||||||||||
488 | rect->setWidth(qRound(width)); | - | ||||||||||||||||||||||||
489 | break; never executed: break; | 0 | ||||||||||||||||||||||||
490 | case never executed: Qt::BottomRightSection:case Qt::BottomRightSection: never executed: case Qt::BottomRightSection: | 0 | ||||||||||||||||||||||||
491 | rect->setWidth(qRound(width)); | - | ||||||||||||||||||||||||
492 | rect->setHeight(qRound(height)); | - | ||||||||||||||||||||||||
493 | break; never executed: break; | 0 | ||||||||||||||||||||||||
494 | case never executed: Qt::BottomSection:case Qt::BottomSection: never executed: case Qt::BottomSection: | 0 | ||||||||||||||||||||||||
495 | rect->setHeight(qRound(height)); | - | ||||||||||||||||||||||||
496 | break; never executed: break; | 0 | ||||||||||||||||||||||||
497 | case never executed: Qt::BottomLeftSection:case Qt::BottomLeftSection: never executed: case Qt::BottomLeftSection: | 0 | ||||||||||||||||||||||||
498 | rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(), | - | ||||||||||||||||||||||||
499 | qRound(width), qRound(height)); | - | ||||||||||||||||||||||||
500 | break; never executed: break; | 0 | ||||||||||||||||||||||||
501 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
502 | break; never executed: break; | 0 | ||||||||||||||||||||||||
503 | } | - | ||||||||||||||||||||||||
504 | } | - | ||||||||||||||||||||||||
505 | - | |||||||||||||||||||||||||
506 | void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event) | - | ||||||||||||||||||||||||
507 | { | - | ||||||||||||||||||||||||
508 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
509 | ensureWindowData(); | - | ||||||||||||||||||||||||
510 | if (!(event->buttons() & Qt::LeftButton)
| 0 | ||||||||||||||||||||||||
511 | return; never executed: return; | 0 | ||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||
513 | QLineF delta(q->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)), event->pos()); | - | ||||||||||||||||||||||||
514 | QLineF parentDelta(q->mapToParent(delta.p1()), q->mapToParent(delta.p2())); | - | ||||||||||||||||||||||||
515 | QLineF parentXDelta(q->mapToParent(QPointF(delta.p1().x(), 0)), q->mapToParent(QPointF(delta.p2().x(), 0))); | - | ||||||||||||||||||||||||
516 | QLineF parentYDelta(q->mapToParent(QPointF(0, delta.p1().y())), q->mapToParent(QPointF(0, delta.p2().y()))); | - | ||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
518 | QRectF newGeometry; | - | ||||||||||||||||||||||||
519 | switch (windowData->grabbedSection) { | - | ||||||||||||||||||||||||
520 | case never executed: Qt::LeftSection:case Qt::LeftSection: never executed: case Qt::LeftSection: | 0 | ||||||||||||||||||||||||
521 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
522 | + QPointF(parentXDelta.dx(), parentXDelta.dy()), | - | ||||||||||||||||||||||||
523 | windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
524 | break; never executed: break; | 0 | ||||||||||||||||||||||||
525 | case never executed: Qt::TopLeftSection:case Qt::TopLeftSection: never executed: case Qt::TopLeftSection: | 0 | ||||||||||||||||||||||||
526 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
527 | + QPointF(parentDelta.dx(), parentDelta.dy()), | - | ||||||||||||||||||||||||
528 | windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
529 | break; never executed: break; | 0 | ||||||||||||||||||||||||
530 | case never executed: Qt::TopSection:case Qt::TopSection: never executed: case Qt::TopSection: | 0 | ||||||||||||||||||||||||
531 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
532 | + QPointF(parentYDelta.dx(), parentYDelta.dy()), | - | ||||||||||||||||||||||||
533 | windowData->startGeometry.size() - QSizeF(0, delta.dy())); | - | ||||||||||||||||||||||||
534 | break; never executed: break; | 0 | ||||||||||||||||||||||||
535 | case never executed: Qt::TopRightSection:case Qt::TopRightSection: never executed: case Qt::TopRightSection: | 0 | ||||||||||||||||||||||||
536 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
537 | + QPointF(parentYDelta.dx(), parentYDelta.dy()), | - | ||||||||||||||||||||||||
538 | windowData->startGeometry.size() - QSizeF(-delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
539 | break; never executed: break; | 0 | ||||||||||||||||||||||||
540 | case never executed: Qt::RightSection:case Qt::RightSection: never executed: case Qt::RightSection: | 0 | ||||||||||||||||||||||||
541 | newGeometry = QRectF(windowData->startGeometry.topLeft(), | - | ||||||||||||||||||||||||
542 | windowData->startGeometry.size() + QSizeF(delta.dx(), 0)); | - | ||||||||||||||||||||||||
543 | break; never executed: break; | 0 | ||||||||||||||||||||||||
544 | case never executed: Qt::BottomRightSection:case Qt::BottomRightSection: never executed: case Qt::BottomRightSection: | 0 | ||||||||||||||||||||||||
545 | newGeometry = QRectF(windowData->startGeometry.topLeft(), | - | ||||||||||||||||||||||||
546 | windowData->startGeometry.size() + QSizeF(delta.dx(), delta.dy())); | - | ||||||||||||||||||||||||
547 | break; never executed: break; | 0 | ||||||||||||||||||||||||
548 | case never executed: Qt::BottomSection:case Qt::BottomSection: never executed: case Qt::BottomSection: | 0 | ||||||||||||||||||||||||
549 | newGeometry = QRectF(windowData->startGeometry.topLeft(), | - | ||||||||||||||||||||||||
550 | windowData->startGeometry.size() + QSizeF(0, delta.dy())); | - | ||||||||||||||||||||||||
551 | break; never executed: break; | 0 | ||||||||||||||||||||||||
552 | case never executed: Qt::BottomLeftSection:case Qt::BottomLeftSection: never executed: case Qt::BottomLeftSection: | 0 | ||||||||||||||||||||||||
553 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
554 | + QPointF(parentXDelta.dx(), parentXDelta.dy()), | - | ||||||||||||||||||||||||
555 | windowData->startGeometry.size() - QSizeF(delta.dx(), -delta.dy())); | - | ||||||||||||||||||||||||
556 | break; never executed: break; | 0 | ||||||||||||||||||||||||
557 | case never executed: Qt::TitleBarArea:case Qt::TitleBarArea: never executed: case Qt::TitleBarArea: | 0 | ||||||||||||||||||||||||
558 | newGeometry = QRectF(windowData->startGeometry.topLeft() | - | ||||||||||||||||||||||||
559 | + QPointF(parentDelta.dx(), parentDelta.dy()), | - | ||||||||||||||||||||||||
560 | windowData->startGeometry.size()); | - | ||||||||||||||||||||||||
561 | break; never executed: break; | 0 | ||||||||||||||||||||||||
562 | case never executed: Qt::NoSection:case Qt::NoSection: never executed: case Qt::NoSection: | 0 | ||||||||||||||||||||||||
563 | break; never executed: break; | 0 | ||||||||||||||||||||||||
564 | } | - | ||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | if (windowData->grabbedSection != Qt::NoSection
| 0 | ||||||||||||||||||||||||
567 | _q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry, | - | ||||||||||||||||||||||||
568 | windowData->grabbedSection, | - | ||||||||||||||||||||||||
569 | q->effectiveSizeHint(Qt::MinimumSize), | - | ||||||||||||||||||||||||
570 | q->effectiveSizeHint(Qt::MaximumSize), | - | ||||||||||||||||||||||||
571 | q); | - | ||||||||||||||||||||||||
572 | q->setGeometry(newGeometry); | - | ||||||||||||||||||||||||
573 | } never executed: end of block | 0 | ||||||||||||||||||||||||
574 | } never executed: end of block | 0 | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event) | - | ||||||||||||||||||||||||
577 | { | - | ||||||||||||||||||||||||
578 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
579 | if (!hasDecoration()
| 0 | ||||||||||||||||||||||||
580 | return; never executed: return; | 0 | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | ensureWindowData(); | - | ||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||
584 | if (q->rect().contains(event->pos())
| 0 | ||||||||||||||||||||||||
585 | if (windowData->buttonMouseOver
| 0 | ||||||||||||||||||||||||
586 | windowFrameHoverLeaveEvent(event); never executed: windowFrameHoverLeaveEvent(event); | 0 | ||||||||||||||||||||||||
587 | return; never executed: return; | 0 | ||||||||||||||||||||||||
588 | } | - | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | bool wasMouseOver = windowData->buttonMouseOver; | - | ||||||||||||||||||||||||
591 | QRect oldButtonRect = windowData->buttonRect; | - | ||||||||||||||||||||||||
592 | windowData->buttonRect = QRect(); | - | ||||||||||||||||||||||||
593 | windowData->buttonMouseOver = false; | - | ||||||||||||||||||||||||
594 | QPointF pos = event->pos(); | - | ||||||||||||||||||||||||
595 | QStyleOptionTitleBar bar; | - | ||||||||||||||||||||||||
596 | - | |||||||||||||||||||||||||
597 | if (windowFrameMargins
| 0 | ||||||||||||||||||||||||
598 | pos.rx() += windowFrameMargins[Left]; | - | ||||||||||||||||||||||||
599 | pos.ry() += windowFrameMargins[Top]; | - | ||||||||||||||||||||||||
600 | } never executed: end of block | 0 | ||||||||||||||||||||||||
601 | initStyleOptionTitleBar(&bar); | - | ||||||||||||||||||||||||
602 | bar.rect = q->windowFrameRect().toRect(); | - | ||||||||||||||||||||||||
603 | bar.rect.moveTo(0,0); | - | ||||||||||||||||||||||||
604 | bar.rect.setHeight(int(titleBarHeight(bar))); | - | ||||||||||||||||||||||||
605 | - | |||||||||||||||||||||||||
606 | Qt::CursorShape cursorShape = Qt::ArrowCursor; | - | ||||||||||||||||||||||||
607 | bool needsSetCursorCall = true; | - | ||||||||||||||||||||||||
608 | switch (q->windowFrameSectionAt(event->pos())) { | - | ||||||||||||||||||||||||
609 | case never executed: Qt::TopLeftSection:case Qt::TopLeftSection: never executed: case Qt::TopLeftSection: | 0 | ||||||||||||||||||||||||
610 | case never executed: Qt::BottomRightSection:case Qt::BottomRightSection: never executed: case Qt::BottomRightSection: | 0 | ||||||||||||||||||||||||
611 | cursorShape = Qt::SizeFDiagCursor; | - | ||||||||||||||||||||||||
612 | break; never executed: break; | 0 | ||||||||||||||||||||||||
613 | case never executed: Qt::TopRightSection:case Qt::TopRightSection: never executed: case Qt::TopRightSection: | 0 | ||||||||||||||||||||||||
614 | case never executed: Qt::BottomLeftSection:case Qt::BottomLeftSection: never executed: case Qt::BottomLeftSection: | 0 | ||||||||||||||||||||||||
615 | cursorShape = Qt::SizeBDiagCursor; | - | ||||||||||||||||||||||||
616 | break; never executed: break; | 0 | ||||||||||||||||||||||||
617 | case never executed: Qt::LeftSection:case Qt::LeftSection: never executed: case Qt::LeftSection: | 0 | ||||||||||||||||||||||||
618 | case never executed: Qt::RightSection:case Qt::RightSection: never executed: case Qt::RightSection: | 0 | ||||||||||||||||||||||||
619 | cursorShape = Qt::SizeHorCursor; | - | ||||||||||||||||||||||||
620 | break; never executed: break; | 0 | ||||||||||||||||||||||||
621 | case never executed: Qt::TopSection:case Qt::TopSection: never executed: case Qt::TopSection: | 0 | ||||||||||||||||||||||||
622 | case never executed: Qt::BottomSection:case Qt::BottomSection: never executed: case Qt::BottomSection: | 0 | ||||||||||||||||||||||||
623 | cursorShape = Qt::SizeVerCursor; | - | ||||||||||||||||||||||||
624 | break; never executed: break; | 0 | ||||||||||||||||||||||||
625 | case never executed: Qt::TitleBarArea:case Qt::TitleBarArea: never executed: case Qt::TitleBarArea: | 0 | ||||||||||||||||||||||||
626 | windowData->buttonRect = q->style()->subControlRect( | - | ||||||||||||||||||||||||
627 | QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0); | - | ||||||||||||||||||||||||
628 | - | |||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | - | |||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||
632 | - | |||||||||||||||||||||||||
633 | - | |||||||||||||||||||||||||
634 | - | |||||||||||||||||||||||||
635 | if (windowData->buttonRect.contains(pos.toPoint())
| 0 | ||||||||||||||||||||||||
636 | windowData->buttonMouseOver = true; never executed: windowData->buttonMouseOver = true; | 0 | ||||||||||||||||||||||||
637 | event->ignore(); | - | ||||||||||||||||||||||||
638 | break; never executed: break; | 0 | ||||||||||||||||||||||||
639 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
640 | needsSetCursorCall = false; | - | ||||||||||||||||||||||||
641 | event->ignore(); | - | ||||||||||||||||||||||||
642 | } never executed: end of block | 0 | ||||||||||||||||||||||||
643 | - | |||||||||||||||||||||||||
644 | if (needsSetCursorCall
| 0 | ||||||||||||||||||||||||
645 | q->setCursor(cursorShape); never executed: q->setCursor(cursorShape); | 0 | ||||||||||||||||||||||||
646 | - | |||||||||||||||||||||||||
647 | - | |||||||||||||||||||||||||
648 | windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0); | - | ||||||||||||||||||||||||
649 | if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton
| 0 | ||||||||||||||||||||||||
650 | windowData->hoveredSubControl = QStyle::SC_TitleBarLabel; never executed: windowData->hoveredSubControl = QStyle::SC_TitleBarLabel; | 0 | ||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||
652 | if (windowData->buttonMouseOver != wasMouseOver
| 0 | ||||||||||||||||||||||||
653 | if (!oldButtonRect.isNull()
| 0 | ||||||||||||||||||||||||
654 | q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft())); never executed: q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft())); | 0 | ||||||||||||||||||||||||
655 | if (!windowData->buttonRect.isNull()
| 0 | ||||||||||||||||||||||||
656 | q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft())); never executed: q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft())); | 0 | ||||||||||||||||||||||||
657 | } never executed: end of block | 0 | ||||||||||||||||||||||||
658 | } never executed: end of block | 0 | ||||||||||||||||||||||||
659 | - | |||||||||||||||||||||||||
660 | void QGraphicsWidgetPrivate::windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event) | - | ||||||||||||||||||||||||
661 | { | - | ||||||||||||||||||||||||
662 | (void)event;; | - | ||||||||||||||||||||||||
663 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
664 | if (hasDecoration()
| 0 | ||||||||||||||||||||||||
665 | - | |||||||||||||||||||||||||
666 | - | |||||||||||||||||||||||||
667 | q->unsetCursor(); | - | ||||||||||||||||||||||||
668 | - | |||||||||||||||||||||||||
669 | - | |||||||||||||||||||||||||
670 | ensureWindowData(); | - | ||||||||||||||||||||||||
671 | - | |||||||||||||||||||||||||
672 | bool needsUpdate = false; | - | ||||||||||||||||||||||||
673 | if (windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton
| 0 | ||||||||||||||||||||||||
674 | || windowData->buttonMouseOver
| 0 | ||||||||||||||||||||||||
675 | needsUpdate = true; never executed: needsUpdate = true; | 0 | ||||||||||||||||||||||||
676 | - | |||||||||||||||||||||||||
677 | - | |||||||||||||||||||||||||
678 | windowData->hoveredSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
679 | windowData->buttonMouseOver = false; | - | ||||||||||||||||||||||||
680 | windowData->buttonRect = QRect(); | - | ||||||||||||||||||||||||
681 | if (needsUpdate
| 0 | ||||||||||||||||||||||||
682 | q->update(windowData->buttonRect); never executed: q->update(windowData->buttonRect); | 0 | ||||||||||||||||||||||||
683 | } never executed: end of block | 0 | ||||||||||||||||||||||||
684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
685 | - | |||||||||||||||||||||||||
686 | bool QGraphicsWidgetPrivate::hasDecoration() const | - | ||||||||||||||||||||||||
687 | { | - | ||||||||||||||||||||||||
688 | return never executed: (return (windowFlags & Qt::Window) && (windowFlags & Qt::WindowTitleHint);
never executed: return (windowFlags & Qt::Window) && (windowFlags & Qt::WindowTitleHint); | 0 | ||||||||||||||||||||||||
689 | } | - | ||||||||||||||||||||||||
690 | - | |||||||||||||||||||||||||
691 | - | |||||||||||||||||||||||||
692 | - | |||||||||||||||||||||||||
693 | - | |||||||||||||||||||||||||
694 | void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene) | - | ||||||||||||||||||||||||
695 | { | - | ||||||||||||||||||||||||
696 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
697 | ((!(focusNext && focusPrev)) ? qt_assert("focusNext && focusPrev",__FILE__,752) : qt_noop()); | - | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | if (q_ptr->isPanel()
| 0 | ||||||||||||||||||||||||
700 | - | |||||||||||||||||||||||||
701 | - | |||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||
703 | return; never executed: return; | 0 | ||||||||||||||||||||||||
704 | } | - | ||||||||||||||||||||||||
705 | - | |||||||||||||||||||||||||
706 | - | |||||||||||||||||||||||||
707 | - | |||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||
709 | - | |||||||||||||||||||||||||
710 | QGraphicsWidget *focusFirst = q; | - | ||||||||||||||||||||||||
711 | QGraphicsWidget *focusBefore = focusPrev; | - | ||||||||||||||||||||||||
712 | QGraphicsWidget *focusLast = focusFirst; | - | ||||||||||||||||||||||||
713 | QGraphicsWidget *focusAfter = focusNext; | - | ||||||||||||||||||||||||
714 | do { | - | ||||||||||||||||||||||||
715 | if (!q->isAncestorOf(focusAfter)
| 0 | ||||||||||||||||||||||||
716 | break; never executed: break; | 0 | ||||||||||||||||||||||||
717 | focusLast = focusAfter; | - | ||||||||||||||||||||||||
718 | } never executed: while ((end of block
| 0 | ||||||||||||||||||||||||
719 | - | |||||||||||||||||||||||||
720 | if (!parent
| 0 | ||||||||||||||||||||||||
721 | - | |||||||||||||||||||||||||
722 | oldScene->d_func()->tabFocusFirst = (
| 0 | ||||||||||||||||||||||||
723 | } never executed: end of block | 0 | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||
726 | focusBefore->d_func()->focusNext = focusAfter; | - | ||||||||||||||||||||||||
727 | focusAfter->d_func()->focusPrev = focusBefore; | - | ||||||||||||||||||||||||
728 | - | |||||||||||||||||||||||||
729 | if (newParent
| 0 | ||||||||||||||||||||||||
730 | - | |||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | QGraphicsWidget *newFocusFirst = newParent; | - | ||||||||||||||||||||||||
733 | QGraphicsWidget *newFocusLast = newFocusFirst; | - | ||||||||||||||||||||||||
734 | QGraphicsWidget *newFocusAfter = newFocusFirst->d_func()->focusNext; | - | ||||||||||||||||||||||||
735 | do { | - | ||||||||||||||||||||||||
736 | if (!newParent->isAncestorOf(newFocusAfter)
| 0 | ||||||||||||||||||||||||
737 | break; never executed: break; | 0 | ||||||||||||||||||||||||
738 | newFocusLast = newFocusAfter; | - | ||||||||||||||||||||||||
739 | } never executed: while ((end of block
| 0 | ||||||||||||||||||||||||
740 | - | |||||||||||||||||||||||||
741 | newFocusLast->d_func()->focusNext = q; | - | ||||||||||||||||||||||||
742 | focusLast->d_func()->focusNext = newFocusAfter; | - | ||||||||||||||||||||||||
743 | newFocusAfter->d_func()->focusPrev = focusLast; | - | ||||||||||||||||||||||||
744 | focusPrev = newFocusLast; | - | ||||||||||||||||||||||||
745 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
746 | - | |||||||||||||||||||||||||
747 | focusPrev = focusLast; | - | ||||||||||||||||||||||||
748 | focusLast->d_func()->focusNext = q; | - | ||||||||||||||||||||||||
749 | } never executed: end of block | 0 | ||||||||||||||||||||||||
750 | } | - | ||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l) | - | ||||||||||||||||||||||||
753 | { | - | ||||||||||||||||||||||||
754 | delete (this->layout); | - | ||||||||||||||||||||||||
755 | layout = l; | - | ||||||||||||||||||||||||
756 | if (!l
| 0 | ||||||||||||||||||||||||
757 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
758 | q->updateGeometry(); | - | ||||||||||||||||||||||||
759 | } never executed: end of block | 0 | ||||||||||||||||||||||||
760 | } never executed: end of block | 0 | ||||||||||||||||||||||||
761 | - | |||||||||||||||||||||||||
762 | qreal QGraphicsWidgetPrivate::width() const | - | ||||||||||||||||||||||||
763 | { | - | ||||||||||||||||||||||||
764 | const QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
765 | return never executed: q->geometry().width();return q->geometry().width(); never executed: return q->geometry().width(); | 0 | ||||||||||||||||||||||||
766 | } | - | ||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||
768 | void QGraphicsWidgetPrivate::setWidth(qreal w) | - | ||||||||||||||||||||||||
769 | { | - | ||||||||||||||||||||||||
770 | if (qIsNaN(w)
| 0 | ||||||||||||||||||||||||
771 | return; never executed: return; | 0 | ||||||||||||||||||||||||
772 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
773 | if (q->geometry().width() == w
| 0 | ||||||||||||||||||||||||
774 | return; never executed: return; | 0 | ||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||
776 | q->setGeometry(QRectF(q->x(), q->y(), w, height())); | - | ||||||||||||||||||||||||
777 | } never executed: end of block | 0 | ||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||
779 | void QGraphicsWidgetPrivate::resetWidth() | - | ||||||||||||||||||||||||
780 | { | - | ||||||||||||||||||||||||
781 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
782 | q->setGeometry(QRectF(q->x(), q->y(), 0, height())); | - | ||||||||||||||||||||||||
783 | } never executed: end of block | 0 | ||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||
785 | qreal QGraphicsWidgetPrivate::height() const | - | ||||||||||||||||||||||||
786 | { | - | ||||||||||||||||||||||||
787 | const QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
788 | return never executed: q->geometry().height();return q->geometry().height(); never executed: return q->geometry().height(); | 0 | ||||||||||||||||||||||||
789 | } | - | ||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | void QGraphicsWidgetPrivate::setHeight(qreal h) | - | ||||||||||||||||||||||||
792 | { | - | ||||||||||||||||||||||||
793 | if (qIsNaN(h)
| 0 | ||||||||||||||||||||||||
794 | return; never executed: return; | 0 | ||||||||||||||||||||||||
795 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
796 | if (q->geometry().height() == h
| 0 | ||||||||||||||||||||||||
797 | return; never executed: return; | 0 | ||||||||||||||||||||||||
798 | - | |||||||||||||||||||||||||
799 | q->setGeometry(QRectF(q->x(), q->y(), width(), h)); | - | ||||||||||||||||||||||||
800 | } never executed: end of block | 0 | ||||||||||||||||||||||||
801 | - | |||||||||||||||||||||||||
802 | void QGraphicsWidgetPrivate::resetHeight() | - | ||||||||||||||||||||||||
803 | { | - | ||||||||||||||||||||||||
804 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
805 | q->setGeometry(QRectF(q->x(), q->y(), width(), 0)); | - | ||||||||||||||||||||||||
806 | } never executed: end of block | 0 | ||||||||||||||||||||||||
807 | - | |||||||||||||||||||||||||
808 | void QGraphicsWidgetPrivate::setGeometryFromSetPos() | - | ||||||||||||||||||||||||
809 | { | - | ||||||||||||||||||||||||
810 | if (inSetGeometry
| 0 | ||||||||||||||||||||||||
811 | return; never executed: return; | 0 | ||||||||||||||||||||||||
812 | QGraphicsWidget * const q = q_func(); | - | ||||||||||||||||||||||||
813 | inSetPos = 1; | - | ||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||
816 | q->setGeometry(QRectF(pos, q->size())); | - | ||||||||||||||||||||||||
817 | inSetPos = 0 ; | - | ||||||||||||||||||||||||
818 | } never executed: end of block | 0 | ||||||||||||||||||||||||
819 | - | |||||||||||||||||||||||||
820 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |