Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qglobal.h" | - |
41 | | - |
42 | #ifndef QT_NO_GRAPHICSVIEW | - |
43 | | - |
44 | #include "qgraphicswidget.h" | - |
45 | #include "qgraphicswidget_p.h" | - |
46 | #include "qgraphicslayout.h" | - |
47 | #include "qgraphicslayout_p.h" | - |
48 | #include "qgraphicsscene.h" | - |
49 | #include "qgraphicssceneevent.h" | - |
50 | | - |
51 | #ifndef QT_NO_ACTION | - |
52 | #include <private/qaction_p.h> | - |
53 | #endif | - |
54 | #include <private/qapplication_p.h> | - |
55 | #include <private/qgraphicsscene_p.h> | - |
56 | #ifndef QT_NO_SHORTCUT | - |
57 | #include <private/qshortcutmap_p.h> | - |
58 | #endif | - |
59 | #include <QtCore/qmutex.h> | - |
60 | #include <QtWidgets/qapplication.h> | - |
61 | #include <QtWidgets/qgraphicsview.h> | - |
62 | #include <QtWidgets/qgraphicsproxywidget.h> | - |
63 | #include <QtGui/qpalette.h> | - |
64 | #include <QtWidgets/qstyleoption.h> | - |
65 | | - |
66 | #include <qdebug.h> | - |
67 | | - |
68 | QT_BEGIN_NAMESPACE | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) | - |
177 | : QGraphicsObject(*new QGraphicsWidgetPrivate, 0), QGraphicsLayoutItem(0, false) | - |
178 | { | - |
179 | Q_D(QGraphicsWidget); | - |
180 | d->init(parent, wFlags); | - |
181 | } | - |
182 | | - |
183 | | - |
184 | | - |
185 | | - |
186 | | - |
187 | | - |
188 | QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags) | - |
189 | : QGraphicsObject(dd, 0), QGraphicsLayoutItem(0, false) | - |
190 | { | - |
191 | Q_D(QGraphicsWidget); | - |
192 | d->init(parent, wFlags); | - |
193 | } | - |
194 | | - |
195 | | - |
196 | | - |
197 | | - |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | class QGraphicsWidgetStyles | - |
205 | { | - |
206 | public: | - |
207 | QStyle *styleForWidget(const QGraphicsWidget *widget) const | - |
208 | { | - |
209 | QMutexLocker locker(&mutex); | - |
210 | return styles.value(widget, 0); | - |
211 | } | - |
212 | | - |
213 | void setStyleForWidget(QGraphicsWidget *widget, QStyle *style) | - |
214 | { | - |
215 | QMutexLocker locker(&mutex); | - |
216 | if (style) | - |
217 | styles[widget] = style; | - |
218 | else | - |
219 | styles.remove(widget); | - |
220 | } | - |
221 | | - |
222 | private: | - |
223 | QHash<const QGraphicsWidget *, QStyle *> styles; | - |
224 | mutable QMutex mutex; | - |
225 | }; | - |
226 | Q_GLOBAL_STATIC(QGraphicsWidgetStyles, widgetStyles) | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | QGraphicsWidget::~QGraphicsWidget() | - |
232 | { | - |
233 | Q_D(QGraphicsWidget); | - |
234 | #ifndef QT_NO_ACTION | - |
235 | | - |
236 | for (int i = 0; i < d->actions.size(); ++i) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
237 | QActionPrivate *apriv = d->actions.at(i)->d_func(); | - |
238 | apriv->graphicsWidgets.removeAll(this); | - |
239 | } never executed: end of block | 0 |
240 | d->actions.clear(); | - |
241 | #endif | - |
242 | | - |
243 | if (QGraphicsScene *scn = scene()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
244 | QGraphicsScenePrivate *sceneD = scn->d_func(); | - |
245 | if (sceneD->tabFocusFirst == this)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
246 | sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext); never executed: sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext); TRUE | never evaluated | FALSE | never evaluated |
| 0 |
247 | } never executed: end of block | 0 |
248 | d->focusPrev->d_func()->focusNext = d->focusNext; | - |
249 | d->focusNext->d_func()->focusPrev = d->focusPrev; | - |
250 | | - |
251 | | - |
252 | d->focusNext = this; | - |
253 | d->focusPrev = this; | - |
254 | | - |
255 | clearFocus(); | - |
256 | | - |
257 | | - |
258 | if (d->layout) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
259 | QGraphicsLayout *temp = d->layout; | - |
260 | foreachconst auto items = childItems(); | - |
261 | for (QGraphicsItem *item , childItems()): items) { | - |
262 | | - |
263 | | - |
264 | | - |
265 | if (item->isWidget()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
266 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); | - |
267 | if (widget->parentLayoutItem() == d->layout)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
268 | widget->setParentLayoutItem(0); never executed: widget->setParentLayoutItem(0); | 0 |
269 | } never executed: end of block | 0 |
270 | } never executed: end of block | 0 |
271 | d->layout = 0; | - |
272 | delete temp; | - |
273 | } never executed: end of block | 0 |
274 | | - |
275 | | - |
276 | widgetStyles()->setStyleForWidget(this, 0); | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | setParentItem(Q_NULLPTR); | - |
282 | } never executed: end of block | 0 |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | | - |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | | - |
302 | | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | QSizeF QGraphicsWidget::size() const | - |
308 | { | - |
309 | return QGraphicsLayoutItem::geometry().size(); | - |
310 | } | - |
311 | | - |
312 | void QGraphicsWidget::resize(const QSizeF &size) | - |
313 | { | - |
314 | setGeometry(QRectF(pos(), size)); | - |
315 | } | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | | - |
325 | | - |
326 | | - |
327 | | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | | - |
346 | | - |
347 | | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | void QGraphicsWidget::setGeometry(const QRectF &rect) | - |
354 | { | - |
355 | QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func(); | - |
356 | QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data(); | - |
357 | QRectF newGeom; | - |
358 | QPointF oldPos = d->geom.topLeft(); | - |
359 | if (!wd->inSetPos) { | - |
360 | setAttribute(Qt::WA_Resized); | - |
361 | newGeom = rect; | - |
362 | newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize)) | - |
363 | .boundedTo(effectiveSizeHint(Qt::MaximumSize))); | - |
364 | | - |
365 | if (newGeom == d->geom) { | - |
366 | goto relayoutChildrenAndReturn; | - |
367 | } | - |
368 | | - |
369 | | - |
370 | wd->inSetGeometry = 1; | - |
371 | setPos(newGeom.topLeft()); | - |
372 | wd->inSetGeometry = 0; | - |
373 | newGeom.moveTopLeft(pos()); | - |
374 | | - |
375 | if (newGeom == d->geom) { | - |
376 | goto relayoutChildrenAndReturn; | - |
377 | } | - |
378 | | - |
379 | | - |
380 | if (wd->scene) { | - |
381 | if (rect.topLeft() == d->geom.topLeft()) { | - |
382 | prepareGeometryChange(); | - |
383 | } | - |
384 | } | - |
385 | } | - |
386 | | - |
387 | | - |
388 | { | - |
389 | bool moved = oldPos != pos(); | - |
390 | if (moved) { | - |
391 | | - |
392 | QGraphicsSceneMoveEvent event; | - |
393 | event.setOldPos(oldPos); | - |
394 | event.setNewPos(pos()); | - |
395 | QApplication::sendEvent(this, &event); | - |
396 | if (wd->inSetPos) { | - |
397 | | - |
398 | d->geom.moveTopLeft(pos()); | - |
399 | emit geometryChanged(); | - |
400 | goto relayoutChildrenAndReturn; | - |
401 | } | - |
402 | } | - |
403 | QSizeF oldSize = size(); | - |
404 | QGraphicsLayoutItem::setGeometry(newGeom); | - |
405 | | - |
406 | bool resized = newGeom.size() != oldSize; | - |
407 | if (resized) { | - |
408 | QGraphicsSceneResizeEvent re; | - |
409 | re.setOldSize(oldSize); | - |
410 | re.setNewSize(newGeom.size()); | - |
411 | if (oldSize.width() != newGeom.size().width()) | - |
412 | emit widthChanged(); | - |
413 | if (oldSize.height() != newGeom.size().height()) | - |
414 | emit heightChanged(); | - |
415 | QGraphicsLayout *lay = wd->layout; | - |
416 | if (QGraphicsLayout::instantInvalidatePropagation()) { | - |
417 | if (!lay || lay->isActivated()) { | - |
418 | QApplication::sendEvent(this, &re); | - |
419 | } | - |
420 | } else { | - |
421 | QApplication::sendEvent(this, &re); | - |
422 | } | - |
423 | } | - |
424 | } | - |
425 | | - |
426 | emit geometryChanged(); | - |
427 | relayoutChildrenAndReturn: | - |
428 | if (QGraphicsLayout::instantInvalidatePropagation()) { | - |
429 | if (QGraphicsLayout *lay = wd->layout) { | - |
430 | if (!lay->isActivated()) { | - |
431 | QEvent layoutRequest(QEvent::LayoutRequest); | - |
432 | QApplication::sendEvent(this, &layoutRequest); | - |
433 | } | - |
434 | } | - |
435 | } | - |
436 | } | - |
437 | | - |
438 | | - |
439 | | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | | - |
445 | | - |
446 | | - |
447 | | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | | - |
465 | | - |
466 | | - |
467 | | - |
468 | | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | | - |
478 | | - |
479 | | - |
480 | | - |
481 | | - |
482 | | - |
483 | | - |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | | - |
493 | void QGraphicsWidget::setContentsMargins(qreal left, qreal top, qreal right, qreal bottom) | - |
494 | { | - |
495 | Q_D(QGraphicsWidget); | - |
496 | | - |
497 | if (!d->margins && left == 0 && top == 0 && right == 0 && bottom == 0) | - |
498 | return; | - |
499 | d->ensureMargins(); | - |
500 | if (left == d->margins[d->Left] | - |
501 | && top == d->margins[d->Top] | - |
502 | && right == d->margins[d->Right] | - |
503 | && bottom == d->margins[d->Bottom]) | - |
504 | return; | - |
505 | | - |
506 | d->margins[d->Left] = left; | - |
507 | d->margins[d->Top] = top; | - |
508 | d->margins[d->Right] = right; | - |
509 | d->margins[d->Bottom] = bottom; | - |
510 | | - |
511 | if (QGraphicsLayout *l = d->layout) | - |
512 | l->invalidate(); | - |
513 | else | - |
514 | updateGeometry(); | - |
515 | | - |
516 | QEvent e(QEvent::ContentsRectChange); | - |
517 | QApplication::sendEvent(this, &e); | - |
518 | } | - |
519 | | - |
520 | | - |
521 | | - |
522 | | - |
523 | | - |
524 | | - |
525 | | - |
526 | | - |
527 | void QGraphicsWidget::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const | - |
528 | { | - |
529 | Q_D(const QGraphicsWidget); | - |
530 | if (left || top || right || bottom) | - |
531 | d->ensureMargins(); | - |
532 | if (left) | - |
533 | *left = d->margins[d->Left]; | - |
534 | if (top) | - |
535 | *top = d->margins[d->Top]; | - |
536 | if (right) | - |
537 | *right = d->margins[d->Right]; | - |
538 | if (bottom) | - |
539 | *bottom = d->margins[d->Bottom]; | - |
540 | } | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | void QGraphicsWidget::setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom) | - |
553 | { | - |
554 | Q_D(QGraphicsWidget); | - |
555 | | - |
556 | if (!d->windowFrameMargins && left == 0 && top == 0 && right == 0 && bottom == 0) | - |
557 | return; | - |
558 | d->ensureWindowFrameMargins(); | - |
559 | bool unchanged = | - |
560 | d->windowFrameMargins[d->Left] == left | - |
561 | && d->windowFrameMargins[d->Top] == top | - |
562 | && d->windowFrameMargins[d->Right] == right | - |
563 | && d->windowFrameMargins[d->Bottom] == bottom; | - |
564 | if (d->setWindowFrameMargins && unchanged) | - |
565 | return; | - |
566 | if (!unchanged) | - |
567 | prepareGeometryChange(); | - |
568 | d->windowFrameMargins[d->Left] = left; | - |
569 | d->windowFrameMargins[d->Top] = top; | - |
570 | d->windowFrameMargins[d->Right] = right; | - |
571 | d->windowFrameMargins[d->Bottom] = bottom; | - |
572 | d->setWindowFrameMargins = true; | - |
573 | } | - |
574 | | - |
575 | | - |
576 | | - |
577 | | - |
578 | | - |
579 | | - |
580 | | - |
581 | | - |
582 | void QGraphicsWidget::getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const | - |
583 | { | - |
584 | Q_D(const QGraphicsWidget); | - |
585 | if (left || top || right || bottom) | - |
586 | d->ensureWindowFrameMargins(); | - |
587 | if (left) | - |
588 | *left = d->windowFrameMargins[d->Left]; | - |
589 | if (top) | - |
590 | *top = d->windowFrameMargins[d->Top]; | - |
591 | if (right) | - |
592 | *right = d->windowFrameMargins[d->Right]; | - |
593 | if (bottom) | - |
594 | *bottom = d->windowFrameMargins[d->Bottom]; | - |
595 | } | - |
596 | | - |
597 | | - |
598 | | - |
599 | | - |
600 | | - |
601 | | - |
602 | void QGraphicsWidget::unsetWindowFrameMargins() | - |
603 | { | - |
604 | Q_D(QGraphicsWidget); | - |
605 | if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup && | - |
606 | (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) { | - |
607 | QStyleOptionTitleBar bar; | - |
608 | d->initStyleOptionTitleBar(&bar); | - |
609 | QStyle *style = this->style(); | - |
610 | qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth); | - |
611 | qreal titleBarHeight = d->titleBarHeight(bar); | - |
612 | setWindowFrameMargins(margin, titleBarHeight, margin, margin); | - |
613 | } else { | - |
614 | setWindowFrameMargins(0, 0, 0, 0); | - |
615 | } | - |
616 | d->setWindowFrameMargins = false; | - |
617 | } | - |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | | - |
625 | QRectF QGraphicsWidget::windowFrameGeometry() const | - |
626 | { | - |
627 | Q_D(const QGraphicsWidget); | - |
628 | return d->windowFrameMargins | - |
629 | ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], | - |
630 | d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) | - |
631 | : geometry(); | - |
632 | } | - |
633 | | - |
634 | | - |
635 | | - |
636 | | - |
637 | | - |
638 | | - |
639 | QRectF QGraphicsWidget::windowFrameRect() const | - |
640 | { | - |
641 | Q_D(const QGraphicsWidget); | - |
642 | return d->windowFrameMargins | - |
643 | ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top], | - |
644 | d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom]) | - |
645 | : rect(); | - |
646 | } | - |
647 | | - |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | | - |
653 | | - |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | | - |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | | - |
669 | | - |
670 | | - |
671 | | - |
672 | | - |
673 | | - |
674 | | - |
675 | | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | | - |
681 | | - |
682 | | - |
683 | | - |
684 | | - |
685 | | - |
686 | | - |
687 | | - |
688 | | - |
689 | | - |
690 | void QGraphicsWidget::initStyleOption(QStyleOption *option) const | - |
691 | { | - |
692 | Q_ASSERT(option); | - |
693 | | - |
694 | option->state = QStyle::State_None; | - |
695 | if (isEnabled()) | - |
696 | option->state |= QStyle::State_Enabled; | - |
697 | if (hasFocus()) | - |
698 | option->state |= QStyle::State_HasFocus; | - |
699 | | - |
700 | | - |
701 | if (isUnderMouse()) | - |
702 | option->state |= QStyle::State_MouseOver; | - |
703 | if (QGraphicsWidget *w = window()) { | - |
704 | if (w->isActiveWindow()) | - |
705 | option->state |= QStyle::State_Active; | - |
706 | } | - |
707 | if (isWindow()) | - |
708 | option->state |= QStyle::State_Window; | - |
709 | | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | | - |
717 | | - |
718 | | - |
719 | | - |
720 | | - |
721 | | - |
722 | | - |
723 | | - |
724 | | - |
725 | | - |
726 | | - |
727 | | - |
728 | | - |
729 | | - |
730 | | - |
731 | | - |
732 | option->direction = layoutDirection(); | - |
733 | option->rect = rect().toRect(); | - |
734 | option->palette = palette(); | - |
735 | if (!isEnabled()) { | - |
736 | option->palette.setCurrentColorGroup(QPalette::Disabled); | - |
737 | } else if (isActiveWindow()) { | - |
738 | option->palette.setCurrentColorGroup(QPalette::Active); | - |
739 | } else { | - |
740 | option->palette.setCurrentColorGroup(QPalette::Inactive); | - |
741 | } | - |
742 | option->fontMetrics = QFontMetrics(font()); | - |
743 | option->styleObject = const_cast<QGraphicsWidget *>(this); | - |
744 | } | - |
745 | | - |
746 | | - |
747 | | - |
748 | | - |
749 | QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | - |
750 | { | - |
751 | Q_D(const QGraphicsWidget); | - |
752 | QSizeF sh; | - |
753 | if (d->layout) { | - |
754 | QSizeF marginSize(0,0); | - |
755 | if (d->margins) { | - |
756 | marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right], | - |
757 | d->margins[d->Top] + d->margins[d->Bottom]); | - |
758 | } | - |
759 | sh = d->layout->effectiveSizeHint(which, constraint - marginSize); | - |
760 | sh += marginSize; | - |
761 | } else { | - |
762 | switch (which) { | - |
763 | case Qt::MinimumSize: | - |
764 | sh = QSizeF(0, 0); | - |
765 | break; | - |
766 | case Qt::PreferredSize: | - |
767 | sh = QSizeF(50, 50); | - |
768 | break; | - |
769 | case Qt::MaximumSize: | - |
770 | sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); | - |
771 | break; | - |
772 | default: | - |
773 | qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'"); | - |
774 | break; | - |
775 | } | - |
776 | } | - |
777 | return sh; | - |
778 | } | - |
779 | | - |
780 | | - |
781 | | - |
782 | | - |
783 | | - |
784 | | - |
785 | | - |
786 | | - |
787 | | - |
788 | | - |
789 | | - |
790 | | - |
791 | | - |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | | - |
799 | | - |
800 | | - |
801 | | - |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | | - |
810 | | - |
811 | | - |
812 | | - |
813 | QGraphicsLayout *QGraphicsWidget::layout() const | - |
814 | { | - |
815 | Q_D(const QGraphicsWidget); | - |
816 | return d->layout; | - |
817 | } | - |
818 | | - |
819 | | - |
820 | | - |
821 | | - |
822 | | - |
823 | | - |
824 | | - |
825 | | - |
826 | | - |
827 | | - |
828 | | - |
829 | | - |
830 | | - |
831 | | - |
832 | | - |
833 | | - |
834 | | - |
835 | | - |
836 | | - |
837 | | - |
838 | void QGraphicsWidget::setLayout(QGraphicsLayout *l) | - |
839 | { | - |
840 | Q_D(QGraphicsWidget); | - |
841 | if (d->layout == l) | - |
842 | return; | - |
843 | d->setLayout_helper(l); | - |
844 | if (!l) | - |
845 | return; | - |
846 | | - |
847 | | - |
848 | QGraphicsLayoutItem *oldParent = l->parentLayoutItem(); | - |
849 | if (oldParent && oldParent != this) { | - |
850 | qWarning("QGraphicsWidget::setLayout: Attempting to set a layout on %s" | - |
851 | " \"%s\", when the layout already has a parent", | - |
852 | metaObject()->className(), qPrintable(objectName())); | - |
853 | return; | - |
854 | } | - |
855 | | - |
856 | | - |
857 | l->setParentLayoutItem(this); | - |
858 | l->d_func()->reparentChildItems(this); | - |
859 | l->invalidate(); | - |
860 | emit layoutChanged(); | - |
861 | } | - |
862 | | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | | - |
871 | void QGraphicsWidget::adjustSize() | - |
872 | { | - |
873 | QSizeF sz = effectiveSizeHint(Qt::PreferredSize); | - |
874 | | - |
875 | if (sz.isValid()) | - |
876 | resize(sz); | - |
877 | } | - |
878 | | - |
879 | | - |
880 | | - |
881 | | - |
882 | | - |
883 | | - |
884 | | - |
885 | | - |
886 | | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | | - |
892 | | - |
893 | | - |
894 | | - |
895 | | - |
896 | | - |
897 | | - |
898 | | - |
899 | | - |
900 | | - |
901 | | - |
902 | | - |
903 | | - |
904 | | - |
905 | Qt::LayoutDirection QGraphicsWidget::layoutDirection() const | - |
906 | { | - |
907 | return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight; | - |
908 | } | - |
909 | void QGraphicsWidget::setLayoutDirection(Qt::LayoutDirection direction) | - |
910 | { | - |
911 | Q_D(QGraphicsWidget); | - |
912 | setAttribute(Qt::WA_SetLayoutDirection, true); | - |
913 | d->setLayoutDirection_helper(direction); | - |
914 | } | - |
915 | void QGraphicsWidget::unsetLayoutDirection() | - |
916 | { | - |
917 | Q_D(QGraphicsWidget); | - |
918 | setAttribute(Qt::WA_SetLayoutDirection, false); | - |
919 | d->resolveLayoutDirection(); | - |
920 | } | - |
921 | | - |
922 | | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | | - |
930 | QStyle *QGraphicsWidget::style() const | - |
931 | { | - |
932 | if (QStyle *style = widgetStyles()->styleForWidget(this)) | - |
933 | return style; | - |
934 | | - |
935 | return scene() ? scene()->style() : QApplication::style(); | - |
936 | } | - |
937 | | - |
938 | | - |
939 | | - |
940 | | - |
941 | | - |
942 | | - |
943 | | - |
944 | | - |
945 | | - |
946 | | - |
947 | | - |
948 | | - |
949 | | - |
950 | | - |
951 | void QGraphicsWidget::setStyle(QStyle *style) | - |
952 | { | - |
953 | setAttribute(Qt::WA_SetStyle, style != 0); | - |
954 | widgetStyles()->setStyleForWidget(this, style); | - |
955 | | - |
956 | | - |
957 | QEvent event(QEvent::StyleChange); | - |
958 | QApplication::sendEvent(this, &event); | - |
959 | } | - |
960 | | - |
961 | | - |
962 | | - |
963 | | - |
964 | | - |
965 | | - |
966 | | - |
967 | | - |
968 | | - |
969 | | - |
970 | | - |
971 | | - |
972 | | - |
973 | | - |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | | - |
979 | | - |
980 | | - |
981 | | - |
982 | | - |
983 | QFont QGraphicsWidget::font() const | - |
984 | { | - |
985 | Q_D(const QGraphicsWidget); | - |
986 | QFont fnt = d->font; | - |
987 | fnt.resolve(fnt.resolve() | d->inheritedFontResolveMask); | - |
988 | return fnt; | - |
989 | } | - |
990 | void QGraphicsWidget::setFont(const QFont &font) | - |
991 | { | - |
992 | Q_D(QGraphicsWidget); | - |
993 | setAttribute(Qt::WA_SetFont, font.resolve() != 0); | - |
994 | | - |
995 | QFont naturalFont = d->naturalWidgetFont(); | - |
996 | QFont resolvedFont = font.resolve(naturalFont); | - |
997 | d->setFont_helper(resolvedFont); | - |
998 | } | - |
999 | | - |
1000 | | - |
1001 | | - |
1002 | | - |
1003 | | - |
1004 | | - |
1005 | | - |
1006 | | - |
1007 | | - |
1008 | | - |
1009 | | - |
1010 | | - |
1011 | | - |
1012 | | - |
1013 | | - |
1014 | | - |
1015 | | - |
1016 | | - |
1017 | | - |
1018 | | - |
1019 | | - |
1020 | | - |
1021 | | - |
1022 | | - |
1023 | | - |
1024 | | - |
1025 | QPalette QGraphicsWidget::palette() const | - |
1026 | { | - |
1027 | Q_D(const QGraphicsWidget); | - |
1028 | return d->palette; | - |
1029 | } | - |
1030 | void QGraphicsWidget::setPalette(const QPalette &palette) | - |
1031 | { | - |
1032 | Q_D(QGraphicsWidget); | - |
1033 | setAttribute(Qt::WA_SetPalette, palette.resolve() != 0); | - |
1034 | | - |
1035 | QPalette naturalPalette = d->naturalWidgetPalette(); | - |
1036 | QPalette resolvedPalette = palette.resolve(naturalPalette); | - |
1037 | d->setPalette_helper(resolvedPalette); | - |
1038 | } | - |
1039 | | - |
1040 | | - |
1041 | | - |
1042 | | - |
1043 | | - |
1044 | | - |
1045 | | - |
1046 | | - |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | | - |
1051 | | - |
1052 | | - |
1053 | | - |
1054 | | - |
1055 | | - |
1056 | bool QGraphicsWidget::autoFillBackground() const | - |
1057 | { | - |
1058 | Q_D(const QGraphicsWidget); | - |
1059 | return d->autoFillBackground; | - |
1060 | } | - |
1061 | void QGraphicsWidget::setAutoFillBackground(bool enabled) | - |
1062 | { | - |
1063 | Q_D(QGraphicsWidget); | - |
1064 | if (d->autoFillBackground != enabled) { | - |
1065 | d->autoFillBackground = enabled; | - |
1066 | update(); | - |
1067 | } | - |
1068 | } | - |
1069 | | - |
1070 | | - |
1071 | | - |
1072 | | - |
1073 | | - |
1074 | | - |
1075 | | - |
1076 | | - |
1077 | | - |
1078 | | - |
1079 | void QGraphicsWidget::updateGeometry() | - |
1080 | { | - |
1081 | QGraphicsLayoutItem::updateGeometry(); | - |
1082 | QGraphicsLayoutItem *parentItem = parentLayoutItem(); | - |
1083 | | - |
1084 | if (parentItem && parentItem->isLayout()) { | - |
1085 | if (QGraphicsLayout::instantInvalidatePropagation()) { | - |
1086 | static_cast<QGraphicsLayout *>(parentItem)->invalidate(); | - |
1087 | } else { | - |
1088 | parentItem->updateGeometry(); | - |
1089 | } | - |
1090 | } else { | - |
1091 | if (parentItem) { | - |
1092 | | - |
1093 | QGraphicsWidget *parentWid = parentWidget(); | - |
1094 | if (parentWid->isVisible()) | - |
1095 | QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest)); | - |
1096 | } else { | - |
1097 | | - |
1098 | | - |
1099 | | - |
1100 | | - |
1101 | | - |
1102 | if (QGraphicsLayout::instantInvalidatePropagation()) | - |
1103 | QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest)); | - |
1104 | } | - |
1105 | if (!QGraphicsLayout::instantInvalidatePropagation()) { | - |
1106 | bool wasResized = testAttribute(Qt::WA_Resized); | - |
1107 | resize(size()); | - |
1108 | setAttribute(Qt::WA_Resized, wasResized); | - |
1109 | } | - |
1110 | } | - |
1111 | } | - |
1112 | | - |
1113 | | - |
1114 | | - |
1115 | | - |
1116 | | - |
1117 | | - |
1118 | | - |
1119 | | - |
1120 | | - |
1121 | | - |
1122 | | - |
1123 | | - |
1124 | | - |
1125 | | - |
1126 | | - |
1127 | | - |
1128 | | - |
1129 | | - |
1130 | | - |
1131 | | - |
1132 | | - |
1133 | QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &value) | - |
1134 | { | - |
1135 | Q_D(QGraphicsWidget); | - |
1136 | switch (change) { | - |
1137 | case ItemEnabledHasChanged: { | - |
1138 | | - |
1139 | QEvent event(QEvent::EnabledChange); | - |
1140 | QApplication::sendEvent(this, &event); | - |
1141 | break; | - |
1142 | } | - |
1143 | case ItemVisibleChange: | - |
1144 | if (value.toBool()) { | - |
1145 | | - |
1146 | QShowEvent event; | - |
1147 | QApplication::sendEvent(this, &event); | - |
1148 | bool resized = testAttribute(Qt::WA_Resized); | - |
1149 | if (!resized) { | - |
1150 | adjustSize(); | - |
1151 | setAttribute(Qt::WA_Resized, false); | - |
1152 | } | - |
1153 | } | - |
1154 | | - |
1155 | | - |
1156 | if (value.toBool() || d->explicitlyHidden) | - |
1157 | updateGeometry(); | - |
1158 | break; | - |
1159 | case ItemVisibleHasChanged: | - |
1160 | if (!value.toBool()) { | - |
1161 | | - |
1162 | QHideEvent event; | - |
1163 | QApplication::sendEvent(this, &event); | - |
1164 | } | - |
1165 | break; | - |
1166 | case ItemPositionHasChanged: | - |
1167 | d->setGeometryFromSetPos(); | - |
1168 | break; | - |
1169 | case ItemParentChange: { | - |
1170 | | - |
1171 | QEvent event(QEvent::ParentAboutToChange); | - |
1172 | QApplication::sendEvent(this, &event); | - |
1173 | break; | - |
1174 | } | - |
1175 | case ItemParentHasChanged: { | - |
1176 | | - |
1177 | QEvent event(QEvent::ParentChange); | - |
1178 | QApplication::sendEvent(this, &event); | - |
1179 | break; | - |
1180 | } | - |
1181 | case ItemCursorHasChanged: { | - |
1182 | | - |
1183 | QEvent event(QEvent::CursorChange); | - |
1184 | QApplication::sendEvent(this, &event); | - |
1185 | break; | - |
1186 | } | - |
1187 | case ItemToolTipHasChanged: { | - |
1188 | | - |
1189 | QEvent event(QEvent::ToolTipChange); | - |
1190 | QApplication::sendEvent(this, &event); | - |
1191 | break; | - |
1192 | } | - |
1193 | default: | - |
1194 | break; | - |
1195 | } | - |
1196 | return QGraphicsItem::itemChange(change, value); | - |
1197 | } | - |
1198 | | - |
1199 | | - |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | | - |
1206 | | - |
1207 | | - |
1208 | | - |
1209 | | - |
1210 | | - |
1211 | | - |
1212 | | - |
1213 | | - |
1214 | | - |
1215 | | - |
1216 | | - |
1217 | | - |
1218 | | - |
1219 | | - |
1220 | | - |
1221 | | - |
1222 | | - |
1223 | | - |
1224 | | - |
1225 | QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVariant &value) | - |
1226 | { | - |
1227 | Q_UNUSED(propertyName); | - |
1228 | return value; | - |
1229 | } | - |
1230 | | - |
1231 | | - |
1232 | | - |
1233 | | - |
1234 | | - |
1235 | | - |
1236 | | - |
1237 | | - |
1238 | | - |
1239 | bool QGraphicsWidget::sceneEvent(QEvent *event) | - |
1240 | { | - |
1241 | return QGraphicsItem::sceneEvent(event); | - |
1242 | } | - |
1243 | | - |
1244 | | - |
1245 | | - |
1246 | | - |
1247 | | - |
1248 | | - |
1249 | | - |
1250 | | - |
1251 | | - |
1252 | | - |
1253 | | - |
1254 | | - |
1255 | | - |
1256 | | - |
1257 | bool QGraphicsWidget::windowFrameEvent(QEvent *event) | - |
1258 | { | - |
1259 | Q_D(QGraphicsWidget); | - |
1260 | switch (event->type()) { | - |
1261 | case QEvent::GraphicsSceneMousePress: | - |
1262 | d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
1263 | break; | - |
1264 | case QEvent::GraphicsSceneMouseMove: | - |
1265 | d->ensureWindowData(); | - |
1266 | if (d->windowData->grabbedSection != Qt::NoSection) { | - |
1267 | d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
1268 | event->accept(); | - |
1269 | } | - |
1270 | break; | - |
1271 | case QEvent::GraphicsSceneMouseRelease: | - |
1272 | d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
1273 | break; | - |
1274 | case QEvent::GraphicsSceneHoverMove: | - |
1275 | d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); | - |
1276 | break; | - |
1277 | case QEvent::GraphicsSceneHoverLeave: | - |
1278 | d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); | - |
1279 | break; | - |
1280 | default: | - |
1281 | break; | - |
1282 | } | - |
1283 | return event->isAccepted(); | - |
1284 | } | - |
1285 | | - |
1286 | | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | | - |
1291 | | - |
1292 | | - |
1293 | | - |
1294 | | - |
1295 | | - |
1296 | | - |
1297 | | - |
1298 | | - |
1299 | | - |
1300 | | - |
1301 | | - |
1302 | | - |
1303 | | - |
1304 | Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) const | - |
1305 | { | - |
1306 | Q_D(const QGraphicsWidget); | - |
1307 | | - |
1308 | const QRectF r = windowFrameRect(); | - |
1309 | if (!r.contains(pos)) | - |
1310 | return Qt::NoSection; | - |
1311 | | - |
1312 | const qreal left = r.left(); | - |
1313 | const qreal top = r.top(); | - |
1314 | const qreal right = r.right(); | - |
1315 | const qreal bottom = r.bottom(); | - |
1316 | const qreal x = pos.x(); | - |
1317 | const qreal y = pos.y(); | - |
1318 | | - |
1319 | const qreal cornerMargin = 20; | - |
1320 | | - |
1321 | const qreal windowFrameWidth = d->windowFrameMargins | - |
1322 | ? d->windowFrameMargins[d->Left] : 0; | - |
1323 | | - |
1324 | Qt::WindowFrameSection s = Qt::NoSection; | - |
1325 | if (x <= left + cornerMargin) { | - |
1326 | if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) { | - |
1327 | s = Qt::TopLeftSection; | - |
1328 | } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - cornerMargin)) { | - |
1329 | s = Qt::BottomLeftSection; | - |
1330 | } else if (x <= left + windowFrameWidth) { | - |
1331 | s = Qt::LeftSection; | - |
1332 | } | - |
1333 | } else if (x >= right - cornerMargin) { | - |
1334 | if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) { | - |
1335 | s = Qt::TopRightSection; | - |
1336 | } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - cornerMargin)) { | - |
1337 | s = Qt::BottomRightSection; | - |
1338 | } else if (x >= right - windowFrameWidth) { | - |
1339 | s = Qt::RightSection; | - |
1340 | } | - |
1341 | } else if (y <= top + windowFrameWidth) { | - |
1342 | s = Qt::TopSection; | - |
1343 | } else if (y >= bottom - windowFrameWidth) { | - |
1344 | s = Qt::BottomSection; | - |
1345 | } | - |
1346 | if (s == Qt::NoSection) { | - |
1347 | QRectF r1 = r; | - |
1348 | r1.setHeight(d->windowFrameMargins | - |
1349 | ? d->windowFrameMargins[d->Top] : 0); | - |
1350 | if (r1.contains(pos)) | - |
1351 | s = Qt::TitleBarArea; | - |
1352 | } | - |
1353 | return s; | - |
1354 | } | - |
1355 | | - |
1356 | | - |
1357 | | - |
1358 | | - |
1359 | | - |
1360 | | - |
1361 | | - |
1362 | | - |
1363 | | - |
1364 | | - |
1365 | | - |
1366 | | - |
1367 | | - |
1368 | | - |
1369 | | - |
1370 | | - |
1371 | | - |
1372 | | - |
1373 | | - |
1374 | | - |
1375 | | - |
1376 | | - |
1377 | | - |
1378 | | - |
1379 | | - |
1380 | | - |
1381 | | - |
1382 | | - |
1383 | | - |
1384 | | - |
1385 | | - |
1386 | | - |
1387 | | - |
1388 | | - |
1389 | | - |
1390 | | - |
1391 | | - |
1392 | | - |
1393 | bool QGraphicsWidget::event(QEvent *event) | - |
1394 | { | - |
1395 | Q_D(QGraphicsWidget); | - |
1396 | | - |
1397 | if (d->layout) | - |
1398 | d->layout->widgetEvent(event); | - |
1399 | | - |
1400 | | - |
1401 | switch (event->type()) { | - |
1402 | case QEvent::GraphicsSceneMove: | - |
1403 | moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event)); | - |
1404 | break; | - |
1405 | case QEvent::GraphicsSceneResize: | - |
1406 | resizeEvent(static_cast<QGraphicsSceneResizeEvent *>(event)); | - |
1407 | break; | - |
1408 | case QEvent::Show: | - |
1409 | showEvent(static_cast<QShowEvent *>(event)); | - |
1410 | break; | - |
1411 | case QEvent::Hide: | - |
1412 | hideEvent(static_cast<QHideEvent *>(event)); | - |
1413 | break; | - |
1414 | case QEvent::Polish: | - |
1415 | polishEvent(); | - |
1416 | d->polished = true; | - |
1417 | if (!d->font.isCopyOf(QApplication::font())) | - |
1418 | d->updateFont(d->font); | - |
1419 | break; | - |
1420 | case QEvent::WindowActivate: | - |
1421 | case QEvent::WindowDeactivate: | - |
1422 | update(); | - |
1423 | break; | - |
1424 | case QEvent::StyleAnimationUpdate: | - |
1425 | if (isVisible()) { | - |
1426 | event->accept(); | - |
1427 | update(); | - |
1428 | } | - |
1429 | break; | - |
1430 | | - |
1431 | case QEvent::ActivationChange: | - |
1432 | case QEvent::EnabledChange: | - |
1433 | case QEvent::FontChange: | - |
1434 | case QEvent::StyleChange: | - |
1435 | case QEvent::PaletteChange: | - |
1436 | case QEvent::ParentChange: | - |
1437 | case QEvent::ContentsRectChange: | - |
1438 | case QEvent::LayoutDirectionChange: | - |
1439 | changeEvent(event); | - |
1440 | break; | - |
1441 | case QEvent::Close: | - |
1442 | closeEvent((QCloseEvent *)event); | - |
1443 | break; | - |
1444 | case QEvent::GrabMouse: | - |
1445 | grabMouseEvent(event); | - |
1446 | break; | - |
1447 | case QEvent::UngrabMouse: | - |
1448 | ungrabMouseEvent(event); | - |
1449 | break; | - |
1450 | case QEvent::GrabKeyboard: | - |
1451 | grabKeyboardEvent(event); | - |
1452 | break; | - |
1453 | case QEvent::UngrabKeyboard: | - |
1454 | ungrabKeyboardEvent(event); | - |
1455 | break; | - |
1456 | case QEvent::GraphicsSceneMousePress: | - |
1457 | if (d->hasDecoration() && windowFrameEvent(event)) | - |
1458 | return true; | - |
1459 | break; | - |
1460 | case QEvent::GraphicsSceneMouseMove: | - |
1461 | case QEvent::GraphicsSceneMouseRelease: | - |
1462 | case QEvent::GraphicsSceneMouseDoubleClick: | - |
1463 | d->ensureWindowData(); | - |
1464 | if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection) | - |
1465 | return windowFrameEvent(event); | - |
1466 | break; | - |
1467 | case QEvent::GraphicsSceneHoverEnter: | - |
1468 | case QEvent::GraphicsSceneHoverMove: | - |
1469 | case QEvent::GraphicsSceneHoverLeave: | - |
1470 | if (d->hasDecoration()) { | - |
1471 | windowFrameEvent(event); | - |
1472 | | - |
1473 | | - |
1474 | if (!acceptHoverEvents()) | - |
1475 | return true; | - |
1476 | } | - |
1477 | break; | - |
1478 | default: | - |
1479 | break; | - |
1480 | } | - |
1481 | return QObject::event(event); | - |
1482 | } | - |
1483 | | - |
1484 | | - |
1485 | | - |
1486 | | - |
1487 | | - |
1488 | | - |
1489 | | - |
1490 | | - |
1491 | | - |
1492 | | - |
1493 | | - |
1494 | void QGraphicsWidget::changeEvent(QEvent *event) | - |
1495 | { | - |
1496 | Q_D(QGraphicsWidget); | - |
1497 | switch (event->type()) { | - |
1498 | case QEvent::StyleChange: | - |
1499 | | - |
1500 | unsetWindowFrameMargins(); | - |
1501 | if (d->layout) | - |
1502 | d->layout->invalidate(); | - |
1503 | case QEvent::FontChange: | - |
1504 | update(); | - |
1505 | updateGeometry(); | - |
1506 | break; | - |
1507 | case QEvent::PaletteChange: | - |
1508 | update(); | - |
1509 | break; | - |
1510 | case QEvent::ParentChange: | - |
1511 | d->resolveFont(d->inheritedFontResolveMask); | - |
1512 | d->resolvePalette(d->inheritedPaletteResolveMask); | - |
1513 | break; | - |
1514 | default: | - |
1515 | break; | - |
1516 | } | - |
1517 | } | - |
1518 | | - |
1519 | | - |
1520 | | - |
1521 | | - |
1522 | | - |
1523 | | - |
1524 | | - |
1525 | | - |
1526 | void QGraphicsWidget::closeEvent(QCloseEvent *event) | - |
1527 | { | - |
1528 | event->accept(); | - |
1529 | } | - |
1530 | | - |
1531 | | - |
1532 | | - |
1533 | | - |
1534 | void QGraphicsWidget::focusInEvent(QFocusEvent *event) | - |
1535 | { | - |
1536 | Q_UNUSED(event); | - |
1537 | if (focusPolicy() != Qt::NoFocus) | - |
1538 | update(); | - |
1539 | } | - |
1540 | | - |
1541 | | - |
1542 | | - |
1543 | | - |
1544 | | - |
1545 | | - |
1546 | | - |
1547 | | - |
1548 | | - |
1549 | | - |
1550 | | - |
1551 | | - |
1552 | | - |
1553 | | - |
1554 | | - |
1555 | | - |
1556 | | - |
1557 | | - |
1558 | | - |
1559 | | - |
1560 | bool QGraphicsWidget::focusNextPrevChild(bool next) | - |
1561 | { | - |
1562 | Q_D(QGraphicsWidget); | - |
1563 | | - |
1564 | QGraphicsWidget *parent = 0; | - |
1565 | if (!isWindow() && (parent = parentWidget())) | - |
1566 | return parent->focusNextPrevChild(next); | - |
1567 | if (!d->scene) | - |
1568 | return false; | - |
1569 | if (d->scene->focusNextPrevChild(next)) | - |
1570 | return true; | - |
1571 | if (isWindow()) { | - |
1572 | setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason); | - |
1573 | if (hasFocus()) | - |
1574 | return true; | - |
1575 | } | - |
1576 | return false; | - |
1577 | } | - |
1578 | | - |
1579 | | - |
1580 | | - |
1581 | | - |
1582 | void QGraphicsWidget::focusOutEvent(QFocusEvent *event) | - |
1583 | { | - |
1584 | Q_UNUSED(event); | - |
1585 | if (focusPolicy() != Qt::NoFocus) | - |
1586 | update(); | - |
1587 | } | - |
1588 | | - |
1589 | | - |
1590 | | - |
1591 | | - |
1592 | | - |
1593 | | - |
1594 | | - |
1595 | | - |
1596 | | - |
1597 | | - |
1598 | | - |
1599 | | - |
1600 | | - |
1601 | void QGraphicsWidget::hideEvent(QHideEvent *event) | - |
1602 | { | - |
1603 | | - |
1604 | | - |
1605 | Q_UNUSED(event); | - |
1606 | } | - |
1607 | | - |
1608 | | - |
1609 | | - |
1610 | | - |
1611 | | - |
1612 | | - |
1613 | | - |
1614 | | - |
1615 | | - |
1616 | | - |
1617 | | - |
1618 | | - |
1619 | | - |
1620 | | - |
1621 | | - |
1622 | | - |
1623 | void QGraphicsWidget::moveEvent(QGraphicsSceneMoveEvent *event) | - |
1624 | { | - |
1625 | | - |
1626 | Q_UNUSED(event); | - |
1627 | } | - |
1628 | | - |
1629 | | - |
1630 | | - |
1631 | | - |
1632 | | - |
1633 | | - |
1634 | | - |
1635 | | - |
1636 | | - |
1637 | void QGraphicsWidget::polishEvent() | - |
1638 | { | - |
1639 | } | - |
1640 | | - |
1641 | | - |
1642 | | - |
1643 | | - |
1644 | | - |
1645 | | - |
1646 | | - |
1647 | | - |
1648 | | - |
1649 | | - |
1650 | | - |
1651 | | - |
1652 | | - |
1653 | | - |
1654 | | - |
1655 | | - |
1656 | | - |
1657 | void QGraphicsWidget::resizeEvent(QGraphicsSceneResizeEvent *event) | - |
1658 | { | - |
1659 | Q_UNUSED(event); | - |
1660 | } | - |
1661 | | - |
1662 | | - |
1663 | | - |
1664 | | - |
1665 | | - |
1666 | | - |
1667 | | - |
1668 | | - |
1669 | | - |
1670 | | - |
1671 | | - |
1672 | | - |
1673 | | - |
1674 | void QGraphicsWidget::showEvent(QShowEvent *event) | - |
1675 | { | - |
1676 | Q_UNUSED(event); | - |
1677 | } | - |
1678 | | - |
1679 | | - |
1680 | | - |
1681 | | - |
1682 | void QGraphicsWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event) | - |
1683 | { | - |
1684 | Q_UNUSED(event); | - |
1685 | } | - |
1686 | | - |
1687 | | - |
1688 | | - |
1689 | | - |
1690 | void QGraphicsWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | - |
1691 | { | - |
1692 | QGraphicsObject::hoverLeaveEvent(event); | - |
1693 | } | - |
1694 | | - |
1695 | | - |
1696 | | - |
1697 | | - |
1698 | | - |
1699 | | - |
1700 | | - |
1701 | void QGraphicsWidget::grabMouseEvent(QEvent *event) | - |
1702 | { | - |
1703 | Q_UNUSED(event); | - |
1704 | } | - |
1705 | | - |
1706 | | - |
1707 | | - |
1708 | | - |
1709 | | - |
1710 | | - |
1711 | | - |
1712 | void QGraphicsWidget::ungrabMouseEvent(QEvent *event) | - |
1713 | { | - |
1714 | Q_UNUSED(event); | - |
1715 | } | - |
1716 | | - |
1717 | | - |
1718 | | - |
1719 | | - |
1720 | | - |
1721 | | - |
1722 | | - |
1723 | void QGraphicsWidget::grabKeyboardEvent(QEvent *event) | - |
1724 | { | - |
1725 | Q_UNUSED(event); | - |
1726 | } | - |
1727 | | - |
1728 | | - |
1729 | | - |
1730 | | - |
1731 | | - |
1732 | | - |
1733 | | - |
1734 | void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event) | - |
1735 | { | - |
1736 | Q_UNUSED(event); | - |
1737 | } | - |
1738 | | - |
1739 | | - |
1740 | | - |
1741 | | - |
1742 | | - |
1743 | | - |
1744 | Qt::WindowType QGraphicsWidget::windowType() const | - |
1745 | { | - |
1746 | return Qt::WindowType(int(windowFlags()) & Qt::WindowType_Mask); | - |
1747 | } | - |
1748 | | - |
1749 | | - |
1750 | | - |
1751 | | - |
1752 | | - |
1753 | | - |
1754 | | - |
1755 | | - |
1756 | | - |
1757 | | - |
1758 | | - |
1759 | | - |
1760 | | - |
1761 | | - |
1762 | | - |
1763 | | - |
1764 | | - |
1765 | | - |
1766 | Qt::WindowFlags QGraphicsWidget::windowFlags() const | - |
1767 | { | - |
1768 | Q_D(const QGraphicsWidget); | - |
1769 | return d->windowFlags; | - |
1770 | } | - |
1771 | void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags) | - |
1772 | { | - |
1773 | Q_D(QGraphicsWidget); | - |
1774 | if (d->windowFlags == wFlags) | - |
1775 | return; | - |
1776 | bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup; | - |
1777 | | - |
1778 | d->adjustWindowFlags(&wFlags); | - |
1779 | d->windowFlags = wFlags; | - |
1780 | if (!d->setWindowFrameMargins) | - |
1781 | unsetWindowFrameMargins(); | - |
1782 | | - |
1783 | setFlag(ItemIsPanel, d->windowFlags & Qt::Window); | - |
1784 | | - |
1785 | bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup; | - |
1786 | if (d->scene && isVisible() && wasPopup != isPopup) { | - |
1787 | | - |
1788 | if (!isPopup) | - |
1789 | d->scene->d_func()->removePopup(this); | - |
1790 | else | - |
1791 | d->scene->d_func()->addPopup(this); | - |
1792 | } | - |
1793 | | - |
1794 | if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) { | - |
1795 | d->scene->d_func()->allItemsIgnoreHoverEvents = false; | - |
1796 | d->scene->d_func()->enableMouseTrackingOnViews(); | - |
1797 | } | - |
1798 | } | - |
1799 | | - |
1800 | | - |
1801 | | - |
1802 | | - |
1803 | | - |
1804 | | - |
1805 | | - |
1806 | | - |
1807 | | - |
1808 | | - |
1809 | | - |
1810 | bool QGraphicsWidget::isActiveWindow() const | - |
1811 | { | - |
1812 | return isActive(); | - |
1813 | } | - |
1814 | | - |
1815 | | - |
1816 | | - |
1817 | | - |
1818 | | - |
1819 | | - |
1820 | | - |
1821 | | - |
1822 | | - |
1823 | | - |
1824 | void QGraphicsWidget::setWindowTitle(const QString &title) | - |
1825 | { | - |
1826 | Q_D(QGraphicsWidget); | - |
1827 | d->ensureWindowData(); | - |
1828 | d->windowData->windowTitle = title; | - |
1829 | } | - |
1830 | QString QGraphicsWidget::windowTitle() const | - |
1831 | { | - |
1832 | Q_D(const QGraphicsWidget); | - |
1833 | return d->windowData ? d->windowData->windowTitle : QString(); | - |
1834 | } | - |
1835 | | - |
1836 | | - |
1837 | | - |
1838 | | - |
1839 | | - |
1840 | | - |
1841 | | - |
1842 | | - |
1843 | | - |
1844 | | - |
1845 | | - |
1846 | | - |
1847 | | - |
1848 | | - |
1849 | | - |
1850 | | - |
1851 | | - |
1852 | | - |
1853 | | - |
1854 | | - |
1855 | | - |
1856 | Qt::FocusPolicy QGraphicsWidget::focusPolicy() const | - |
1857 | { | - |
1858 | Q_D(const QGraphicsWidget); | - |
1859 | return d->focusPolicy; | - |
1860 | } | - |
1861 | void QGraphicsWidget::setFocusPolicy(Qt::FocusPolicy policy) | - |
1862 | { | - |
1863 | Q_D(QGraphicsWidget); | - |
1864 | if (d->focusPolicy == policy) | - |
1865 | return; | - |
1866 | d->focusPolicy = policy; | - |
1867 | if (hasFocus() && policy == Qt::NoFocus) | - |
1868 | clearFocus(); | - |
1869 | setFlag(ItemIsFocusable, policy != Qt::NoFocus); | - |
1870 | } | - |
1871 | | - |
1872 | | - |
1873 | | - |
1874 | | - |
1875 | | - |
1876 | | - |
1877 | | - |
1878 | | - |
1879 | QGraphicsWidget *QGraphicsWidget::focusWidget() const | - |
1880 | { | - |
1881 | Q_D(const QGraphicsWidget); | - |
1882 | if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget) | - |
1883 | return static_cast<QGraphicsWidget *>(d->subFocusItem); | - |
1884 | return 0; | - |
1885 | } | - |
1886 | | - |
1887 | #ifndef QT_NO_SHORTCUT | - |
1888 | | - |
1889 | | - |
1890 | | - |
1891 | | - |
1892 | | - |
1893 | | - |
1894 | | - |
1895 | | - |
1896 | | - |
1897 | | - |
1898 | | - |
1899 | | - |
1900 | | - |
1901 | | - |
1902 | | - |
1903 | | - |
1904 | | - |
1905 | | - |
1906 | | - |
1907 | | - |
1908 | | - |
1909 | | - |
1910 | | - |
1911 | | - |
1912 | | - |
1913 | | - |
1914 | | - |
1915 | int QGraphicsWidget::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context) | - |
1916 | { | - |
1917 | Q_ASSERT(qApp); | - |
1918 | if (sequence.isEmpty()) | - |
1919 | return 0; | - |
1920 | | - |
1921 | return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher); | - |
1922 | } | - |
1923 | | - |
1924 | | - |
1925 | | - |
1926 | | - |
1927 | | - |
1928 | | - |
1929 | | - |
1930 | | - |
1931 | | - |
1932 | | - |
1933 | | - |
1934 | | - |
1935 | | - |
1936 | | - |
1937 | | - |
1938 | | - |
1939 | | - |
1940 | | - |
1941 | void QGraphicsWidget::releaseShortcut(int id) | - |
1942 | { | - |
1943 | Q_ASSERT(qApp); | - |
1944 | if (id) | - |
1945 | qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); | - |
1946 | } | - |
1947 | | - |
1948 | | - |
1949 | | - |
1950 | | - |
1951 | | - |
1952 | | - |
1953 | | - |
1954 | | - |
1955 | | - |
1956 | | - |
1957 | | - |
1958 | | - |
1959 | | - |
1960 | | - |
1961 | | - |
1962 | void QGraphicsWidget::setShortcutEnabled(int id, bool enabled) | - |
1963 | { | - |
1964 | Q_ASSERT(qApp); | - |
1965 | if (id) | - |
1966 | qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0); | - |
1967 | } | - |
1968 | | - |
1969 | | - |
1970 | | - |
1971 | | - |
1972 | | - |
1973 | | - |
1974 | | - |
1975 | | - |
1976 | | - |
1977 | void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled) | - |
1978 | { | - |
1979 | Q_ASSERT(qApp); | - |
1980 | if (id) | - |
1981 | qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0); | - |
1982 | } | - |
1983 | #endif | - |
1984 | | - |
1985 | #ifndef QT_NO_ACTION | - |
1986 | | - |
1987 | | - |
1988 | | - |
1989 | | - |
1990 | | - |
1991 | | - |
1992 | | - |
1993 | | - |
1994 | | - |
1995 | | - |
1996 | | - |
1997 | | - |
1998 | | - |
1999 | | - |
2000 | void QGraphicsWidget::addAction(QAction *action) | - |
2001 | { | - |
2002 | insertAction(0, action); | - |
2003 | } | - |
2004 | | - |
2005 | | - |
2006 | | - |
2007 | | - |
2008 | | - |
2009 | | - |
2010 | | - |
2011 | | - |
2012 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - |
2013 | void QGraphicsWidget::addActions(const QList<QAction *> &actions) | - |
2014 | #else | - |
2015 | void QGraphicsWidget::addActions(QList<QAction *> actions) | - |
2016 | #endif | - |
2017 | { | - |
2018 | for (int i = 0; i < actions.count(); ++i) | - |
2019 | insertAction(0, actions.at(i)); | - |
2020 | } | - |
2021 | | - |
2022 | | - |
2023 | | - |
2024 | | - |
2025 | | - |
2026 | | - |
2027 | | - |
2028 | | - |
2029 | | - |
2030 | | - |
2031 | | - |
2032 | | - |
2033 | | - |
2034 | void QGraphicsWidget::insertAction(QAction *before, QAction *action) | - |
2035 | { | - |
2036 | if (!action) { | - |
2037 | qWarning("QWidget::insertAction: Attempt to insert null action"); | - |
2038 | return; | - |
2039 | } | - |
2040 | | - |
2041 | Q_D(QGraphicsWidget); | - |
2042 | int index = d->actions.indexOf(action); | - |
2043 | if (index != -1) | - |
2044 | d->actions.removeAt(index); | - |
2045 | | - |
2046 | int pos = d->actions.indexOf(before); | - |
2047 | if (pos < 0) { | - |
2048 | before = 0; | - |
2049 | pos = d->actions.size(); | - |
2050 | } | - |
2051 | d->actions.insert(pos, action); | - |
2052 | | - |
2053 | if (index == -1) { | - |
2054 | QActionPrivate *apriv = action->d_func(); | - |
2055 | apriv->graphicsWidgets.append(this); | - |
2056 | } | - |
2057 | | - |
2058 | QActionEvent e(QEvent::ActionAdded, action, before); | - |
2059 | QApplication::sendEvent(this, &e); | - |
2060 | } | - |
2061 | | - |
2062 | | - |
2063 | | - |
2064 | | - |
2065 | | - |
2066 | | - |
2067 | | - |
2068 | | - |
2069 | | - |
2070 | | - |
2071 | | - |
2072 | | - |
2073 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - |
2074 | void QGraphicsWidget::insertActions(QAction *before, const QList<QAction *> &actions) | - |
2075 | #else | - |
2076 | void QGraphicsWidget::insertActions(QAction *before, QList<QAction *> actions) | - |
2077 | #endif | - |
2078 | { | - |
2079 | for (int i = 0; i < actions.count(); ++i)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2080 | insertAction(before, actions.at(i)); never executed: insertAction(before, actions.at(i)); | 0 |
2081 | } never executed: end of block | 0 |
2082 | | - |
2083 | | - |
2084 | | - |
2085 | | - |
2086 | | - |
2087 | | - |
2088 | | - |
2089 | | - |
2090 | void QGraphicsWidget::removeAction(QAction *action) | - |
2091 | { | - |
2092 | if (!action) | - |
2093 | return; | - |
2094 | | - |
2095 | Q_D(QGraphicsWidget); | - |
2096 | | - |
2097 | QActionPrivate *apriv = action->d_func(); | - |
2098 | apriv->graphicsWidgets.removeAll(this); | - |
2099 | | - |
2100 | if (d->actions.removeAll(action)) { | - |
2101 | QActionEvent e(QEvent::ActionRemoved, action); | - |
2102 | QApplication::sendEvent(this, &e); | - |
2103 | } | - |
2104 | } | - |
2105 | | - |
2106 | | - |
2107 | | - |
2108 | | - |
2109 | | - |
2110 | | - |
2111 | | - |
2112 | | - |
2113 | | - |
2114 | QList<QAction *> QGraphicsWidget::actions() const | - |
2115 | { | - |
2116 | Q_D(const QGraphicsWidget); | - |
2117 | return d->actions; | - |
2118 | } | - |
2119 | #endif | - |
2120 | | - |
2121 | | - |
2122 | | - |
2123 | | - |
2124 | | - |
2125 | | - |
2126 | | - |
2127 | | - |
2128 | | - |
2129 | | - |
2130 | | - |
2131 | | - |
2132 | | - |
2133 | | - |
2134 | | - |
2135 | | - |
2136 | | - |
2137 | | - |
2138 | | - |
2139 | | - |
2140 | | - |
2141 | | - |
2142 | | - |
2143 | | - |
2144 | | - |
2145 | void QGraphicsWidget::setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second) | - |
2146 | { | - |
2147 | if (!first && !second) { | - |
2148 | qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined"); | - |
2149 | return; | - |
2150 | } | - |
2151 | if ((first && second) && first->scene() != second->scene()) { | - |
2152 | qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different", | - |
2153 | first->scene(), second->scene()); | - |
2154 | return; | - |
2155 | } | - |
2156 | QGraphicsScene *scene = first ? first->scene() : second->scene(); | - |
2157 | if (!scene && (!first || !second)) { | - |
2158 | qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the" | - |
2159 | " scene requires the item to be in a scene."); | - |
2160 | return; | - |
2161 | } | - |
2162 | | - |
2163 | | - |
2164 | | - |
2165 | | - |
2166 | QGraphicsScenePrivate *sceneD = scene->d_func(); | - |
2167 | if (!first) { | - |
2168 | sceneD->tabFocusFirst = second; | - |
2169 | return; | - |
2170 | } | - |
2171 | if (!second) { | - |
2172 | sceneD->tabFocusFirst = first->d_func()->focusNext; | - |
2173 | return; | - |
2174 | } | - |
2175 | | - |
2176 | | - |
2177 | QGraphicsWidget *firstFocusNext = first->d_func()->focusNext; | - |
2178 | if (firstFocusNext == second) { | - |
2179 | | - |
2180 | return; | - |
2181 | } | - |
2182 | | - |
2183 | | - |
2184 | QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev; | - |
2185 | QGraphicsWidget *secondFocusNext = second->d_func()->focusNext; | - |
2186 | firstFocusNext->d_func()->focusPrev = second; | - |
2187 | first->d_func()->focusNext = second; | - |
2188 | second->d_func()->focusNext = firstFocusNext; | - |
2189 | second->d_func()->focusPrev = first; | - |
2190 | secondFocusPrev->d_func()->focusNext = secondFocusNext; | - |
2191 | secondFocusNext->d_func()->focusPrev = secondFocusPrev; | - |
2192 | | - |
2193 | Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first); | - |
2194 | Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first); | - |
2195 | | - |
2196 | Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second); | - |
2197 | Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second); | - |
2198 | | - |
2199 | } | - |
2200 | | - |
2201 | | - |
2202 | | - |
2203 | | - |
2204 | | - |
2205 | | - |
2206 | | - |
2207 | | - |
2208 | | - |
2209 | | - |
2210 | void QGraphicsWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) | - |
2211 | { | - |
2212 | Q_D(QGraphicsWidget); | - |
2213 | | - |
2214 | | - |
2215 | | - |
2216 | d->setAttribute(attribute, on); | - |
2217 | } | - |
2218 | | - |
2219 | | - |
2220 | | - |
2221 | | - |
2222 | | - |
2223 | | - |
2224 | | - |
2225 | bool QGraphicsWidget::testAttribute(Qt::WidgetAttribute attribute) const | - |
2226 | { | - |
2227 | Q_D(const QGraphicsWidget); | - |
2228 | return d->testAttribute(attribute); | - |
2229 | } | - |
2230 | | - |
2231 | | - |
2232 | | - |
2233 | | - |
2234 | int QGraphicsWidget::type() const | - |
2235 | { | - |
2236 | return Type; | - |
2237 | } | - |
2238 | | - |
2239 | | - |
2240 | | - |
2241 | | - |
2242 | void QGraphicsWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | - |
2243 | { | - |
2244 | Q_UNUSED(painter); | - |
2245 | Q_UNUSED(option); | - |
2246 | Q_UNUSED(widget); | - |
2247 | } | - |
2248 | | - |
2249 | | - |
2250 | | - |
2251 | | - |
2252 | | - |
2253 | | - |
2254 | | - |
2255 | | - |
2256 | | - |
2257 | | - |
2258 | | - |
2259 | | - |
2260 | void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
2261 | QWidget *widget) | - |
2262 | { | - |
2263 | const bool fillBackground = !testAttribute(Qt::WA_OpaquePaintEvent)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2264 | && !testAttribute(Qt::WA_NoSystemBackground);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2265 | QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(this); | - |
2266 | const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2267 | | - |
2268 | if (rect().contains(option->exposedRect)) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2269 | if (fillBackground && !embeddedWidgetFillsOwnBackground)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2270 | painter->fillRect(option->exposedRect, palette().window()); never executed: painter->fillRect(option->exposedRect, palette().window()); | 0 |
2271 | return; never executed: return; | 0 |
2272 | } | - |
2273 | | - |
2274 | Q_D(QGraphicsWidget); | - |
2275 | | - |
2276 | QRect windowFrameRect = QRect(QPoint(), windowFrameGeometry().size().toSize()); | - |
2277 | QStyleOptionTitleBar bar; | - |
2278 | bar.QStyleOption::operator=(*option); | - |
2279 | d->initStyleOptionTitleBar(&bar); | - |
2280 | d->ensureWindowData(); | - |
2281 | if (d->windowData->buttonMouseOver)bar.state|= QStyle::State_MouseOver; | - |
| else | |
| bar.state &= ~setFlag(QStyle::State_MouseOver; | |
| if (, d->windowData->buttonSunken)buttonMouseOver); | |
2282 | bar.state|= QStyle::State_Sunken; | - |
| else | |
| bar.state &= ~setFlag(QStyle::State_Sunken;, d->windowData->buttonSunken); | |
2283 | bar.rect = windowFrameRect; | - |
2284 | | - |
2285 | | - |
2286 | const QPointF styleOrigin = this->windowFrameRect().topLeft(); | - |
2287 | painter->translate(styleOrigin); | - |
2288 | | - |
2289 | #ifdef Q_OS_MAC | - |
2290 | const QSize pixmapSize = windowFrameRect.size(); | - |
2291 | if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0) | - |
2292 | return; | - |
2293 | QPainter *realPainter = painter; | - |
2294 | QPixmap pm(pixmapSize); | - |
2295 | painter = new QPainter(&pm); | - |
2296 | #endif | - |
2297 | | - |
2298 | | - |
2299 | QStyleHintReturnMask mask; | - |
2300 | bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2301 | bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget); | - |
2302 | int frameWidth = style()->pixelMetric(QStyle::PM_MDIFrameWidth, &bar, widget); | - |
2303 | if (setMask) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2304 | painter->save(); | - |
2305 | painter->setClipRegion(mask.region, Qt::IntersectClip); | - |
2306 | } never executed: end of block | 0 |
2307 | if (fillBackground) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2308 | if (embeddedWidgetFillsOwnBackground) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2309 | | - |
2310 | QPainterPath windowFrameBackground; | - |
2311 | windowFrameBackground.addRect(windowFrameRect); | - |
2312 | | - |
2313 | | - |
2314 | windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5)); | - |
2315 | painter->fillPath(windowFrameBackground, palette().window()); | - |
2316 | } else { never executed: end of block | 0 |
2317 | painter->fillRect(windowFrameRect, palette().window()); | - |
2318 | } never executed: end of block | 0 |
2319 | } | - |
2320 | | - |
2321 | | - |
2322 | int height = (int)d->titleBarHeight(bar); | - |
2323 | bar.rect.setHeight(height); | - |
2324 | if (hasBorder) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2325 | bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0); never executed: bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0); | 0 |
2326 | | - |
2327 | painter->save(); | - |
2328 | painter->setFont(QApplication::font("QMdiSubWindowTitleBar")); | - |
2329 | style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget); | - |
2330 | painter->restore(); | - |
2331 | if (setMask)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2332 | painter->restore(); never executed: painter->restore(); | 0 |
2333 | | - |
2334 | QStyleOptionFrame frameOptions; | - |
2335 | frameOptions.QStyleOption::operator=(*option); | - |
2336 | initStyleOption(&frameOptions); | - |
2337 | if (!hasBorder)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
2338 | painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip); never executed: painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip); | 0 |
2339 | if (hasFocus()) {frameOptions.state|= QStyle::State_HasFocus; | - |
| } else { | |
| frameOptions.state &= ~setFlag(QStyle::State_HasFocus; | |
| }, hasFocus()); | |
2340 | bool isActive = isActiveWindow(); | - |
2341 | if (isActive) {frameOptions.state|= QStyle::State_Active; | - |
| } else { | |
| frameOptions.state &= ~setFlag(QStyle::State_Active; | |
| }, isActive); | |
2342 | | - |
2343 | frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal); | - |
2344 | frameOptions.rect = windowFrameRect; | - |
2345 | frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget); | - |
2346 | frameOptions.midLineWidth = 1; | - |
2347 | style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget); | - |
2348 | | - |
2349 | #ifdef Q_OS_MAC | - |
2350 | realPainter->drawPixmap(QPoint(), pm); | - |
2351 | delete painter; | - |
2352 | #endif | - |
2353 | } never executed: end of block | 0 |
2354 | | - |
2355 | | - |
2356 | | - |
2357 | | - |
2358 | QRectF QGraphicsWidget::boundingRect() const | - |
2359 | { | - |
2360 | return windowFrameRect(); | - |
2361 | } | - |
2362 | | - |
2363 | | - |
2364 | | - |
2365 | | - |
2366 | QPainterPath QGraphicsWidget::shape() const | - |
2367 | { | - |
2368 | QPainterPath path; | - |
2369 | path.addRect(rect()); | - |
2370 | return path; | - |
2371 | } | - |
2372 | | - |
2373 | | - |
2374 | | - |
2375 | | - |
2376 | | - |
2377 | | - |
2378 | | - |
2379 | | - |
2380 | | - |
2381 | | - |
2382 | | - |
2383 | | - |
2384 | bool QGraphicsWidget::close() | - |
2385 | { | - |
2386 | QCloseEvent closeEvent; | - |
2387 | QApplication::sendEvent(this, &closeEvent); | - |
2388 | if (!closeEvent.isAccepted()) { | - |
2389 | return false; | - |
2390 | } | - |
2391 | | - |
2392 | if (isVisible()) { | - |
2393 | hide(); | - |
2394 | } | - |
2395 | if (testAttribute(Qt::WA_DeleteOnClose)) { | - |
2396 | deleteLater(); | - |
2397 | } | - |
2398 | return true; | - |
2399 | } | - |
2400 | | - |
2401 | #if 0 | - |
2402 | void QGraphicsWidget::dumpFocusChain() | - |
2403 | { | - |
2404 | qDebug("=========== Dumping focus chain =============="); | - |
2405 | int i = 0; | - |
2406 | QGraphicsWidget *next = this; | - |
2407 | QSet<QGraphicsWidget*> visited; | - |
2408 | do { | - |
2409 | if (!next) { | - |
2410 | qWarning("Found a focus chain that is not circular, (next == 0)"); | - |
2411 | break; | - |
2412 | } | - |
2413 | qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromLatin1("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << QLatin1String("next:") << next->d_func()->focusNext->data(0) << QLatin1String("prev:") << next->d_func()->focusPrev->data(0); | - |
2414 | if (visited.contains(next)) { | - |
2415 | qWarning("Already visited this node. However, I expected to dump until I found myself."); | - |
2416 | break; | - |
2417 | } | - |
2418 | visited << next; | - |
2419 | next = next->d_func()->focusNext; | - |
2420 | } while (next != this); | - |
2421 | } | - |
2422 | #endif | - |
2423 | | - |
2424 | QT_END_NAMESPACE | - |
2425 | | - |
2426 | #include "moc_qgraphicswidget.cpp" | - |
2427 | | - |
2428 | #endif //QT_NO_GRAPHICSVIEW | - |
| | |