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

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