widgets/qfocusframe.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
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 }
executed: }
Execution Count:1
1
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())) {
partially evaluated: q->parentWidget()->rect().intersects(q->geometry())
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
27 if (showFrameAboveWidget)
partially evaluated: showFrameAboveWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
28 q->raise();
never executed: q->raise();
0
29 else -
30 q->stackUnder(widget);
executed: q->stackUnder(widget);
Execution Count:1
1
31 q->show(); -
32 } else {
executed: }
Execution Count:1
1
33 q->hide(); -
34 }
never executed: }
0
35} -
36 -
37void QFocusFramePrivate::updateSize() -
38{ -
39 QFocusFrame * const q = q_func(); -
40 if (!widget)
partially evaluated: !widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
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())
partially evaluated: q->parentWidget() != widget->parentWidget()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
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)
partially evaluated: q->geometry() == geom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
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))
partially evaluated: q->style()->styleHint(QStyle::SH_FocusFrame_Mask, &opt, q, &mask)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
58 q->setMask(mask.region);
executed: q->setMask(mask.region);
Execution Count:1
1
59}
executed: }
Execution Count:1
1
60void QFocusFrame::initStyleOption(QStyleOption *option) const -
61{ -
62 if (!option)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
63 return;
never executed: return;
0
64 -
65 option->initFrom(this); -
66}
executed: }
Execution Count:1
1
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}
executed: }
Execution Count:1
1
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))
partially evaluated: style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
89 d->showFrameAboveWidget = true;
never executed: d->showFrameAboveWidget = true;
0
90 else -
91 d->showFrameAboveWidget = false;
executed: d->showFrameAboveWidget = false;
Execution Count:2
2
92 -
93 if (widget == d->widget)
partially evaluated: widget == d->widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
94 return;
never executed: return;
0
95 if (d->widget) {
evaluated: d->widget
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
96 -
97 QWidget *p = d->widget; -
98 do { -
99 p->removeEventFilter(this); -
100 if (!d->showFrameAboveWidget || p == d->frameParent)
partially evaluated: !d->showFrameAboveWidget
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: p == d->frameParent
0-1
101 break;
executed: break;
Execution Count:1
1
102 p = p->parentWidget(); -
103 }while (p);
never executed: }
never evaluated: p
0
104 }
executed: }
Execution Count:1
1
105 if (widget && !widget->isWindow() && widget->parentWidget()->windowType() != Qt::SubWindow) {
evaluated: widget
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: !widget->isWindow()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: widget->parentWidget()->windowType() != Qt::SubWindow
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
106 d->widget = widget; -
107 d->widget->installEventFilter(this); -
108 QWidget *p = widget->parentWidget(); -
109 QWidget *prev = 0; -
110 if (d->showFrameAboveWidget) {
partially evaluated: d->showFrameAboveWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
111 -
112 while (p) {
never evaluated: p
0
113 -
114 -
115 -
116 -
117 bool isScrollArea = false; -
118 if (p->isWindow() || p->inherits("QToolBar") || (isScrollArea = p->inherits("QAbstractScrollArea"))) {
never evaluated: p->isWindow()
never evaluated: p->inherits("QToolBar")
never evaluated: (isScrollArea = p->inherits("QAbstractScrollArea"))
0
119 d->frameParent = p; -
120 -
121 if (prev && isScrollArea)
never evaluated: prev
never evaluated: isScrollArea
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: }
0
129 } -
130 } else {
never executed: }
0
131 d->frameParent = p; -
132 }
executed: }
Execution Count:1
1
133 d->update(); -
134 } else {
executed: }
Execution Count:1
1
135 d->widget = 0; -
136 hide(); -
137 }
executed: }
Execution Count:1
1
138} -
139QWidget * -
140QFocusFrame::widget() const -
141{ -
142 const QFocusFramePrivate * const d = d_func(); -
143 return d->widget;
executed: return d->widget;
Execution Count:2
2
144} -
145 -
146 -
147 -
148void -
149QFocusFrame::paintEvent(QPaintEvent *) -
150{ -
151 QFocusFramePrivate * const d = d_func(); -
152 QStylePainter p(this); -
153 QStyleOption option; -
154 initStyleOption(&option); -
155 int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin); -
156 int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin); -
157 QWidgetPrivate *wd = qt_widget_private(d->widget); -
158 QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2); -
159 p.setClipRect(rect); -
160 p.drawControl(QStyle::CE_FocusFrame, option); -
161}
never executed: }
0
162 -
163 -
164 -
165bool -
166QFocusFrame::eventFilter(QObject *o, QEvent *e) -
167{ -
168 QFocusFramePrivate * const d = d_func(); -
169 if(o == d->widget) {
never evaluated: o == d->widget
0
170 switch(e->type()) { -
171 case QEvent::Move: -
172 case QEvent::Resize: -
173 d->updateSize(); -
174 break;
never executed: break;
0
175 case QEvent::Hide: -
176 case QEvent::StyleChange: -
177 hide(); -
178 break;
never executed: break;
0
179 case QEvent::ParentChange: -
180 if (d->showFrameAboveWidget) {
never evaluated: d->showFrameAboveWidget
0
181 QWidget *w = d->widget; -
182 setWidget(0); -
183 setWidget(w); -
184 } else {
never executed: }
0
185 d->update(); -
186 }
never executed: }
0
187 break;
never executed: break;
0
188 case QEvent::Show: -
189 d->update(); -
190 show(); -
191 break;
never executed: break;
0
192 case QEvent::PaletteChange: -
193 setPalette(d->widget->palette()); -
194 break;
never executed: break;
0
195 case QEvent::ZOrderChange: -
196 if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this))
never evaluated: style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)
0
197 raise();
never executed: raise();
0
198 else -
199 stackUnder(d->widget);
never executed: stackUnder(d->widget);
0
200 break;
never executed: break;
0
201 case QEvent::Destroy: -
202 setWidget(0); -
203 break;
never executed: break;
0
204 default: -
205 break;
never executed: break;
0
206 } -
207 } else if (d->showFrameAboveWidget) {
never executed: }
never evaluated: d->showFrameAboveWidget
0
208 -
209 switch(e->type()) { -
210 case QEvent::Move: -
211 case QEvent::Resize: -
212 d->updateSize(); -
213 break;
never executed: break;
0
214 case QEvent::ZOrderChange: -
215 raise(); -
216 break;
never executed: break;
0
217 default: -
218 break;
never executed: break;
0
219 } -
220 }
never executed: }
0
221 return false;
never executed: return false;
0
222} -
223 -
224 -
225bool QFocusFrame::event(QEvent *e) -
226{ -
227 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:5
5
228} -
229 -
230 -
231 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial