widgets/qframe.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5QFramePrivate::QFramePrivate() -
6 : frect(QRect(0, 0, 0, 0)), -
7 frameStyle(QFrame::NoFrame | QFrame::Plain), -
8 lineWidth(1), -
9 midLineWidth(0), -
10 frameWidth(0), -
11 leftFrameWidth(0), rightFrameWidth(0), -
12 topFrameWidth(0), bottomFrameWidth(0) -
13{ -
14}
executed: }
Execution Count:7245
7245
15 -
16inline void QFramePrivate::init() -
17{ -
18 setLayoutItemMargins(QStyle::SE_FrameLayoutItem); -
19}
executed: }
Execution Count:7245
7245
20QFrame::QFrame(QWidget* parent, Qt::WindowFlags f) -
21 : QWidget(*new QFramePrivate, parent, f) -
22{ -
23 QFramePrivate * const d = d_func(); -
24 d->init(); -
25}
executed: }
Execution Count:613
613
26 -
27 -
28QFrame::QFrame(QFramePrivate &dd, QWidget* parent, Qt::WindowFlags f) -
29 : QWidget(dd, parent, f) -
30{ -
31 QFramePrivate * const d = d_func(); -
32 d->init(); -
33}
executed: }
Execution Count:6632
6632
34 -
35 -
36 -
37 -
38 -
39QFrame::~QFrame() -
40{ -
41} -
42int QFrame::frameStyle() const -
43{ -
44 const QFramePrivate * const d = d_func(); -
45 return d->frameStyle;
never executed: return d->frameStyle;
0
46} -
47QFrame::Shape QFrame::frameShape() const -
48{ -
49 const QFramePrivate * const d = d_func(); -
50 return (Shape) (d->frameStyle & Shape_Mask);
executed: return (Shape) (d->frameStyle & Shape_Mask);
Execution Count:1317
1317
51} -
52 -
53void QFrame::setFrameShape(QFrame::Shape s) -
54{ -
55 QFramePrivate * const d = d_func(); -
56 setFrameStyle((d->frameStyle & Shadow_Mask) | s); -
57}
executed: }
Execution Count:191
191
58QFrame::Shadow QFrame::frameShadow() const -
59{ -
60 const QFramePrivate * const d = d_func(); -
61 return (Shadow) (d->frameStyle & Shadow_Mask);
never executed: return (Shadow) (d->frameStyle & Shadow_Mask);
0
62} -
63 -
64void QFrame::setFrameShadow(QFrame::Shadow s) -
65{ -
66 QFramePrivate * const d = d_func(); -
67 setFrameStyle((d->frameStyle & Shape_Mask) | s); -
68}
executed: }
Execution Count:191
191
69void QFrame::setFrameStyle(int style) -
70{ -
71 QFramePrivate * const d = d_func(); -
72 if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
evaluated: !testAttribute(Qt::WA_WState_OwnSizePolicy)
TRUEFALSE
yes
Evaluation Count:5834
yes
Evaluation Count:2941
2941-5834
73 QSizePolicy sp; -
74 -
75 switch (style & Shape_Mask) { -
76 case HLine: -
77 sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Line); -
78 break;
executed: break;
Execution Count:4
4
79 case VLine: -
80 sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum, QSizePolicy::Line); -
81 break;
never executed: break;
0
82 default: -
83 sp = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::Frame); -
84 }
executed: }
Execution Count:5830
5830
85 setSizePolicy(sp); -
86 setAttribute(Qt::WA_WState_OwnSizePolicy, false); -
87 }
executed: }
Execution Count:5834
5834
88 d->frameStyle = (short)style; -
89 update(); -
90 d->updateFrameWidth(); -
91}
executed: }
Execution Count:8775
8775
92void QFrame::setLineWidth(int w) -
93{ -
94 QFramePrivate * const d = d_func(); -
95 if (short(w) == d->lineWidth)
evaluated: short(w) == d->lineWidth
TRUEFALSE
yes
Evaluation Count:379
yes
Evaluation Count:430
379-430
96 return;
executed: return;
Execution Count:379
379
97 d->lineWidth = short(w); -
98 d->updateFrameWidth(); -
99}
executed: }
Execution Count:430
430
100 -
101int QFrame::lineWidth() const -
102{ -
103 const QFramePrivate * const d = d_func(); -
104 return d->lineWidth;
executed: return d->lineWidth;
Execution Count:7755
7755
105} -
106void QFrame::setMidLineWidth(int w) -
107{ -
108 QFramePrivate * const d = d_func(); -
109 if (short(w) == d->midLineWidth)
evaluated: short(w) == d->midLineWidth
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:7
7-85
110 return;
executed: return;
Execution Count:85
85
111 d->midLineWidth = short(w); -
112 d->updateFrameWidth(); -
113}
executed: }
Execution Count:7
7
114 -
115int QFrame::midLineWidth() const -
116{ -
117 const QFramePrivate * const d = d_func(); -
118 return d->midLineWidth;
never executed: return d->midLineWidth;
0
119} -
120 -
121 -
122 -
123 -
124 -
125void QFramePrivate::updateStyledFrameWidths() -
126{ -
127 const QFrame * const q = q_func(); -
128 QStyleOptionFrameV3 opt; -
129 opt.initFrom(q); -
130 opt.lineWidth = lineWidth; -
131 opt.midLineWidth = midLineWidth; -
132 opt.frameShape = QFrame::Shape(frameStyle & QFrame::Shape_Mask); -
133 -
134 QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q); -
135 leftFrameWidth = cr.left() - opt.rect.left(); -
136 topFrameWidth = cr.top() - opt.rect.top(); -
137 rightFrameWidth = opt.rect.right() - cr.right(), -
138 bottomFrameWidth = opt.rect.bottom() - cr.bottom(); -
139 frameWidth = qMax(qMax(leftFrameWidth, rightFrameWidth), -
140 qMax(topFrameWidth, bottomFrameWidth)); -
141}
executed: }
Execution Count:18223
18223
142 -
143 -
144 -
145 -
146 -
147 -
148void QFramePrivate::updateFrameWidth() -
149{ -
150 QFrame * const q = q_func(); -
151 QRect fr = q->frameRect(); -
152 updateStyledFrameWidths(); -
153 q->setFrameRect(fr); -
154 setLayoutItemMargins(QStyle::SE_FrameLayoutItem); -
155}
executed: }
Execution Count:16545
16545
156int QFrame::frameWidth() const -
157{ -
158 const QFramePrivate * const d = d_func(); -
159 return d->frameWidth;
executed: return d->frameWidth;
Execution Count:8444
8444
160} -
161QRect QFrame::frameRect() const -
162{ -
163 const QFramePrivate * const d = d_func(); -
164 QRect fr = contentsRect(); -
165 fr.adjust(-d->leftFrameWidth, -d->topFrameWidth, d->rightFrameWidth, d->bottomFrameWidth); -
166 return fr;
executed: return fr;
Execution Count:19243
19243
167} -
168 -
169void QFrame::setFrameRect(const QRect &r) -
170{ -
171 QFramePrivate * const d = d_func(); -
172 QRect cr = r.isValid() ? r : rect();
evaluated: r.isValid()
TRUEFALSE
yes
Evaluation Count:39743
yes
Evaluation Count:5000
5000-39743
173 cr.adjust(d->leftFrameWidth, d->topFrameWidth, -d->rightFrameWidth, -d->bottomFrameWidth); -
174 setContentsMargins(cr.left(), cr.top(), rect().right() - cr.right(), rect().bottom() - cr.bottom()); -
175}
executed: }
Execution Count:44743
44743
176 -
177 -
178 -
179QSize QFrame::sizeHint() const -
180{ -
181 const QFramePrivate * const d = d_func(); -
182 -
183 -
184 -
185 switch (d->frameStyle & Shape_Mask) { -
186 case HLine: -
187 return QSize(-1,3);
never executed: return QSize(-1,3);
0
188 case VLine: -
189 return QSize(3,-1);
never executed: return QSize(3,-1);
0
190 default: -
191 return QWidget::sizeHint();
executed: return QWidget::sizeHint();
Execution Count:2499
2499
192 } -
193}
never executed: }
0
194 -
195 -
196 -
197 -
198void QFrame::paintEvent(QPaintEvent *) -
199{ -
200 QPainter paint(this); -
201 drawFrame(&paint); -
202}
executed: }
Execution Count:1978
1978
203 -
204 -
205 -
206 -
207 -
208 -
209void QFrame::drawFrame(QPainter *p) -
210{ -
211 QFramePrivate * const d = d_func(); -
212 QStyleOptionFrameV3 opt; -
213 opt.init(this); -
214 int frameShape = d->frameStyle & QFrame::Shape_Mask; -
215 int frameShadow = d->frameStyle & QFrame::Shadow_Mask; -
216 opt.frameShape = Shape(int(opt.frameShape) | frameShape); -
217 opt.rect = frameRect(); -
218 switch (frameShape) { -
219 case QFrame::Box: -
220 case QFrame::HLine: -
221 case QFrame::VLine: -
222 case QFrame::StyledPanel: -
223 case QFrame::Panel: -
224 opt.lineWidth = d->lineWidth; -
225 opt.midLineWidth = d->midLineWidth; -
226 break;
executed: break;
Execution Count:1801
1801
227 default: -
228 -
229 -
230 opt.lineWidth = d->frameWidth; -
231 break;
executed: break;
Execution Count:897
897
232 } -
233 -
234 if (frameShadow == Sunken)
evaluated: frameShadow == Sunken
TRUEFALSE
yes
Evaluation Count:1208
yes
Evaluation Count:1490
1208-1490
235 opt.state |= QStyle::State_Sunken;
executed: opt.state |= QStyle::State_Sunken;
Execution Count:1208
1208
236 else if (frameShadow == Raised)
evaluated: frameShadow == Raised
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:1440
50-1440
237 opt.state |= QStyle::State_Raised;
executed: opt.state |= QStyle::State_Raised;
Execution Count:50
50
238 -
239 style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this); -
240}
executed: }
Execution Count:2698
2698
241 -
242 -
243 -
244 -
245void QFrame::changeEvent(QEvent *ev) -
246{ -
247 QFramePrivate * const d = d_func(); -
248 if (ev->type() == QEvent::StyleChange
evaluated: ev->type() == QEvent::StyleChange
TRUEFALSE
yes
Evaluation Count:918
yes
Evaluation Count:11239
918-11239
249 -
250 -
251 -
252 ) -
253 d->updateFrameWidth();
executed: d->updateFrameWidth();
Execution Count:918
918
254 QWidget::changeEvent(ev); -
255}
executed: }
Execution Count:12157
12157
256 -
257 -
258bool QFrame::event(QEvent *e) -
259{ -
260 if (e->type() == QEvent::ParentChange)
evaluated: e->type() == QEvent::ParentChange
TRUEFALSE
yes
Evaluation Count:845
yes
Evaluation Count:129388
845-129388
261 d_func()->updateFrameWidth();
executed: d_func()->updateFrameWidth();
Execution Count:845
845
262 bool result = QWidget::event(e); -
263 -
264 if (e->type() == QEvent::Polish)
evaluated: e->type() == QEvent::Polish
TRUEFALSE
yes
Evaluation Count:5570
yes
Evaluation Count:124663
5570-124663
265 d_func()->updateFrameWidth();
executed: d_func()->updateFrameWidth();
Execution Count:5570
5570
266 return result;
executed: return result;
Execution Count:130233
130233
267} -
268 -
269 -
270 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial