OpenCoverage

qgraphicswidget.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicswidget.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets 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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qglobal.h"-
41-
42#ifndef QT_NO_GRAPHICSVIEW-
43-
44#include "qgraphicswidget.h"-
45#include "qgraphicswidget_p.h"-
46#include "qgraphicslayout.h"-
47#include "qgraphicslayout_p.h"-
48#include "qgraphicsscene.h"-
49#include "qgraphicssceneevent.h"-
50-
51#ifndef QT_NO_ACTION-
52#include <private/qaction_p.h>-
53#endif-
54#include <private/qapplication_p.h>-
55#include <private/qgraphicsscene_p.h>-
56#ifndef QT_NO_SHORTCUT-
57#include <private/qshortcutmap_p.h>-
58#endif-
59#include <QtCore/qmutex.h>-
60#include <QtWidgets/qapplication.h>-
61#include <QtWidgets/qgraphicsview.h>-
62#include <QtWidgets/qgraphicsproxywidget.h>-
63#include <QtGui/qpalette.h>-
64#include <QtWidgets/qstyleoption.h>-
65-
66#include <qdebug.h>-
67-
68QT_BEGIN_NAMESPACE-
69-
70/*!-
71 \class QGraphicsWidget-
72 \brief The QGraphicsWidget class is the base class for all widget-
73 items in a QGraphicsScene.-
74 \since 4.4-
75 \ingroup graphicsview-api-
76 \inmodule QtWidgets-
77-
78 QGraphicsWidget is an extended base item that provides extra functionality-
79 over QGraphicsItem. It is similar to QWidget in many ways:-
80-
81 \list-
82 \li Provides a \l palette, a \l font and a \l style().-
83 \li Has a defined geometry().-
84 \li Supports layouts with setLayout() and layout().-
85 \li Supports shortcuts and actions with grabShortcut() and insertAction()-
86 \endlist-
87-
88 Unlike QGraphicsItem, QGraphicsWidget is not an abstract class; you can-
89 create instances of a QGraphicsWidget without having to subclass it.-
90 This approach is useful for widgets that only serve the purpose of-
91 organizing child widgets into a layout.-
92-
93 QGraphicsWidget can be used as a base item for your own custom item if-
94 you require advanced input focus handling, e.g., tab focus and activation, or-
95 layouts.-
96-
97 Since QGraphicsWidget resembles QWidget and has similar API, it is-
98 easier to port a widget from QWidget to QGraphicsWidget, instead of-
99 QGraphicsItem.-
100-
101 \note QWidget-based widgets can be directly embedded into a-
102 QGraphicsScene using QGraphicsProxyWidget.-
103-
104 Noticeable differences between QGraphicsWidget and QWidget are:-
105-
106 \table-
107 \header \li QGraphicsWidget-
108 \li QWidget-
109 \row \li Coordinates and geometry are defined with qreals (doubles or-
110 floats, depending on the platform).-
111 \li QWidget uses integer geometry (QPoint, QRect).-
112 \row \li The widget is already visible by default; you do not have to-
113 call show() to display the widget.-
114 \li QWidget is hidden by default until you call show().-
115 \row \li A subset of widget attributes are supported.-
116 \li All widget attributes are supported.-
117 \row \li A top-level item's style defaults to QGraphicsScene::style-
118 \li A top-level widget's style defaults to QApplication::style-
119 \row \li Graphics View provides a custom drag and drop framework, different-
120 from QWidget.-
121 \li Standard drag and drop framework.-
122 \row \li Widget items do not support modality.-
123 \li Full modality support.-
124 \endtable-
125-
126 QGraphicsWidget supports a subset of Qt's widget attributes,-
127 (Qt::WidgetAttribute), as shown in the table below. Any attributes not-
128 listed in this table are unsupported, or otherwise unused.-
129-
130 \table-
131 \header \li Widget Attribute \li Usage-
132 \row \li Qt::WA_SetLayoutDirection-
133 \li Set by setLayoutDirection(), cleared by-
134 unsetLayoutDirection(). You can test this attribute to-
135 check if the widget has been explicitly assigned a-
136 \l{QGraphicsWidget::layoutDirection()}-
137 {layoutDirection}. If the attribute is not set, the-
138 \l{QGraphicsWidget::layoutDirection()}-
139 {layoutDirection()} is inherited.-
140 \row \li Qt::WA_RightToLeft-
141 \li Toggled by setLayoutDirection(). Inherited from the-
142 parent/scene. If set, the widget's layout will order-
143 horizontally arranged widgets from right to left.-
144 \row \li Qt::WA_SetStyle-
145 \li Set and cleared by setStyle(). If this attribute is-
146 set, the widget has been explicitly assigned a style.-
147 If it is unset, the widget will use the scene's or the-
148 application's style.-
149 \row \li Qt::WA_Resized-
150 \li Set by setGeometry() and resize().-
151 \row \li Qt::WA_SetPalette-
152 \li Set by setPalette().-
153 \row \li Qt::WA_SetFont-
154 \li Set by setFont().-
155 \row \li Qt::WA_WindowPropagation-
156 \li Enables propagation to window widgets.-
157 \endtable-
158-
159 Although QGraphicsWidget inherits from both QObject and QGraphicsItem,-
160 you should use the functions provided by QGraphicsItem, \e not QObject, to-
161 manage the relationships between parent and child items. These functions-
162 control the stacking order of items as well as their ownership.-
163-
164 \note The QObject::parent() should always return 0 for QGraphicsWidgets,-
165 but this policy is not strictly defined.-
166-
167 \sa QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}-
168*/-
169-
170/*!-
171 Constructs a QGraphicsWidget instance. The optional \a parent argument is-
172 passed to QGraphicsItem's constructor. The optional \a wFlags argument-
173 specifies the widget's window flags (e.g., whether the widget should be a-
174 window, a tool, a popup, etc).-
175*/-
176QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)-
177 : QGraphicsObject(*new QGraphicsWidgetPrivate, 0), QGraphicsLayoutItem(0, false)-
178{-
179 Q_D(QGraphicsWidget);-
180 d->init(parent, wFlags);-
181}
never executed: end of block
0
182-
183/*!-
184 \internal-
185-
186 Constructs a new QGraphicsWidget, using \a dd as parent.-
187*/-
188QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags)-
189 : QGraphicsObject(dd, 0), QGraphicsLayoutItem(0, false)-
190{-
191 Q_D(QGraphicsWidget);-
192 d->init(parent, wFlags);-
193}
never executed: end of block
0
194-
195/*-
196 \internal-
197 \class QGraphicsWidgetStyles-
198-
199 We use this thread-safe class to maintain a hash of styles for widgets-
200 styles. Note that QApplication::style() itself isn't thread-safe, QStyle-
201 isn't thread-safe, and we don't have a thread-safe factory for creating-
202 the default style, nor cloning a style.-
203*/-
204class QGraphicsWidgetStyles-
205{-
206public:-
207 QStyle *styleForWidget(const QGraphicsWidget *widget) const-
208 {-
209 QMutexLocker locker(&mutex);-
210 return styles.value(widget, 0);
never executed: return styles.value(widget, 0);
0
211 }-
212-
213 void setStyleForWidget(QGraphicsWidget *widget, QStyle *style)-
214 {-
215 QMutexLocker locker(&mutex);-
216 if (style)
styleDescription
TRUEnever evaluated
FALSEnever evaluated
0
217 styles[widget] = style;
never executed: styles[widget] = style;
0
218 else-
219 styles.remove(widget);
never executed: styles.remove(widget);
0
220 }-
221-
222private:-
223 QHash<const QGraphicsWidget *, QStyle *> styles;-
224 mutable QMutex mutex;-
225};-
226Q_GLOBAL_STATIC(QGraphicsWidgetStyles, widgetStyles)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
227-
228/*!-
229 Destroys the QGraphicsWidget instance.-
230*/-
231QGraphicsWidget::~QGraphicsWidget()-
232{-
233 Q_D(QGraphicsWidget);-
234#ifndef QT_NO_ACTION-
235 // Remove all actions from this widget-
236 for (int i = 0; i < d->actions.size(); ++i) {
i < d->actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
237 QActionPrivate *apriv = d->actions.at(i)->d_func();-
238 apriv->graphicsWidgets.removeAll(this);-
239 }
never executed: end of block
0
240 d->actions.clear();-
241#endif-
242-
243 if (QGraphicsScene *scn = scene()) {
QGraphicsScene *scn = scene()Description
TRUEnever evaluated
FALSEnever evaluated
0
244 QGraphicsScenePrivate *sceneD = scn->d_func();-
245 if (sceneD->tabFocusFirst == this)
sceneD->tabFocusFirst == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
246 sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
never executed: sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
d->focusNext == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
247 }
never executed: end of block
0
248 d->focusPrev->d_func()->focusNext = d->focusNext;-
249 d->focusNext->d_func()->focusPrev = d->focusPrev;-
250-
251 // Play it really safe-
252 d->focusNext = this;-
253 d->focusPrev = this;-
254-
255 clearFocus();-
256-
257 //we check if we have a layout previously-
258 if (d->layout) {
d->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
259 QGraphicsLayout *temp = d->layout;-
260 const auto items = childItems();-
261 for (QGraphicsItem *item : items) {-
262 // In case of a custom layout which doesn't remove and delete items, we ensure that-
263 // the parent layout item does not point to the deleted layout. This code is here to-
264 // avoid regression from 4.4 to 4.5, because according to 4.5 docs it is not really needed.-
265 if (item->isWidget()) {
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
266 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);-
267 if (widget->parentLayoutItem() == d->layout)
widget->parent...) == d->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
268 widget->setParentLayoutItem(0);
never executed: widget->setParentLayoutItem(0);
0
269 }
never executed: end of block
0
270 }
never executed: end of block
0
271 d->layout = 0;-
272 delete temp;-
273 }
never executed: end of block
0
274-
275 // Remove this graphics widget from widgetStyles-
276 widgetStyles()->setStyleForWidget(this, 0);-
277-
278 // Unset the parent here, when we're still a QGraphicsWidget.-
279 // It is otherwise done in ~QGraphicsItem() where we'd be-
280 // calling QGraphicsWidget members on an ex-QGraphicsWidget object-
281 setParentItem(Q_NULLPTR);-
282}
never executed: end of block
0
283-
284/*!-
285 \property QGraphicsWidget::size-
286 \brief the size of the widget-
287-
288 Calling resize() resizes the widget to a \a size bounded by minimumSize()-
289 and maximumSize(). This property only affects the widget's width and-
290 height (e.g., its right and bottom edges); the widget's position and-
291 top-left corner remains unaffected.-
292-
293 Resizing a widget triggers the widget to immediately receive a-
294 \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} event with the-
295 widget's old and new size. If the widget has a layout assigned when this-
296 event arrives, the layout will be activated and it will automatically-
297 update any child widgets's geometry.-
298-
299 This property does not affect any layout of the parent widget. If the-
300 widget itself is managed by a parent layout; e.g., it has a parent widget-
301 with a layout assigned, that layout will not activate.-
302-
303 By default, this property contains a size with zero width and height.-
304-
305 \sa setGeometry(), QGraphicsSceneResizeEvent, QGraphicsLayout-
306*/-
307QSizeF QGraphicsWidget::size() const-
308{-
309 return QGraphicsLayoutItem::geometry().size();
never executed: return QGraphicsLayoutItem::geometry().size();
0
310}-
311-
312void QGraphicsWidget::resize(const QSizeF &size)-
313{-
314 setGeometry(QRectF(pos(), size));-
315}
never executed: end of block
0
316-
317/*!-
318 \fn void QGraphicsWidget::resize(qreal w, qreal h)-
319 \overload-
320-
321 Constructs a resize with the given \c width (\a w) and \c height (\a h).-
322 This convenience function is equivalent to calling resize(QSizeF(w, h)).-
323-
324 \sa setGeometry(), setTransform()-
325*/-
326-
327/*!-
328 \property QGraphicsWidget::sizePolicy-
329 \brief the size policy for the widget-
330 \sa sizePolicy(), setSizePolicy(), QWidget::sizePolicy()-
331*/-
332-
333/*!-
334 \fn QGraphicsWidget::geometryChanged()-
335-
336 This signal gets emitted whenever the geometry is changed in setGeometry().-
337*/-
338-
339/*!-
340 \property QGraphicsWidget::geometry-
341 \brief the geometry of the widget-
342-
343 Sets the item's geometry to \a rect. The item's position and size are-
344 modified as a result of calling this function. The item is first moved,-
345 then resized.-
346-
347 A side effect of calling this function is that the widget will receive-
348 a move event and a resize event. Also, if the widget has a layout-
349 assigned, the layout will activate.-
350-
351 \sa geometry(), resize()-
352*/-
353void QGraphicsWidget::setGeometry(const QRectF &rect)-
354{-
355 QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();-
356 QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();-
357 QRectF newGeom;-
358 QPointF oldPos = d->geom.topLeft();-
359 if (!wd->inSetPos) {
!wd->inSetPosDescription
TRUEnever evaluated
FALSEnever evaluated
0
360 setAttribute(Qt::WA_Resized);-
361 newGeom = rect;-
362 newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))-
363 .boundedTo(effectiveSizeHint(Qt::MaximumSize)));-
364-
365 if (newGeom == d->geom) {
newGeom == d->geomDescription
TRUEnever evaluated
FALSEnever evaluated
0
366 goto relayoutChildrenAndReturn;
never executed: goto relayoutChildrenAndReturn;
0
367 }-
368-
369 // setPos triggers ItemPositionChange, which can adjust position-
370 wd->inSetGeometry = 1;-
371 setPos(newGeom.topLeft());-
372 wd->inSetGeometry = 0;-
373 newGeom.moveTopLeft(pos());-
374-
375 if (newGeom == d->geom) {
newGeom == d->geomDescription
TRUEnever evaluated
FALSEnever evaluated
0
376 goto relayoutChildrenAndReturn;
never executed: goto relayoutChildrenAndReturn;
0
377 }-
378-
379 // Update and prepare to change the geometry (remove from index) if the size has changed.-
380 if (wd->scene) {
wd->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
381 if (rect.topLeft() == d->geom.topLeft()) {
rect.topLeft()...geom.topLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
382 prepareGeometryChange();-
383 }
never executed: end of block
0
384 }
never executed: end of block
0
385 }
never executed: end of block
0
386-
387 // Update the layout item geometry-
388 {-
389 bool moved = oldPos != pos();-
390 if (moved) {
movedDescription
TRUEnever evaluated
FALSEnever evaluated
0
391 // Send move event.-
392 QGraphicsSceneMoveEvent event;-
393 event.setOldPos(oldPos);-
394 event.setNewPos(pos());-
395 QApplication::sendEvent(this, &event);-
396 if (wd->inSetPos) {
wd->inSetPosDescription
TRUEnever evaluated
FALSEnever evaluated
0
397 //set the new pos-
398 d->geom.moveTopLeft(pos());-
399 emit geometryChanged();-
400 goto relayoutChildrenAndReturn;
never executed: goto relayoutChildrenAndReturn;
0
401 }-
402 }
never executed: end of block
0
403 QSizeF oldSize = size();-
404 QGraphicsLayoutItem::setGeometry(newGeom);-
405 // Send resize event-
406 bool resized = newGeom.size() != oldSize;-
407 if (resized) {
resizedDescription
TRUEnever evaluated
FALSEnever evaluated
0
408 QGraphicsSceneResizeEvent re;-
409 re.setOldSize(oldSize);-
410 re.setNewSize(newGeom.size());-
411 if (oldSize.width() != newGeom.size().width())
oldSize.width(...size().width()Description
TRUEnever evaluated
FALSEnever evaluated
0
412 emit widthChanged();
never executed: widthChanged();
0
413 if (oldSize.height() != newGeom.size().height())
oldSize.height...ize().height()Description
TRUEnever evaluated
FALSEnever evaluated
0
414 emit heightChanged();
never executed: heightChanged();
0
415 QGraphicsLayout *lay = wd->layout;-
416 if (QGraphicsLayout::instantInvalidatePropagation()) {
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
0
417 if (!lay || lay->isActivated()) {
!layDescription
TRUEnever evaluated
FALSEnever evaluated
lay->isActivated()Description
TRUEnever evaluated
FALSEnever evaluated
0
418 QApplication::sendEvent(this, &re);-
419 }
never executed: end of block
0
420 } else {
never executed: end of block
0
421 QApplication::sendEvent(this, &re);-
422 }
never executed: end of block
0
423 }-
424 }-
425-
426 emit geometryChanged();-
427relayoutChildrenAndReturn:
code before this statement never executed: relayoutChildrenAndReturn:
0
428 if (QGraphicsLayout::instantInvalidatePropagation()) {
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
0
429 if (QGraphicsLayout *lay = wd->layout) {
QGraphicsLayou...y = wd->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
430 if (!lay->isActivated()) {
!lay->isActivated()Description
TRUEnever evaluated
FALSEnever evaluated
0
431 QEvent layoutRequest(QEvent::LayoutRequest);-
432 QApplication::sendEvent(this, &layoutRequest);-
433 }
never executed: end of block
0
434 }
never executed: end of block
0
435 }
never executed: end of block
0
436}
never executed: end of block
0
437-
438/*!-
439 \fn QRectF QGraphicsWidget::rect() const-
440-
441 Returns the item's local rect as a QRectF. This function is equivalent-
442 to QRectF(QPointF(), size()).-
443-
444 \sa setGeometry(), resize()-
445*/-
446-
447/*!-
448 \fn void QGraphicsWidget::setGeometry(qreal x, qreal y, qreal w, qreal h)-
449-
450 This convenience function is equivalent to calling setGeometry(QRectF(-
451 \a x, \a y, \a w, \a h)).-
452-
453 \sa geometry(), resize()-
454*/-
455-
456/*!-
457 \property QGraphicsWidget::minimumSize-
458 \brief the minimum size of the widget-
459-
460 \sa setMinimumSize(), minimumSize(), preferredSize, maximumSize-
461*/-
462-
463/*!-
464 \property QGraphicsWidget::preferredSize-
465 \brief the preferred size of the widget-
466-
467 \sa setPreferredSize(), preferredSize(), minimumSize, maximumSize-
468*/-
469-
470/*!-
471 \property QGraphicsWidget::maximumSize-
472 \brief the maximum size of the widget-
473-
474 \sa setMaximumSize(), maximumSize(), minimumSize, preferredSize-
475*/-
476-
477/*!-
478 Sets the widget's contents margins to \a left, \a top, \a right and \a-
479 bottom.-
480-
481 Contents margins are used by the assigned layout to define the placement-
482 of subwidgets and layouts. Margins are particularly useful for widgets-
483 that constrain subwidgets to only a section of its own geometry. For-
484 example, a group box with a layout will place subwidgets inside its frame,-
485 but below the title.-
486-
487 Changing a widget's contents margins will always trigger an update(), and-
488 any assigned layout will be activated automatically. The widget will then-
489 receive a \l{QEvent::ContentsRectChange}{ContentsRectChange} event.-
490-
491 \sa getContentsMargins(), setGeometry()-
492*/-
493void QGraphicsWidget::setContentsMargins(qreal left, qreal top, qreal right, qreal bottom)-
494{-
495 Q_D(QGraphicsWidget);-
496-
497 if (!d->margins && left == 0 && top == 0 && right == 0 && bottom == 0)
!d->marginsDescription
TRUEnever evaluated
FALSEnever evaluated
left == 0Description
TRUEnever evaluated
FALSEnever evaluated
top == 0Description
TRUEnever evaluated
FALSEnever evaluated
right == 0Description
TRUEnever evaluated
FALSEnever evaluated
bottom == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
498 return;
never executed: return;
0
499 d->ensureMargins();-
500 if (left == d->margins[d->Left]
left == d->margins[d->Left]Description
TRUEnever evaluated
FALSEnever evaluated
0
501 && top == d->margins[d->Top]
top == d->margins[d->Top]Description
TRUEnever evaluated
FALSEnever evaluated
0
502 && right == d->margins[d->Right]
right == d->margins[d->Right]Description
TRUEnever evaluated
FALSEnever evaluated
0
503 && bottom == d->margins[d->Bottom])
bottom == d->m...ins[d->Bottom]Description
TRUEnever evaluated
FALSEnever evaluated
0
504 return;
never executed: return;
0
505-
506 d->margins[d->Left] = left;-
507 d->margins[d->Top] = top;-
508 d->margins[d->Right] = right;-
509 d->margins[d->Bottom] = bottom;-
510-
511 if (QGraphicsLayout *l = d->layout)
QGraphicsLayout *l = d->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
512 l->invalidate();
never executed: l->invalidate();
0
513 else-
514 updateGeometry();
never executed: updateGeometry();
0
515-
516 QEvent e(QEvent::ContentsRectChange);-
517 QApplication::sendEvent(this, &e);-
518}
never executed: end of block
0
519-
520/*!-
521 Gets the widget's contents margins. The margins are stored in \a left, \a-
522 top, \a right and \a bottom, as pointers to qreals. Each argument can-
523 be \e {omitted} by passing 0.-
524-
525 \sa setContentsMargins()-
526*/-
527void QGraphicsWidget::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const-
528{-
529 Q_D(const QGraphicsWidget);-
530 if (left || top || right || bottom)
leftDescription
TRUEnever evaluated
FALSEnever evaluated
topDescription
TRUEnever evaluated
FALSEnever evaluated
rightDescription
TRUEnever evaluated
FALSEnever evaluated
bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
531 d->ensureMargins();
never executed: d->ensureMargins();
0
532 if (left)
leftDescription
TRUEnever evaluated
FALSEnever evaluated
0
533 *left = d->margins[d->Left];
never executed: *left = d->margins[d->Left];
0
534 if (top)
topDescription
TRUEnever evaluated
FALSEnever evaluated
0
535 *top = d->margins[d->Top];
never executed: *top = d->margins[d->Top];
0
536 if (right)
rightDescription
TRUEnever evaluated
FALSEnever evaluated
0
537 *right = d->margins[d->Right];
never executed: *right = d->margins[d->Right];
0
538 if (bottom)
bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
539 *bottom = d->margins[d->Bottom];
never executed: *bottom = d->margins[d->Bottom];
0
540}
never executed: end of block
0
541-
542/*!-
543 Sets the widget's window frame margins to \a left, \a top, \a right and-
544 \a bottom. The default frame margins are provided by the style, and they-
545 depend on the current window flags.-
546-
547 If you would like to draw your own window decoration, you can set your-
548 own frame margins to override the default margins.-
549-
550 \sa unsetWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()-
551*/-
552void QGraphicsWidget::setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom)-
553{-
554 Q_D(QGraphicsWidget);-
555-
556 if (!d->windowFrameMargins && left == 0 && top == 0 && right == 0 && bottom == 0)
!d->windowFrameMarginsDescription
TRUEnever evaluated
FALSEnever evaluated
left == 0Description
TRUEnever evaluated
FALSEnever evaluated
top == 0Description
TRUEnever evaluated
FALSEnever evaluated
right == 0Description
TRUEnever evaluated
FALSEnever evaluated
bottom == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
557 return;
never executed: return;
0
558 d->ensureWindowFrameMargins();-
559 bool unchanged =-
560 d->windowFrameMargins[d->Left] == left
d->windowFrame...>Left] == leftDescription
TRUEnever evaluated
FALSEnever evaluated
0
561 && d->windowFrameMargins[d->Top] == top
d->windowFrame...d->Top] == topDescription
TRUEnever evaluated
FALSEnever evaluated
0
562 && d->windowFrameMargins[d->Right] == right
d->windowFrame...ight] == rightDescription
TRUEnever evaluated
FALSEnever evaluated
0
563 && d->windowFrameMargins[d->Bottom] == bottom;
d->windowFrame...tom] == bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
564 if (d->setWindowFrameMargins && unchanged)
d->setWindowFrameMarginsDescription
TRUEnever evaluated
FALSEnever evaluated
unchangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
565 return;
never executed: return;
0
566 if (!unchanged)
!unchangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
567 prepareGeometryChange();
never executed: prepareGeometryChange();
0
568 d->windowFrameMargins[d->Left] = left;-
569 d->windowFrameMargins[d->Top] = top;-
570 d->windowFrameMargins[d->Right] = right;-
571 d->windowFrameMargins[d->Bottom] = bottom;-
572 d->setWindowFrameMargins = true;-
573}
never executed: end of block
0
574-
575/*!-
576 Gets the widget's window frame margins. The margins are stored in \a left,-
577 \a top, \a right and \a bottom as pointers to qreals. Each argument can-
578 be \e {omitted} by passing 0.-
579-
580 \sa setWindowFrameMargins(), windowFrameRect()-
581*/-
582void QGraphicsWidget::getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const-
583{-
584 Q_D(const QGraphicsWidget);-
585 if (left || top || right || bottom)
leftDescription
TRUEnever evaluated
FALSEnever evaluated
topDescription
TRUEnever evaluated
FALSEnever evaluated
rightDescription
TRUEnever evaluated
FALSEnever evaluated
bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
586 d->ensureWindowFrameMargins();
never executed: d->ensureWindowFrameMargins();
0
587 if (left)
leftDescription
TRUEnever evaluated
FALSEnever evaluated
0
588 *left = d->windowFrameMargins[d->Left];
never executed: *left = d->windowFrameMargins[d->Left];
0
589 if (top)
topDescription
TRUEnever evaluated
FALSEnever evaluated
0
590 *top = d->windowFrameMargins[d->Top];
never executed: *top = d->windowFrameMargins[d->Top];
0
591 if (right)
rightDescription
TRUEnever evaluated
FALSEnever evaluated
0
592 *right = d->windowFrameMargins[d->Right];
never executed: *right = d->windowFrameMargins[d->Right];
0
593 if (bottom)
bottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
594 *bottom = d->windowFrameMargins[d->Bottom];
never executed: *bottom = d->windowFrameMargins[d->Bottom];
0
595}
never executed: end of block
0
596-
597/*!-
598 Resets the window frame margins to the default value, provided by the style.-
599-
600 \sa setWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()-
601*/-
602void QGraphicsWidget::unsetWindowFrameMargins()-
603{-
604 Q_D(QGraphicsWidget);-
605 if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
(d->windowFlags & Qt::Window)Description
TRUEnever evaluated
FALSEnever evaluated
(d->windowFlag...) != Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
606 (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
(d->windowFlag...!= Qt::ToolTipDescription
TRUEnever evaluated
FALSEnever evaluated
!(d->windowFla...essWindowHint)Description
TRUEnever evaluated
FALSEnever evaluated
0
607 QStyleOptionTitleBar bar;-
608 d->initStyleOptionTitleBar(&bar);-
609 QStyle *style = this->style();-
610 qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);-
611 qreal titleBarHeight = d->titleBarHeight(bar);-
612 setWindowFrameMargins(margin, titleBarHeight, margin, margin);-
613 } else {
never executed: end of block
0
614 setWindowFrameMargins(0, 0, 0, 0);-
615 }
never executed: end of block
0
616 d->setWindowFrameMargins = false;-
617}
never executed: end of block
0
618-
619/*!-
620 Returns the widget's geometry in parent coordinates including any window-
621 frame.-
622-
623 \sa windowFrameRect(), getWindowFrameMargins(), setWindowFrameMargins()-
624*/-
625QRectF QGraphicsWidget::windowFrameGeometry() const-
626{-
627 Q_D(const QGraphicsWidget);-
628 return d->windowFrameMargins
never executed: return d->windowFrameMargins ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : geometry();
0
629 ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
never executed: return d->windowFrameMargins ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : geometry();
0
630 d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
never executed: return d->windowFrameMargins ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : geometry();
0
631 : geometry();
never executed: return d->windowFrameMargins ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : geometry();
0
632}-
633-
634/*!-
635 Returns the widget's local rect including any window frame.-
636-
637 \sa windowFrameGeometry(), getWindowFrameMargins(), setWindowFrameMargins()-
638*/-
639QRectF QGraphicsWidget::windowFrameRect() const-
640{-
641 Q_D(const QGraphicsWidget);-
642 return d->windowFrameMargins
never executed: return d->windowFrameMargins ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : rect();
0
643 ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
never executed: return d->windowFrameMargins ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : rect();
0
644 d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
never executed: return d->windowFrameMargins ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : rect();
0
645 : rect();
never executed: return d->windowFrameMargins ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) : rect();
0
646}-
647-
648/*!-
649 Populates a style option object for this widget based on its current-
650 state, and stores the output in \a option. The default implementation-
651 populates \a option with the following properties.-
652-
653 \table-
654 \header-
655 \li Style Option Property-
656 \li Value-
657 \row-
658 \li state & QStyle::State_Enabled-
659 \li Corresponds to QGraphicsItem::isEnabled().-
660 \row-
661 \li state & QStyle::State_HasFocus-
662 \li Corresponds to QGraphicsItem::hasFocus().-
663 \row-
664 \li state & QStyle::State_MouseOver-
665 \li Corresponds to QGraphicsItem::isUnderMouse().-
666 \row-
667 \li direction-
668 \li Corresponds to QGraphicsWidget::layoutDirection().-
669 \row-
670 \li rect-
671 \li Corresponds to QGraphicsWidget::rect().toRect().-
672 \row-
673 \li palette-
674 \li Corresponds to QGraphicsWidget::palette().-
675 \row-
676 \li fontMetrics-
677 \li Corresponds to QFontMetrics(QGraphicsWidget::font()).-
678 \endtable-
679-
680 Subclasses of QGraphicsWidget should call the base implementation, and-
681 then test the type of \a option using qstyleoption_cast<>() or test-
682 QStyleOption::Type before storing widget-specific options.-
683-
684 For example:-
685-
686 \snippet code/src_gui_graphicsview_qgraphicswidget.cpp 0-
687-
688 \sa QStyleOption::initFrom()-
689*/-
690void QGraphicsWidget::initStyleOption(QStyleOption *option) const-
691{-
692 Q_ASSERT(option);-
693-
694 option->state = QStyle::State_None;-
695 if (isEnabled())
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
696 option->state |= QStyle::State_Enabled;
never executed: option->state |= QStyle::State_Enabled;
0
697 if (hasFocus())
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
698 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
699 // if (window->testAttribute(Qt::WA_KeyboardFocusChange)) // ### Window-
700 // option->state |= QStyle::State_KeyboardFocusChange;-
701 if (isUnderMouse())
isUnderMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
702 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
703 if (QGraphicsWidget *w = window()) {
QGraphicsWidget *w = window()Description
TRUEnever evaluated
FALSEnever evaluated
0
704 if (w->isActiveWindow())
w->isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
705 option->state |= QStyle::State_Active;
never executed: option->state |= QStyle::State_Active;
0
706 }
never executed: end of block
0
707 if (isWindow())
isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
708 option->state |= QStyle::State_Window;
never executed: option->state |= QStyle::State_Window;
0
709 /*-
710 ###-
711#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
712 extern bool qt_mac_can_clickThrough(const QGraphicsWidget *w); //qwidget_mac.cpp-
713 if (!(option->state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))-
714 option->state &= ~QStyle::State_Enabled;-
715-
716 switch (QMacStyle::widgetSizePolicy(widget)) {-
717 case QMacStyle::SizeSmall:-
718 option->state |= QStyle::State_Small;-
719 break;-
720 case QMacStyle::SizeMini:-
721 option->state |= QStyle::State_Mini;-
722 break;-
723 default:-
724 ;-
725 }-
726#endif-
727#ifdef QT_KEYPAD_NAVIGATION-
728 if (widget->hasEditFocus())-
729 state |= QStyle::State_HasEditFocus;-
730#endif-
731 */-
732 option->direction = layoutDirection();-
733 option->rect = rect().toRect(); // ### truncation!-
734 option->palette = palette();-
735 if (!isEnabled()) {
!isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
736 option->palette.setCurrentColorGroup(QPalette::Disabled);-
737 } else if (isActiveWindow()) {
never executed: end of block
isActiveWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
738 option->palette.setCurrentColorGroup(QPalette::Active);-
739 } else {
never executed: end of block
0
740 option->palette.setCurrentColorGroup(QPalette::Inactive);-
741 }
never executed: end of block
0
742 option->fontMetrics = QFontMetrics(font());-
743 option->styleObject = const_cast<QGraphicsWidget *>(this);-
744}
never executed: end of block
0
745-
746/*!-
747 \reimp-
748*/-
749QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const-
750{-
751 Q_D(const QGraphicsWidget);-
752 QSizeF sh;-
753 if (d->layout) {
d->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
754 QSizeF marginSize(0,0);-
755 if (d->margins) {
d->marginsDescription
TRUEnever evaluated
FALSEnever evaluated
0
756 marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right],-
757 d->margins[d->Top] + d->margins[d->Bottom]);-
758 }
never executed: end of block
0
759 sh = d->layout->effectiveSizeHint(which, constraint - marginSize);-
760 sh += marginSize;-
761 } else {
never executed: end of block
0
762 switch (which) {-
763 case Qt::MinimumSize:
never executed: case Qt::MinimumSize:
0
764 sh = QSizeF(0, 0);-
765 break;
never executed: break;
0
766 case Qt::PreferredSize:
never executed: case Qt::PreferredSize:
0
767 sh = QSizeF(50, 50); //rather arbitrary-
768 break;
never executed: break;
0
769 case Qt::MaximumSize:
never executed: case Qt::MaximumSize:
0
770 sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);-
771 break;
never executed: break;
0
772 default:
never executed: default:
0
773 qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");-
774 break;
never executed: break;
0
775 }-
776 }-
777 return sh;
never executed: return sh;
0
778}-
779-
780/*!-
781 \property QGraphicsWidget::layout-
782 \brief The layout of the widget-
783-
784 Any existing layout manager is deleted before the new layout is assigned. If-
785 \a layout is 0, the widget is left without a layout. Existing subwidgets'-
786 geometries will remain unaffected.-
787-
788 QGraphicsWidget takes ownership of \a layout.-
789-
790 All widgets that are currently managed by \a layout or all of its-
791 sublayouts, are automatically reparented to this item. The layout is then-
792 invalidated, and the child widget geometries are adjusted according to-
793 this item's geometry() and contentsMargins(). Children who are not-
794 explicitly managed by \a layout remain unaffected by the layout after-
795 it has been assigned to this widget.-
796-
797 If no layout is currently managing this widget, layout() will return 0.-
798-
799*/-
800-
801/*!-
802 \fn void QGraphicsWidget::layoutChanged()-
803 This signal gets emitted whenever the layout of the item changes-
804 \internal-
805*/-
806-
807/*!-
808 Returns this widget's layout, or 0 if no layout is currently managing this-
809 widget.-
810-
811 \sa setLayout()-
812*/-
813QGraphicsLayout *QGraphicsWidget::layout() const-
814{-
815 Q_D(const QGraphicsWidget);-
816 return d->layout;
never executed: return d->layout;
0
817}-
818-
819/*!-
820 \fn void QGraphicsWidget::setLayout(QGraphicsLayout *layout)-
821-
822 Sets the layout for this widget to \a layout. Any existing layout manager-
823 is deleted before the new layout is assigned. If \a layout is 0, the-
824 widget is left without a layout. Existing subwidgets' geometries will-
825 remain unaffected.-
826-
827 All widgets that are currently managed by \a layout or all of its-
828 sublayouts, are automatically reparented to this item. The layout is then-
829 invalidated, and the child widget geometries are adjusted according to-
830 this item's geometry() and contentsMargins(). Children who are not-
831 explicitly managed by \a layout remain unaffected by the layout after-
832 it has been assigned to this widget.-
833-
834 QGraphicsWidget takes ownership of \a layout.-
835-
836 \sa layout(), QGraphicsLinearLayout::addItem(), QGraphicsLayout::invalidate()-
837*/-
838void QGraphicsWidget::setLayout(QGraphicsLayout *l)-
839{-
840 Q_D(QGraphicsWidget);-
841 if (d->layout == l)
d->layout == lDescription
TRUEnever evaluated
FALSEnever evaluated
0
842 return;
never executed: return;
0
843 d->setLayout_helper(l);-
844 if (!l)
!lDescription
TRUEnever evaluated
FALSEnever evaluated
0
845 return;
never executed: return;
0
846-
847 // Prevent assigning a layout that is already assigned to another widget.-
848 QGraphicsLayoutItem *oldParent = l->parentLayoutItem();-
849 if (oldParent && oldParent != this) {
oldParentDescription
TRUEnever evaluated
FALSEnever evaluated
oldParent != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
850 qWarning("QGraphicsWidget::setLayout: Attempting to set a layout on %s"-
851 " \"%s\", when the layout already has a parent",-
852 metaObject()->className(), qPrintable(objectName()));-
853 return;
never executed: return;
0
854 }-
855-
856 // Install and activate the layout.-
857 l->setParentLayoutItem(this);-
858 l->d_func()->reparentChildItems(this);-
859 l->invalidate();-
860 emit layoutChanged();-
861}
never executed: end of block
0
862-
863/*!-
864 Adjusts the size of the widget to its effective preferred size hint.-
865-
866 This function is called implicitly when the item is shown for the first-
867 time.-
868-
869 \sa effectiveSizeHint(), Qt::MinimumSize-
870*/-
871void QGraphicsWidget::adjustSize()-
872{-
873 QSizeF sz = effectiveSizeHint(Qt::PreferredSize);-
874 // What if sz is not valid?!-
875 if (sz.isValid())
sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
876 resize(sz);
never executed: resize(sz);
0
877}
never executed: end of block
0
878-
879/*!-
880 \property QGraphicsWidget::layoutDirection-
881 \brief the layout direction for this widget.-
882-
883 This property modifies this widget's and all of its descendants'-
884 Qt::WA_RightToLeft attribute. It also sets this widget's-
885 Qt::WA_SetLayoutDirection attribute.-
886-
887 The widget's layout direction determines the order in which the layout-
888 manager horizontally arranges subwidgets of this widget. The default-
889 value depends on the language and locale of the application, and is-
890 typically in the same direction as words are read and written. With-
891 Qt::LeftToRight, the layout starts placing subwidgets from the left-
892 side of this widget towards the right. Qt::RightToLeft does the opposite --
893 the layout will place widgets starting from the right edge moving towards-
894 the left.-
895-
896 Subwidgets inherit their layout direction from the parent. Top-level-
897 widget items inherit their layout direction from-
898 QGraphicsScene::layoutDirection. If you change a widget's layout direction-
899 by calling setLayoutDirection(), the widget will send itself a-
900 \l{QEvent::LayoutDirectionChange}{LayoutDirectionChange} event, and then-
901 propagate the new layout direction to all its descendants.-
902-
903 \sa QWidget::layoutDirection, QApplication::layoutDirection-
904*/-
905Qt::LayoutDirection QGraphicsWidget::layoutDirection() const-
906{-
907 return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
never executed: return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
0
908}-
909void QGraphicsWidget::setLayoutDirection(Qt::LayoutDirection direction)-
910{-
911 Q_D(QGraphicsWidget);-
912 setAttribute(Qt::WA_SetLayoutDirection, true);-
913 d->setLayoutDirection_helper(direction);-
914}
never executed: end of block
0
915void QGraphicsWidget::unsetLayoutDirection()-
916{-
917 Q_D(QGraphicsWidget);-
918 setAttribute(Qt::WA_SetLayoutDirection, false);-
919 d->resolveLayoutDirection();-
920}
never executed: end of block
0
921-
922/*!-
923 Returns a pointer to the widget's style. If this widget does not have any-
924 explicitly assigned style, the scene's style is returned instead. In turn,-
925 if the scene does not have any assigned style, this function returns-
926 QApplication::style().-
927-
928 \sa setStyle()-
929*/-
930QStyle *QGraphicsWidget::style() const-
931{-
932 if (QStyle *style = widgetStyles()->styleForWidget(this))
QStyle *style ...orWidget(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
933 return style;
never executed: return style;
0
934 // ### This is not thread-safe. QApplication::style() is not thread-safe.-
935 return scene() ? scene()->style() : QApplication::style();
never executed: return scene() ? scene()->style() : QApplication::style();
0
936}-
937-
938/*!-
939 Sets the widget's style to \a style. QGraphicsWidget does \e not take-
940 ownership of \a style.-
941-
942 If no style is assigned, or \a style is 0, the widget will use-
943 QGraphicsScene::style() (if this has been set). Otherwise the widget will-
944 use QApplication::style().-
945-
946 This function sets the Qt::WA_SetStyle attribute if \a style is not 0;-
947 otherwise it clears the attribute.-
948-
949 \sa style()-
950*/-
951void QGraphicsWidget::setStyle(QStyle *style)-
952{-
953 setAttribute(Qt::WA_SetStyle, style != 0);-
954 widgetStyles()->setStyleForWidget(this, style);-
955-
956 // Deliver StyleChange to the widget itself (doesn't propagate).-
957 QEvent event(QEvent::StyleChange);-
958 QApplication::sendEvent(this, &event);-
959}
never executed: end of block
0
960-
961/*!-
962 \property QGraphicsWidget::font-
963 \brief the widgets' font-
964-
965 This property provides the widget's font.-
966-
967 QFont consists of font properties that have been explicitly defined and-
968 properties implicitly inherited from the widget's parent. Hence, font()-
969 can return a different font compared to the one set with setFont().-
970 This scheme allows you to define single entries in a font without-
971 affecting the font's inherited entries.-
972-
973 When a widget's font changes, it resolves its entries against its-
974 parent widget. If the widget does not have a parent widget, it resolves-
975 its entries against the scene. The widget then sends itself a-
976 \l{QEvent::FontChange}{FontChange} event and notifies all its-
977 descendants so that they can resolve their fonts as well.-
978-
979 By default, this property contains the application's default font.-
980-
981 \sa QApplication::font(), QGraphicsScene::font, QFont::resolve()-
982*/-
983QFont QGraphicsWidget::font() const-
984{-
985 Q_D(const QGraphicsWidget);-
986 QFont fnt = d->font;-
987 fnt.resolve(fnt.resolve() | d->inheritedFontResolveMask);-
988 return fnt;
never executed: return fnt;
0
989}-
990void QGraphicsWidget::setFont(const QFont &font)-
991{-
992 Q_D(QGraphicsWidget);-
993 setAttribute(Qt::WA_SetFont, font.resolve() != 0);-
994-
995 QFont naturalFont = d->naturalWidgetFont();-
996 QFont resolvedFont = font.resolve(naturalFont);-
997 d->setFont_helper(resolvedFont);-
998}
never executed: end of block
0
999-
1000/*!-
1001 \property QGraphicsWidget::palette-
1002 \brief the widget's palette-
1003-
1004 This property provides the widget's palette. The palette provides colors-
1005 and brushes for color groups (e.g., QPalette::Button) and states (e.g.,-
1006 QPalette::Inactive), loosely defining the general look of the widget and-
1007 its children.-
1008-
1009 QPalette consists of color groups that have been explicitly defined, and-
1010 groups that are implicitly inherited from the widget's parent. Because of-
1011 this, palette() can return a different palette than what has been set with-
1012 setPalette(). This scheme allows you to define single entries in a palette-
1013 without affecting the palette's inherited entries.-
1014-
1015 When a widget's palette changes, it resolves its entries against its-
1016 parent widget, or if it doesn't have a parent widget, it resolves against-
1017 the scene. It then sends itself a \l{QEvent::PaletteChange}{PaletteChange}-
1018 event, and notifies all its descendants so they can resolve their palettes-
1019 as well.-
1020-
1021 By default, this property contains the application's default palette.-
1022-
1023 \sa QApplication::palette(), QGraphicsScene::palette, QPalette::resolve()-
1024*/-
1025QPalette QGraphicsWidget::palette() const-
1026{-
1027 Q_D(const QGraphicsWidget);-
1028 return d->palette;
never executed: return d->palette;
0
1029}-
1030void QGraphicsWidget::setPalette(const QPalette &palette)-
1031{-
1032 Q_D(QGraphicsWidget);-
1033 setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);-
1034-
1035 QPalette naturalPalette = d->naturalWidgetPalette();-
1036 QPalette resolvedPalette = palette.resolve(naturalPalette);-
1037 d->setPalette_helper(resolvedPalette);-
1038}
never executed: end of block
0
1039-
1040/*!-
1041 \property QGraphicsWidget::autoFillBackground-
1042 \brief whether the widget background is filled automatically-
1043 \since 4.7-
1044-
1045 If enabled, this property will cause Qt to fill the background of the-
1046 widget before invoking the paint() method. The color used is defined by the-
1047 QPalette::Window color role from the widget's \l{QPalette}{palette}.-
1048-
1049 In addition, Windows are always filled with QPalette::Window, unless the-
1050 WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.-
1051-
1052 By default, this property is \c false.-
1053-
1054 \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,-
1055*/-
1056bool QGraphicsWidget::autoFillBackground() const-
1057{-
1058 Q_D(const QGraphicsWidget);-
1059 return d->autoFillBackground;
never executed: return d->autoFillBackground;
0
1060}-
1061void QGraphicsWidget::setAutoFillBackground(bool enabled)-
1062{-
1063 Q_D(QGraphicsWidget);-
1064 if (d->autoFillBackground != enabled) {
d->autoFillBac...und != enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1065 d->autoFillBackground = enabled;-
1066 update();-
1067 }
never executed: end of block
0
1068}
never executed: end of block
0
1069-
1070/*!-
1071 If this widget is currently managed by a layout, this function notifies-
1072 the layout that the widget's size hints have changed and the layout-
1073 may need to resize and reposition the widget accordingly.-
1074-
1075 Call this function if the widget's sizeHint() has changed.-
1076-
1077 \sa QGraphicsLayout::invalidate()-
1078*/-
1079void QGraphicsWidget::updateGeometry()-
1080{-
1081 QGraphicsLayoutItem::updateGeometry();-
1082 QGraphicsLayoutItem *parentItem = parentLayoutItem();-
1083-
1084 if (parentItem && parentItem->isLayout()) {
parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
parentItem->isLayout()Description
TRUEnever evaluated
FALSEnever evaluated
0
1085 if (QGraphicsLayout::instantInvalidatePropagation()) {
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
0
1086 static_cast<QGraphicsLayout *>(parentItem)->invalidate();-
1087 } else {
never executed: end of block
0
1088 parentItem->updateGeometry();-
1089 }
never executed: end of block
0
1090 } else {-
1091 if (parentItem) {
parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1092 // This is for custom layouting-
1093 QGraphicsWidget *parentWid = parentWidget(); //###-
1094 if (parentWid->isVisible())
parentWid->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1095 QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest));
never executed: QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest));
0
1096 } else {
never executed: end of block
0
1097 /**-
1098 * If this is the topmost widget, post a LayoutRequest event to the widget.-
1099 * When the event is received, it will start flowing all the way down to the leaf-
1100 * widgets in one go. This will make a relayout flicker-free.-
1101 */-
1102 if (QGraphicsLayout::instantInvalidatePropagation())
QGraphicsLayou...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
0
1103 QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest));
never executed: QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest));
0
1104 }
never executed: end of block
0
1105 if (!QGraphicsLayout::instantInvalidatePropagation()) {
!QGraphicsLayo...ePropagation()Description
TRUEnever evaluated
FALSEnever evaluated
0
1106 bool wasResized = testAttribute(Qt::WA_Resized);-
1107 resize(size()); // this will restrict the size-
1108 setAttribute(Qt::WA_Resized, wasResized);-
1109 }
never executed: end of block
0
1110 }
never executed: end of block
0
1111}-
1112-
1113/*!-
1114 \reimp-
1115-
1116 QGraphicsWidget uses the base implementation of this function to catch and-
1117 deliver events related to state changes in the item. Because of this, it is-
1118 very important that subclasses call the base implementation.-
1119-
1120 \a change specifies the type of change, and \a value is the new value.-
1121-
1122 For example, QGraphicsWidget uses ItemVisibleChange to deliver-
1123 \l{QEvent::Show} {Show} and \l{QEvent::Hide}{Hide} events,-
1124 ItemPositionHasChanged to deliver \l{QEvent::Move}{Move} events,-
1125 and ItemParentChange both to deliver \l{QEvent::ParentChange}-
1126 {ParentChange} events, and for managing the focus chain.-
1127-
1128 QGraphicsWidget enables the ItemSendsGeometryChanges flag by default in-
1129 order to track position changes.-
1130-
1131 \sa QGraphicsItem::itemChange()-
1132*/-
1133QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &value)-
1134{-
1135 Q_D(QGraphicsWidget);-
1136 switch (change) {-
1137 case ItemEnabledHasChanged: {
never executed: case ItemEnabledHasChanged:
0
1138 // Send EnabledChange after the enabled state has changed.-
1139 QEvent event(QEvent::EnabledChange);-
1140 QApplication::sendEvent(this, &event);-
1141 break;
never executed: break;
0
1142 }-
1143 case ItemVisibleChange:
never executed: case ItemVisibleChange:
0
1144 if (value.toBool()) {
value.toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
1145 // Send Show event before the item has been shown.-
1146 QShowEvent event;-
1147 QApplication::sendEvent(this, &event);-
1148 bool resized = testAttribute(Qt::WA_Resized);-
1149 if (!resized) {
!resizedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1150 adjustSize();-
1151 setAttribute(Qt::WA_Resized, false);-
1152 }
never executed: end of block
0
1153 }
never executed: end of block
0
1154-
1155 // layout size hint only changes if an item changes from/to explicitly hidden state-
1156 if (value.toBool() || d->explicitlyHidden)
value.toBool()Description
TRUEnever evaluated
FALSEnever evaluated
d->explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1157 updateGeometry();
never executed: updateGeometry();
0
1158 break;
never executed: break;
0
1159 case ItemVisibleHasChanged:
never executed: case ItemVisibleHasChanged:
0
1160 if (!value.toBool()) {
!value.toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
1161 // Send Hide event after the item has been hidden.-
1162 QHideEvent event;-
1163 QApplication::sendEvent(this, &event);-
1164 }
never executed: end of block
0
1165 break;
never executed: break;
0
1166 case ItemPositionHasChanged:
never executed: case ItemPositionHasChanged:
0
1167 d->setGeometryFromSetPos();-
1168 break;
never executed: break;
0
1169 case ItemParentChange: {
never executed: case ItemParentChange:
0
1170 // Deliver ParentAboutToChange.-
1171 QEvent event(QEvent::ParentAboutToChange);-
1172 QApplication::sendEvent(this, &event);-
1173 break;
never executed: break;
0
1174 }-
1175 case ItemParentHasChanged: {
never executed: case ItemParentHasChanged:
0
1176 // Deliver ParentChange.-
1177 QEvent event(QEvent::ParentChange);-
1178 QApplication::sendEvent(this, &event);-
1179 break;
never executed: break;
0
1180 }-
1181 case ItemCursorHasChanged: {
never executed: case ItemCursorHasChanged:
0
1182 // Deliver CursorChange.-
1183 QEvent event(QEvent::CursorChange);-
1184 QApplication::sendEvent(this, &event);-
1185 break;
never executed: break;
0
1186 }-
1187 case ItemToolTipHasChanged: {
never executed: case ItemToolTipHasChanged:
0
1188 // Deliver ToolTipChange.-
1189 QEvent event(QEvent::ToolTipChange);-
1190 QApplication::sendEvent(this, &event);-
1191 break;
never executed: break;
0
1192 }-
1193 default:
never executed: default:
0
1194 break;
never executed: break;
0
1195 }-
1196 return QGraphicsItem::itemChange(change, value);
never executed: return QGraphicsItem::itemChange(change, value);
0
1197}-
1198-
1199/*!-
1200 \internal-
1201-
1202 This virtual function is used to notify changes to any property (both-
1203 dynamic properties, and registered with Q_PROPERTY) in the-
1204 widget. Depending on the property itself, the notification can be-
1205 delivered before or after the value has changed.-
1206-
1207 \a propertyName is the name of the property (e.g., "size" or "font"), and-
1208 \a value is the (proposed) new value of the property. The function returns-
1209 the new value, which may be different from \a value if the notification-
1210 supports adjusting the property value. The base implementation simply-
1211 returns \a value for any \a propertyName.-
1212-
1213 QGraphicsWidget delivers notifications for the following properties:-
1214-
1215 \table-
1216 \header \li propertyName \li Property-
1217 \row \li layoutDirection \li QGraphicsWidget::layoutDirection-
1218 \row \li size \li QGraphicsWidget::size-
1219 \row \li font \li QGraphicsWidget::font-
1220 \row \li palette \li QGraphicsWidget::palette-
1221 \endtable-
1222-
1223 \sa itemChange()-
1224*/-
1225QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVariant &value)-
1226{-
1227 Q_UNUSED(propertyName);-
1228 return value;
never executed: return value;
0
1229}-
1230-
1231/*!-
1232 QGraphicsWidget's implementation of sceneEvent() simply passes \a event to-
1233 QGraphicsWidget::event(). You can handle all events for your widget in-
1234 event() or in any of the convenience functions; you should not have to-
1235 reimplement this function in a subclass of QGraphicsWidget.-
1236-
1237 \sa QGraphicsItem::sceneEvent()-
1238*/-
1239bool QGraphicsWidget::sceneEvent(QEvent *event)-
1240{-
1241 return QGraphicsItem::sceneEvent(event);
never executed: return QGraphicsItem::sceneEvent(event);
0
1242}-
1243-
1244/*!-
1245 This event handler, for \a event, receives events for the window frame if-
1246 this widget is a window. Its base implementation provides support for-
1247 default window frame interaction such as moving, resizing, etc.-
1248-
1249 You can reimplement this handler in a subclass of QGraphicsWidget to-
1250 provide your own custom window frame interaction support.-
1251-
1252 Returns \c true if \a event has been recognized and processed; otherwise,-
1253 returns \c false.-
1254-
1255 \sa event()-
1256*/-
1257bool QGraphicsWidget::windowFrameEvent(QEvent *event)-
1258{-
1259 Q_D(QGraphicsWidget);-
1260 switch (event->type()) {-
1261 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
1262 d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
1263 break;
never executed: break;
0
1264 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
1265 d->ensureWindowData();-
1266 if (d->windowData->grabbedSection != Qt::NoSection) {
d->windowData-... Qt::NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1267 d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
1268 event->accept();-
1269 }
never executed: end of block
0
1270 break;
never executed: break;
0
1271 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
1272 d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
1273 break;
never executed: break;
0
1274 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
1275 d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
1276 break;
never executed: break;
0
1277 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
1278 d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
1279 break;
never executed: break;
0
1280 default:
never executed: default:
0
1281 break;
never executed: break;
0
1282 }-
1283 return event->isAccepted();
never executed: return event->isAccepted();
0
1284}-
1285-
1286/*!-
1287 \since 4.4-
1288-
1289 Returns the window frame section at position \a pos, or-
1290 Qt::NoSection if there is no window frame section at this-
1291 position.-
1292-
1293 This function is used in QGraphicsWidget's base implementation for window-
1294 frame interaction.-
1295-
1296 You can reimplement this function if you want to customize how a window-
1297 can be interactively moved or resized. For instance, if you only want to-
1298 allow a window to be resized by the bottom right corner, you can-
1299 reimplement this function to return Qt::NoSection for all sections except-
1300 Qt::BottomRightSection.-
1301-
1302 \sa windowFrameEvent(), paintWindowFrame(), windowFrameGeometry()-
1303*/-
1304Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) const-
1305{-
1306 Q_D(const QGraphicsWidget);-
1307-
1308 const QRectF r = windowFrameRect();-
1309 if (!r.contains(pos))
!r.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1310 return Qt::NoSection;
never executed: return Qt::NoSection;
0
1311-
1312 const qreal left = r.left();-
1313 const qreal top = r.top();-
1314 const qreal right = r.right();-
1315 const qreal bottom = r.bottom();-
1316 const qreal x = pos.x();-
1317 const qreal y = pos.y();-
1318-
1319 const qreal cornerMargin = 20;-
1320 //### Not sure of this one, it should be the same value for all edges.-
1321 const qreal windowFrameWidth = d->windowFrameMargins
d->windowFrameMarginsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1322 ? d->windowFrameMargins[d->Left] : 0;-
1323-
1324 Qt::WindowFrameSection s = Qt::NoSection;-
1325 if (x <= left + cornerMargin) {
x <= left + cornerMarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1326 if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) {
y <= top + windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
x <= left + windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
y <= top + cornerMarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1327 s = Qt::TopLeftSection;-
1328 } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - cornerMargin)) {
never executed: end of block
y >= bottom - windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
x <= left + windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
y >= bottom - cornerMarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1329 s = Qt::BottomLeftSection;-
1330 } else if (x <= left + windowFrameWidth) {
never executed: end of block
x <= left + windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1331 s = Qt::LeftSection;-
1332 }
never executed: end of block
0
1333 } else if (x >= right - cornerMargin) {
never executed: end of block
x >= right - cornerMarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1334 if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) {
y <= top + windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
x >= right - windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
y <= top + cornerMarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1335 s = Qt::TopRightSection;-
1336 } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - cornerMargin)) {
never executed: end of block
y >= bottom - windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
x >= right - windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
y >= bottom - cornerMarginDescription
TRUEnever evaluated
FALSEnever evaluated
0
1337 s = Qt::BottomRightSection;-
1338 } else if (x >= right - windowFrameWidth) {
never executed: end of block
x >= right - windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1339 s = Qt::RightSection;-
1340 }
never executed: end of block
0
1341 } else if (y <= top + windowFrameWidth) {
never executed: end of block
y <= top + windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1342 s = Qt::TopSection;-
1343 } else if (y >= bottom - windowFrameWidth) {
never executed: end of block
y >= bottom - windowFrameWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
1344 s = Qt::BottomSection;-
1345 }
never executed: end of block
0
1346 if (s == Qt::NoSection) {
s == Qt::NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1347 QRectF r1 = r;-
1348 r1.setHeight(d->windowFrameMargins-
1349 ? d->windowFrameMargins[d->Top] : 0);-
1350 if (r1.contains(pos))
r1.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
1351 s = Qt::TitleBarArea;
never executed: s = Qt::TitleBarArea;
0
1352 }
never executed: end of block
0
1353 return s;
never executed: return s;
0
1354}-
1355-
1356/*!-
1357 \reimp-
1358-
1359 Handles the \a event. QGraphicsWidget handles the following-
1360 events:-
1361-
1362 \table-
1363 \header \li Event \li Usage-
1364 \row \li Polish-
1365 \li Delivered to the widget some time after it has been-
1366 shown.-
1367 \row \li GraphicsSceneMove-
1368 \li Delivered to the widget after its local position has-
1369 changed.-
1370 \row \li GraphicsSceneResize-
1371 \li Delivered to the widget after its size has changed.-
1372 \row \li Show-
1373 \li Delivered to the widget before it has been shown.-
1374 \row \li Hide-
1375 \li Delivered to the widget after it has been hidden.-
1376 \row \li PaletteChange-
1377 \li Delivered to the widget after its palette has changed.-
1378 \row \li FontChange-
1379 \li Delivered to the widget after its font has changed.-
1380 \row \li EnabledChange-
1381 \li Delivered to the widget after its enabled state has-
1382 changed.-
1383 \row \li StyleChange-
1384 \li Delivered to the widget after its style has changed.-
1385 \row \li LayoutDirectionChange-
1386 \li Delivered to the widget after its layout direction has-
1387 changed.-
1388 \row \li ContentsRectChange-
1389 \li Delivered to the widget after its contents margins/-
1390 contents rect has changed.-
1391 \endtable-
1392*/-
1393bool QGraphicsWidget::event(QEvent *event)-
1394{-
1395 Q_D(QGraphicsWidget);-
1396 // Forward the event to the layout first.-
1397 if (d->layout)
d->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1398 d->layout->widgetEvent(event);
never executed: d->layout->widgetEvent(event);
0
1399-
1400 // Handle the event itself.-
1401 switch (event->type()) {-
1402 case QEvent::GraphicsSceneMove:
never executed: case QEvent::GraphicsSceneMove:
0
1403 moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event));-
1404 break;
never executed: break;
0
1405 case QEvent::GraphicsSceneResize:
never executed: case QEvent::GraphicsSceneResize:
0
1406 resizeEvent(static_cast<QGraphicsSceneResizeEvent *>(event));-
1407 break;
never executed: break;
0
1408 case QEvent::Show:
never executed: case QEvent::Show:
0
1409 showEvent(static_cast<QShowEvent *>(event));-
1410 break;
never executed: break;
0
1411 case QEvent::Hide:
never executed: case QEvent::Hide:
0
1412 hideEvent(static_cast<QHideEvent *>(event));-
1413 break;
never executed: break;
0
1414 case QEvent::Polish:
never executed: case QEvent::Polish:
0
1415 polishEvent();-
1416 d->polished = true;-
1417 if (!d->font.isCopyOf(QApplication::font()))
!d->font.isCop...ation::font())Description
TRUEnever evaluated
FALSEnever evaluated
0
1418 d->updateFont(d->font);
never executed: d->updateFont(d->font);
0
1419 break;
never executed: break;
0
1420 case QEvent::WindowActivate:
never executed: case QEvent::WindowActivate:
0
1421 case QEvent::WindowDeactivate:
never executed: case QEvent::WindowDeactivate:
0
1422 update();-
1423 break;
never executed: break;
0
1424 case QEvent::StyleAnimationUpdate:
never executed: case QEvent::StyleAnimationUpdate:
0
1425 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1426 event->accept();-
1427 update();-
1428 }
never executed: end of block
0
1429 break;
never executed: break;
0
1430 // Taken from QWidget::event-
1431 case QEvent::ActivationChange:
never executed: case QEvent::ActivationChange:
0
1432 case QEvent::EnabledChange:
never executed: case QEvent::EnabledChange:
0
1433 case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
1434 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1435 case QEvent::PaletteChange:
never executed: case QEvent::PaletteChange:
0
1436 case QEvent::ParentChange:
never executed: case QEvent::ParentChange:
0
1437 case QEvent::ContentsRectChange:
never executed: case QEvent::ContentsRectChange:
0
1438 case QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
1439 changeEvent(event);-
1440 break;
never executed: break;
0
1441 case QEvent::Close:
never executed: case QEvent::Close:
0
1442 closeEvent((QCloseEvent *)event);-
1443 break;
never executed: break;
0
1444 case QEvent::GrabMouse:
never executed: case QEvent::GrabMouse:
0
1445 grabMouseEvent(event);-
1446 break;
never executed: break;
0
1447 case QEvent::UngrabMouse:
never executed: case QEvent::UngrabMouse:
0
1448 ungrabMouseEvent(event);-
1449 break;
never executed: break;
0
1450 case QEvent::GrabKeyboard:
never executed: case QEvent::GrabKeyboard:
0
1451 grabKeyboardEvent(event);-
1452 break;
never executed: break;
0
1453 case QEvent::UngrabKeyboard:
never executed: case QEvent::UngrabKeyboard:
0
1454 ungrabKeyboardEvent(event);-
1455 break;
never executed: break;
0
1456 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
1457 if (d->hasDecoration() && windowFrameEvent(event))
d->hasDecoration()Description
TRUEnever evaluated
FALSEnever evaluated
windowFrameEvent(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
1458 return true;
never executed: return true;
0
1459 break;
never executed: break;
0
1460 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
1461 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
1462 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
1463 d->ensureWindowData();-
1464 if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection)
d->hasDecoration()Description
TRUEnever evaluated
FALSEnever evaluated
d->windowData-... Qt::NoSectionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1465 return windowFrameEvent(event);
never executed: return windowFrameEvent(event);
0
1466 break;
never executed: break;
0
1467 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
1468 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
1469 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
1470 if (d->hasDecoration()) {
d->hasDecoration()Description
TRUEnever evaluated
FALSEnever evaluated
0
1471 windowFrameEvent(event);-
1472 // Filter out hover events if they were sent to us only because of the-
1473 // decoration (special case in QGraphicsScenePrivate::dispatchHoverEvent).-
1474 if (!acceptHoverEvents())
!acceptHoverEvents()Description
TRUEnever evaluated
FALSEnever evaluated
0
1475 return true;
never executed: return true;
0
1476 }
never executed: end of block
0
1477 break;
never executed: break;
0
1478 default:
never executed: default:
0
1479 break;
never executed: break;
0
1480 }-
1481 return QObject::event(event);
never executed: return QObject::event(event);
0
1482}-
1483-
1484/*!-
1485 This event handler can be reimplemented to handle state changes.-
1486-
1487 The state being changed in this event can be retrieved through \a event.-
1488-
1489 Change events include: QEvent::ActivationChange, QEvent::EnabledChange,-
1490 QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange,-
1491 QEvent::ParentChange, QEvent::LayoutDirectionChange, and-
1492 QEvent::ContentsRectChange.-
1493*/-
1494void QGraphicsWidget::changeEvent(QEvent *event)-
1495{-
1496 Q_D(QGraphicsWidget);-
1497 switch (event->type()) {-
1498 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1499 // ### Don't unset if the margins are explicitly set.-
1500 unsetWindowFrameMargins();-
1501 if (d->layout)
d->layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
1502 d->layout->invalidate();
never executed: d->layout->invalidate();
0
1503 case QEvent::FontChange:
code before this statement never executed: case QEvent::FontChange:
never executed: case QEvent::FontChange:
0
1504 update();-
1505 updateGeometry();-
1506 break;
never executed: break;
0
1507 case QEvent::PaletteChange:
never executed: case QEvent::PaletteChange:
0
1508 update();-
1509 break;
never executed: break;
0
1510 case QEvent::ParentChange:
never executed: case QEvent::ParentChange:
0
1511 d->resolveFont(d->inheritedFontResolveMask);-
1512 d->resolvePalette(d->inheritedPaletteResolveMask);-
1513 break;
never executed: break;
0
1514 default:
never executed: default:
0
1515 break;
never executed: break;
0
1516 }-
1517}-
1518-
1519/*!-
1520 This event handler, for \a event, can be reimplemented in a subclass to-
1521 receive widget close events. The default implementation accepts the-
1522 event.-
1523-
1524 \sa close(), QCloseEvent-
1525*/-
1526void QGraphicsWidget::closeEvent(QCloseEvent *event)-
1527{-
1528 event->accept();-
1529}
never executed: end of block
0
1530-
1531/*!-
1532 \reimp-
1533*/-
1534void QGraphicsWidget::focusInEvent(QFocusEvent *event)-
1535{-
1536 Q_UNUSED(event);-
1537 if (focusPolicy() != Qt::NoFocus)
focusPolicy() != Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1538 update();
never executed: update();
0
1539}
never executed: end of block
0
1540-
1541/*!-
1542 Finds a new widget to give the keyboard focus to, as appropriate for Tab-
1543 and Shift+Tab, and returns \c true if it can find a new widget; returns \c false-
1544 otherwise. If \a next is true, this function searches forward; if \a next-
1545 is false, it searches backward.-
1546-
1547 Sometimes, you will want to reimplement this function to provide special-
1548 focus handling for your widget and its subwidgets. For example, a web-
1549 browser might reimplement it to move its current active link forward or-
1550 backward, and call the base implementation only when it reaches the last-
1551 or first link on the page.-
1552-
1553 Child widgets call focusNextPrevChild() on their parent widgets, but only-
1554 the window that contains the child widgets decides where to redirect-
1555 focus. By reimplementing this function for an object, you gain control of-
1556 focus traversal for all child widgets.-
1557-
1558 \sa focusPolicy()-
1559*/-
1560bool QGraphicsWidget::focusNextPrevChild(bool next)-
1561{-
1562 Q_D(QGraphicsWidget);-
1563 // Let the parent's focusNextPrevChild implementation decide what to do.-
1564 QGraphicsWidget *parent = 0;-
1565 if (!isWindow() && (parent = parentWidget()))
!isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
(parent = parentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
0
1566 return parent->focusNextPrevChild(next);
never executed: return parent->focusNextPrevChild(next);
0
1567 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1568 return false;
never executed: return false;
0
1569 if (d->scene->focusNextPrevChild(next))
d->scene->focu...revChild(next)Description
TRUEnever evaluated
FALSEnever evaluated
0
1570 return true;
never executed: return true;
0
1571 if (isWindow()) {
isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
1572 setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);-
1573 if (hasFocus())
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
1574 return true;
never executed: return true;
0
1575 }
never executed: end of block
0
1576 return false;
never executed: return false;
0
1577}-
1578-
1579/*!-
1580 \reimp-
1581*/-
1582void QGraphicsWidget::focusOutEvent(QFocusEvent *event)-
1583{-
1584 Q_UNUSED(event);-
1585 if (focusPolicy() != Qt::NoFocus)
focusPolicy() != Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1586 update();
never executed: update();
0
1587}
never executed: end of block
0
1588-
1589/*!-
1590 This event handler, for \l{QEvent::Hide}{Hide} events, is delivered after-
1591 the widget has been hidden, for example, setVisible(false) has been called-
1592 for the widget or one of its ancestors when the widget was previously-
1593 shown.-
1594-
1595 You can reimplement this event handler to detect when your widget is-
1596 hidden. Calling QEvent::accept() or QEvent::ignore() on \a event has no-
1597 effect.-
1598-
1599 \sa showEvent(), QWidget::hideEvent(), ItemVisibleChange-
1600*/-
1601void QGraphicsWidget::hideEvent(QHideEvent *event)-
1602{-
1603 ///### focusNextPrevChild(true), don't lose focus when the focus widget-
1604 // is hidden.-
1605 Q_UNUSED(event);-
1606}
never executed: end of block
0
1607-
1608/*!-
1609 This event handler, for \l{QEvent::GraphicsSceneMove}{GraphicsSceneMove}-
1610 events, is delivered after the widget has moved (e.g., its local position-
1611 has changed).-
1612-
1613 This event is only delivered when the item is moved locally. Calling-
1614 setTransform() or moving any of the item's ancestors does not affect the-
1615 item's local position.-
1616-
1617 You can reimplement this event handler to detect when your widget has-
1618 moved. Calling QEvent::accept() or QEvent::ignore() on \a event has no-
1619 effect.-
1620-
1621 \sa ItemPositionChange, ItemPositionHasChanged-
1622*/-
1623void QGraphicsWidget::moveEvent(QGraphicsSceneMoveEvent *event)-
1624{-
1625 // ### Last position is always == current position-
1626 Q_UNUSED(event);-
1627}
never executed: end of block
0
1628-
1629/*!-
1630 This event is delivered to the item by the scene at some point after it-
1631 has been constructed, but before it is shown or otherwise accessed through-
1632 the scene. You can use this event handler to do last-minute initializations-
1633 of the widget which require the item to be fully constructed.-
1634-
1635 The base implementation does nothing.-
1636*/-
1637void QGraphicsWidget::polishEvent()-
1638{-
1639}-
1640-
1641/*!-
1642 This event handler, for-
1643 \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} events, is-
1644 delivered after the widget has been resized (i.e., its local size has-
1645 changed). \a event contains both the old and the new size.-
1646-
1647 This event is only delivered when the widget is resized locally; calling-
1648 setTransform() on the widget or any of its ancestors or view, does not-
1649 affect the widget's local size.-
1650-
1651 You can reimplement this event handler to detect when your widget has been-
1652 resized. Calling QEvent::accept() or QEvent::ignore() on \a event has no-
1653 effect.-
1654-
1655 \sa geometry(), setGeometry()-
1656*/-
1657void QGraphicsWidget::resizeEvent(QGraphicsSceneResizeEvent *event)-
1658{-
1659 Q_UNUSED(event);-
1660}
never executed: end of block
0
1661-
1662/*!-
1663 This event handler, for \l{QEvent::Show}{Show} events, is delivered before-
1664 the widget has been shown, for example, setVisible(true) has been called-
1665 for the widget or one of its ancestors when the widget was previously-
1666 hidden.-
1667-
1668 You can reimplement this event handler to detect when your widget is-
1669 shown. Calling QEvent::accept() or QEvent::ignore() on \a event has no-
1670 effect.-
1671-
1672 \sa hideEvent(), QWidget::showEvent(), ItemVisibleChange-
1673*/-
1674void QGraphicsWidget::showEvent(QShowEvent *event)-
1675{-
1676 Q_UNUSED(event);-
1677}
never executed: end of block
0
1678-
1679/*!-
1680 \reimp-
1681*/-
1682void QGraphicsWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)-
1683{-
1684 Q_UNUSED(event);-
1685}
never executed: end of block
0
1686-
1687/*!-
1688 \reimp-
1689*/-
1690void QGraphicsWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)-
1691{-
1692 QGraphicsObject::hoverLeaveEvent(event);-
1693}
never executed: end of block
0
1694-
1695/*!-
1696 This event handler, for \a event, can be reimplemented in a subclass to-
1697 receive notifications for QEvent::GrabMouse events.-
1698-
1699 \sa grabMouse(), grabKeyboard()-
1700*/-
1701void QGraphicsWidget::grabMouseEvent(QEvent *event)-
1702{-
1703 Q_UNUSED(event);-
1704}
never executed: end of block
0
1705-
1706/*!-
1707 This event handler, for \a event, can be reimplemented in a subclass to-
1708 receive notifications for QEvent::UngrabMouse events.-
1709-
1710 \sa ungrabMouse(), ungrabKeyboard()-
1711*/-
1712void QGraphicsWidget::ungrabMouseEvent(QEvent *event)-
1713{-
1714 Q_UNUSED(event);-
1715}
never executed: end of block
0
1716-
1717/*!-
1718 This event handler, for \a event, can be reimplemented in a subclass to-
1719 receive notifications for QEvent::GrabKeyboard events.-
1720-
1721 \sa grabKeyboard(), grabMouse()-
1722*/-
1723void QGraphicsWidget::grabKeyboardEvent(QEvent *event)-
1724{-
1725 Q_UNUSED(event);-
1726}
never executed: end of block
0
1727-
1728/*!-
1729 This event handler, for \a event, can be reimplemented in a subclass to-
1730 receive notifications for QEvent::UngrabKeyboard events.-
1731-
1732 \sa ungrabKeyboard(), ungrabMouse()-
1733*/-
1734void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event)-
1735{-
1736 Q_UNUSED(event);-
1737}
never executed: end of block
0
1738-
1739/*!-
1740 Returns the widgets window type.-
1741-
1742 \sa windowFlags(), isWindow(), isPanel()-
1743*/-
1744Qt::WindowType QGraphicsWidget::windowType() const-
1745{-
1746 return Qt::WindowType(int(windowFlags()) & Qt::WindowType_Mask);
never executed: return Qt::WindowType(int(windowFlags()) & Qt::WindowType_Mask);
0
1747}-
1748-
1749/*!-
1750 \property QGraphicsWidget::windowFlags-
1751 \brief the widget's window flags-
1752-
1753 Window flags are a combination of a window type (e.g., Qt::Dialog) and-
1754 several flags giving hints on the behavior of the window. The behavior-
1755 is platform-dependent.-
1756-
1757 By default, this property contains no window flags.-
1758-
1759 Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag-
1760 will be set automatically. If you clear the Qt::Window flag, the-
1761 ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be-
1762 set independently of Qt::Window.-
1763-
1764 \sa isWindow(), isPanel()-
1765*/-
1766Qt::WindowFlags QGraphicsWidget::windowFlags() const-
1767{-
1768 Q_D(const QGraphicsWidget);-
1769 return d->windowFlags;
never executed: return d->windowFlags;
0
1770}-
1771void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)-
1772{-
1773 Q_D(QGraphicsWidget);-
1774 if (d->windowFlags == wFlags)
d->windowFlags == wFlagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1775 return;
never executed: return;
0
1776 bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;-
1777-
1778 d->adjustWindowFlags(&wFlags);-
1779 d->windowFlags = wFlags;-
1780 if (!d->setWindowFrameMargins)
!d->setWindowFrameMarginsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1781 unsetWindowFrameMargins();
never executed: unsetWindowFrameMargins();
0
1782-
1783 setFlag(ItemIsPanel, d->windowFlags & Qt::Window);-
1784-
1785 bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;-
1786 if (d->scene && isVisible() && wasPopup != isPopup) {
d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
wasPopup != isPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1787 // Popup state changed; update implicit mouse grab.-
1788 if (!isPopup)
!isPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1789 d->scene->d_func()->removePopup(this);
never executed: d->scene->d_func()->removePopup(this);
0
1790 else-
1791 d->scene->d_func()->addPopup(this);
never executed: d->scene->d_func()->addPopup(this);
0
1792 }-
1793-
1794 if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
d->scene->d_fu...oreHoverEventsDescription
TRUEnever evaluated
FALSEnever evaluated
d->hasDecoration()Description
TRUEnever evaluated
FALSEnever evaluated
0
1795 d->scene->d_func()->allItemsIgnoreHoverEvents = false;-
1796 d->scene->d_func()->enableMouseTrackingOnViews();-
1797 }
never executed: end of block
0
1798}
never executed: end of block
0
1799-
1800/*!-
1801 Returns \c true if this widget's window is in the active window, or if the-
1802 widget does not have a window but is in an active scene (i.e., a scene-
1803 that currently has focus).-
1804-
1805 The active window is the window that either contains a child widget that-
1806 currently has input focus, or that itself has input focus.-
1807-
1808 \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), isActive()-
1809*/-
1810bool QGraphicsWidget::isActiveWindow() const-
1811{-
1812 return isActive();
never executed: return isActive();
0
1813}-
1814-
1815/*!-
1816 \property QGraphicsWidget::windowTitle-
1817 \brief This property holds the window title (caption).-
1818-
1819 This property is only used for windows.-
1820-
1821 By default, if no title has been set, this property contains an-
1822 empty string.-
1823*/-
1824void QGraphicsWidget::setWindowTitle(const QString &title)-
1825{-
1826 Q_D(QGraphicsWidget);-
1827 d->ensureWindowData();-
1828 d->windowData->windowTitle = title;-
1829}
never executed: end of block
0
1830QString QGraphicsWidget::windowTitle() const-
1831{-
1832 Q_D(const QGraphicsWidget);-
1833 return d->windowData ? d->windowData->windowTitle : QString();
never executed: return d->windowData ? d->windowData->windowTitle : QString();
0
1834}-
1835-
1836/*!-
1837 \property QGraphicsWidget::focusPolicy-
1838 \brief the way the widget accepts keyboard focus-
1839-
1840 The focus policy is Qt::TabFocus if the widget accepts keyboard focus by-
1841 tabbing, Qt::ClickFocus if the widget accepts focus by clicking,-
1842 Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it-
1843 does not accept focus at all.-
1844-
1845 You must enable keyboard focus for a widget if it processes keyboard-
1846 events. This is normally done from the widget's constructor. For instance,-
1847 the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus).-
1848-
1849 If you enable a focus policy (i.e., not Qt::NoFocus), QGraphicsWidget will-
1850 automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a-
1851 widget will clear the ItemIsFocusable flag. If the widget currently has-
1852 keyboard focus, the widget will automatically lose focus.-
1853-
1854 \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled-
1855*/-
1856Qt::FocusPolicy QGraphicsWidget::focusPolicy() const-
1857{-
1858 Q_D(const QGraphicsWidget);-
1859 return d->focusPolicy;
never executed: return d->focusPolicy;
0
1860}-
1861void QGraphicsWidget::setFocusPolicy(Qt::FocusPolicy policy)-
1862{-
1863 Q_D(QGraphicsWidget);-
1864 if (d->focusPolicy == policy)
d->focusPolicy == policyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1865 return;
never executed: return;
0
1866 d->focusPolicy = policy;-
1867 if (hasFocus() && policy == Qt::NoFocus)
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
policy == Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1868 clearFocus();
never executed: clearFocus();
0
1869 setFlag(ItemIsFocusable, policy != Qt::NoFocus);-
1870}
never executed: end of block
0
1871-
1872/*!-
1873 If this widget, a child or descendant of this widget currently has input-
1874 focus, this function will return a pointer to that widget. If-
1875 no descendant widget has input focus, 0 is returned.-
1876-
1877 \sa QGraphicsItem::focusItem(), QWidget::focusWidget()-
1878*/-
1879QGraphicsWidget *QGraphicsWidget::focusWidget() const-
1880{-
1881 Q_D(const QGraphicsWidget);-
1882 if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
d->subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
d->subFocusIte..._ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1883 return static_cast<QGraphicsWidget *>(d->subFocusItem);
never executed: return static_cast<QGraphicsWidget *>(d->subFocusItem);
0
1884 return 0;
never executed: return 0;
0
1885}-
1886-
1887#ifndef QT_NO_SHORTCUT-
1888/*!-
1889 \since 4.5-
1890-
1891 Adds a shortcut to Qt's shortcut system that watches for the given key \a-
1892 sequence in the given \a context. If the \a context is-
1893 Qt::ApplicationShortcut, the shortcut applies to the application as a-
1894 whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut,-
1895 or to the window itself, Qt::WindowShortcut. For widgets that are not part-
1896 of a window (i.e., top-level widgets and their children),-
1897 Qt::WindowShortcut shortcuts apply to the scene.-
1898-
1899 If the same key \a sequence has been grabbed by several widgets,-
1900 when the key \a sequence occurs a QEvent::Shortcut event is sent-
1901 to all the widgets to which it applies in a non-deterministic-
1902 order, but with the ``ambiguous'' flag set to true.-
1903-
1904 \warning You should not normally need to use this function;-
1905 instead create \l{QAction}s with the shortcut key sequences you-
1906 require (if you also want equivalent menu options and toolbar-
1907 buttons), or create \l{QShortcut}s if you just need key sequences.-
1908 Both QAction and QShortcut handle all the event filtering for you,-
1909 and provide signals which are triggered when the user triggers the-
1910 key sequence, so are much easier to use than this low-level-
1911 function.-
1912-
1913 \sa releaseShortcut(), setShortcutEnabled(), QWidget::grabShortcut()-
1914*/-
1915int QGraphicsWidget::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context)-
1916{-
1917 Q_ASSERT(qApp);-
1918 if (sequence.isEmpty())
sequence.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1919 return 0;
never executed: return 0;
0
1920 // ### setAttribute(Qt::WA_GrabbedShortcut);-
1921 return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher);
never executed: return (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher);
0
1922}-
1923-
1924/*!-
1925 \since 4.5-
1926-
1927 Removes the shortcut with the given \a id from Qt's shortcut-
1928 system. The widget will no longer receive QEvent::Shortcut events-
1929 for the shortcut's key sequence (unless it has other shortcuts-
1930 with the same key sequence).-
1931-
1932 \warning You should not normally need to use this function since-
1933 Qt's shortcut system removes shortcuts automatically when their-
1934 parent widget is destroyed. It is best to use QAction or-
1935 QShortcut to handle shortcuts, since they are easier to use than-
1936 this low-level function. Note also that this is an expensive-
1937 operation.-
1938-
1939 \sa grabShortcut(), setShortcutEnabled(), QWidget::releaseShortcut()-
1940*/-
1941void QGraphicsWidget::releaseShortcut(int id)-
1942{-
1943 Q_ASSERT(qApp);-
1944 if (id)
idDescription
TRUEnever evaluated
FALSEnever evaluated
0
1945 qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.removeShortcut(id, this, 0);
0
1946}
never executed: end of block
0
1947-
1948/*!-
1949 \since 4.5-
1950-
1951 If \a enabled is true, the shortcut with the given \a id is-
1952 enabled; otherwise the shortcut is disabled.-
1953-
1954 \warning You should not normally need to use this function since-
1955 Qt's shortcut system enables/disables shortcuts automatically as-
1956 widgets become hidden/visible and gain or lose focus. It is best-
1957 to use QAction or QShortcut to handle shortcuts, since they are-
1958 easier to use than this low-level function.-
1959-
1960 \sa grabShortcut(), releaseShortcut(), QWidget::setShortcutEnabled()-
1961*/-
1962void QGraphicsWidget::setShortcutEnabled(int id, bool enabled)-
1963{-
1964 Q_ASSERT(qApp);-
1965 if (id)
idDescription
TRUEnever evaluated
FALSEnever evaluated
0
1966 qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
0
1967}
never executed: end of block
0
1968-
1969/*!-
1970 \since 4.5-
1971-
1972 If \a enabled is true, auto repeat of the shortcut with the-
1973 given \a id is enabled; otherwise it is disabled.-
1974-
1975 \sa grabShortcut(), releaseShortcut(), QWidget::setShortcutAutoRepeat()-
1976*/-
1977void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled)-
1978{-
1979 Q_ASSERT(qApp);-
1980 if (id)
idDescription
TRUEnever evaluated
FALSEnever evaluated
0
1981 qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
0
1982}
never executed: end of block
0
1983#endif-
1984-
1985#ifndef QT_NO_ACTION-
1986/*!-
1987 \since 4.5-
1988-
1989 Appends the action \a action to this widget's list of actions.-
1990-
1991 All QGraphicsWidgets have a list of \l{QAction}s, however they can be-
1992 represented graphically in many different ways. The default use of the-
1993 QAction list (as returned by actions()) is to create a context QMenu.-
1994-
1995 A QGraphicsWidget should only have one of each action and adding an action-
1996 it already has will not cause the same action to be in the widget twice.-
1997-
1998 \sa removeAction(), insertAction(), actions(), QWidget::addAction()-
1999*/-
2000void QGraphicsWidget::addAction(QAction *action)-
2001{-
2002 insertAction(0, action);-
2003}
never executed: end of block
0
2004-
2005/*!-
2006 \since 4.5-
2007-
2008 Appends the actions \a actions to this widget's list of actions.-
2009-
2010 \sa removeAction(), QMenu, addAction(), QWidget::addActions()-
2011*/-
2012#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)-
2013void QGraphicsWidget::addActions(const QList<QAction *> &actions)-
2014#else-
2015void QGraphicsWidget::addActions(QList<QAction *> actions)-
2016#endif-
2017{-
2018 for (int i = 0; i < actions.count(); ++i)
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2019 insertAction(0, actions.at(i));
never executed: insertAction(0, actions.at(i));
0
2020}
never executed: end of block
0
2021-
2022/*!-
2023 \since 4.5-
2024-
2025 Inserts the action \a action to this widget's list of actions,-
2026 before the action \a before. It appends the action if \a before is 0 or-
2027 \a before is not a valid action for this widget.-
2028-
2029 A QGraphicsWidget should only have one of each action.-
2030-
2031 \sa removeAction(), addAction(), QMenu, actions(),-
2032 QWidget::insertActions()-
2033*/-
2034void QGraphicsWidget::insertAction(QAction *before, QAction *action)-
2035{-
2036 if (!action) {
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2037 qWarning("QWidget::insertAction: Attempt to insert null action");-
2038 return;
never executed: return;
0
2039 }-
2040-
2041 Q_D(QGraphicsWidget);-
2042 int index = d->actions.indexOf(action);-
2043 if (index != -1)
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2044 d->actions.removeAt(index);
never executed: d->actions.removeAt(index);
0
2045-
2046 int pos = d->actions.indexOf(before);-
2047 if (pos < 0) {
pos < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2048 before = 0;-
2049 pos = d->actions.size();-
2050 }
never executed: end of block
0
2051 d->actions.insert(pos, action);-
2052-
2053 if (index == -1) {
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
2054 QActionPrivate *apriv = action->d_func();-
2055 apriv->graphicsWidgets.append(this);-
2056 }
never executed: end of block
0
2057-
2058 QActionEvent e(QEvent::ActionAdded, action, before);-
2059 QApplication::sendEvent(this, &e);-
2060}
never executed: end of block
0
2061-
2062/*!-
2063 \since 4.5-
2064-
2065 Inserts the actions \a actions to this widget's list of actions,-
2066 before the action \a before. It appends the action if \a before is 0 or-
2067 \a before is not a valid action for this widget.-
2068-
2069 A QGraphicsWidget can have at most one of each action.-
2070-
2071 \sa removeAction(), QMenu, insertAction(), QWidget::insertActions()-
2072*/-
2073#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)-
2074void QGraphicsWidget::insertActions(QAction *before, const QList<QAction *> &actions)-
2075#else-
2076void QGraphicsWidget::insertActions(QAction *before, QList<QAction *> actions)-
2077#endif-
2078{-
2079 for (int i = 0; i < actions.count(); ++i)
i < actions.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2080 insertAction(before, actions.at(i));
never executed: insertAction(before, actions.at(i));
0
2081}
never executed: end of block
0
2082-
2083/*!-
2084 \since 4.5-
2085-
2086 Removes the action \a action from this widget's list of actions.-
2087-
2088 \sa insertAction(), actions(), insertAction(), QWidget::removeAction()-
2089*/-
2090void QGraphicsWidget::removeAction(QAction *action)-
2091{-
2092 if (!action)
!actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
2093 return;
never executed: return;
0
2094-
2095 Q_D(QGraphicsWidget);-
2096-
2097 QActionPrivate *apriv = action->d_func();-
2098 apriv->graphicsWidgets.removeAll(this);-
2099-
2100 if (d->actions.removeAll(action)) {
d->actions.removeAll(action)Description
TRUEnever evaluated
FALSEnever evaluated
0
2101 QActionEvent e(QEvent::ActionRemoved, action);-
2102 QApplication::sendEvent(this, &e);-
2103 }
never executed: end of block
0
2104}
never executed: end of block
0
2105-
2106/*!-
2107 \since 4.5-
2108-
2109 Returns the (possibly empty) list of this widget's actions.-
2110-
2111 \sa insertAction(), removeAction(), QWidget::actions(),-
2112 QAction::associatedWidgets(), QAction::associatedGraphicsWidgets()-
2113*/-
2114QList<QAction *> QGraphicsWidget::actions() const-
2115{-
2116 Q_D(const QGraphicsWidget);-
2117 return d->actions;
never executed: return d->actions;
0
2118}-
2119#endif-
2120-
2121/*!-
2122 Moves the \a second widget around the ring of focus widgets so that-
2123 keyboard focus moves from the \a first widget to the \a second widget when-
2124 the Tab key is pressed.-
2125-
2126 Note that since the tab order of the \a second widget is changed, you-
2127 should order a chain like this:-
2128-
2129 \snippet code/src_gui_graphicsview_qgraphicswidget.cpp 1-
2130-
2131 \e not like this:-
2132-
2133 \snippet code/src_gui_graphicsview_qgraphicswidget.cpp 2-
2134-
2135 If \a first is 0, this indicates that \a second should be the first widget-
2136 to receive input focus should the scene gain Tab focus (i.e., the user-
2137 hits Tab so that focus passes into the scene). If \a second is 0, this-
2138 indicates that \a first should be the first widget to gain focus if the-
2139 scene gained BackTab focus.-
2140-
2141 By default, tab order is defined implicitly using widget creation order.-
2142-
2143 \sa focusPolicy, {Keyboard Focus in Widgets}-
2144*/-
2145void QGraphicsWidget::setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second)-
2146{-
2147 if (!first && !second) {
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
!secondDescription
TRUEnever evaluated
FALSEnever evaluated
0
2148 qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined");-
2149 return;
never executed: return;
0
2150 }-
2151 if ((first && second) && first->scene() != second->scene()) {
firstDescription
TRUEnever evaluated
FALSEnever evaluated
secondDescription
TRUEnever evaluated
FALSEnever evaluated
first->scene()...econd->scene()Description
TRUEnever evaluated
FALSEnever evaluated
0
2152 qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different",-
2153 first->scene(), second->scene());-
2154 return;
never executed: return;
0
2155 }-
2156 QGraphicsScene *scene = first ? first->scene() : second->scene();
firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
2157 if (!scene && (!first || !second)) {
!sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
!secondDescription
TRUEnever evaluated
FALSEnever evaluated
0
2158 qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"-
2159 " scene requires the item to be in a scene.");-
2160 return;
never executed: return;
0
2161 }-
2162-
2163 // If either first or second are 0, the scene's tabFocusFirst is updated-
2164 // to point to the first item in the scene's focus chain. Then first or-
2165 // second are set to point to tabFocusFirst.-
2166 QGraphicsScenePrivate *sceneD = scene->d_func();-
2167 if (!first) {
!firstDescription
TRUEnever evaluated
FALSEnever evaluated
0
2168 sceneD->tabFocusFirst = second;-
2169 return;
never executed: return;
0
2170 }-
2171 if (!second) {
!secondDescription
TRUEnever evaluated
FALSEnever evaluated
0
2172 sceneD->tabFocusFirst = first->d_func()->focusNext;-
2173 return;
never executed: return;
0
2174 }-
2175-
2176 // Both first and second are != 0.-
2177 QGraphicsWidget *firstFocusNext = first->d_func()->focusNext;-
2178 if (firstFocusNext == second) {
firstFocusNext == secondDescription
TRUEnever evaluated
FALSEnever evaluated
0
2179 // Nothing to do.-
2180 return;
never executed: return;
0
2181 }-
2182-
2183 // Update the focus chain.-
2184 QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev;-
2185 QGraphicsWidget *secondFocusNext = second->d_func()->focusNext;-
2186 firstFocusNext->d_func()->focusPrev = second;-
2187 first->d_func()->focusNext = second;-
2188 second->d_func()->focusNext = firstFocusNext;-
2189 second->d_func()->focusPrev = first;-
2190 secondFocusPrev->d_func()->focusNext = secondFocusNext;-
2191 secondFocusNext->d_func()->focusPrev = secondFocusPrev;-
2192-
2193 Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first);-
2194 Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first);-
2195-
2196 Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);-
2197 Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);-
2198-
2199}
never executed: end of block
0
2200-
2201/*!-
2202 If \a on is true, this function enables \a attribute; otherwise-
2203 \a attribute is disabled.-
2204-
2205 See the class documentation for QGraphicsWidget for a complete list of-
2206 which attributes are supported, and what they are for.-
2207-
2208 \sa testAttribute(), QWidget::setAttribute()-
2209*/-
2210void QGraphicsWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)-
2211{-
2212 Q_D(QGraphicsWidget);-
2213 // ### most flags require some immediate action-
2214 // ### we might want to qWarn use of unsupported attributes-
2215 // ### we might want to not use Qt::WidgetAttribute, but roll our own instead-
2216 d->setAttribute(attribute, on);-
2217}
never executed: end of block
0
2218-
2219/*!-
2220 Returns \c true if \a attribute is enabled for this widget; otherwise,-
2221 returns \c false.-
2222-
2223 \sa setAttribute()-
2224*/-
2225bool QGraphicsWidget::testAttribute(Qt::WidgetAttribute attribute) const-
2226{-
2227 Q_D(const QGraphicsWidget);-
2228 return d->testAttribute(attribute);
never executed: return d->testAttribute(attribute);
0
2229}-
2230-
2231/*!-
2232 \reimp-
2233*/-
2234int QGraphicsWidget::type() const-
2235{-
2236 return Type;
never executed: return Type;
0
2237}-
2238-
2239/*!-
2240 \reimp-
2241*/-
2242void QGraphicsWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
2243{-
2244 Q_UNUSED(painter);-
2245 Q_UNUSED(option);-
2246 Q_UNUSED(widget);-
2247}
never executed: end of block
0
2248-
2249/*!-
2250 This virtual function is called by QGraphicsScene to draw the window frame-
2251 for windows using \a painter, \a option, and \a widget, in local-
2252 coordinates. The base implementation uses the current style to render the-
2253 frame and title bar.-
2254-
2255 You can reimplement this function in a subclass of QGraphicsWidget to-
2256 provide custom rendering of the widget's window frame.-
2257-
2258 \sa QGraphicsItem::paint()-
2259*/-
2260void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,-
2261 QWidget *widget)-
2262{-
2263 const bool fillBackground = !testAttribute(Qt::WA_OpaquePaintEvent)
!testAttribute...quePaintEvent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2264 && !testAttribute(Qt::WA_NoSystemBackground);
!testAttribute...temBackground)Description
TRUEnever evaluated
FALSEnever evaluated
0
2265 QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(this);-
2266 const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();
proxyDescription
TRUEnever evaluated
FALSEnever evaluated
proxy->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
2267-
2268 if (rect().contains(option->exposedRect)) {
rect().contain...->exposedRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
2269 if (fillBackground && !embeddedWidgetFillsOwnBackground)
fillBackgroundDescription
TRUEnever evaluated
FALSEnever evaluated
!embeddedWidge...sOwnBackgroundDescription
TRUEnever evaluated
FALSEnever evaluated
0
2270 painter->fillRect(option->exposedRect, palette().window());
never executed: painter->fillRect(option->exposedRect, palette().window());
0
2271 return;
never executed: return;
0
2272 }-
2273-
2274 Q_D(QGraphicsWidget);-
2275-
2276 QRect windowFrameRect = QRect(QPoint(), windowFrameGeometry().size().toSize());-
2277 QStyleOptionTitleBar bar;-
2278 bar.QStyleOption::operator=(*option);-
2279 d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state-
2280 d->ensureWindowData();-
2281 bar.state.setFlag(QStyle::State_MouseOver, d->windowData->buttonMouseOver);-
2282 bar.state.setFlag(QStyle::State_Sunken, d->windowData->buttonSunken);-
2283 bar.rect = windowFrameRect;-
2284-
2285 // translate painter to make the style happy-
2286 const QPointF styleOrigin = this->windowFrameRect().topLeft();-
2287 painter->translate(styleOrigin);-
2288-
2289#ifdef Q_OS_MAC-
2290 const QSize pixmapSize = windowFrameRect.size();-
2291 if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0)-
2292 return;-
2293 QPainter *realPainter = painter;-
2294 QPixmap pm(pixmapSize);-
2295 painter = new QPainter(&pm);-
2296#endif-
2297-
2298 // Fill background-
2299 QStyleHintReturnMask mask;-
2300 bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
style()->style...widget, &mask)Description
TRUEnever evaluated
FALSEnever evaluated
!mask.region.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2301 bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);-
2302 int frameWidth = style()->pixelMetric(QStyle::PM_MDIFrameWidth, &bar, widget);-
2303 if (setMask) {
setMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
2304 painter->save();-
2305 painter->setClipRegion(mask.region, Qt::IntersectClip);-
2306 }
never executed: end of block
0
2307 if (fillBackground) {
fillBackgroundDescription
TRUEnever evaluated
FALSEnever evaluated
0
2308 if (embeddedWidgetFillsOwnBackground) {
embeddedWidget...sOwnBackgroundDescription
TRUEnever evaluated
FALSEnever evaluated
0
2309 // Don't fill the background twice.-
2310 QPainterPath windowFrameBackground;-
2311 windowFrameBackground.addRect(windowFrameRect);-
2312 // Adjust with 0.5 to avoid border artifacts between-
2313 // widget background and frame background.-
2314 windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));-
2315 painter->fillPath(windowFrameBackground, palette().window());-
2316 } else {
never executed: end of block
0
2317 painter->fillRect(windowFrameRect, palette().window());-
2318 }
never executed: end of block
0
2319 }-
2320-
2321 // Draw title-
2322 int height = (int)d->titleBarHeight(bar);-
2323 bar.rect.setHeight(height);-
2324 if (hasBorder) // Frame is painted by PE_FrameWindow
hasBorderDescription
TRUEnever evaluated
FALSEnever evaluated
0
2325 bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
never executed: bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
0
2326-
2327 painter->save();-
2328 painter->setFont(QApplication::font("QMdiSubWindowTitleBar"));-
2329 style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget);-
2330 painter->restore();-
2331 if (setMask)
setMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
2332 painter->restore();
never executed: painter->restore();
0
2333 // Draw window frame-
2334 QStyleOptionFrame frameOptions;-
2335 frameOptions.QStyleOption::operator=(*option);-
2336 initStyleOption(&frameOptions);-
2337 if (!hasBorder)
!hasBorderDescription
TRUEnever evaluated
FALSEnever evaluated
0
2338 painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip);
never executed: painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip);
0
2339 frameOptions.state.setFlag(QStyle::State_HasFocus, hasFocus());-
2340 bool isActive = isActiveWindow();-
2341 frameOptions.state.setFlag(QStyle::State_Active, isActive);-
2342-
2343 frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);-
2344 frameOptions.rect = windowFrameRect;-
2345 frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget);-
2346 frameOptions.midLineWidth = 1;-
2347 style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget);-
2348-
2349#ifdef Q_OS_MAC-
2350 realPainter->drawPixmap(QPoint(), pm);-
2351 delete painter;-
2352#endif-
2353}
never executed: end of block
0
2354-
2355/*!-
2356 \reimp-
2357*/-
2358QRectF QGraphicsWidget::boundingRect() const-
2359{-
2360 return windowFrameRect();
never executed: return windowFrameRect();
0
2361}-
2362-
2363/*!-
2364 \reimp-
2365*/-
2366QPainterPath QGraphicsWidget::shape() const-
2367{-
2368 QPainterPath path;-
2369 path.addRect(rect());-
2370 return path;
never executed: return path;
0
2371}-
2372-
2373/*!-
2374 Call this function to close the widget.-
2375-
2376 Returns \c true if the widget was closed; otherwise returns \c false.-
2377 This slot will first send a QCloseEvent to the widget, which may or may-
2378 not accept the event. If the event was ignored, nothing happens. If the-
2379 event was accepted, it will hide() the widget.-
2380-
2381 If the widget has the Qt::WA_DeleteOnClose attribute set it will be-
2382 deleted.-
2383*/-
2384bool QGraphicsWidget::close()-
2385{-
2386 QCloseEvent closeEvent;-
2387 QApplication::sendEvent(this, &closeEvent);-
2388 if (!closeEvent.isAccepted()) {
!closeEvent.isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
2389 return false;
never executed: return false;
0
2390 }-
2391 // hide-
2392 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2393 hide();-
2394 }
never executed: end of block
0
2395 if (testAttribute(Qt::WA_DeleteOnClose)) {
testAttribute(...DeleteOnClose)Description
TRUEnever evaluated
FALSEnever evaluated
0
2396 deleteLater();-
2397 }
never executed: end of block
0
2398 return true;
never executed: return true;
0
2399}-
2400-
2401#if 0-
2402void QGraphicsWidget::dumpFocusChain()-
2403{-
2404 qDebug("=========== Dumping focus chain ==============");-
2405 int i = 0;-
2406 QGraphicsWidget *next = this;-
2407 QSet<QGraphicsWidget*> visited;-
2408 do {-
2409 if (!next) {-
2410 qWarning("Found a focus chain that is not circular, (next == 0)");-
2411 break;-
2412 }-
2413 qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromLatin1("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << QLatin1String("next:") << next->d_func()->focusNext->data(0) << QLatin1String("prev:") << next->d_func()->focusPrev->data(0);-
2414 if (visited.contains(next)) {-
2415 qWarning("Already visited this node. However, I expected to dump until I found myself.");-
2416 break;-
2417 }-
2418 visited << next;-
2419 next = next->d_func()->focusNext;-
2420 } while (next != this);-
2421}-
2422#endif-
2423-
2424QT_END_NAMESPACE-
2425-
2426#include "moc_qgraphicswidget.cpp"-
2427-
2428#endif //QT_NO_GRAPHICSVIEW-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9