qfocusframe.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qfocusframe.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4class QFocusFramePrivate : public QWidgetPrivate-
5{-
6 inline QFocusFrame* q_func() { return static_cast<QFocusFrame *>(q_ptr); } inline const QFocusFrame* q_func() const { return static_cast<const QFocusFrame *>(q_ptr); } friend class QFocusFrame;-
7 QWidget *widget;-
8 QWidget *frameParent;-
9 bool showFrameAboveWidget;-
10public:-
11 QFocusFramePrivate() {-
12 widget = 0;-
13 frameParent = 0;-
14 sendChildEvents = false;-
15 showFrameAboveWidget = false;-
16 }
never executed: end of block
0
17 void updateSize();-
18 void update();-
19};-
20-
21void QFocusFramePrivate::update()-
22{-
23 QFocusFrame * const q = q_func();-
24 q->setParent(frameParent);-
25 updateSize();-
26 if (q->parentWidget()->rect().intersects(q->geometry())
q->parentWidge...q->geometry())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
27 if (showFrameAboveWidget
showFrameAboveWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
28 q->raise();
never executed: q->raise();
0
29 else-
30 q->stackUnder(widget);
never executed: q->stackUnder(widget);
0
31 q->show();-
32 }
never executed: end of block
else {
0
33 q->hide();-
34 }
never executed: end of block
0
35}-
36-
37void QFocusFramePrivate::updateSize()-
38{-
39 QFocusFrame * const q = q_func();-
40 if (!widget
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
41 return;
never executed: return;
0
42-
43 int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin),-
44 hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin);-
45 QPoint pos(widget->x(), widget->y());-
46 if (q->parentWidget() != widget->parentWidget()
q->parentWidge...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
47 pos = widget->parentWidget()->mapTo(q->parentWidget(), pos);
never executed: pos = widget->parentWidget()->mapTo(q->parentWidget(), pos);
0
48 QRect geom(pos.x()-hmargin, pos.y()-vmargin,-
49 widget->width()+(hmargin*2), widget->height()+(vmargin*2));-
50 if(q->geometry() == geom
q->geometry() == geomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
51 return;
never executed: return;
0
52-
53 q->setGeometry(geom);-
54 QStyleHintReturnMask mask;-
55 QStyleOption opt;-
56 q->initStyleOption(&opt);-
57 if (q->style()->styleHint(QStyle::SH_FocusFrame_Mask, &opt, q, &mask)
q->style()->st...opt, q, &mask)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
58 q->setMask(mask.region);
never executed: q->setMask(mask.region);
0
59}
never executed: end of block
0
60void QFocusFrame::initStyleOption(QStyleOption *option) const-
61{-
62 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
63 return;
never executed: return;
0
64-
65 option->initFrom(this);-
66}
never executed: end of block
0
67QFocusFrame::QFocusFrame(QWidget *parent)-
68 : QWidget(*new QFocusFramePrivate, parent, 0)-
69{-
70 setAttribute(Qt::WA_TransparentForMouseEvents);-
71 setFocusPolicy(Qt::NoFocus);-
72 setAttribute(Qt::WA_NoChildEventsForParent, true);-
73 setAttribute(Qt::WA_AcceptDrops, style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this));-
74}
never executed: end of block
0
75-
76-
77-
78-
79-
80QFocusFrame::~QFocusFrame()-
81{-
82}-
83void-
84QFocusFrame::setWidget(QWidget *widget)-
85{-
86 QFocusFramePrivate * const d = d_func();-
87-
88 if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)
style()->style...dget, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
89 d->showFrameAboveWidget = true;
never executed: d->showFrameAboveWidget = true;
0
90 else-
91 d->showFrameAboveWidget = false;
never executed: d->showFrameAboveWidget = false;
0
92-
93 if (widget == d->widget
widget == d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
94 return;
never executed: return;
0
95 if (d->widget
d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
96-
97 QWidget *p = d->widget;-
98 do {-
99 p->removeEventFilter(this);-
100 if (!d->showFrameAboveWidget
!d->showFrameAboveWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
|| p == d->frameParent
p == d->frameParentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
101 break;
never executed: break;
0
102 p = p->parentWidget();-
103 }
never executed: end of block
while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
104 }
never executed: end of block
0
105 if (widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
&& !widget->isWindow()
!widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
&& widget->parentWidget()->windowType() != Qt::SubWindow
widget->parent... Qt::SubWindowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
106 d->widget = widget;-
107 d->widget->installEventFilter(this);-
108 QWidget *p = widget->parentWidget();-
109 QWidget *prev = 0;-
110 if (d->showFrameAboveWidget
d->showFrameAboveWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
111-
112 while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
113-
114-
115-
116-
117 bool isScrollArea = false;-
118 if (p->isWindow()
p->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
|| p->inherits("QToolBar")
p->inherits("QToolBar")Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(isScrollArea ...tScrollArea"))Description
TRUEnever evaluated
FALSEnever evaluated
isScrollArea = p->inherits("QAbstractScrollArea"))
(isScrollArea ...tScrollArea"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
119 d->frameParent = p;-
120-
121 if (prev
prevDescription
TRUEnever evaluated
FALSEnever evaluated
&& isScrollArea
isScrollAreaDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
122 d->frameParent = prev;
never executed: d->frameParent = prev;
0
123 break;
never executed: break;
0
124 } else {-
125 p->installEventFilter(this);-
126 prev = p;-
127 p = p->parentWidget();-
128 }
never executed: end of block
0
129 }-
130 }
never executed: end of block
else {
0
131 d->frameParent = p;-
132 }
never executed: end of block
0
133 d->update();-
134 }
never executed: end of block
else {
0
135 d->widget = 0;-
136 hide();-
137 }
never executed: end of block
0
138}-
139QWidget *-
140QFocusFrame::widget() const-
141{-
142 const QFocusFramePrivate * const d = d_func();-
143 return
never executed: return d->widget;
d->widget;
never executed: return d->widget;
0
144}-
145-
146-
147-
148void-
149QFocusFrame::paintEvent(QPaintEvent *)-
150{-
151 QFocusFramePrivate * const d = d_func();-
152-
153 if (!d->widget
!d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
154 return;
never executed: return;
0
155-
156 QStylePainter p(this);-
157 QStyleOption option;-
158 initStyleOption(&option);-
159 int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin);-
160 int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin);-
161 QWidgetPrivate *wd = qt_widget_private(d->widget);-
162 QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2);-
163 p.setClipRect(rect);-
164 p.drawControl(QStyle::CE_FocusFrame, option);-
165}
never executed: end of block
0
166-
167-
168-
169bool-
170QFocusFrame::eventFilter(QObject *o, QEvent *e)-
171{-
172 QFocusFramePrivate * const d = d_func();-
173 if(o == d->widget
o == d->widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
174 switch(e->type()) {-
175 case
never executed: case QEvent::Move:
QEvent::Move:
never executed: case QEvent::Move:
0
176 case
never executed: case QEvent::Resize:
QEvent::Resize:
never executed: case QEvent::Resize:
0
177 d->updateSize();-
178 break;
never executed: break;
0
179 case
never executed: case QEvent::Hide:
QEvent::Hide:
never executed: case QEvent::Hide:
0
180 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
181 hide();-
182 break;
never executed: break;
0
183 case
never executed: case QEvent::ParentChange:
QEvent::ParentChange:
never executed: case QEvent::ParentChange:
0
184 if (d->showFrameAboveWidget
d->showFrameAboveWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
185 QWidget *w = d->widget;-
186 setWidget(0);-
187 setWidget(w);-
188 }
never executed: end of block
else {
0
189 d->update();-
190 }
never executed: end of block
0
191 break;
never executed: break;
0
192 case
never executed: case QEvent::Show:
QEvent::Show:
never executed: case QEvent::Show:
0
193 d->update();-
194 show();-
195 break;
never executed: break;
0
196 case
never executed: case QEvent::PaletteChange:
QEvent::PaletteChange:
never executed: case QEvent::PaletteChange:
0
197 setPalette(d->widget->palette());-
198 break;
never executed: break;
0
199 case
never executed: case QEvent::ZOrderChange:
QEvent::ZOrderChange:
never executed: case QEvent::ZOrderChange:
0
200 if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)
style()->style...dget, 0, this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
201 raise();
never executed: raise();
0
202 else-
203 stackUnder(d->widget);
never executed: stackUnder(d->widget);
0
204 break;
never executed: break;
0
205 case
never executed: case QEvent::Destroy:
QEvent::Destroy:
never executed: case QEvent::Destroy:
0
206 setWidget(0);-
207 break;
never executed: break;
0
208 default
never executed: default:
:
never executed: default:
0
209 break;
never executed: break;
0
210 }-
211 } else if (d->showFrameAboveWidget
d->showFrameAboveWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
212-
213 switch(e->type()) {-
214 case
never executed: case QEvent::Move:
QEvent::Move:
never executed: case QEvent::Move:
0
215 case
never executed: case QEvent::Resize:
QEvent::Resize:
never executed: case QEvent::Resize:
0
216 d->updateSize();-
217 break;
never executed: break;
0
218 case
never executed: case QEvent::ZOrderChange:
QEvent::ZOrderChange:
never executed: case QEvent::ZOrderChange:
0
219 raise();-
220 break;
never executed: break;
0
221 default
never executed: default:
:
never executed: default:
0
222 break;
never executed: break;
0
223 }-
224 }-
225 return
never executed: return false;
false;
never executed: return false;
0
226}-
227-
228-
229bool QFocusFrame::event(QEvent *e)-
230{-
231 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
232}-
233-
234-
235-
Switch to Source codePreprocessed file

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