graphicsview/qgraphicsproxywidget.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qglobal.h" -
43 -
44#ifndef QT_NO_GRAPHICSVIEW -
45 -
46#include "qgraphicslayout.h" -
47#include "qgraphicsproxywidget.h" -
48#include "private/qgraphicsproxywidget_p.h" -
49#include "private/qwidget_p.h" -
50#include "private/qapplication_p.h" -
51 -
52#include <QtCore/qdebug.h> -
53#include <QtGui/qevent.h> -
54#include <QtWidgets/qgraphicsscene.h> -
55#include <QtWidgets/qgraphicssceneevent.h> -
56#include <QtWidgets/qlayout.h> -
57#include <QtGui/qpainter.h> -
58#include <QtWidgets/qstyleoption.h> -
59#include <QtWidgets/qgraphicsview.h> -
60#include <QtWidgets/qlistview.h> -
61#include <QtWidgets/qlineedit.h> -
62#include <QtWidgets/qtextedit.h> -
63 -
64QT_BEGIN_NAMESPACE -
65 -
66//#define GRAPHICSPROXYWIDGET_DEBUG -
67 -
68/*! -
69 \class QGraphicsProxyWidget -
70 \brief The QGraphicsProxyWidget class provides a proxy layer for embedding -
71 a QWidget in a QGraphicsScene. -
72 \since 4.4 -
73 \ingroup graphicsview-api -
74 \inmodule QtWidgets -
75 -
76 QGraphicsProxyWidget embeds QWidget-based widgets, for example, a -
77 QPushButton, QFontComboBox, or even QFileDialog, into -
78 QGraphicsScene. It forwards events between the two objects and -
79 translates between QWidget's integer-based geometry and -
80 QGraphicsWidget's qreal-based geometry. QGraphicsProxyWidget -
81 supports all core features of QWidget, including tab focus, -
82 keyboard input, Drag & Drop, and popups. You can also embed -
83 complex widgets, e.g., widgets with subwidgets. -
84 -
85 Example: -
86 -
87 \snippet code/src_gui_graphicsview_qgraphicsproxywidget.cpp 0 -
88 -
89 QGraphicsProxyWidget takes care of automatically embedding popup children -
90 of embedded widgets through creating a child proxy for each popup. This -
91 means that when an embedded QComboBox shows its popup list, a new -
92 QGraphicsProxyWidget is created automatically, embedding the popup, and -
93 positioning it correctly. This only works if the popup is child of the -
94 embedded widget (for example QToolButton::setMenu() requires the QMenu instance -
95 to be child of the QToolButton). -
96 -
97 \section1 Embedding a Widget with QGraphicsProxyWidget -
98 -
99 There are two ways to embed a widget using QGraphicsProxyWidget. The most -
100 common way is to pass a widget pointer to QGraphicsScene::addWidget() -
101 together with any relevant \l Qt::WindowFlags. This function returns a -
102 pointer to a QGraphicsProxyWidget. You can then choose to reparent or -
103 position either the proxy, or the embedded widget itself. -
104 -
105 For example, in the code snippet below, we embed a group box into the proxy: -
106 -
107 \snippet code/src_gui_graphicsview_qgraphicsproxywidget.cpp 1 -
108 -
109 The image below is the output obtained with its contents margin and -
110 contents rect labeled. -
111 -
112 \image qgraphicsproxywidget-embed.png -
113 -
114 Alternatively, you can start by creating a new QGraphicsProxyWidget item, -
115 and then call setWidget() to embed a QWidget later. The widget() function -
116 returns a pointer to the embedded widget. QGraphicsProxyWidget shares -
117 ownership with QWidget, so if either of the two widgets are destroyed, the -
118 other widget will be automatically destroyed as well. -
119 -
120 \section1 Synchronizing Widget States -
121 -
122 QGraphicsProxyWidget keeps its state in sync with the embedded widget. For -
123 example, if the proxy is hidden or disabled, the embedded widget will be -
124 hidden or disabled as well, and vice versa. When the widget is embedded by -
125 calling addWidget(), QGraphicsProxyWidget copies the state from the widget -
126 into the proxy, and after that, the two will stay synchronized where -
127 possible. By default, when you embed a widget into a proxy, both the widget -
128 and the proxy will be visible because a QGraphicsWidget is visible when -
129 created (you do not have to call show()). If you explicitly hide the -
130 embedded widget, the proxy will also become invisible. -
131 -
132 Example: -
133 -
134 \snippet code/src_gui_graphicsview_qgraphicsproxywidget.cpp 2 -
135 -
136 QGraphicsProxyWidget maintains symmetry for the following states: -
137 -
138 \table -
139 \header \li QWidget state \li QGraphicsProxyWidget state \li Notes -
140 \row \li QWidget::enabled -
141 \li QGraphicsProxyWidget::enabled -
142 \li -
143 \row \li QWidget::visible -
144 \li QGraphicsProxyWidget::visible -
145 \li The explicit state is also symmetric. -
146 \row \li QWidget::geometry -
147 \li QGraphicsProxyWidget::geometry -
148 \li Geometry is only guaranteed to be symmetric while -
149 the embedded widget is visible. -
150 \row \li QWidget::layoutDirection -
151 \li QGraphicsProxyWidget::layoutDirection -
152 \li -
153 \row \li QWidget::style -
154 \li QGraphicsProxyWidget::style -
155 \li -
156 \row \li QWidget::palette -
157 \li QGraphicsProxyWidget::palette -
158 \li -
159 \row \li QWidget::font -
160 \li QGraphicsProxyWidget::font -
161 \li -
162 \row \li QWidget::cursor -
163 \li QGraphicsProxyWidget::cursor -
164 \li The embedded widget overrides the proxy widget -
165 cursor. The proxy cursor changes depending on -
166 which embedded subwidget is currently under the -
167 mouse. -
168 \row \li QWidget::sizeHint() -
169 \li QGraphicsProxyWidget::sizeHint() -
170 \li All size hint functionality from the embedded -
171 widget is forwarded by the proxy. -
172 \row \li QWidget::getContentsMargins() -
173 \li QGraphicsProxyWidget::getContentsMargins() -
174 \li Updated once by setWidget(). -
175 \row \li QWidget::windowTitle -
176 \li QGraphicsProxyWidget::windowTitle -
177 \li Updated once by setWidget(). -
178 \endtable -
179 -
180 \note QGraphicsScene keeps the embedded widget in a special state that -
181 prevents it from disturbing other widgets (both embedded and not embedded) -
182 while the widget is embedded. In this state, the widget may differ slightly -
183 in behavior from when it is not embedded. -
184 -
185 \warning This class is provided for convenience when bridging -
186 QWidgets and QGraphicsItems, it should not be used for -
187 high-performance scenarios. -
188 -
189 \sa QGraphicsScene::addWidget(), QGraphicsWidget -
190*/ -
191 -
192extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); -
193Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets(); -
194 -
195/*! -
196 \internal -
197*/ -
198void QGraphicsProxyWidgetPrivate::init() -
199{ -
200 Q_Q(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
201 q->setFocusPolicy(Qt::WheelFocus);
executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::WheelFocus);
-
202 q->setAcceptDrops(true);
executed (the execution status of this line is deduced): q->setAcceptDrops(true);
-
203}
executed: }
Execution Count:8
8
204 -
205/*! -
206 \internal -
207*/ -
208void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneHoverEvent *event) -
209{ -
210 QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
never executed (the execution status of this line is deduced): QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
-
211 mouseEvent.setPos(event->pos());
never executed (the execution status of this line is deduced): mouseEvent.setPos(event->pos());
-
212 mouseEvent.setScreenPos(event->screenPos());
never executed (the execution status of this line is deduced): mouseEvent.setScreenPos(event->screenPos());
-
213 mouseEvent.setButton(Qt::NoButton);
never executed (the execution status of this line is deduced): mouseEvent.setButton(Qt::NoButton);
-
214 mouseEvent.setButtons(0);
never executed (the execution status of this line is deduced): mouseEvent.setButtons(0);
-
215 mouseEvent.setModifiers(event->modifiers());
never executed (the execution status of this line is deduced): mouseEvent.setModifiers(event->modifiers());
-
216 sendWidgetMouseEvent(&mouseEvent);
never executed (the execution status of this line is deduced): sendWidgetMouseEvent(&mouseEvent);
-
217 event->setAccepted(mouseEvent.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(mouseEvent.isAccepted());
-
218}
never executed: }
0
219 -
220/*! -
221 \internal -
222*/ -
223void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent *event) -
224{ -
225 if (!event || !widget || !widget->isVisible())
never evaluated: !event
never evaluated: !widget
never evaluated: !widget->isVisible()
0
226 return;
never executed: return;
0
227 Q_Q(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
228 -
229 // Find widget position and receiver. -
230 QPointF pos = event->pos();
never executed (the execution status of this line is deduced): QPointF pos = event->pos();
-
231 QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
never executed (the execution status of this line is deduced): QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
-
232 QPointer<QWidget> receiver = alienWidget ? alienWidget : widget;
never evaluated: alienWidget
0
233 -
234 if (QWidgetPrivate::nearestGraphicsProxyWidget(receiver) != q)
never evaluated: QWidgetPrivate::nearestGraphicsProxyWidget(receiver) != q
0
235 return; //another proxywidget will handle the events
never executed: return;
0
236 -
237 // Translate QGraphicsSceneMouse events to QMouseEvents. -
238 QEvent::Type type = QEvent::None;
never executed (the execution status of this line is deduced): QEvent::Type type = QEvent::None;
-
239 switch (event->type()) { -
240 case QEvent::GraphicsSceneMousePress: -
241 type = QEvent::MouseButtonPress;
never executed (the execution status of this line is deduced): type = QEvent::MouseButtonPress;
-
242 if (!embeddedMouseGrabber)
never evaluated: !embeddedMouseGrabber
0
243 embeddedMouseGrabber = receiver;
never executed: embeddedMouseGrabber = receiver;
0
244 else -
245 receiver = embeddedMouseGrabber;
never executed: receiver = embeddedMouseGrabber;
0
246 break;
never executed: break;
0
247 case QEvent::GraphicsSceneMouseRelease: -
248 type = QEvent::MouseButtonRelease;
never executed (the execution status of this line is deduced): type = QEvent::MouseButtonRelease;
-
249 if (embeddedMouseGrabber)
never evaluated: embeddedMouseGrabber
0
250 receiver = embeddedMouseGrabber;
never executed: receiver = embeddedMouseGrabber;
0
251 break;
never executed: break;
0
252 case QEvent::GraphicsSceneMouseDoubleClick: -
253 type = QEvent::MouseButtonDblClick;
never executed (the execution status of this line is deduced): type = QEvent::MouseButtonDblClick;
-
254 if (!embeddedMouseGrabber)
never evaluated: !embeddedMouseGrabber
0
255 embeddedMouseGrabber = receiver;
never executed: embeddedMouseGrabber = receiver;
0
256 else -
257 receiver = embeddedMouseGrabber;
never executed: receiver = embeddedMouseGrabber;
0
258 break;
never executed: break;
0
259 case QEvent::GraphicsSceneMouseMove: -
260 type = QEvent::MouseMove;
never executed (the execution status of this line is deduced): type = QEvent::MouseMove;
-
261 if (embeddedMouseGrabber)
never evaluated: embeddedMouseGrabber
0
262 receiver = embeddedMouseGrabber;
never executed: receiver = embeddedMouseGrabber;
0
263 break;
never executed: break;
0
264 default: -
265 Q_ASSERT_X(false, "QGraphicsProxyWidget", "internal error");
never executed (the execution status of this line is deduced): qt_noop();
-
266 break;
never executed: break;
0
267 } -
268 -
269 if (!lastWidgetUnderMouse) {
never evaluated: !lastWidgetUnderMouse
0
270 QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
never executed (the execution status of this line is deduced): QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
-
271 lastWidgetUnderMouse = receiver;
never executed (the execution status of this line is deduced): lastWidgetUnderMouse = receiver;
-
272 }
never executed: }
0
273 -
274 // Map event position from us to the receiver -
275 pos = mapToReceiver(pos, receiver);
never executed (the execution status of this line is deduced): pos = mapToReceiver(pos, receiver);
-
276 -
277 // Send mouse event. -
278 QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
never executed (the execution status of this line is deduced): QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
-
279 receiver->mapToGlobal(pos.toPoint()),
never executed (the execution status of this line is deduced): receiver->mapToGlobal(pos.toPoint()),
-
280 event->button(), event->buttons(), event->modifiers());
never executed (the execution status of this line is deduced): event->button(), event->buttons(), event->modifiers());
-
281 -
282 QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
never executed (the execution status of this line is deduced): QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
-
283 QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
never executed (the execution status of this line is deduced): QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
-
284 &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
never executed (the execution status of this line is deduced): &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
-
285 embeddedMouseGrabber = embeddedMouseGrabberPtr;
never executed (the execution status of this line is deduced): embeddedMouseGrabber = embeddedMouseGrabberPtr;
-
286 -
287 // Handle enter/leave events when last button is released from mouse -
288 // grabber child widget. -
289 if (embeddedMouseGrabber && type == QEvent::MouseButtonRelease && !event->buttons()) {
never evaluated: embeddedMouseGrabber
never evaluated: type == QEvent::MouseButtonRelease
never evaluated: !event->buttons()
0
290 Q_Q(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
291 if (q->rect().contains(event->pos()) && q->acceptHoverEvents())
never evaluated: q->rect().contains(event->pos())
never evaluated: q->acceptHoverEvents()
0
292 lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
never executed: lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
never evaluated: alienWidget
0
293 else // released on the frame our outside the item, or doesn't accept hover events. -
294 lastWidgetUnderMouse = 0;
never executed: lastWidgetUnderMouse = 0;
0
295 -
296 QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
never executed (the execution status of this line is deduced): QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
-
297 embeddedMouseGrabber = 0;
never executed (the execution status of this line is deduced): embeddedMouseGrabber = 0;
-
298 -
299#ifndef QT_NO_CURSOR -
300 // ### Restore the cursor, don't override it. -
301 if (!lastWidgetUnderMouse)
never evaluated: !lastWidgetUnderMouse
0
302 q->unsetCursor();
never executed: q->unsetCursor();
0
303#endif -
304 }
never executed: }
0
305 -
306 event->setAccepted(mouseEvent.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(mouseEvent.isAccepted());
-
307}
never executed: }
0
308 -
309void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event) -
310{ -
311 Q_Q(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
312 if (!event || !widget || !widget->isVisible())
never evaluated: !event
never evaluated: !widget
never evaluated: !widget->isVisible()
0
313 return;
never executed: return;
0
314 -
315 QPointer<QWidget> receiver = widget->focusWidget();
never executed (the execution status of this line is deduced): QPointer<QWidget> receiver = widget->focusWidget();
-
316 if (!receiver)
never evaluated: !receiver
0
317 receiver = widget;
never executed: receiver = widget;
0
318 Q_ASSERT(receiver);
never executed (the execution status of this line is deduced): qt_noop();
-
319 -
320 do { -
321 bool res = QApplication::sendEvent(receiver, event);
never executed (the execution status of this line is deduced): bool res = QApplication::sendEvent(receiver, event);
-
322 if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget))
never evaluated: res
never evaluated: event->isAccepted()
never evaluated: q->isWindow()
never evaluated: receiver == widget
0
323 break;
never executed: break;
0
324 receiver = receiver->parentWidget();
never executed (the execution status of this line is deduced): receiver = receiver->parentWidget();
-
325 } while (receiver);
never executed: }
never evaluated: receiver
0
326}
never executed: }
0
327 -
328/*! -
329 \internal -
330*/ -
331void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::FocusReason reason) -
332{ -
333 QFocusEvent event(QEvent::FocusOut, reason);
never executed (the execution status of this line is deduced): QFocusEvent event(QEvent::FocusOut, reason);
-
334 QPointer<QWidget> widgetGuard = widget;
never executed (the execution status of this line is deduced): QPointer<QWidget> widgetGuard = widget;
-
335 QApplication::sendEvent(widget, &event);
never executed (the execution status of this line is deduced): QApplication::sendEvent(widget, &event);
-
336 if (widgetGuard && event.isAccepted())
never evaluated: widgetGuard
never evaluated: event.isAccepted()
0
337 QApplication::sendEvent(widget->style(), &event);
never executed: QApplication::sendEvent(widget->style(), &event);
0
338}
never executed: }
0
339 -
340/*! -
341 \internal -
342 Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper -
343*/ -
344QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const -
345{ -
346 if (!widget)
never evaluated: !widget
0
347 return 0;
never executed: return 0;
0
348 -
349 // Run around the focus chain until we find a widget that can take tab focus. -
350 if (!child) {
never evaluated: !child
0
351 child = next ? (QWidget *)widget : widget->d_func()->focus_prev;
never evaluated: next
0
352 } else {
never executed: }
0
353 child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
never evaluated: next
0
354 if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
never evaluated: next
never evaluated: child == widget
never evaluated: !next
never evaluated: child == widget->d_func()->focus_prev
0
355 return 0;
never executed: return 0;
0
356 } -
357 }
never executed: }
0
358 -
359 QWidget *oldChild = child;
never executed (the execution status of this line is deduced): QWidget *oldChild = child;
-
360 uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
never evaluated: qt_tab_all_widgets()
0
361 do { -
362 if (child->isEnabled()
never evaluated: child->isEnabled()
0
363 && child->isVisibleTo(widget)
never evaluated: child->isVisibleTo(widget)
0
364 && ((child->focusPolicy() & focus_flag) == focus_flag)
never evaluated: ((child->focusPolicy() & focus_flag) == focus_flag)
0
365 && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
never evaluated: child->d_func()->extra
never evaluated: child->d_func()->extra->focus_proxy
0
366 return child;
never executed: return child;
0
367 } -
368 child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
never evaluated: next
0
369 } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
never executed: }
never evaluated: child != oldChild
never evaluated: next
never evaluated: child == widget
never evaluated: !next
never evaluated: child == widget->d_func()->focus_prev
0
370 return 0;
never executed: return 0;
0
371} -
372 -
373/*! -
374 \internal -
375*/ -
376void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot() -
377{ -
378 Q_Q(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
379 widget = 0;
never executed (the execution status of this line is deduced): widget = 0;
-
380 delete q;
never executed (the execution status of this line is deduced): delete q;
-
381}
never executed: }
0
382 -
383/*! -
384 \internal -
385*/ -
386void QGraphicsProxyWidgetPrivate::updateWidgetGeometryFromProxy() -
387{ -
388} -
389 -
390/*! -
391 \internal -
392*/ -
393void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget() -
394{ -
395 Q_Q(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
396 if (!widget)
partially evaluated: !widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
397 return;
never executed: return;
0
398 -
399 QRectF widgetGeometry = widget->geometry();
executed (the execution status of this line is deduced): QRectF widgetGeometry = widget->geometry();
-
400 QWidget *parentWidget = widget->parentWidget();
executed (the execution status of this line is deduced): QWidget *parentWidget = widget->parentWidget();
-
401 if (widget->isWindow()) {
partially evaluated: widget->isWindow()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
402 QGraphicsProxyWidget *proxyParent = 0;
executed (the execution status of this line is deduced): QGraphicsProxyWidget *proxyParent = 0;
-
403 if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
partially evaluated: parentWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
never evaluated: (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))
0-8
404 // Nested window proxy (e.g., combobox popup), map widget to the -
405 // parent widget's global coordinates, and map that to the parent -
406 // proxy's child coordinates. -
407 widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
never executed (the execution status of this line is deduced): widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
-
408 + parentWidget->mapFromGlobal(widget->pos()));
never executed (the execution status of this line is deduced): + parentWidget->mapFromGlobal(widget->pos()));
-
409 }
never executed: }
0
410 }
executed: }
Execution Count:8
8
411 -
412 // Adjust to size hint if the widget has never been resized. -
413 if (!widget->size().isValid())
partially evaluated: !widget->size().isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
414 widgetGeometry.setSize(widget->sizeHint());
never executed: widgetGeometry.setSize(widget->sizeHint());
0
415 -
416 // Assign new geometry. -
417 posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
418 sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
419 q->setGeometry(widgetGeometry);
executed (the execution status of this line is deduced): q->setGeometry(widgetGeometry);
-
420 posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
421 sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
422}
executed: }
Execution Count:8
8
423 -
424/*! -
425 \internal -
426*/ -
427void QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget() -
428{ -
429 Q_Q(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
430 if (!widget)
partially evaluated: !widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
431 return;
never executed: return;
0
432 -
433 QWidget *focusWidget = widget->focusWidget();
executed (the execution status of this line is deduced): QWidget *focusWidget = widget->focusWidget();
-
434 if (!focusWidget)
partially evaluated: !focusWidget
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
435 focusWidget = widget;
executed: focusWidget = widget;
Execution Count:8
8
436 q->setFlag(QGraphicsItem::ItemAcceptsInputMethod,
executed (the execution status of this line is deduced): q->setFlag(QGraphicsItem::ItemAcceptsInputMethod,
-
437 focusWidget->testAttribute(Qt::WA_InputMethodEnabled));
executed (the execution status of this line is deduced): focusWidget->testAttribute(Qt::WA_InputMethodEnabled));
-
438}
executed: }
Execution Count:8
8
439 -
440/*! -
441 \internal -
442 -
443 Embeds \a subWin as a subwindow of this proxy widget. \a subWin must be a top-level -
444 widget and a descendant of the widget managed by this proxy. A separate subproxy -
445 will be created as a child of this proxy widget to manage \a subWin. -
446*/ -
447void QGraphicsProxyWidgetPrivate::embedSubWindow(QWidget *subWin) -
448{ -
449 QWExtra *extra;
never executed (the execution status of this line is deduced): QWExtra *extra;
-
450 if (!((extra = subWin->d_func()->extra) && extra->proxyWidget)) {
never evaluated: (extra = subWin->d_func()->extra)
never evaluated: extra->proxyWidget
0
451 QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
never executed (the execution status of this line is deduced): QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
-
452 subProxy->d_func()->setWidget_helper(subWin, false);
never executed (the execution status of this line is deduced): subProxy->d_func()->setWidget_helper(subWin, false);
-
453 }
never executed: }
0
454}
never executed: }
0
455 -
456/*! -
457 \internal -
458 -
459 Removes ("unembeds") \a subWin and deletes the proxy holder item. This can -
460 happen when QWidget::setParent() reparents the embedded window out of -
461 "embedded space". -
462*/ -
463void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin) -
464{ -
465 foreach (QGraphicsItem *child, children) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
466 if (child->isWidget()) {
never evaluated: child->isWidget()
0
467 if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
never evaluated: QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))
0
468 if (proxy->widget() == subWin) {
never evaluated: proxy->widget() == subWin
0
469 proxy->setWidget(0);
never executed (the execution status of this line is deduced): proxy->setWidget(0);
-
470 scene->removeItem(proxy);
never executed (the execution status of this line is deduced): scene->removeItem(proxy);
-
471 delete proxy;
never executed (the execution status of this line is deduced): delete proxy;
-
472 return;
never executed: return;
0
473 } -
474 }
never executed: }
0
475 }
never executed: }
0
476 }
never executed: }
0
477}
never executed: }
0
478 -
479bool QGraphicsProxyWidgetPrivate::isProxyWidget() const -
480{ -
481 return true;
never executed: return true;
0
482} -
483 -
484/*! -
485 \internal -
486*/ -
487QPointF QGraphicsProxyWidgetPrivate::mapToReceiver(const QPointF &pos, const QWidget *receiver) const -
488{ -
489 QPointF p = pos;
never executed (the execution status of this line is deduced): QPointF p = pos;
-
490 // Map event position from us to the receiver, preserving its -
491 // precision (don't use QWidget::mapFrom here). -
492 while (receiver && receiver != widget) {
never evaluated: receiver
never evaluated: receiver != widget
0
493 p -= QPointF(receiver->pos());
never executed (the execution status of this line is deduced): p -= QPointF(receiver->pos());
-
494 receiver = receiver->parentWidget();
never executed (the execution status of this line is deduced): receiver = receiver->parentWidget();
-
495 }
never executed: }
0
496 return p;
never executed: return p;
0
497} -
498 -
499/*! -
500 Constructs a new QGraphicsProxy widget. \a parent and \a wFlags are passed -
501 to QGraphicsItem's constructor. -
502*/ -
503QGraphicsProxyWidget::QGraphicsProxyWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) -
504 : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, wFlags) -
505{ -
506 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
507 d->init();
executed (the execution status of this line is deduced): d->init();
-
508}
executed: }
Execution Count:8
8
509 -
510/*! -
511 Destroys the proxy widget and any embedded widget. -
512*/ -
513QGraphicsProxyWidget::~QGraphicsProxyWidget() -
514{ -
515 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
516 if (d->widget) {
partially evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
517 QObject::disconnect(d->widget, SIGNAL(destroyed()), this, SLOT(_q_removeWidgetSlot()));
executed (the execution status of this line is deduced): QObject::disconnect(d->widget, "2""destroyed()", this, "1""_q_removeWidgetSlot()");
-
518 delete d->widget;
executed (the execution status of this line is deduced): delete d->widget;
-
519 }
executed: }
Execution Count:4
4
520}
executed: }
Execution Count:4
4
521 -
522/*! -
523 Embeds \a widget into this proxy widget. The embedded widget must reside -
524 exclusively either inside or outside of Graphics View. You cannot embed a -
525 widget as long as it is is visible elsewhere in the UI, at the same time. -
526 -
527 \a widget must be a top-level widget whose parent is 0. -
528 -
529 When the widget is embedded, its state (e.g., visible, enabled, geometry, -
530 size hints) is copied into the proxy widget. If the embedded widget is -
531 explicitly hidden or disabled, the proxy widget will become explicitly -
532 hidden or disabled after embedding is complete. The class documentation -
533 has a full overview over the shared state. -
534 -
535 QGraphicsProxyWidget's window flags determine whether the widget, after -
536 embedding, will be given window decorations or not. -
537 -
538 After this function returns, QGraphicsProxyWidget will keep its state -
539 synchronized with that of \a widget whenever possible. -
540 -
541 If a widget is already embedded by this proxy when this function is -
542 called, that widget will first be automatically unembedded. Passing 0 for -
543 the \a widget argument will only unembed the widget, and the ownership of -
544 the currently embedded widget will be passed on to the caller. -
545 Every child widget that are embedded will also be embedded and their proxy -
546 widget destroyed. -
547 -
548 Note that widgets with the Qt::WA_PaintOnScreen widget attribute -
549 set and widgets that wrap an external application or controller -
550 cannot be embedded. Examples are QGLWidget and QAxWidget. -
551 -
552 \sa widget() -
553*/ -
554void QGraphicsProxyWidget::setWidget(QWidget *widget) -
555{ -
556 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
557 d->setWidget_helper(widget, true);
executed (the execution status of this line is deduced): d->setWidget_helper(widget, true);
-
558}
executed: }
Execution Count:8
8
559 -
560void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool autoShow) -
561{ -
562 Q_Q(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidget * const q = q_func();
-
563 if (newWidget == widget)
partially evaluated: newWidget == widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
564 return;
never executed: return;
0
565 if (widget) {
partially evaluated: widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
566 QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
never executed (the execution status of this line is deduced): QObject::disconnect(widget, "2""destroyed()", q, "1""_q_removeWidgetSlot()");
-
567 widget->removeEventFilter(q);
never executed (the execution status of this line is deduced): widget->removeEventFilter(q);
-
568 widget->setAttribute(Qt::WA_DontShowOnScreen, false);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_DontShowOnScreen, false);
-
569 widget->d_func()->extra->proxyWidget = 0;
never executed (the execution status of this line is deduced): widget->d_func()->extra->proxyWidget = 0;
-
570 resolveFont(inheritedFontResolveMask);
never executed (the execution status of this line is deduced): resolveFont(inheritedFontResolveMask);
-
571 resolvePalette(inheritedPaletteResolveMask);
never executed (the execution status of this line is deduced): resolvePalette(inheritedPaletteResolveMask);
-
572 widget->update();
never executed (the execution status of this line is deduced): widget->update();
-
573 -
574 foreach (QGraphicsItem *child, q->childItems()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(q->childItems())> _container_(q->childItems()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
575 if (child->d_ptr->isProxyWidget()) {
never evaluated: child->d_ptr->isProxyWidget()
0
576 QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child);
never executed (the execution status of this line is deduced): QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child);
-
577 QWidget * parent = childProxy->widget();
never executed (the execution status of this line is deduced): QWidget * parent = childProxy->widget();
-
578 while (parent->parentWidget() != 0) {
never evaluated: parent->parentWidget() != 0
0
579 if (parent == widget)
never evaluated: parent == widget
0
580 break;
never executed: break;
0
581 parent = parent->parentWidget();
never executed (the execution status of this line is deduced): parent = parent->parentWidget();
-
582 }
never executed: }
0
583 if (!childProxy->widget() || parent != widget)
never evaluated: !childProxy->widget()
never evaluated: parent != widget
0
584 continue;
never executed: continue;
0
585 childProxy->setWidget(0);
never executed (the execution status of this line is deduced): childProxy->setWidget(0);
-
586 delete childProxy;
never executed (the execution status of this line is deduced): delete childProxy;
-
587 }
never executed: }
0
588 }
never executed: }
0
589 -
590 widget = 0;
never executed (the execution status of this line is deduced): widget = 0;
-
591#ifndef QT_NO_CURSOR -
592 q->unsetCursor();
never executed (the execution status of this line is deduced): q->unsetCursor();
-
593#endif -
594 q->setAcceptHoverEvents(false);
never executed (the execution status of this line is deduced): q->setAcceptHoverEvents(false);
-
595 if (!newWidget)
never evaluated: !newWidget
0
596 q->update();
never executed: q->update();
0
597 }
never executed: }
0
598 if (!newWidget)
partially evaluated: !newWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
599 return;
never executed: return;
0
600 if (!newWidget->isWindow()) {
partially evaluated: !newWidget->isWindow()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
601 QWExtra *extra = newWidget->parentWidget()->d_func()->extra;
never executed (the execution status of this line is deduced): QWExtra *extra = newWidget->parentWidget()->d_func()->extra;
-
602 if (!extra || !extra->proxyWidget) {
never evaluated: !extra
never evaluated: !extra->proxyWidget
0
603 qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p "
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsproxywidget.cpp", 603, __PRETTY_FUNCTION__).warning("QGraphicsProxyWidget::setWidget: cannot embed widget %p "
-
604 "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
never executed (the execution status of this line is deduced): "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
-
605 return;
never executed: return;
0
606 } -
607 }
never executed: }
0
608 -
609 // Register this proxy within the widget's private. -
610 // ### This is a bit backdoorish -
611 QWExtra *extra = newWidget->d_func()->extra;
executed (the execution status of this line is deduced): QWExtra *extra = newWidget->d_func()->extra;
-
612 if (!extra) {
evaluated: !extra
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
1-7
613 newWidget->d_func()->createExtra();
executed (the execution status of this line is deduced): newWidget->d_func()->createExtra();
-
614 extra = newWidget->d_func()->extra;
executed (the execution status of this line is deduced): extra = newWidget->d_func()->extra;
-
615 }
executed: }
Execution Count:7
7
616 QGraphicsProxyWidget **proxyWidget = &extra->proxyWidget;
executed (the execution status of this line is deduced): QGraphicsProxyWidget **proxyWidget = &extra->proxyWidget;
-
617 if (*proxyWidget) {
partially evaluated: *proxyWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
618 if (*proxyWidget != q) {
never evaluated: *proxyWidget != q
0
619 qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p"
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsproxywidget.cpp", 619, __PRETTY_FUNCTION__).warning("QGraphicsProxyWidget::setWidget: cannot embed widget %p"
-
620 "; already embedded", newWidget);
never executed (the execution status of this line is deduced): "; already embedded", newWidget);
-
621 }
never executed: }
0
622 return;
never executed: return;
0
623 } -
624 *proxyWidget = q;
executed (the execution status of this line is deduced): *proxyWidget = q;
-
625 -
626 newWidget->setAttribute(Qt::WA_DontShowOnScreen);
executed (the execution status of this line is deduced): newWidget->setAttribute(Qt::WA_DontShowOnScreen);
-
627 newWidget->ensurePolished();
executed (the execution status of this line is deduced): newWidget->ensurePolished();
-
628 // Do not wait for this widget to close before the app closes ### -
629 // shouldn't this widget inherit the attribute? -
630 newWidget->setAttribute(Qt::WA_QuitOnClose, false);
executed (the execution status of this line is deduced): newWidget->setAttribute(Qt::WA_QuitOnClose, false);
-
631 q->setAcceptHoverEvents(true);
executed (the execution status of this line is deduced): q->setAcceptHoverEvents(true);
-
632 -
633 if (newWidget->testAttribute(Qt::WA_NoSystemBackground))
partially evaluated: newWidget->testAttribute(Qt::WA_NoSystemBackground)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
634 q->setAttribute(Qt::WA_NoSystemBackground);
never executed: q->setAttribute(Qt::WA_NoSystemBackground);
0
635 if (newWidget->testAttribute(Qt::WA_OpaquePaintEvent))
partially evaluated: newWidget->testAttribute(Qt::WA_OpaquePaintEvent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
636 q->setAttribute(Qt::WA_OpaquePaintEvent);
never executed: q->setAttribute(Qt::WA_OpaquePaintEvent);
0
637 -
638 widget = newWidget;
executed (the execution status of this line is deduced): widget = newWidget;
-
639 -
640 // Changes only go from the widget to the proxy. -
641 enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
642 visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
643 posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
644 sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
645 -
646 if ((autoShow && !newWidget->testAttribute(Qt::WA_WState_ExplicitShowHide)) || !newWidget->testAttribute(Qt::WA_WState_Hidden)) {
partially evaluated: autoShow
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
partially evaluated: !newWidget->testAttribute(Qt::WA_WState_ExplicitShowHide)
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
never evaluated: !newWidget->testAttribute(Qt::WA_WState_Hidden)
0-8
647 newWidget->show();
executed (the execution status of this line is deduced): newWidget->show();
-
648 }
executed: }
Execution Count:8
8
649 -
650 // Copy the state from the widget onto the proxy. -
651#ifndef QT_NO_CURSOR -
652 if (newWidget->testAttribute(Qt::WA_SetCursor))
evaluated: newWidget->testAttribute(Qt::WA_SetCursor)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
653 q->setCursor(widget->cursor());
executed: q->setCursor(widget->cursor());
Execution Count:1
1
654#endif -
655 q->setEnabled(newWidget->isEnabled());
executed (the execution status of this line is deduced): q->setEnabled(newWidget->isEnabled());
-
656 q->setVisible(newWidget->isVisible());
executed (the execution status of this line is deduced): q->setVisible(newWidget->isVisible());
-
657 q->setLayoutDirection(newWidget->layoutDirection());
executed (the execution status of this line is deduced): q->setLayoutDirection(newWidget->layoutDirection());
-
658 if (newWidget->testAttribute(Qt::WA_SetStyle))
partially evaluated: newWidget->testAttribute(Qt::WA_SetStyle)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
659 q->setStyle(widget->style());
never executed: q->setStyle(widget->style());
0
660 -
661 resolveFont(inheritedFontResolveMask);
executed (the execution status of this line is deduced): resolveFont(inheritedFontResolveMask);
-
662 resolvePalette(inheritedPaletteResolveMask);
executed (the execution status of this line is deduced): resolvePalette(inheritedPaletteResolveMask);
-
663 -
664 if (!newWidget->testAttribute(Qt::WA_Resized))
partially evaluated: !newWidget->testAttribute(Qt::WA_Resized)
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
665 newWidget->adjustSize();
executed: newWidget->adjustSize();
Execution Count:8
8
666 -
667 int left, top, right, bottom;
executed (the execution status of this line is deduced): int left, top, right, bottom;
-
668 newWidget->getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): newWidget->getContentsMargins(&left, &top, &right, &bottom);
-
669 q->setContentsMargins(left, top, right, bottom);
executed (the execution status of this line is deduced): q->setContentsMargins(left, top, right, bottom);
-
670 q->setWindowTitle(newWidget->windowTitle());
executed (the execution status of this line is deduced): q->setWindowTitle(newWidget->windowTitle());
-
671 -
672 // size policies and constraints.. -
673 q->setSizePolicy(newWidget->sizePolicy());
executed (the execution status of this line is deduced): q->setSizePolicy(newWidget->sizePolicy());
-
674 QSize sz = newWidget->minimumSize();
executed (the execution status of this line is deduced): QSize sz = newWidget->minimumSize();
-
675 q->setMinimumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
executed (the execution status of this line is deduced): q->setMinimumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
-
676 sz = newWidget->maximumSize();
executed (the execution status of this line is deduced): sz = newWidget->maximumSize();
-
677 q->setMaximumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
executed (the execution status of this line is deduced): q->setMaximumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
-
678 -
679 updateProxyGeometryFromWidget();
executed (the execution status of this line is deduced): updateProxyGeometryFromWidget();
-
680 -
681 updateProxyInputMethodAcceptanceFromWidget();
executed (the execution status of this line is deduced): updateProxyInputMethodAcceptanceFromWidget();
-
682 -
683 // Hook up the event filter to keep the state up to date. -
684 newWidget->installEventFilter(q);
executed (the execution status of this line is deduced): newWidget->installEventFilter(q);
-
685 QObject::connect(newWidget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
executed (the execution status of this line is deduced): QObject::connect(newWidget, "2""destroyed()", q, "1""_q_removeWidgetSlot()");
-
686 -
687 // Changes no longer go only from the widget to the proxy. -
688 enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
689 visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
690 posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
691 sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
692}
executed: }
Execution Count:8
8
693 -
694/*! -
695 Returns a pointer to the embedded widget. -
696 -
697 \sa setWidget() -
698*/ -
699QWidget *QGraphicsProxyWidget::widget() const -
700{ -
701 Q_D(const QGraphicsProxyWidget);
executed (the execution status of this line is deduced): const QGraphicsProxyWidgetPrivate * const d = d_func();
-
702 return d->widget;
executed: return d->widget;
Execution Count:16
16
703} -
704 -
705/*! -
706 Returns the rectangle for \a widget, which must be a descendant of -
707 widget(), or widget() itself, in this proxy item's local coordinates. -
708 -
709 If no widget is embedded, \a widget is 0, or \a widget is not a -
710 descendant of the embedded widget, this function returns an empty QRectF. -
711 -
712 \sa widget() -
713*/ -
714QRectF QGraphicsProxyWidget::subWidgetRect(const QWidget *widget) const -
715{ -
716 Q_D(const QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): const QGraphicsProxyWidgetPrivate * const d = d_func();
-
717 if (!widget || !d->widget)
never evaluated: !widget
never evaluated: !d->widget
0
718 return QRectF();
never executed: return QRectF();
0
719 if (d->widget == widget || d->widget->isAncestorOf(widget))
never evaluated: d->widget == widget
never evaluated: d->widget->isAncestorOf(widget)
0
720 return QRectF(widget->mapTo(d->widget, QPoint(0, 0)), widget->size());
never executed: return QRectF(widget->mapTo(d->widget, QPoint(0, 0)), widget->size());
0
721 return QRectF();
never executed: return QRectF();
0
722} -
723 -
724/*! -
725 \reimp -
726*/ -
727void QGraphicsProxyWidget::setGeometry(const QRectF &rect) -
728{ -
729 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
730 bool proxyResizesWidget = !d->posChangeMode && !d->sizeChangeMode;
evaluated: !d->posChangeMode
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:22
partially evaluated: !d->sizeChangeMode
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-22
731 if (proxyResizesWidget) {
evaluated: proxyResizesWidget
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:22
4-22
732 d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
executed (the execution status of this line is deduced): d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
-
733 d->sizeChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
executed (the execution status of this line is deduced): d->sizeChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
-
734 }
executed: }
Execution Count:4
4
735 QGraphicsWidget::setGeometry(rect);
executed (the execution status of this line is deduced): QGraphicsWidget::setGeometry(rect);
-
736 if (proxyResizesWidget) {
evaluated: proxyResizesWidget
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:22
4-22
737 d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
738 d->sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): d->sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
739 }
executed: }
Execution Count:4
4
740}
executed: }
Execution Count:26
26
741 -
742/*! -
743 \reimp -
744*/ -
745QVariant QGraphicsProxyWidget::itemChange(GraphicsItemChange change, -
746 const QVariant &value) -
747{ -
748 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
749 -
750 switch (change) { -
751 case ItemPositionChange: -
752 // The item's position is either changed directly on the proxy, in -
753 // which case the position change should propagate to the widget, -
754 // otherwise it happens as a side effect when filtering QEvent::Move. -
755 if (!d->posChangeMode)
never evaluated: !d->posChangeMode
0
756 d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
never executed: d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
0
757 break;
never executed: break;
0
758 case ItemPositionHasChanged: -
759 // Move the internal widget if we're in widget-to-proxy -
760 // mode. Otherwise the widget has already moved. -
761 if (d->widget && d->posChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
never evaluated: d->widget
never evaluated: d->posChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode
0
762 d->widget->move(value.toPoint());
never executed: d->widget->move(value.toPoint());
0
763 if (d->posChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
never evaluated: d->posChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode
0
764 d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed: d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
0
765 break;
never executed: break;
0
766 case ItemVisibleChange: -
767 if (!d->visibleChangeMode)
evaluated: !d->visibleChangeMode
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
768 d->visibleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
executed: d->visibleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
Execution Count:5
5
769 break;
executed: break;
Execution Count:9
9
770 case ItemVisibleHasChanged: -
771 if (d->widget && d->visibleChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
partially evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
evaluated: d->visibleChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
0-9
772 d->widget->setVisible(isVisible());
executed: d->widget->setVisible(isVisible());
Execution Count:5
5
773 if (d->visibleChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
evaluated: d->visibleChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
774 d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed: d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
Execution Count:5
5
775 break;
executed: break;
Execution Count:9
9
776 case ItemEnabledChange: -
777 if (!d->enabledChangeMode)
never evaluated: !d->enabledChangeMode
0
778 d->enabledChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
never executed: d->enabledChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
0
779 break;
never executed: break;
0
780 case ItemEnabledHasChanged: -
781 if (d->widget && d->enabledChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
never evaluated: d->widget
never evaluated: d->enabledChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode
0
782 d->widget->setEnabled(isEnabled());
never executed: d->widget->setEnabled(isEnabled());
0
783 if (d->enabledChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
never evaluated: d->enabledChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode
0
784 d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed: d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
0
785 break;
never executed: break;
0
786 default: -
787 break;
executed: break;
Execution Count:57
57
788 } -
789 return QGraphicsWidget::itemChange(change, value);
executed: return QGraphicsWidget::itemChange(change, value);
Execution Count:75
75
790} -
791 -
792/*! -
793 \reimp -
794*/ -
795bool QGraphicsProxyWidget::event(QEvent *event) -
796{ -
797 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
798 if (!d->widget)
partially evaluated: !d->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:58
0-58
799 return QGraphicsWidget::event(event);
never executed: return QGraphicsWidget::event(event);
0
800 -
801 switch (event->type()) { -
802 case QEvent::StyleChange: -
803 // Propagate style changes to the embedded widget. -
804 if (!d->styleChangeMode) {
never evaluated: !d->styleChangeMode
0
805 d->styleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
never executed (the execution status of this line is deduced): d->styleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
-
806 d->widget->setStyle(style());
never executed (the execution status of this line is deduced): d->widget->setStyle(style());
-
807 d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed (the execution status of this line is deduced): d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
808 }
never executed: }
0
809 break;
never executed: break;
0
810 case QEvent::FontChange: { -
811 // Propagate to widget. -
812 QWidgetPrivate *wd = d->widget->d_func();
never executed (the execution status of this line is deduced): QWidgetPrivate *wd = d->widget->d_func();
-
813 int mask = d->font.resolve() | d->inheritedFontResolveMask;
never executed (the execution status of this line is deduced): int mask = d->font.resolve() | d->inheritedFontResolveMask;
-
814 wd->inheritedFontResolveMask = mask;
never executed (the execution status of this line is deduced): wd->inheritedFontResolveMask = mask;
-
815 wd->resolveFont();
never executed (the execution status of this line is deduced): wd->resolveFont();
-
816 break;
never executed: break;
0
817 } -
818 case QEvent::PaletteChange: { -
819 // Propagate to widget. -
820 QWidgetPrivate *wd = d->widget->d_func();
executed (the execution status of this line is deduced): QWidgetPrivate *wd = d->widget->d_func();
-
821 int mask = d->palette.resolve() | d->inheritedPaletteResolveMask;
executed (the execution status of this line is deduced): int mask = d->palette.resolve() | d->inheritedPaletteResolveMask;
-
822 wd->inheritedPaletteResolveMask = mask;
executed (the execution status of this line is deduced): wd->inheritedPaletteResolveMask = mask;
-
823 wd->resolvePalette();
executed (the execution status of this line is deduced): wd->resolvePalette();
-
824 break;
executed: break;
Execution Count:21
21
825 } -
826 case QEvent::InputMethod: { -
827 inputMethodEvent(static_cast<QInputMethodEvent *>(event));
never executed (the execution status of this line is deduced): inputMethodEvent(static_cast<QInputMethodEvent *>(event));
-
828 break;
never executed: break;
0
829 } -
830 case QEvent::ShortcutOverride: { -
831 QWidget *focusWidget = d->widget->focusWidget();
never executed (the execution status of this line is deduced): QWidget *focusWidget = d->widget->focusWidget();
-
832 while (focusWidget) {
never evaluated: focusWidget
0
833 QApplication::sendEvent(focusWidget, event);
never executed (the execution status of this line is deduced): QApplication::sendEvent(focusWidget, event);
-
834 if (event->isAccepted())
never evaluated: event->isAccepted()
0
835 return true;
never executed: return true;
0
836 focusWidget = focusWidget->parentWidget();
never executed (the execution status of this line is deduced): focusWidget = focusWidget->parentWidget();
-
837 }
never executed: }
0
838 return false;
never executed: return false;
0
839 } -
840 case QEvent::KeyPress: { -
841 QKeyEvent *k = static_cast<QKeyEvent *>(event);
never executed (the execution status of this line is deduced): QKeyEvent *k = static_cast<QKeyEvent *>(event);
-
842 if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
never evaluated: k->key() == Qt::Key_Tab
never evaluated: k->key() == Qt::Key_Backtab
0
843 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
never evaluated: !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))
0
844 QWidget *focusWidget = d->widget->focusWidget();
never executed (the execution status of this line is deduced): QWidget *focusWidget = d->widget->focusWidget();
-
845 while (focusWidget) {
never evaluated: focusWidget
0
846 bool res = QApplication::sendEvent(focusWidget, event);
never executed (the execution status of this line is deduced): bool res = QApplication::sendEvent(focusWidget, event);
-
847 if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) {
never evaluated: res
never evaluated: event->isAccepted()
never evaluated: isWindow()
never evaluated: focusWidget == d->widget
0
848 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
849 break;
never executed: break;
0
850 } -
851 focusWidget = focusWidget->parentWidget();
never executed (the execution status of this line is deduced): focusWidget = focusWidget->parentWidget();
-
852 }
never executed: }
0
853 return true;
never executed: return true;
0
854 } -
855 }
never executed: }
0
856 break;
never executed: break;
0
857 } -
858#ifndef QT_NO_TOOLTIP -
859 case QEvent::GraphicsSceneHelp: { -
860 // Propagate the help event (for tooltip) to the widget under mouse -
861 if (d->lastWidgetUnderMouse) {
never evaluated: d->lastWidgetUnderMouse
0
862 QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event);
-
863 QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
never executed (the execution status of this line is deduced): QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
-
864 QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
never executed (the execution status of this line is deduced): QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
-
865 QApplication::sendEvent(d->lastWidgetUnderMouse, &e);
never executed (the execution status of this line is deduced): QApplication::sendEvent(d->lastWidgetUnderMouse, &e);
-
866 event->setAccepted(e.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(e.isAccepted());
-
867 return e.isAccepted();
never executed: return e.isAccepted();
0
868 } -
869 break;
never executed: break;
0
870 } -
871 case QEvent::ToolTipChange: { -
872 // Propagate tooltip change to the widget -
873 if (!d->tooltipChangeMode) {
never evaluated: !d->tooltipChangeMode
0
874 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
never executed (the execution status of this line is deduced): d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
-
875 d->widget->setToolTip(toolTip());
never executed (the execution status of this line is deduced): d->widget->setToolTip(toolTip());
-
876 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed (the execution status of this line is deduced): d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
877 }
never executed: }
0
878 break;
never executed: break;
0
879 } -
880#endif -
881 default: -
882 break;
executed: break;
Execution Count:37
37
883 } -
884 return QGraphicsWidget::event(event);
executed: return QGraphicsWidget::event(event);
Execution Count:58
58
885} -
886 -
887/*! -
888 \reimp -
889*/ -
890bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event) -
891{ -
892 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
893 -
894 if (object == d->widget) {
partially evaluated: object == d->widget
TRUEFALSE
yes
Evaluation Count:41
no
Evaluation Count:0
0-41
895 switch (event->type()) { -
896 case QEvent::LayoutRequest: -
897 updateGeometry();
executed (the execution status of this line is deduced): updateGeometry();
-
898 break;
executed: break;
Execution Count:1
1
899 case QEvent::Resize: -
900 // If the widget resizes itself, we resize the proxy too. -
901 // Prevent feed-back by checking the geometry change mode. -
902 if (!d->sizeChangeMode)
partially evaluated: !d->sizeChangeMode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
903 d->updateProxyGeometryFromWidget();
never executed: d->updateProxyGeometryFromWidget();
0
904 break;
executed: break;
Execution Count:3
3
905 case QEvent::Move: -
906 // If the widget moves itself, we move the proxy too. Prevent -
907 // feed-back by checking the geometry change mode. -
908 if (!d->posChangeMode)
never evaluated: !d->posChangeMode
0
909 d->updateProxyGeometryFromWidget();
never executed: d->updateProxyGeometryFromWidget();
0
910 break;
never executed: break;
0
911 case QEvent::Hide: -
912 case QEvent::Show: -
913 // If the widget toggles its visible state, the proxy will follow. -
914 if (!d->visibleChangeMode) {
partially evaluated: !d->visibleChangeMode
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
915 d->visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
executed (the execution status of this line is deduced): d->visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
916 setVisible(event->type() == QEvent::Show);
executed (the execution status of this line is deduced): setVisible(event->type() == QEvent::Show);
-
917 d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
executed (the execution status of this line is deduced): d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
918 }
executed: }
Execution Count:4
4
919 break;
executed: break;
Execution Count:4
4
920 case QEvent::EnabledChange: -
921 // If the widget toggles its enabled state, the proxy will follow. -
922 if (!d->enabledChangeMode) {
never evaluated: !d->enabledChangeMode
0
923 d->enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
never executed (the execution status of this line is deduced): d->enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
924 setEnabled(d->widget->isEnabled());
never executed (the execution status of this line is deduced): setEnabled(d->widget->isEnabled());
-
925 d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed (the execution status of this line is deduced): d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
926 }
never executed: }
0
927 break;
never executed: break;
0
928 case QEvent::StyleChange: -
929 // Propagate style changes to the proxy. -
930 if (!d->styleChangeMode) {
never evaluated: !d->styleChangeMode
0
931 d->styleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
never executed (the execution status of this line is deduced): d->styleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
932 setStyle(d->widget->style());
never executed (the execution status of this line is deduced): setStyle(d->widget->style());
-
933 d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed (the execution status of this line is deduced): d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
934 }
never executed: }
0
935 break;
never executed: break;
0
936#ifndef QT_NO_TOOLTIP -
937 case QEvent::ToolTipChange: -
938 // Propagate tooltip change to the proxy. -
939 if (!d->tooltipChangeMode) {
never evaluated: !d->tooltipChangeMode
0
940 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
never executed (the execution status of this line is deduced): d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
941 setToolTip(d->widget->toolTip());
never executed (the execution status of this line is deduced): setToolTip(d->widget->toolTip());
-
942 d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
never executed (the execution status of this line is deduced): d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-
943 }
never executed: }
0
944 break;
never executed: break;
0
945#endif -
946 default: -
947 break;
executed: break;
Execution Count:33
33
948 } -
949 }
executed: }
Execution Count:41
41
950 return QGraphicsWidget::eventFilter(object, event);
executed: return QGraphicsWidget::eventFilter(object, event);
Execution Count:41
41
951} -
952 -
953/*! -
954 \reimp -
955*/ -
956void QGraphicsProxyWidget::showEvent(QShowEvent *event) -
957{ -
958 Q_UNUSED(event);
executed (the execution status of this line is deduced): (void)event;;
-
959}
executed: }
Execution Count:5
5
960 -
961/*! -
962 \reimp -
963*/ -
964void QGraphicsProxyWidget::hideEvent(QHideEvent *event) -
965{ -
966 Q_UNUSED(event);
executed (the execution status of this line is deduced): (void)event;;
-
967}
executed: }
Execution Count:4
4
968 -
969#ifndef QT_NO_CONTEXTMENU -
970/*! -
971 \reimp -
972*/ -
973void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -
974{ -
975 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
976 if (!event || !d->widget || !d->widget->isVisible() || !hasFocus())
never evaluated: !event
never evaluated: !d->widget
never evaluated: !d->widget->isVisible()
never evaluated: !hasFocus()
0
977 return;
never executed: return;
0
978 -
979 // Find widget position and receiver. -
980 QPointF pos = event->pos();
never executed (the execution status of this line is deduced): QPointF pos = event->pos();
-
981 QPointer<QWidget> alienWidget = d->widget->childAt(pos.toPoint());
never executed (the execution status of this line is deduced): QPointer<QWidget> alienWidget = d->widget->childAt(pos.toPoint());
-
982 QPointer<QWidget> receiver = alienWidget ? alienWidget : d->widget;
never evaluated: alienWidget
0
983 -
984 // Map event position from us to the receiver -
985 pos = d->mapToReceiver(pos, receiver);
never executed (the execution status of this line is deduced): pos = d->mapToReceiver(pos, receiver);
-
986 -
987 QPoint globalPos = receiver->mapToGlobal(pos.toPoint());
never executed (the execution status of this line is deduced): QPoint globalPos = receiver->mapToGlobal(pos.toPoint());
-
988 //If the receiver by-pass the proxy its popups -
989 //will be top level QWidgets therefore they need -
990 //the screen position. mapToGlobal expect the widget to -
991 //have proper coordinates in regards of the windowing system -
992 //but it's not true because the widget is embedded. -
993 if (bypassGraphicsProxyWidget(receiver))
never evaluated: bypassGraphicsProxyWidget(receiver)
0
994 globalPos = event->screenPos();
never executed: globalPos = event->screenPos();
0
995 -
996 // Send mouse event. ### Doesn't propagate the event. -
997 QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
never executed (the execution status of this line is deduced): QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
-
998 pos.toPoint(), globalPos, event->modifiers());
never executed (the execution status of this line is deduced): pos.toPoint(), globalPos, event->modifiers());
-
999 QApplication::sendEvent(receiver, &contextMenuEvent);
never executed (the execution status of this line is deduced): QApplication::sendEvent(receiver, &contextMenuEvent);
-
1000 -
1001 event->setAccepted(contextMenuEvent.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(contextMenuEvent.isAccepted());
-
1002}
never executed: }
0
1003#endif // QT_NO_CONTEXTMENU -
1004 -
1005#ifndef QT_NO_DRAGANDDROP -
1006/*! -
1007 \reimp -
1008*/ -
1009void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -
1010{ -
1011#ifdef QT_NO_DRAGANDDROP -
1012 Q_UNUSED(event); -
1013#else -
1014 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1015 if (!d->widget)
never evaluated: !d->widget
0
1016 return;
never executed: return;
0
1017 -
1018 QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers());
never executed (the execution status of this line is deduced): QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers());
-
1019 proxyDragEnter.setAccepted(event->isAccepted());
never executed (the execution status of this line is deduced): proxyDragEnter.setAccepted(event->isAccepted());
-
1020 QApplication::sendEvent(d->widget, &proxyDragEnter);
never executed (the execution status of this line is deduced): QApplication::sendEvent(d->widget, &proxyDragEnter);
-
1021 event->setAccepted(proxyDragEnter.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(proxyDragEnter.isAccepted());
-
1022 if (proxyDragEnter.isAccepted()) // we discard answerRect
never evaluated: proxyDragEnter.isAccepted()
0
1023 event->setDropAction(proxyDragEnter.dropAction());
never executed: event->setDropAction(proxyDragEnter.dropAction());
0
1024#endif -
1025}
never executed: }
0
1026/*! -
1027 \reimp -
1028*/ -
1029void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -
1030{ -
1031 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
1032#ifndef QT_NO_DRAGANDDROP -
1033 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1034 if (!d->widget || !d->dragDropWidget)
never evaluated: !d->widget
never evaluated: !d->dragDropWidget
0
1035 return;
never executed: return;
0
1036 QDragLeaveEvent proxyDragLeave;
never executed (the execution status of this line is deduced): QDragLeaveEvent proxyDragLeave;
-
1037 QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
never executed (the execution status of this line is deduced): QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
-
1038 d->dragDropWidget = 0;
never executed (the execution status of this line is deduced): d->dragDropWidget = 0;
-
1039#endif -
1040}
never executed: }
0
1041 -
1042/*! -
1043 \reimp -
1044*/ -
1045void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -
1046{ -
1047#ifdef QT_NO_DRAGANDDROP -
1048 Q_UNUSED(event); -
1049#else -
1050 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1051 if (!d->widget)
never evaluated: !d->widget
0
1052 return;
never executed: return;
0
1053 QPointF p = event->pos();
never executed (the execution status of this line is deduced): QPointF p = event->pos();
-
1054 event->ignore();
never executed (the execution status of this line is deduced): event->ignore();
-
1055 QPointer<QWidget> subWidget = d->widget->childAt(p.toPoint());
never executed (the execution status of this line is deduced): QPointer<QWidget> subWidget = d->widget->childAt(p.toPoint());
-
1056 QPointer<QWidget> receiver = subWidget ? subWidget : d->widget;
never evaluated: subWidget
0
1057 bool eventDelivered = false;
never executed (the execution status of this line is deduced): bool eventDelivered = false;
-
1058 for (; receiver; receiver = receiver->parentWidget()) {
never evaluated: receiver
0
1059 if (!receiver->isEnabled() || !receiver->acceptDrops())
never evaluated: !receiver->isEnabled()
never evaluated: !receiver->acceptDrops()
0
1060 continue;
never executed: continue;
0
1061 // Map event position from us to the receiver -
1062 QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
never executed (the execution status of this line is deduced): QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
-
1063 if (receiver != d->dragDropWidget) {
never evaluated: receiver != d->dragDropWidget
0
1064 // Try to enter before we leave -
1065 QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
never executed (the execution status of this line is deduced): QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
-
1066 dragEnter.setDropAction(event->proposedAction());
never executed (the execution status of this line is deduced): dragEnter.setDropAction(event->proposedAction());
-
1067 QApplication::sendEvent(receiver, &dragEnter);
never executed (the execution status of this line is deduced): QApplication::sendEvent(receiver, &dragEnter);
-
1068 event->setAccepted(dragEnter.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(dragEnter.isAccepted());
-
1069 event->setDropAction(dragEnter.dropAction());
never executed (the execution status of this line is deduced): event->setDropAction(dragEnter.dropAction());
-
1070 if (!event->isAccepted()) {
never evaluated: !event->isAccepted()
0
1071 // propagate to the parent widget -
1072 continue;
never executed: continue;
0
1073 } -
1074 -
1075 d->lastDropAction = event->dropAction();
never executed (the execution status of this line is deduced): d->lastDropAction = event->dropAction();
-
1076 -
1077 if (d->dragDropWidget) {
never evaluated: d->dragDropWidget
0
1078 QDragLeaveEvent dragLeave;
never executed (the execution status of this line is deduced): QDragLeaveEvent dragLeave;
-
1079 QApplication::sendEvent(d->dragDropWidget, &dragLeave);
never executed (the execution status of this line is deduced): QApplication::sendEvent(d->dragDropWidget, &dragLeave);
-
1080 }
never executed: }
0
1081 d->dragDropWidget = receiver;
never executed (the execution status of this line is deduced): d->dragDropWidget = receiver;
-
1082 }
never executed: }
0
1083 -
1084 QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
never executed (the execution status of this line is deduced): QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
-
1085 event->setDropAction(d->lastDropAction);
never executed (the execution status of this line is deduced): event->setDropAction(d->lastDropAction);
-
1086 QApplication::sendEvent(receiver, &dragMove);
never executed (the execution status of this line is deduced): QApplication::sendEvent(receiver, &dragMove);
-
1087 event->setAccepted(dragMove.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(dragMove.isAccepted());
-
1088 event->setDropAction(dragMove.dropAction());
never executed (the execution status of this line is deduced): event->setDropAction(dragMove.dropAction());
-
1089 if (event->isAccepted())
never evaluated: event->isAccepted()
0
1090 d->lastDropAction = event->dropAction();
never executed: d->lastDropAction = event->dropAction();
0
1091 eventDelivered = true;
never executed (the execution status of this line is deduced): eventDelivered = true;
-
1092 break;
never executed: break;
0
1093 } -
1094 -
1095 if (!eventDelivered) {
never evaluated: !eventDelivered
0
1096 if (d->dragDropWidget) {
never evaluated: d->dragDropWidget
0
1097 // Leave the last drag drop item -
1098 QDragLeaveEvent dragLeave;
never executed (the execution status of this line is deduced): QDragLeaveEvent dragLeave;
-
1099 QApplication::sendEvent(d->dragDropWidget, &dragLeave);
never executed (the execution status of this line is deduced): QApplication::sendEvent(d->dragDropWidget, &dragLeave);
-
1100 d->dragDropWidget = 0;
never executed (the execution status of this line is deduced): d->dragDropWidget = 0;
-
1101 }
never executed: }
0
1102 // Propagate -
1103 event->setDropAction(Qt::IgnoreAction);
never executed (the execution status of this line is deduced): event->setDropAction(Qt::IgnoreAction);
-
1104 }
never executed: }
0
1105#endif -
1106}
never executed: }
0
1107 -
1108/*! -
1109 \reimp -
1110*/ -
1111void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event) -
1112{ -
1113#ifdef QT_NO_DRAGANDDROP -
1114 Q_UNUSED(event); -
1115#else -
1116 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1117 if (d->widget && d->dragDropWidget) {
never evaluated: d->widget
never evaluated: d->dragDropWidget
0
1118 QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint();
never executed (the execution status of this line is deduced): QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint();
-
1119 QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
never executed (the execution status of this line is deduced): QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
-
1120 QApplication::sendEvent(d->dragDropWidget, &dropEvent);
never executed (the execution status of this line is deduced): QApplication::sendEvent(d->dragDropWidget, &dropEvent);
-
1121 event->setAccepted(dropEvent.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(dropEvent.isAccepted());
-
1122 d->dragDropWidget = 0;
never executed (the execution status of this line is deduced): d->dragDropWidget = 0;
-
1123 }
never executed: }
0
1124#endif -
1125}
never executed: }
0
1126#endif -
1127 -
1128/*! -
1129 \reimp -
1130*/ -
1131void QGraphicsProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -
1132{ -
1133 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
1134}
never executed: }
0
1135 -
1136/*! -
1137 \reimp -
1138*/ -
1139void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -
1140{ -
1141 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
1142 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1143 // If hoverMove was compressed away, make sure we update properly here. -
1144 if (d->lastWidgetUnderMouse) {
never evaluated: d->lastWidgetUnderMouse
0
1145 QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
never executed (the execution status of this line is deduced): QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
-
1146 d->lastWidgetUnderMouse = 0;
never executed (the execution status of this line is deduced): d->lastWidgetUnderMouse = 0;
-
1147 }
never executed: }
0
1148}
never executed: }
0
1149 -
1150/*! -
1151 \reimp -
1152*/ -
1153void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -
1154{ -
1155 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1156#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1157 qDebug() << "QGraphicsProxyWidget::hoverMoveEvent"; -
1158#endif -
1159 // Ignore events on the window frame. -
1160 if (!d->widget || !rect().contains(event->pos())) {
never evaluated: !d->widget
never evaluated: !rect().contains(event->pos())
0
1161 if (d->lastWidgetUnderMouse) {
never evaluated: d->lastWidgetUnderMouse
0
1162 QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
never executed (the execution status of this line is deduced): QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
-
1163 d->lastWidgetUnderMouse = 0;
never executed (the execution status of this line is deduced): d->lastWidgetUnderMouse = 0;
-
1164 }
never executed: }
0
1165 return;
never executed: return;
0
1166 } -
1167 -
1168 d->embeddedMouseGrabber = 0;
never executed (the execution status of this line is deduced): d->embeddedMouseGrabber = 0;
-
1169 d->sendWidgetMouseEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetMouseEvent(event);
-
1170}
never executed: }
0
1171 -
1172/*! -
1173 \reimp -
1174*/ -
1175void QGraphicsProxyWidget::grabMouseEvent(QEvent *event) -
1176{ -
1177 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
1178}
never executed: }
0
1179 -
1180/*! -
1181 \reimp -
1182*/ -
1183void QGraphicsProxyWidget::ungrabMouseEvent(QEvent *event) -
1184{ -
1185 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1186 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
1187 d->embeddedMouseGrabber = 0;
never executed (the execution status of this line is deduced): d->embeddedMouseGrabber = 0;
-
1188}
never executed: }
0
1189 -
1190/*! -
1191 \reimp -
1192*/ -
1193void QGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -
1194{ -
1195 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1196#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1197 qDebug() << "QGraphicsProxyWidget::mouseMoveEvent"; -
1198#endif -
1199 d->sendWidgetMouseEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetMouseEvent(event);
-
1200}
never executed: }
0
1201 -
1202/*! -
1203 \reimp -
1204*/ -
1205void QGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) -
1206{ -
1207 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1208#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1209 qDebug() << "QGraphicsProxyWidget::mousePressEvent"; -
1210#endif -
1211 d->sendWidgetMouseEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetMouseEvent(event);
-
1212}
never executed: }
0
1213 -
1214/*! -
1215 \reimp -
1216*/ -
1217void QGraphicsProxyWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -
1218{ -
1219 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1220#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1221 qDebug() << "QGraphicsProxyWidget::mouseDoubleClickEvent"; -
1222#endif -
1223 d->sendWidgetMouseEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetMouseEvent(event);
-
1224}
never executed: }
0
1225 -
1226/*! -
1227 \reimp -
1228*/ -
1229#ifndef QT_NO_WHEELEVENT -
1230void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) -
1231{ -
1232 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1233#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1234 qDebug() << "QGraphicsProxyWidget::wheelEvent"; -
1235#endif -
1236 if (!d->widget)
never evaluated: !d->widget
0
1237 return;
never executed: return;
0
1238 -
1239 QPointF pos = event->pos();
never executed (the execution status of this line is deduced): QPointF pos = event->pos();
-
1240 QPointer<QWidget> receiver = d->widget->childAt(pos.toPoint());
never executed (the execution status of this line is deduced): QPointer<QWidget> receiver = d->widget->childAt(pos.toPoint());
-
1241 if (!receiver)
never evaluated: !receiver
0
1242 receiver = d->widget;
never executed: receiver = d->widget;
0
1243 -
1244 // Map event position from us to the receiver -
1245 pos = d->mapToReceiver(pos, receiver);
never executed (the execution status of this line is deduced): pos = d->mapToReceiver(pos, receiver);
-
1246 -
1247 // Send mouse event. -
1248 QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(),
never executed (the execution status of this line is deduced): QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(),
-
1249 event->buttons(), event->modifiers(), event->orientation());
never executed (the execution status of this line is deduced): event->buttons(), event->modifiers(), event->orientation());
-
1250 QPointer<QWidget> focusWidget = d->widget->focusWidget();
never executed (the execution status of this line is deduced): QPointer<QWidget> focusWidget = d->widget->focusWidget();
-
1251 extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
never executed (the execution status of this line is deduced): extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
-
1252 qt_sendSpontaneousEvent(receiver, &wheelEvent);
never executed (the execution status of this line is deduced): qt_sendSpontaneousEvent(receiver, &wheelEvent);
-
1253 event->setAccepted(wheelEvent.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(wheelEvent.isAccepted());
-
1254 -
1255 // ### Remove, this should be done by proper focusIn/focusOut events. -
1256 if (focusWidget && !focusWidget->hasFocus()) {
never evaluated: focusWidget
never evaluated: !focusWidget->hasFocus()
0
1257 focusWidget->update();
never executed (the execution status of this line is deduced): focusWidget->update();
-
1258 focusWidget = d->widget->focusWidget();
never executed (the execution status of this line is deduced): focusWidget = d->widget->focusWidget();
-
1259 if (focusWidget && focusWidget->hasFocus())
never evaluated: focusWidget
never evaluated: focusWidget->hasFocus()
0
1260 focusWidget->update();
never executed: focusWidget->update();
0
1261 }
never executed: }
0
1262}
never executed: }
0
1263#endif -
1264 -
1265/*! -
1266 \reimp -
1267*/ -
1268void QGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -
1269{ -
1270 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1271#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1272 qDebug() << "QGraphicsProxyWidget::mouseReleaseEvent"; -
1273#endif -
1274 d->sendWidgetMouseEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetMouseEvent(event);
-
1275}
never executed: }
0
1276 -
1277/*! -
1278 \reimp -
1279*/ -
1280void QGraphicsProxyWidget::keyPressEvent(QKeyEvent *event) -
1281{ -
1282 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1283#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1284 qDebug() << "QGraphicsProxyWidget::keyPressEvent"; -
1285#endif -
1286 d->sendWidgetKeyEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetKeyEvent(event);
-
1287}
never executed: }
0
1288 -
1289/*! -
1290 \reimp -
1291*/ -
1292void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event) -
1293{ -
1294 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1295#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1296 qDebug() << "QGraphicsProxyWidget::keyReleaseEvent"; -
1297#endif -
1298 d->sendWidgetKeyEvent(event);
never executed (the execution status of this line is deduced): d->sendWidgetKeyEvent(event);
-
1299}
never executed: }
0
1300 -
1301/*! -
1302 \reimp -
1303*/ -
1304void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event) -
1305{ -
1306#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1307 qDebug() << "QGraphicsProxyWidget::focusInEvent"; -
1308#endif -
1309 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1310 -
1311 if (d->focusFromWidgetToProxy) {
never evaluated: d->focusFromWidgetToProxy
0
1312 // Prevent recursion when the proxy autogains focus through the -
1313 // embedded widget calling setFocus(). ### Could be done with event -
1314 // filter on FocusIn instead? -
1315 return;
never executed: return;
0
1316 } -
1317 -
1318 d->proxyIsGivingFocus = true;
never executed (the execution status of this line is deduced): d->proxyIsGivingFocus = true;
-
1319 -
1320 switch (event->reason()) { -
1321 case Qt::TabFocusReason: { -
1322 if (QWidget *focusChild = d->findFocusChild(0, true))
never evaluated: QWidget *focusChild = d->findFocusChild(0, true)
0
1323 focusChild->setFocus(event->reason());
never executed: focusChild->setFocus(event->reason());
0
1324 break;
never executed: break;
0
1325 } -
1326 case Qt::BacktabFocusReason: -
1327 if (QWidget *focusChild = d->findFocusChild(0, false))
never evaluated: QWidget *focusChild = d->findFocusChild(0, false)
0
1328 focusChild->setFocus(event->reason());
never executed: focusChild->setFocus(event->reason());
0
1329 break;
never executed: break;
0
1330 default: -
1331 if (d->widget && d->widget->focusWidget()) {
never evaluated: d->widget
never evaluated: d->widget->focusWidget()
0
1332 d->widget->focusWidget()->setFocus(event->reason());
never executed (the execution status of this line is deduced): d->widget->focusWidget()->setFocus(event->reason());
-
1333 }
never executed: }
0
1334 break;
never executed: break;
0
1335 } -
1336 -
1337 d->proxyIsGivingFocus = false;
never executed (the execution status of this line is deduced): d->proxyIsGivingFocus = false;
-
1338}
never executed: }
0
1339 -
1340/*! -
1341 \reimp -
1342*/ -
1343void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event) -
1344{ -
1345#ifdef GRAPHICSPROXYWIDGET_DEBUG -
1346 qDebug() << "QGraphicsProxyWidget::focusOutEvent"; -
1347#endif -
1348 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1349 if (d->widget) {
never evaluated: d->widget
0
1350 // We need to explicitly remove subfocus from the embedded widget's -
1351 // focus widget. -
1352 if (QWidget *focusWidget = d->widget->focusWidget())
never evaluated: QWidget *focusWidget = d->widget->focusWidget()
0
1353 d->removeSubFocusHelper(focusWidget, event->reason());
never executed: d->removeSubFocusHelper(focusWidget, event->reason());
0
1354 }
never executed: }
0
1355}
never executed: }
0
1356 -
1357/*! -
1358 \reimp -
1359*/ -
1360bool QGraphicsProxyWidget::focusNextPrevChild(bool next) -
1361{ -
1362 Q_D(QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1363 if (!d->widget || !d->scene)
never evaluated: !d->widget
never evaluated: !d->scene
0
1364 return QGraphicsWidget::focusNextPrevChild(next);
never executed: return QGraphicsWidget::focusNextPrevChild(next);
0
1365 -
1366 Qt::FocusReason reason = next ? Qt::TabFocusReason : Qt::BacktabFocusReason;
never evaluated: next
0
1367 QWidget *lastFocusChild = d->widget->focusWidget();
never executed (the execution status of this line is deduced): QWidget *lastFocusChild = d->widget->focusWidget();
-
1368 if (QWidget *newFocusChild = d->findFocusChild(lastFocusChild, next)) {
never evaluated: QWidget *newFocusChild = d->findFocusChild(lastFocusChild, next)
0
1369 newFocusChild->setFocus(reason);
never executed (the execution status of this line is deduced): newFocusChild->setFocus(reason);
-
1370 return true;
never executed: return true;
0
1371 } -
1372 -
1373 return QGraphicsWidget::focusNextPrevChild(next);
never executed: return QGraphicsWidget::focusNextPrevChild(next);
0
1374} -
1375 -
1376/*! -
1377 \reimp -
1378*/ -
1379QVariant QGraphicsProxyWidget::inputMethodQuery(Qt::InputMethodQuery query) const -
1380{ -
1381 Q_D(const QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): const QGraphicsProxyWidgetPrivate * const d = d_func();
-
1382 -
1383 if (!d->widget || !hasFocus())
never evaluated: !d->widget
never evaluated: !hasFocus()
0
1384 return QVariant();
never executed: return QVariant();
0
1385 -
1386 QWidget *focusWidget = widget()->focusWidget();
never executed (the execution status of this line is deduced): QWidget *focusWidget = widget()->focusWidget();
-
1387 if (!focusWidget)
never evaluated: !focusWidget
0
1388 focusWidget = d->widget;
never executed: focusWidget = d->widget;
0
1389 QVariant v = focusWidget->inputMethodQuery(query);
never executed (the execution status of this line is deduced): QVariant v = focusWidget->inputMethodQuery(query);
-
1390 QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft();
never executed (the execution status of this line is deduced): QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft();
-
1391 switch (v.type()) { -
1392 case QVariant::RectF: -
1393 v = v.toRectF().translated(focusWidgetPos);
never executed (the execution status of this line is deduced): v = v.toRectF().translated(focusWidgetPos);
-
1394 break;
never executed: break;
0
1395 case QVariant::PointF: -
1396 v = v.toPointF() + focusWidgetPos;
never executed (the execution status of this line is deduced): v = v.toPointF() + focusWidgetPos;
-
1397 break;
never executed: break;
0
1398 case QVariant::Rect: -
1399 v = v.toRect().translated(focusWidgetPos.toPoint());
never executed (the execution status of this line is deduced): v = v.toRect().translated(focusWidgetPos.toPoint());
-
1400 break;
never executed: break;
0
1401 case QVariant::Point: -
1402 v = v.toPoint() + focusWidgetPos.toPoint();
never executed (the execution status of this line is deduced): v = v.toPoint() + focusWidgetPos.toPoint();
-
1403 break;
never executed: break;
0
1404 default: -
1405 break;
never executed: break;
0
1406 } -
1407 return v;
never executed: return v;
0
1408} -
1409 -
1410/*! -
1411 \reimp -
1412*/ -
1413void QGraphicsProxyWidget::inputMethodEvent(QInputMethodEvent *event) -
1414{ -
1415 // Forward input method events if the focus widget enables input methods. -
1416 Q_D(const QGraphicsProxyWidget);
never executed (the execution status of this line is deduced): const QGraphicsProxyWidgetPrivate * const d = d_func();
-
1417 QWidget *focusWidget = d->widget->focusWidget();
never executed (the execution status of this line is deduced): QWidget *focusWidget = d->widget->focusWidget();
-
1418 if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
never evaluated: focusWidget
never evaluated: focusWidget->testAttribute(Qt::WA_InputMethodEnabled)
0
1419 QApplication::sendEvent(focusWidget, event);
never executed: QApplication::sendEvent(focusWidget, event);
0
1420}
never executed: }
0
1421 -
1422/*! -
1423 \reimp -
1424*/ -
1425QSizeF QGraphicsProxyWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -
1426{ -
1427 Q_D(const QGraphicsProxyWidget);
executed (the execution status of this line is deduced): const QGraphicsProxyWidgetPrivate * const d = d_func();
-
1428 if (!d->widget)
partially evaluated: !d->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36
0-36
1429 return QGraphicsWidget::sizeHint(which, constraint);
never executed: return QGraphicsWidget::sizeHint(which, constraint);
0
1430 -
1431 QSizeF sh;
executed (the execution status of this line is deduced): QSizeF sh;
-
1432 switch (which) { -
1433 case Qt::PreferredSize: -
1434 if (QLayout *l = d->widget->layout())
partially evaluated: QLayout *l = d->widget->layout()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1435 sh = l->sizeHint();
never executed: sh = l->sizeHint();
0
1436 else -
1437 sh = d->widget->sizeHint();
executed: sh = d->widget->sizeHint();
Execution Count:15
15
1438 break;
executed: break;
Execution Count:15
15
1439 case Qt::MinimumSize: -
1440 if (QLayout *l = d->widget->layout())
partially evaluated: QLayout *l = d->widget->layout()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1441 sh = l->minimumSize();
never executed: sh = l->minimumSize();
0
1442 else -
1443 sh = d->widget->minimumSizeHint();
executed: sh = d->widget->minimumSizeHint();
Execution Count:15
15
1444 break;
executed: break;
Execution Count:15
15
1445 case Qt::MaximumSize: -
1446 if (QLayout *l = d->widget->layout())
partially evaluated: QLayout *l = d->widget->layout()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1447 sh = l->maximumSize();
never executed: sh = l->maximumSize();
0
1448 else -
1449 sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
executed: sh = QSizeF(((1<<24)-1), ((1<<24)-1));
Execution Count:6
6
1450 break;
executed: break;
Execution Count:6
6
1451 case Qt::MinimumDescent: -
1452 sh = constraint;
never executed (the execution status of this line is deduced): sh = constraint;
-
1453 break;
never executed: break;
0
1454 default: -
1455 break;
never executed: break;
0
1456 } -
1457 return sh;
executed: return sh;
Execution Count:36
36
1458} -
1459 -
1460/*! -
1461 \reimp -
1462*/ -
1463void QGraphicsProxyWidget::resizeEvent(QGraphicsSceneResizeEvent *event) -
1464{ -
1465 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1466 if (d->widget) {
partially evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
1467 if (d->sizeChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
evaluated: d->sizeChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:10
3-10
1468 d->widget->resize(event->newSize().toSize());
executed: d->widget->resize(event->newSize().toSize());
Execution Count:3
3
1469 }
executed: }
Execution Count:13
13
1470 QGraphicsWidget::resizeEvent(event);
executed (the execution status of this line is deduced): QGraphicsWidget::resizeEvent(event);
-
1471}
executed: }
Execution Count:13
13
1472 -
1473/*! -
1474 \reimp -
1475*/ -
1476void QGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -
1477{ -
1478 Q_D(QGraphicsProxyWidget);
executed (the execution status of this line is deduced): QGraphicsProxyWidgetPrivate * const d = d_func();
-
1479 Q_UNUSED(widget);
executed (the execution status of this line is deduced): (void)widget;;
-
1480 if (!d->widget || !d->widget->isVisible())
partially evaluated: !d->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: !d->widget->isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1481 return;
never executed: return;
0
1482 -
1483 // Filter out repaints on the window frame. -
1484 const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
executed (the execution status of this line is deduced): const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
-
1485 if (exposedWidgetRect.isEmpty())
partially evaluated: exposedWidgetRect.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1486 return;
never executed: return;
0
1487 -
1488 d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
executed (the execution status of this line is deduced): d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
-
1489}
executed: }
Execution Count:8
8
1490 -
1491/*! -
1492 \reimp -
1493*/ -
1494int QGraphicsProxyWidget::type() const -
1495{ -
1496 return Type;
never executed: return Type;
0
1497} -
1498 -
1499/*! -
1500 \since 4.5 -
1501 -
1502 Creates a proxy widget for the given \a child of the widget -
1503 contained in this proxy. -
1504 -
1505 This function makes it possible to acquire proxies for -
1506 non top-level widgets. For instance, you can embed a dialog, -
1507 and then transform only one of its widgets. -
1508 -
1509 If the widget is already embedded, return the existing proxy widget. -
1510 -
1511 \sa newProxyWidget(), QGraphicsScene::addWidget() -
1512*/ -
1513QGraphicsProxyWidget *QGraphicsProxyWidget::createProxyForChildWidget(QWidget *child) -
1514{ -
1515 QGraphicsProxyWidget *proxy = child->graphicsProxyWidget();
never executed (the execution status of this line is deduced): QGraphicsProxyWidget *proxy = child->graphicsProxyWidget();
-
1516 if (proxy)
never evaluated: proxy
0
1517 return proxy;
never executed: return proxy;
0
1518 if (!child->parentWidget()) {
never evaluated: !child->parentWidget()
0
1519 qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsproxywidget.cpp", 1519, __PRETTY_FUNCTION__).warning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
-
1520 return 0;
never executed: return 0;
0
1521 } -
1522 -
1523 QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
never executed (the execution status of this line is deduced): QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
-
1524 if (!parentProxy)
never evaluated: !parentProxy
0
1525 return 0;
never executed: return 0;
0
1526 -
1527 if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
never evaluated: !QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection, QReturnArgument<QGraphicsProxyWidget* >("QGraphicsProxyWidget*", proxy), QArgument<const QWidget* >("const QWidget*", child))
0
1528 Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child)))
never evaluated: !QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection, QReturnArgument<QGraphicsProxyWidget* >("QGraphicsProxyWidget*", proxy), QArgument<const QWidget* >("const QWidget*", child))
0
1529 return 0;
never executed: return 0;
0
1530 proxy->setParent(parentProxy);
never executed (the execution status of this line is deduced): proxy->setParent(parentProxy);
-
1531 proxy->setWidget(child);
never executed (the execution status of this line is deduced): proxy->setWidget(child);
-
1532 return proxy;
never executed: return proxy;
0
1533} -
1534 -
1535/*! -
1536 \fn QGraphicsProxyWidget *QGraphicsProxyWidget::newProxyWidget(const QWidget *child) -
1537 \since 4.5 -
1538 -
1539 Creates a proxy widget for the given \a child of the widget contained in this -
1540 proxy. -
1541 -
1542 You should not call this function directly; use -
1543 QGraphicsProxyWidget::createProxyForChildWidget() instead. -
1544 -
1545 This function is a fake virtual slot that you can reimplement in -
1546 your subclass in order to control how new proxy widgets are -
1547 created. The default implementation returns a proxy created with -
1548 the QGraphicsProxyWidget() constructor with this proxy widget as -
1549 the parent. -
1550 -
1551 \sa createProxyForChildWidget() -
1552*/ -
1553QGraphicsProxyWidget *QGraphicsProxyWidget::newProxyWidget(const QWidget *) -
1554{ -
1555 return new QGraphicsProxyWidget(this);
never executed: return new QGraphicsProxyWidget(this);
0
1556} -
1557 -
1558 -
1559 -
1560QT_END_NAMESPACE -
1561 -
1562#include "moc_qgraphicsproxywidget.cpp" -
1563 -
1564#endif //QT_NO_GRAPHICSVIEW -
1565 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial