OpenCoverage

qformlayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qformlayout.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4namespace {-
5-
6-
7template <class T, int NumColumns>-
8class FixedColumnMatrix {-
9public:-
10 typedef QVector<T> Storage;-
11-
12 FixedColumnMatrix() { }-
13-
14 void clear() { m_storage.clear(); }
never executed: end of block
0
15-
16 const T &operator()(int r, int c) const { return
never executed: return m_storage[r * NumColumns + c];
m_storage[r * NumColumns + c];
never executed: return m_storage[r * NumColumns + c];
}
0
17 T &operator()(int r, int c) { return
never executed: return m_storage[r * NumColumns + c];
m_storage[r * NumColumns + c];
never executed: return m_storage[r * NumColumns + c];
}
0
18-
19 int rowCount() const { return
never executed: return m_storage.size() / NumColumns;
m_storage.size() / NumColumns;
never executed: return m_storage.size() / NumColumns;
}
0
20 void insertRow(int r, const T &value);-
21-
22-
23 const Storage &storage() const { return
never executed: return m_storage;
m_storage;
never executed: return m_storage;
}
0
24-
25 static void storageIndexToPosition(int idx, int *rowPtr, int *colPtr);-
26-
27private:-
28 Storage m_storage;-
29};-
30-
31template <class T, int NumColumns>-
32void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value)-
33{-
34 typename Storage::iterator it = m_storage.begin();-
35 it += r * NumColumns;-
36 m_storage.insert(it, NumColumns, value);-
37}
never executed: end of block
0
38-
39template <class T, int NumColumns>-
40void FixedColumnMatrix<T, NumColumns>::storageIndexToPosition(int idx, int *rowPtr, int *colPtr)-
41{-
42 *rowPtr = idx / NumColumns;-
43 *colPtr = idx % NumColumns;-
44}
never executed: end of block
0
45}-
46-
47-
48-
49const uint DefaultFieldGrowthPolicy = 255;-
50const uint DefaultRowWrapPolicy = 255;-
51-
52enum { ColumnCount = 2 };-
53-
54-
55-
56struct QFormLayoutItem-
57{-
58 QFormLayoutItem(QLayoutItem* i) : item(i), fullRow(false), isHfw(false) { }
never executed: end of block
0
59 ~QFormLayoutItem() { delete item; }
never executed: end of block
0
60-
61-
62 QWidget *widget() const { return
never executed: return item->widget();
item->widget();
never executed: return item->widget();
}
0
63 QLayout *layout() const { return
never executed: return item->layout();
item->layout();
never executed: return item->layout();
}
0
64-
65 bool hasHeightForWidth() const { return
never executed: return item->hasHeightForWidth();
item->hasHeightForWidth();
never executed: return item->hasHeightForWidth();
}
0
66 int heightForWidth(int width) const { return
never executed: return item->heightForWidth(width);
item->heightForWidth(width);
never executed: return item->heightForWidth(width);
}
0
67 int minimumHeightForWidth(int width) const { return
never executed: return item->minimumHeightForWidth(width);
item->minimumHeightForWidth(width);
never executed: return item->minimumHeightForWidth(width);
}
0
68 Qt::Orientations expandingDirections() const { return
never executed: return item->expandingDirections();
item->expandingDirections();
never executed: return item->expandingDirections();
}
0
69 QSizePolicy::ControlTypes controlTypes() const { return
never executed: return item->controlTypes();
item->controlTypes();
never executed: return item->controlTypes();
}
0
70 int vStretch() const { return
never executed: return widget() ? widget()->sizePolicy().verticalStretch() : 0;
widget() ? widget()->sizePolicy().verticalStretch() : 0;
never executed: return widget() ? widget()->sizePolicy().verticalStretch() : 0;
}
0
71-
72 void setGeometry(const QRect& r) { item->setGeometry(r); }
never executed: end of block
0
73 QRect geometry() const { return
never executed: return item->geometry();
item->geometry();
never executed: return item->geometry();
}
0
74-
75-
76 bool operator==(const QFormLayoutItem& other) { return
never executed: return item == other.item;
item == other.item;
never executed: return item == other.item;
}
0
77-
78 QLayoutItem *item;-
79 bool fullRow;-
80-
81-
82 bool isHfw;-
83 QSize minSize;-
84 QSize sizeHint;-
85 QSize maxSize;-
86-
87-
88 int sbsHSpace;-
89 int vSpace;-
90-
91-
92 bool sideBySide;-
93 int vLayoutIndex;-
94-
95-
96 int layoutPos;-
97 int layoutWidth;-
98};-
99-
100class QFormLayoutPrivate : public QLayoutPrivate-
101{-
102 inline QFormLayout* q_func() { return static_cast<QFormLayout *>(q_ptr); } inline const QFormLayout* q_func() const { return static_cast<const QFormLayout *>(q_ptr); } friend class QFormLayout;-
103-
104public:-
105 typedef FixedColumnMatrix<QFormLayoutItem *, ColumnCount> ItemMatrix;-
106-
107 QFormLayoutPrivate();-
108 ~QFormLayoutPrivate() { }-
109-
110 int insertRow(int row);-
111 void insertRows(int row, int count);-
112 bool setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item);-
113 void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout);-
114 void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget);-
115-
116 void arrangeWidgets(const QVector<QLayoutStruct>& layouts, QRect &rect);-
117-
118 void updateSizes();-
119-
120 void setupVerticalLayoutData(int width);-
121 void setupHorizontalLayoutData(int width);-
122-
123 QStyle* getStyle() const;-
124-
125 inline bool haveHfwCached(int width) const-
126 {-
127 return
never executed: return (hfw_width == width) || (width == sh_width && hfw_sh_height >= 0);
(hfw_width == width) || (width == sh_width && hfw_sh_height >= 0);
never executed: return (hfw_width == width) || (width == sh_width && hfw_sh_height >= 0);
0
128 }-
129-
130 void recalcHFW(int w);-
131 void setupHfwLayoutData();-
132-
133 uint fieldGrowthPolicy : 8;-
134 uint rowWrapPolicy : 8;-
135 uint has_hfw : 2;-
136 uint dirty : 2;-
137 uint sizesDirty : 2;-
138 uint expandVertical : 1;-
139 uint expandHorizontal : 1;-
140 Qt::Alignment labelAlignment;-
141 Qt::Alignment formAlignment;-
142-
143 ItemMatrix m_matrix;-
144 QList<QFormLayoutItem *> m_things;-
145-
146 int layoutWidth;-
147-
148 int hfw_width;-
149 int hfw_height;-
150 int hfw_minheight;-
151-
152 int hfw_sh_height;-
153 int hfw_sh_minheight;-
154-
155 int min_width;-
156 int sh_width;-
157 int thresh_width;-
158 QSize minSize;-
159 QSize prefSize;-
160 int formMaxWidth;-
161 void calcSizeHints();-
162-
163 QVector<QLayoutStruct> vLayouts;-
164 int vLayoutCount;-
165 int maxLabelWidth;-
166-
167 QVector<QLayoutStruct> hfwLayouts;-
168-
169 int hSpacing;-
170 int vSpacing;-
171 QLayoutItem* replaceAt(int index, QLayoutItem*) override;-
172};-
173-
174QFormLayoutPrivate::QFormLayoutPrivate()-
175 : fieldGrowthPolicy(DefaultFieldGrowthPolicy),-
176 rowWrapPolicy(DefaultRowWrapPolicy), has_hfw(false), dirty(true), sizesDirty(true),-
177 expandVertical(0), expandHorizontal(0), labelAlignment(0), formAlignment(0),-
178 layoutWidth(-1), hfw_width(-1), hfw_sh_height(-1), min_width(-1),-
179 sh_width(-1), thresh_width(QLAYOUTSIZE_MAX), hSpacing(-1), vSpacing(-1)-
180{-
181}
never executed: end of block
0
182-
183static Qt::Alignment fixedAlignment(Qt::Alignment alignment, Qt::LayoutDirection layoutDirection)-
184{-
185 if (layoutDirection == Qt::RightToLeft
layoutDirectio...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& alignment & Qt::AlignAbsolute
alignment & Qt::AlignAbsoluteDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
186-
187 return
never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0));
Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute))
never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0));
0
188 | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0)
never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0));
0
189 | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0));
never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0));
0
190 } else {-
191 return
never executed: return alignment & ~Qt::AlignAbsolute;
alignment & ~Qt::AlignAbsolute;
never executed: return alignment & ~Qt::AlignAbsolute;
0
192 }-
193}-
194-
195static int storageIndexFromLayoutItem(const QFormLayoutPrivate::ItemMatrix &m,-
196 QFormLayoutItem *item)-
197{-
198 if (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
199 return
never executed: return m.storage().indexOf(item);
m.storage().indexOf(item);
never executed: return m.storage().indexOf(item);
0
200 } else {-
201 return
never executed: return -1;
-1;
never executed: return -1;
0
202 }-
203}-
204-
205static void updateFormLayoutItem(QFormLayoutItem *item, int userVSpacing,-
206 QFormLayout::FieldGrowthPolicy fieldGrowthPolicy,-
207 bool fullRow)-
208{-
209 item->minSize = item->item->minimumSize();-
210 item->sizeHint = item->item->sizeHint();-
211 item->maxSize = item->item->maximumSize();-
212-
213 if (!fullRow
!fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
&& (fieldGrowthPolicy == QFormLayout::FieldsStayAtSizeHint
fieldGrowthPol...StayAtSizeHintDescription
TRUEnever evaluated
FALSEnever evaluated
0
214 || (fieldGrowthPolicy == QFormLayout::ExpandingFieldsGrow
fieldGrowthPol...dingFieldsGrowDescription
TRUEnever evaluated
FALSEnever evaluated
0
215 && !(item->item->expandingDirections() & Qt::Horizontal)
!(item->item->...t::Horizontal)Description
TRUEnever evaluated
FALSEnever evaluated
)))
0
216 item->maxSize.setWidth(item->sizeHint.width());
never executed: item->maxSize.setWidth(item->sizeHint.width());
0
217-
218 item->isHfw = item->item->hasHeightForWidth();-
219 item->vSpace = userVSpacing;-
220}
never executed: end of block
0
221-
222-
223-
224-
225-
226-
227-
228void QFormLayoutPrivate::updateSizes()-
229{-
230 QFormLayout * const q = q_func();-
231-
232 if (sizesDirty
sizesDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
233 QFormLayout::RowWrapPolicy wrapPolicy = q->rowWrapPolicy();-
234 bool wrapAllRows = (wrapPolicy == QFormLayout::WrapAllRows);-
235 bool dontWrapRows = (wrapPolicy == QFormLayout::DontWrapRows);-
236 int rr = m_matrix.rowCount();-
237-
238 has_hfw = false;-
239-
240-
241-
242 bool expandH = false;-
243 bool expandV = false;-
244-
245 QFormLayoutItem *prevLbl = 0;-
246 QFormLayoutItem *prevFld = 0;-
247-
248 QWidget *parent = q->parentWidget();-
249 QStyle *style = parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
? parent->style() : 0;
0
250-
251 int userVSpacing = q->verticalSpacing();-
252 int userHSpacing = wrapAllRows
wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
? 0 : q->horizontalSpacing();
0
253-
254 int maxMinLblWidth = 0;-
255 int maxMinFldWidth = 0;-
256 int maxMinIfldWidth = 0;-
257-
258 int maxShLblWidth = 0;-
259 int maxShFldWidth = 0;-
260 int maxShIfldWidth = 0;-
261-
262 for (int i = 0; i < rr
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
263 QFormLayoutItem *label = m_matrix(i, 0);-
264 QFormLayoutItem *field = m_matrix(i, 1);-
265-
266-
267 if (!label
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& !field
!fieldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
268 continue;
never executed: continue;
0
269-
270 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
271 updateFormLayoutItem(label, userVSpacing, q->fieldGrowthPolicy(), false);-
272 if (label->isHfw
label->isHfwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
273 has_hfw = true;
never executed: has_hfw = true;
0
274 Qt::Orientations o = label->expandingDirections();-
275-
276 if (o & Qt::Vertical
o & Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
277 expandV = true;
never executed: expandV = true;
0
278 if (o & Qt::Horizontal
o & Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
279 expandH = true;
never executed: expandH = true;
0
280 }
never executed: end of block
0
281 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
282 updateFormLayoutItem(field, userVSpacing, q->fieldGrowthPolicy(), !label && field->fullRow);-
283 field->sbsHSpace = (!label
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& field->fullRow
field->fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
) ? 0 : userHSpacing;
0
284 if (field->isHfw
field->isHfwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
285 has_hfw = true;
never executed: has_hfw = true;
0
286-
287 Qt::Orientations o = field->expandingDirections();-
288-
289 if (o & Qt::Vertical
o & Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
290 expandV = true;
never executed: expandV = true;
0
291 if (o & Qt::Horizontal
o & Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
292 expandH = true;
never executed: expandH = true;
0
293 }
never executed: end of block
0
294-
295-
296 if ((userHSpacing < 0
userHSpacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| userVSpacing < 0
userVSpacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
) && style
styleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
297 QSizePolicy::ControlTypes lbltypes =-
298 QSizePolicy::ControlTypes(label ? label->controlTypes() : QSizePolicy::DefaultType);-
299 QSizePolicy::ControlTypes fldtypes =-
300 QSizePolicy::ControlTypes(field ? field->controlTypes() : QSizePolicy::DefaultType);-
301-
302-
303 if (userVSpacing < 0
userVSpacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
304 if (wrapAllRows
wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
305-
306 QFormLayoutItem *lbltop = prevFld
prevFldDescription
TRUEnever evaluated
FALSEnever evaluated
? prevFld : prevLbl;
0
307-
308 QFormLayoutItem *fldtop = label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
? label : lbltop;
0
309 QSizePolicy::ControlTypes lbltoptypes =-
310 QSizePolicy::ControlTypes(lbltop ? lbltop->controlTypes() : QSizePolicy::DefaultType);-
311 QSizePolicy::ControlTypes fldtoptypes =-
312 QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType);-
313 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& lbltop
lbltopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
314 label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
never executed: label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
0
315 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
&& fldtop
fldtopDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
316 field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
never executed: field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
0
317 }
never executed: end of block
else {
0
318-
319-
320 QFormLayoutItem *lbltop = prevLbl
prevLblDescription
TRUEnever evaluated
FALSEnever evaluated
? prevLbl : prevFld;
0
321 QFormLayoutItem *fldtop = prevFld;-
322 QSizePolicy::ControlTypes lbltoptypes =-
323 QSizePolicy::ControlTypes(lbltop ? lbltop->controlTypes() : QSizePolicy::DefaultType);-
324 QSizePolicy::ControlTypes fldtoptypes =-
325 QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType);-
326-
327-
328 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
329 if (!field
!fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
330 int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);-
331 int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, 0, parent);-
332 label->vSpace = qMax(lblspacing, fldspacing);-
333 }
never executed: end of block
else
0
334 label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
never executed: label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
0
335 }-
336-
337 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
338-
339 if (!label
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
340 int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, 0, parent);-
341 int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);-
342 field->vSpace = qMax(lblspacing, fldspacing);-
343 }
never executed: end of block
else
0
344 field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
never executed: field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
0
345 }-
346 }
never executed: end of block
0
347 }-
348-
349-
350-
351-
352 if (userHSpacing < 0
userHSpacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& !wrapAllRows
!wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
&& (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
|| !field->fullRow
!field->fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
) && field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
353 field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent);
never executed: field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent);
0
354 }
never executed: end of block
0
355 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
356 maxMinLblWidth = qMax(maxMinLblWidth, label->minSize.width());-
357 maxShLblWidth = qMax(maxShLblWidth, label->sizeHint.width());-
358 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
359 maxMinFldWidth = qMax(maxMinFldWidth, field->minSize.width() + field->sbsHSpace);-
360 maxShFldWidth = qMax(maxShFldWidth, field->sizeHint.width() + field->sbsHSpace);-
361 }
never executed: end of block
0
362 }
never executed: end of block
else if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
363 maxMinIfldWidth = qMax(maxMinIfldWidth, field->minSize.width());-
364 maxShIfldWidth = qMax(maxShIfldWidth, field->sizeHint.width());-
365 }
never executed: end of block
0
366-
367 prevLbl = label;-
368 prevFld = field;-
369 }
never executed: end of block
0
370-
371-
372 if (wrapAllRows
wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
373 sh_width = qMax(maxShLblWidth, qMax(maxShIfldWidth, maxShFldWidth));-
374 min_width = qMax(maxMinLblWidth, qMax(maxMinIfldWidth, maxMinFldWidth));-
375-
376 thresh_width = 0;-
377 }
never executed: end of block
else if (dontWrapRows
dontWrapRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
378-
379 sh_width = qMax(maxShLblWidth + maxShFldWidth, maxShIfldWidth);-
380 min_width = qMax(maxMinLblWidth + maxMinFldWidth, maxMinIfldWidth);-
381 thresh_width = ((1<<24)-1);-
382 }
never executed: end of block
else {
0
383-
384 sh_width = qMax(maxShLblWidth + maxShFldWidth, maxShIfldWidth);-
385-
386-
387 min_width = qMax(maxMinLblWidth, qMax(maxMinIfldWidth, maxMinFldWidth));-
388-
389 thresh_width = maxShLblWidth + maxMinFldWidth;-
390 }
never executed: end of block
0
391-
392-
393 expandVertical = expandV;-
394 expandHorizontal = expandH;-
395 }
never executed: end of block
0
396 sizesDirty = false;-
397}
never executed: end of block
0
398-
399void QFormLayoutPrivate::recalcHFW(int w)-
400{-
401 setupHfwLayoutData();-
402-
403 int h = 0;-
404 int mh = 0;-
405-
406 for (int r = 0; r < vLayoutCount
r < vLayoutCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++r) {
0
407 int spacing = hfwLayouts.at(r).spacing;-
408 h += hfwLayouts.at(r).sizeHint + spacing;-
409 mh += hfwLayouts.at(r).minimumSize + spacing;-
410 }
never executed: end of block
0
411-
412 if (sh_width > 0
sh_width > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& sh_width == w
sh_width == wDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
413 hfw_sh_height = qMin(QLAYOUTSIZE_MAX, h);-
414 hfw_sh_minheight = qMin(QLAYOUTSIZE_MAX, mh);-
415 }
never executed: end of block
else {
0
416 hfw_width = w;-
417 hfw_height = qMin(QLAYOUTSIZE_MAX, h);-
418 hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh);-
419 }
never executed: end of block
0
420}-
421-
422void QFormLayoutPrivate::setupHfwLayoutData()-
423{-
424 int i;-
425 int rr = m_matrix.rowCount();-
426-
427 hfwLayouts.clear();-
428 hfwLayouts.resize(vLayoutCount);-
429 for (i = 0; i < vLayoutCount
i < vLayoutCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
430 hfwLayouts[i] = vLayouts.at(i);
never executed: hfwLayouts[i] = vLayouts.at(i);
0
431-
432 for (i = 0; i < rr
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
433 QFormLayoutItem *label = m_matrix(i, 0);-
434 QFormLayoutItem *field = m_matrix(i, 1);-
435-
436 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
437 if (label->isHfw
label->isHfwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
438-
439-
440 int hfw = label->heightForWidth(label->layoutWidth);-
441 hfwLayouts[label->vLayoutIndex].minimumSize = hfw;-
442 hfwLayouts[label->vLayoutIndex].sizeHint = hfw;-
443 }
never executed: end of block
else {
0
444-
445-
446 hfwLayouts[label->vLayoutIndex].sizeHint = label->sizeHint.height();-
447 hfwLayouts[label->vLayoutIndex].minimumSize = label->minSize.height();-
448 }
never executed: end of block
0
449 }-
450-
451 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
452 int hfw = field->isHfw
field->isHfwDescription
TRUEnever evaluated
FALSEnever evaluated
? field->heightForWidth(field->layoutWidth) : 0;
0
453 int h = field->isHfw
field->isHfwDescription
TRUEnever evaluated
FALSEnever evaluated
? hfw : field->sizeHint.height();
0
454 int mh = field->isHfw
field->isHfwDescription
TRUEnever evaluated
FALSEnever evaluated
? hfw : field->minSize.height();
0
455-
456 if (field->sideBySide
field->sideBySideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
457 int oh = hfwLayouts.at(field->vLayoutIndex).sizeHint;-
458 int omh = hfwLayouts.at(field->vLayoutIndex).minimumSize;-
459-
460 hfwLayouts[field->vLayoutIndex].sizeHint = qMax(h, oh);-
461 hfwLayouts[field->vLayoutIndex].minimumSize = qMax(mh, omh);-
462 }
never executed: end of block
else {
0
463 hfwLayouts[field->vLayoutIndex].sizeHint = h;-
464 hfwLayouts[field->vLayoutIndex].minimumSize = mh;-
465 }
never executed: end of block
0
466 }-
467 }
never executed: end of block
0
468}
never executed: end of block
0
469static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing, bool recalculate, QFormLayoutItem* item1, QFormLayoutItem* item2, QFormLayoutItem* prevItem1, QFormLayoutItem *prevItem2)-
470{-
471 int spacing = userVSpacing;-
472 if (spacing < 0
spacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
473 if (!recalculate
!recalculateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
474 if (item1
item1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
475 spacing = item1->vSpace;
never executed: spacing = item1->vSpace;
0
476 if (item2
item2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
477 spacing = qMax(spacing, item2->vSpace);
never executed: spacing = qMax(spacing, item2->vSpace);
0
478 }
never executed: end of block
else {
0
479 if (style
styleDescription
TRUEnever evaluated
FALSEnever evaluated
&& prevItem1
prevItem1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
480 QSizePolicy::ControlTypes itemtypes =-
481 QSizePolicy::ControlTypes(item1 ? item1->controlTypes() : QSizePolicy::DefaultType);-
482 int spacing2 = 0;-
483-
484 spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, 0, parent);-
485-
486-
487 if (item2
item2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
488 spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent);
never executed: spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent);
0
489 else if (prevItem2
prevItem2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
490 spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent);
never executed: spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent);
0
491-
492 spacing = qMax(spacing, spacing2);-
493 }
never executed: end of block
0
494 }
never executed: end of block
0
495 } else {-
496 if (prevItem1
prevItem1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
497 QWidget *wid = prevItem1->item->widget();-
498 if (wid
widDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
499 spacing = qMax(spacing, prevItem1->geometry().top() - wid->geometry().top() );
never executed: spacing = qMax(spacing, prevItem1->geometry().top() - wid->geometry().top() );
0
500 }
never executed: end of block
0
501 if (prevItem2
prevItem2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
502 QWidget *wid = prevItem2->item->widget();-
503 if (wid
widDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
504 spacing = qMax(spacing, prevItem2->geometry().top() - wid->geometry().top() );
never executed: spacing = qMax(spacing, prevItem2->geometry().top() - wid->geometry().top() );
0
505 }
never executed: end of block
0
506 }
never executed: end of block
0
507 return
never executed: return qMax(spacing, 0);
qMax(spacing, 0);
never executed: return qMax(spacing, 0);
0
508}-
509-
510static inline void initLayoutStruct(QLayoutStruct& sl, QFormLayoutItem* item)-
511{-
512 sl.init(item->vStretch(), item->minSize.height());-
513 sl.sizeHint = item->sizeHint.height();-
514 sl.maximumSize = item->maxSize.height();-
515 sl.expansive = (item->expandingDirections() & Qt::Vertical);-
516 sl.empty = false;-
517}
never executed: end of block
0
518-
519void QFormLayoutPrivate::setupVerticalLayoutData(int width)-
520{-
521 QFormLayout * const q = q_func();-
522-
523-
524 if ((width == layoutWidth
width == layoutWidthDescription
TRUEnever evaluated
FALSEnever evaluated
|| (width >= thresh_width
width >= thresh_widthDescription
TRUEnever evaluated
FALSEnever evaluated
&& layoutWidth >= thresh_width
layoutWidth >= thresh_widthDescription
TRUEnever evaluated
FALSEnever evaluated
)) && !dirty
!dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
&& !sizesDirty
!sizesDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
525 return;
never executed: return;
0
526-
527 layoutWidth = width;-
528-
529 int rr = m_matrix.rowCount();-
530 int vidx = 1;-
531 QFormLayout::RowWrapPolicy rowWrapPolicy = q->rowWrapPolicy();-
532 bool wrapAllRows = (rowWrapPolicy == QFormLayout::WrapAllRows);-
533 bool addTopBottomStretch = true;-
534-
535 vLayouts.clear();-
536 vLayouts.resize((2 * rr) + 2);-
537-
538 QStyle *style = 0;-
539-
540 int userVSpacing = q->verticalSpacing();-
541-
542 if (userVSpacing < 0
userVSpacing < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
543 if (QWidget *widget = q->parentWidget()
QWidget *widge...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
544 style = widget->style();
never executed: style = widget->style();
0
545 }
never executed: end of block
0
546-
547-
548 updateSizes();-
549-
550-
551-
552-
553-
554 maxLabelWidth = 0;-
555 if (!wrapAllRows
!wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
556 for (int i = 0; i < rr
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
557 const QFormLayoutItem *label = m_matrix(i, 0);-
558 const QFormLayoutItem *field = m_matrix(i, 1);-
559 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(label->sizeHi...: 0) <= width)Description
TRUEnever evaluated
FALSEnever evaluated
label->sizeHint.width() + (field ? field->minSize.width() : 0) <= width)
(label->sizeHi...: 0) <= width)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
560 maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width());
never executed: maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width());
0
561 }
never executed: end of block
0
562 }
never executed: end of block
else {
0
563 maxLabelWidth = width;-
564 }
never executed: end of block
0
565-
566 QFormLayoutItem *prevItem1 = 0;-
567 QFormLayoutItem *prevItem2 = 0;-
568 bool prevRowSplit = false;-
569-
570 for (int i = 0; i < rr
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
571 QFormLayoutItem *label = m_matrix(i, 0);-
572 QFormLayoutItem *field = m_matrix(i, 1);-
573-
574-
575 if (!label
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& !field
!fieldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
576 continue;
never executed: continue;
0
577-
578 QSize min1;-
579 QSize min2;-
580 QSize sh1;-
581 QSize sh2;-
582 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
583 min1 = label->minSize;-
584 sh1 = label->sizeHint;-
585 }
never executed: end of block
0
586 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
587 min2 = field->minSize;-
588 sh2 = field->sizeHint;-
589 }
never executed: end of block
0
590-
591-
592-
593 bool splitSideBySide = (
(rowWrapPolicy...:WrapLongRows)Description
TRUEnever evaluated
FALSEnever evaluated
rowWrapPolicy == QFormLayout::WrapLongRows)
(rowWrapPolicy...:WrapLongRows)Description
TRUEnever evaluated
FALSEnever evaluated
0
594 && ((
(maxLabelWidth < sh1.width())Description
TRUEnever evaluated
FALSEnever evaluated
maxLabelWidth < sh1.width())
(maxLabelWidth < sh1.width())Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(width < (maxL...min2.width()))Description
TRUEnever evaluated
FALSEnever evaluated
width < (maxLabelWidth + min2.width()))
(width < (maxL...min2.width()))Description
TRUEnever evaluated
FALSEnever evaluated
);
0
595-
596 if (wrapAllRows
wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
|| splitSideBySide
splitSideBySideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
598 initLayoutStruct(vLayouts[vidx], label);-
599-
600 if (vidx > 1
vidx > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
601 vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2);
never executed: vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2);
0
602-
603 label->vLayoutIndex = vidx;-
604 label->sideBySide = false;-
605-
606 prevItem1 = label;-
607 prevItem2 = 0;-
608-
609 if (vLayouts[vidx].stretch > 0
vLayouts[vidx].stretch > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
610 addTopBottomStretch = false;
never executed: addTopBottomStretch = false;
0
611-
612 ++vidx;-
613 }
never executed: end of block
0
614-
615 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
616 initLayoutStruct(vLayouts[vidx], field);-
617-
618 if (vidx > 1
vidx > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
619 vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2);
never executed: vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2);
0
620-
621 field->vLayoutIndex = vidx;-
622 field->sideBySide = false;-
623-
624 prevItem1 = field;-
625 prevItem2 = 0;-
626-
627 if (vLayouts[vidx].stretch > 0
vLayouts[vidx].stretch > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
628 addTopBottomStretch = false;
never executed: addTopBottomStretch = false;
0
629-
630 ++vidx;-
631 }
never executed: end of block
0
632-
633 prevRowSplit = splitSideBySide;-
634 }
never executed: end of block
else {
0
635-
636 QSize max1(((1<<24)-1), ((1<<24)-1));-
637 QSize max2(((1<<24)-1), ((1<<24)-1));-
638-
639 int stretch1 = 0;-
640 int stretch2 = 0;-
641 bool expanding = false;-
642-
643 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
644 max1 = label->maxSize;-
645 if (label->expandingDirections() & Qt::Vertical
label->expandi...& Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
646 expanding = true;
never executed: expanding = true;
0
647-
648 label->sideBySide = (field != 0);-
649 label->vLayoutIndex = vidx;-
650 stretch1 = label->vStretch();-
651 }
never executed: end of block
0
652-
653 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
654 max2 = field->maxSize;-
655 if (field->expandingDirections() & Qt::Vertical
field->expandi...& Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
656 expanding = true;
never executed: expanding = true;
0
657-
658 field->sideBySide = (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
|| !field->fullRow
!field->fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
659 field->vLayoutIndex = vidx;-
660 stretch2 = field->vStretch();-
661 }
never executed: end of block
0
662-
663 vLayouts[vidx].init(qMax(stretch1, stretch2), qMax(min1.height(), min2.height()));-
664 vLayouts[vidx].sizeHint = qMax(sh1.height(), sh2.height());-
665 vLayouts[vidx].maximumSize = qMin(max1.height(), max2.height());-
666 vLayouts[vidx].expansive = expanding
expandingDescription
TRUEnever evaluated
FALSEnever evaluated
|| (
(vLayouts[vidx].stretch > 0)Description
TRUEnever evaluated
FALSEnever evaluated
vLayouts[vidx].stretch > 0)
(vLayouts[vidx].stretch > 0)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
667 vLayouts[vidx].empty = false;-
668-
669 if (vLayouts[vidx].stretch > 0
vLayouts[vidx].stretch > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
670 addTopBottomStretch = false;
never executed: addTopBottomStretch = false;
0
671-
672 if (vidx > 1
vidx > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
673 vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, prevRowSplit, label, field, prevItem1, prevItem2);
never executed: vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, prevRowSplit, label, field, prevItem1, prevItem2);
0
674-
675 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
676 prevItem1 = label;-
677 prevItem2 = field;-
678 }
never executed: end of block
else {
0
679 prevItem1 = field;-
680 prevItem2 = 0;-
681 }
never executed: end of block
0
682-
683 prevRowSplit = false;-
684 ++vidx;-
685 }
never executed: end of block
0
686 }-
687-
688 if (addTopBottomStretch
addTopBottomStretchDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
689 Qt::Alignment formAlignment = q->formAlignment();-
690-
691 if (!(formAlignment & Qt::AlignBottom)
!(formAlignmen...::AlignBottom)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
692-
693 vLayouts[vidx].init(1, 0);-
694 vLayouts[vidx].expansive = true;-
695 ++vidx;-
696 }
never executed: end of block
0
697-
698 if (formAlignment & (Qt::AlignVCenter | Qt::AlignBottom)
formAlignment ...::AlignBottom)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
699-
700 vLayouts[0].init(1, 0);-
701 vLayouts[0].expansive = true;-
702 }
never executed: end of block
else {
0
703 vLayouts[0].init(0, 0);-
704 }
never executed: end of block
0
705 } else {-
706 vLayouts[0].init(0, 0);-
707 }
never executed: end of block
0
708-
709 vLayoutCount = vidx;-
710 dirty = false;-
711}
never executed: end of block
0
712-
713void QFormLayoutPrivate::setupHorizontalLayoutData(int width)-
714{-
715 QFormLayout * const q = q_func();-
716-
717-
718-
719 int fieldMaxWidth = 0;-
720-
721 int rr = m_matrix.rowCount();-
722 bool wrapAllRows = (q->rowWrapPolicy() == QFormLayout::WrapAllRows);-
723-
724 for (int i = 0; i < rr
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
725 QFormLayoutItem *label = m_matrix(i, 0);-
726 QFormLayoutItem *field = m_matrix(i, 1);-
727-
728-
729 if (!label
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& !field
!fieldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
730 continue;
never executed: continue;
0
731-
732 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
733-
734-
735 label->layoutWidth = (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
&& label->sideBySide
label->sideBySideDescription
TRUEnever evaluated
FALSEnever evaluated
) ? maxLabelWidth : label->sizeHint.width();
0
736 label->layoutPos = 0;-
737 }
never executed: end of block
0
738-
739 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
740-
741 int fldwidth = width - maxLabelWidth - field->sbsHSpace;-
742-
743-
744-
745-
746 if (!field->sideBySide
!field->sideBySideDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
747 if (wrapAllRows
wrapAllRowsDescription
TRUEnever evaluated
FALSEnever evaluated
|| (!label
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& field->fullRow
field->fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
) || field->sizeHint.width() > fldwidth
field->sizeHin...h() > fldwidthDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
748 field->layoutWidth = width;-
749 field->layoutPos = 0;-
750 }
never executed: end of block
else {
0
751 field->layoutWidth = fldwidth;-
752 field->layoutPos = width - fldwidth;-
753 }
never executed: end of block
0
754 } else {-
755-
756 field->layoutWidth = fldwidth;-
757 field->layoutPos = width - fldwidth;-
758 }
never executed: end of block
0
759-
760 fieldMaxWidth = qMax(fieldMaxWidth, field->maxSize.width());-
761 }
never executed: end of block
0
762 }
never executed: end of block
0
763-
764 formMaxWidth = maxLabelWidth + fieldMaxWidth;-
765}
never executed: end of block
0
766-
767void QFormLayoutPrivate::calcSizeHints()-
768{-
769 QFormLayout * const q = q_func();-
770-
771 int leftMargin, topMargin, rightMargin, bottomMargin;-
772 q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);-
773-
774 updateSizes();-
775 setupVerticalLayoutData(QLAYOUTSIZE_MAX);-
776-
777-
778 int h = topMargin + bottomMargin;-
779 int mh = topMargin + bottomMargin;-
780-
781-
782 int w = sh_width + leftMargin + rightMargin;-
783 int mw = min_width + leftMargin + rightMargin;-
784-
785 for (int i = 0; i < vLayoutCount
i < vLayoutCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
786 int spacing = vLayouts.at(i).spacing;-
787 h += vLayouts.at(i).sizeHint + spacing;-
788 mh += vLayouts.at(i).minimumSize + spacing;-
789 }
never executed: end of block
0
790-
791 minSize.rwidth() = qMin(mw, QLAYOUTSIZE_MAX);-
792 minSize.rheight() = qMin(mh, QLAYOUTSIZE_MAX);-
793 prefSize.rwidth() = qMin(w, QLAYOUTSIZE_MAX);-
794 prefSize.rheight() = qMin(h, QLAYOUTSIZE_MAX);-
795}
never executed: end of block
0
796-
797int QFormLayoutPrivate::insertRow(int row)-
798{-
799 int rowCnt = m_matrix.rowCount();-
800 if (uint(row) > uint(rowCnt)
uint(row) > uint(rowCnt)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
801 row = rowCnt;
never executed: row = rowCnt;
0
802-
803 insertRows(row, 1);-
804 return
never executed: return row;
row;
never executed: return row;
0
805}-
806-
807void QFormLayoutPrivate::insertRows(int row, int count)-
808{-
809 while (count > 0
count > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
810 m_matrix.insertRow(row, 0);-
811 --count;-
812 }
never executed: end of block
0
813}
never executed: end of block
0
814-
815bool QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item)-
816{-
817 const bool fullRow = role == QFormLayout::SpanningRole;-
818 const int column = role == QFormLayout::SpanningRole
role == QFormL...::SpanningRoleDescription
TRUEnever evaluated
FALSEnever evaluated
? 1 : static_cast<int>(role);
0
819 if (__builtin_expect(!!(uint(row) >= uint(m_matrix.rowCount()) || uint(column) > 1U), false)
__builtin_expe... > 1U), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
820 QMessageLogger(__FILE__, 927, __PRETTY_FUNCTION__).warning("QFormLayoutPrivate::setItem: Invalid cell (%d, %d)", row, column);-
821 return
never executed: return false;
false;
never executed: return false;
0
822 }-
823-
824 if (!item
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
825 return
never executed: return false;
false;
never executed: return false;
0
826-
827 if (__builtin_expect(!!(m_matrix(row, column)), false)
__builtin_expe...lumn)), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
828 QMessageLogger(__FILE__, 935, __PRETTY_FUNCTION__).warning("QFormLayoutPrivate::setItem: Cell (%d, %d) already occupied", row, column);-
829 return
never executed: return false;
false;
never executed: return false;
0
830 }-
831-
832 QFormLayoutItem *i = new QFormLayoutItem(item);-
833 i->fullRow = fullRow;-
834 m_matrix(row, column) = i;-
835-
836 m_things.append(i);-
837 return
never executed: return true;
true;
never executed: return true;
0
838}-
839-
840void QFormLayoutPrivate::setLayout(int row, QFormLayout::ItemRole role, QLayout *layout)-
841{-
842 if (layout
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
843 QFormLayout * const q = q_func();-
844 if (q->adoptLayout(layout)
q->adoptLayout(layout)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
845 setItem(row, role, layout);
never executed: setItem(row, role, layout);
0
846 }
never executed: end of block
0
847}
never executed: end of block
0
848-
849void QFormLayoutPrivate::setWidget(int row, QFormLayout::ItemRole role, QWidget *widget)-
850{-
851 if (widget
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
852 QFormLayout * const q = q_func();-
853 q->addChildWidget(widget);-
854 QWidgetItem *item = QLayoutPrivate::createWidgetItem(q, widget);-
855 if (!setItem(row, role, item)
!setItem(row, role, item)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
856 delete item;
never executed: delete item;
0
857 }
never executed: end of block
0
858}
never executed: end of block
0
859-
860QStyle* QFormLayoutPrivate::getStyle() const-
861{-
862 const QFormLayout * const q = q_func();-
863-
864-
865 if (QWidget *parentWidget = q->parentWidget()
QWidget *paren...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
866 return
never executed: return parentWidget->style();
parentWidget->style();
never executed: return parentWidget->style();
0
867 else-
868 return
never executed: return QApplication::style();
QApplication::style();
never executed: return QApplication::style();
0
869}-
870-
871QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem)-
872{-
873 QFormLayout * const q = q_func();-
874 if (!newitem
!newitemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
875 return
never executed: return 0;
0;
never executed: return 0;
0
876 const int storageIndex = storageIndexFromLayoutItem(m_matrix, m_things.value(index));-
877 if (__builtin_expect(!!(storageIndex == -1), false)
__builtin_expe...== -1), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
878-
879 QMessageLogger(__FILE__, 986, __PRETTY_FUNCTION__).warning("QFormLayoutPrivate::replaceAt: Invalid index %d", index);-
880 return
never executed: return 0;
0;
never executed: return 0;
0
881 }-
882-
883 int row, col;-
884 QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col);-
885 ((!(m_matrix(row, col))) ? qt_assert("m_matrix(row, col)",__FILE__,992) : qt_noop());-
886-
887 QFormLayoutItem *item = m_matrix(row, col);-
888 ((!(item)) ? qt_assert("item",__FILE__,995) : qt_noop());-
889-
890 QLayoutItem *olditem = item->item;-
891 item->item = newitem;-
892-
893 q->invalidate();-
894 return
never executed: return olditem;
olditem;
never executed: return olditem;
0
895}-
896QFormLayout::QFormLayout(QWidget *parent)-
897 : QLayout(*new QFormLayoutPrivate, 0, parent)-
898{-
899}
never executed: end of block
0
900-
901-
902-
903-
904QFormLayout::~QFormLayout()-
905{-
906 QFormLayoutPrivate * const d = d_func();-
907-
908-
909-
910-
911-
912-
913 d->m_things.clear();-
914 qDeleteAll(d->m_matrix.storage());-
915 d->m_matrix.clear();-
916}
never executed: end of block
0
917-
918-
919-
920-
921-
922-
923-
924void QFormLayout::addRow(QWidget *label, QWidget *field)-
925{-
926 insertRow(-1, label, field);-
927}
never executed: end of block
0
928-
929-
930-
931-
932void QFormLayout::addRow(QWidget *label, QLayout *field)-
933{-
934 insertRow(-1, label, field);-
935}
never executed: end of block
0
936void QFormLayout::addRow(const QString &labelText, QWidget *field)-
937{-
938 insertRow(-1, labelText, field);-
939}
never executed: end of block
0
940-
941-
942-
943-
944-
945-
946-
947void QFormLayout::addRow(const QString &labelText, QLayout *field)-
948{-
949 insertRow(-1, labelText, field);-
950}
never executed: end of block
0
951-
952-
953-
954-
955-
956-
957-
958void QFormLayout::addRow(QWidget *widget)-
959{-
960 insertRow(-1, widget);-
961}
never executed: end of block
0
962-
963-
964-
965-
966-
967-
968-
969void QFormLayout::addRow(QLayout *layout)-
970{-
971 insertRow(-1, layout);-
972}
never executed: end of block
0
973void QFormLayout::insertRow(int row, QWidget *label, QWidget *field)-
974{-
975 QFormLayoutPrivate * const d = d_func();-
976 if ((label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->checkWidget(label)
!d->checkWidget(label)Description
TRUEnever evaluated
FALSEnever evaluated
) || (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->checkWidget(field)
!d->checkWidget(field)Description
TRUEnever evaluated
FALSEnever evaluated
))
0
977 return;
never executed: return;
0
978-
979 row = d->insertRow(row);-
980 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
981 d->setWidget(row, LabelRole, label);
never executed: d->setWidget(row, LabelRole, label);
0
982 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
983 d->setWidget(row, FieldRole, field);
never executed: d->setWidget(row, FieldRole, field);
0
984 invalidate();-
985}
never executed: end of block
0
986-
987-
988-
989-
990void QFormLayout::insertRow(int row, QWidget *label, QLayout *field)-
991{-
992 QFormLayoutPrivate * const d = d_func();-
993 if ((label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->checkWidget(label)
!d->checkWidget(label)Description
TRUEnever evaluated
FALSEnever evaluated
) || (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->checkLayout(field)
!d->checkLayout(field)Description
TRUEnever evaluated
FALSEnever evaluated
))
0
994 return;
never executed: return;
0
995-
996 row = d->insertRow(row);-
997 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
998 d->setWidget(row, LabelRole, label);
never executed: d->setWidget(row, LabelRole, label);
0
999 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1000 d->setLayout(row, FieldRole, field);
never executed: d->setLayout(row, FieldRole, field);
0
1001 invalidate();-
1002}
never executed: end of block
0
1003void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field)-
1004{-
1005 QFormLayoutPrivate * const d = d_func();-
1006 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->checkWidget(field)
!d->checkWidget(field)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1007 return;
never executed: return;
0
1008-
1009 QLabel *label = 0;-
1010 if (!labelText.isEmpty()
!labelText.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1011 label = new QLabel(labelText);-
1012-
1013 label->setBuddy(field);-
1014-
1015 }
never executed: end of block
0
1016 insertRow(row, label, field);-
1017}
never executed: end of block
0
1018-
1019-
1020-
1021-
1022-
1023-
1024-
1025void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field)-
1026{-
1027 QFormLayoutPrivate * const d = d_func();-
1028 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->checkLayout(field)
!d->checkLayout(field)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1029 return;
never executed: return;
0
1030-
1031 insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field);-
1032}
never executed: end of block
0
1033void QFormLayout::insertRow(int row, QWidget *widget)-
1034{-
1035 QFormLayoutPrivate * const d = d_func();-
1036 if (!d->checkWidget(widget)
!d->checkWidget(widget)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1037 return;
never executed: return;
0
1038-
1039 row = d->insertRow(row);-
1040 d->setWidget(row, SpanningRole, widget);-
1041 invalidate();-
1042}
never executed: end of block
0
1043void QFormLayout::insertRow(int row, QLayout *layout)-
1044{-
1045 QFormLayoutPrivate * const d = d_func();-
1046 if (!d->checkLayout(layout)
!d->checkLayout(layout)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1047 return;
never executed: return;
0
1048-
1049 row = d->insertRow(row);-
1050 d->setLayout(row, SpanningRole, layout);-
1051 invalidate();-
1052}
never executed: end of block
0
1053-
1054-
1055-
1056-
1057void QFormLayout::addItem(QLayoutItem *item)-
1058{-
1059 QFormLayoutPrivate * const d = d_func();-
1060-
1061 int row = d->insertRow(d->m_matrix.rowCount());-
1062 d->setItem(row, FieldRole, item);-
1063 invalidate();-
1064}
never executed: end of block
0
1065-
1066-
1067-
1068-
1069int QFormLayout::count() const-
1070{-
1071 const QFormLayoutPrivate * const d = d_func();-
1072 return
never executed: return d->m_things.count();
d->m_things.count();
never executed: return d->m_things.count();
0
1073}-
1074-
1075-
1076-
1077-
1078QLayoutItem *QFormLayout::itemAt(int index) const-
1079{-
1080 const QFormLayoutPrivate * const d = d_func();-
1081 if (QFormLayoutItem *formItem = d->m_things.value(index)
QFormLayoutIte...s.value(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1082 return
never executed: return formItem->item;
formItem->item;
never executed: return formItem->item;
0
1083 return
never executed: return 0;
0;
never executed: return 0;
0
1084}-
1085-
1086-
1087-
1088-
1089QLayoutItem *QFormLayout::takeAt(int index)-
1090{-
1091 QFormLayoutPrivate * const d = d_func();-
1092-
1093 const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index));-
1094 if (__builtin_expect(!!(storageIndex == -1), false)
__builtin_expe...== -1), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1095 QMessageLogger(__FILE__, 1399, __PRETTY_FUNCTION__).warning("QFormLayout::takeAt: Invalid index %d", index);-
1096 return
never executed: return 0;
0;
never executed: return 0;
0
1097 }-
1098-
1099 int row, col;-
1100 QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col);-
1101 ((!(d->m_matrix(row, col))) ? qt_assert("d->m_matrix(row, col)",__FILE__,1405) : qt_noop());-
1102-
1103 QFormLayoutItem *item = d->m_matrix(row, col);-
1104 ((!(item)) ? qt_assert("item",__FILE__,1408) : qt_noop());-
1105 d->m_things.removeAt(index);-
1106 d->m_matrix(row, col) = 0;-
1107-
1108 invalidate();-
1109-
1110-
1111 QLayoutItem *i = item->item;-
1112 item->item = 0;-
1113 delete item;-
1114-
1115 if (QLayout *l = i->layout()
QLayout *l = i->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1116-
1117 if (l->parent() == this
l->parent() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1118 l->setParent(0);
never executed: l->setParent(0);
0
1119 }
never executed: end of block
0
1120-
1121 return
never executed: return i;
i;
never executed: return i;
0
1122}-
1123-
1124-
1125-
1126-
1127Qt::Orientations QFormLayout::expandingDirections() const-
1128{-
1129 const QFormLayoutPrivate * const d = d_func();-
1130 QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d);-
1131 e->updateSizes();-
1132-
1133 Qt::Orientations o = 0;-
1134 if (e->expandHorizontal
e->expandHorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1135 o = Qt::Horizontal;
never executed: o = Qt::Horizontal;
0
1136 if (e->expandVertical
e->expandVerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1137 o |= Qt::Vertical;
never executed: o |= Qt::Vertical;
0
1138 return
never executed: return o;
o;
never executed: return o;
0
1139}-
1140-
1141-
1142-
1143-
1144bool QFormLayout::hasHeightForWidth() const-
1145{-
1146 const QFormLayoutPrivate * const d = d_func();-
1147 QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d);-
1148 e->updateSizes();-
1149 return
never executed: return (d->has_hfw || rowWrapPolicy() == WrapLongRows);
(d->has_hfw || rowWrapPolicy() == WrapLongRows);
never executed: return (d->has_hfw || rowWrapPolicy() == WrapLongRows);
0
1150}-
1151-
1152-
1153-
1154-
1155int QFormLayout::heightForWidth(int width) const-
1156{-
1157 const QFormLayoutPrivate * const d = d_func();-
1158 if (!hasHeightForWidth()
!hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1159 return
never executed: return -1;
-1;
never executed: return -1;
0
1160-
1161 int leftMargin, topMargin, rightMargin, bottomMargin;-
1162 getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);-
1163-
1164 int targetWidth = width - leftMargin - rightMargin;-
1165-
1166 if (!d->haveHfwCached(targetWidth)
!d->haveHfwCached(targetWidth)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1167 QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d);-
1168 dat->setupVerticalLayoutData(targetWidth);-
1169 dat->setupHorizontalLayoutData(targetWidth);-
1170 dat->recalcHFW(targetWidth);-
1171 }
never executed: end of block
0
1172 if (targetWidth == d->sh_width
targetWidth == d->sh_widthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1173 return
never executed: return d->hfw_sh_height + topMargin + bottomMargin;
d->hfw_sh_height + topMargin + bottomMargin;
never executed: return d->hfw_sh_height + topMargin + bottomMargin;
0
1174 else-
1175 return
never executed: return d->hfw_height + topMargin + bottomMargin;
d->hfw_height + topMargin + bottomMargin;
never executed: return d->hfw_height + topMargin + bottomMargin;
0
1176}-
1177-
1178-
1179-
1180-
1181void QFormLayout::setGeometry(const QRect &rect)-
1182{-
1183 QFormLayoutPrivate * const d = d_func();-
1184 if (d->dirty
d->dirtyDescription
TRUEnever evaluated
FALSEnever evaluated
|| rect != geometry()
rect != geometry()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1185 QRect cr = rect;-
1186 int leftMargin, topMargin, rightMargin, bottomMargin;-
1187 getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);-
1188 cr.adjust(+leftMargin, +topMargin, -rightMargin, -bottomMargin);-
1189-
1190 bool hfw = hasHeightForWidth();-
1191 d->setupVerticalLayoutData(cr.width());-
1192 d->setupHorizontalLayoutData(cr.width());-
1193 if (hfw
hfwDescription
TRUEnever evaluated
FALSEnever evaluated
&& (!d->haveHfwCached(cr.width())
!d->haveHfwCached(cr.width())Description
TRUEnever evaluated
FALSEnever evaluated
|| d->hfwLayouts.size() != d->vLayoutCount
d->hfwLayouts....->vLayoutCountDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
1194 d->recalcHFW(cr.width());
never executed: d->recalcHFW(cr.width());
0
1195 if (hfw
hfwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1196 qGeomCalc(d->hfwLayouts, 0, d->vLayoutCount, cr.y(), cr.height());-
1197 d->arrangeWidgets(d->hfwLayouts, cr);-
1198 }
never executed: end of block
else {
0
1199 qGeomCalc(d->vLayouts, 0, d->vLayoutCount, cr.y(), cr.height());-
1200 d->arrangeWidgets(d->vLayouts, cr);-
1201 }
never executed: end of block
0
1202 QLayout::setGeometry(rect);-
1203 }
never executed: end of block
0
1204}
never executed: end of block
0
1205-
1206-
1207-
1208-
1209QSize QFormLayout::sizeHint() const-
1210{-
1211 const QFormLayoutPrivate * const d = d_func();-
1212 if (!d->prefSize.isValid()
!d->prefSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1213 QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d);-
1214 dat->calcSizeHints();-
1215 }
never executed: end of block
0
1216 return
never executed: return d->prefSize;
d->prefSize;
never executed: return d->prefSize;
0
1217}-
1218-
1219-
1220-
1221-
1222QSize QFormLayout::minimumSize() const-
1223{-
1224-
1225 const QFormLayoutPrivate * const d = d_func();-
1226 if (!d->minSize.isValid()
!d->minSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1227 QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d);-
1228 dat->calcSizeHints();-
1229 }
never executed: end of block
0
1230 return
never executed: return d->minSize;
d->minSize;
never executed: return d->minSize;
0
1231}-
1232-
1233-
1234-
1235-
1236void QFormLayout::invalidate()-
1237{-
1238 QFormLayoutPrivate * const d = d_func();-
1239 d->dirty = true;-
1240 d->sizesDirty = true;-
1241 d->minSize = QSize();-
1242 d->prefSize = QSize();-
1243 d->formMaxWidth = -1;-
1244 d->hfw_width = -1;-
1245 d->sh_width = -1;-
1246 d->layoutWidth = -1;-
1247 d->hfw_sh_height = -1;-
1248 QLayout::invalidate();-
1249}
never executed: end of block
0
1250-
1251-
1252-
1253-
1254-
1255-
1256int QFormLayout::rowCount() const-
1257{-
1258 const QFormLayoutPrivate * const d = d_func();-
1259 return
never executed: return d->m_matrix.rowCount();
d->m_matrix.rowCount();
never executed: return d->m_matrix.rowCount();
0
1260}-
1261-
1262-
1263-
1264-
1265-
1266-
1267-
1268QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const-
1269{-
1270 const QFormLayoutPrivate * const d = d_func();-
1271 if (uint(row) >= uint(d->m_matrix.rowCount())
uint(row) >= u...ix.rowCount())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1272 return
never executed: return 0;
0;
never executed: return 0;
0
1273 switch (role) {-
1274 case
never executed: case SpanningRole:
SpanningRole:
never executed: case SpanningRole:
0
1275 if (QFormLayoutItem *item = d->m_matrix(row, 1)
QFormLayoutIte...matrix(row, 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1276 if (item->fullRow
item->fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1277 return
never executed: return item->item;
item->item;
never executed: return item->item;
0
1278 break;
never executed: break;
0
1279 case
never executed: case LabelRole:
LabelRole:
never executed: case LabelRole:
0
1280 case
never executed: case FieldRole:
FieldRole:
never executed: case FieldRole:
0
1281 if (QFormLayoutItem *item = d->m_matrix(row, (role == LabelRole) ? 0 : 1)
QFormLayoutIte...Role) ? 0 : 1)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1282 return
never executed: return item->item;
item->item;
never executed: return item->item;
0
1283 break;
never executed: break;
0
1284 }-
1285 return
never executed: return 0;
0;
never executed: return 0;
0
1286}-
1287void QFormLayout::getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const-
1288{-
1289 const QFormLayoutPrivate * const d = d_func();-
1290 int col = -1;-
1291 int row = -1;-
1292-
1293 const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index));-
1294 if (storageIndex != -1
storageIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1295 QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col);
never executed: QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col);
0
1296-
1297 if (rowPtr
rowPtrDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1298 *
never executed: *rowPtr = row;
rowPtr = row;
never executed: *rowPtr = row;
0
1299 if (rolePtr
rolePtrDescription
TRUEnever evaluated
FALSEnever evaluated
&& col != -1
col != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1300 const bool spanning = col == 1
col == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& d->m_matrix(row, col)->fullRow
d->m_matrix(row, col)->fullRowDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
1301 if (spanning
spanningDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1302 *rolePtr = SpanningRole;-
1303 }
never executed: end of block
else {
0
1304 *rolePtr = ItemRole(col);-
1305 }
never executed: end of block
0
1306 }-
1307}
never executed: end of block
0
1308-
1309-
1310-
1311-
1312-
1313-
1314-
1315void QFormLayout::getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const-
1316{-
1317 int n = count();-
1318 int index = 0;-
1319 while (index < n
index < nDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1320 if (itemAt(index) == layout
itemAt(index) == layoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1321 break;
never executed: break;
0
1322 ++index;-
1323 }
never executed: end of block
0
1324 getItemPosition(index, rowPtr, rolePtr);-
1325}
never executed: end of block
0
1326void QFormLayout::getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const-
1327{-
1328 getItemPosition(indexOf(widget), rowPtr, rolePtr);-
1329}
never executed: end of block
0
1330QWidget *QFormLayout::labelForField(QWidget *field) const-
1331{-
1332 const QFormLayoutPrivate * const d = d_func();-
1333-
1334 int row;-
1335 ItemRole role = LabelRole;-
1336-
1337 getWidgetPosition(field, &row, &role);-
1338-
1339 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& role == FieldRole
role == FieldRoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1340 if (QFormLayoutItem *label = d->m_matrix(row, LabelRole)
QFormLayoutIte...ow, LabelRole)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1341 return
never executed: return label->widget();
label->widget();
never executed: return label->widget();
0
1342 }
never executed: end of block
0
1343 return
never executed: return 0;
0;
never executed: return 0;
0
1344}-
1345-
1346-
1347-
1348-
1349QWidget *QFormLayout::labelForField(QLayout *field) const-
1350{-
1351 const QFormLayoutPrivate * const d = d_func();-
1352-
1353 int row;-
1354 ItemRole role;-
1355-
1356 getLayoutPosition(field, &row, &role);-
1357-
1358 if (row != -1
row != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& role == FieldRole
role == FieldRoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1359 if (QFormLayoutItem *label = d->m_matrix(row, LabelRole)
QFormLayoutIte...ow, LabelRole)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1360 return
never executed: return label->widget();
label->widget();
never executed: return label->widget();
0
1361 }
never executed: end of block
0
1362 return
never executed: return 0;
0;
never executed: return 0;
0
1363}-
1364void QFormLayout::setFieldGrowthPolicy(FieldGrowthPolicy policy)-
1365{-
1366 QFormLayoutPrivate * const d = d_func();-
1367 if (FieldGrowthPolicy(d->fieldGrowthPolicy) != policy
FieldGrowthPol...icy) != policyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1368 d->fieldGrowthPolicy = policy;-
1369 invalidate();-
1370 }
never executed: end of block
0
1371}
never executed: end of block
0
1372-
1373QFormLayout::FieldGrowthPolicy QFormLayout::fieldGrowthPolicy() const-
1374{-
1375 const QFormLayoutPrivate * const d = d_func();-
1376 if (d->fieldGrowthPolicy == DefaultFieldGrowthPolicy
d->fieldGrowth...ldGrowthPolicyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1377 return
never executed: return QFormLayout::FieldGrowthPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutFieldGrowthPolicy));
QFormLayout::FieldGrowthPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutFieldGrowthPolicy));
never executed: return QFormLayout::FieldGrowthPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutFieldGrowthPolicy));
0
1378 } else {-
1379 return
never executed: return QFormLayout::FieldGrowthPolicy(d->fieldGrowthPolicy);
QFormLayout::FieldGrowthPolicy(d->fieldGrowthPolicy);
never executed: return QFormLayout::FieldGrowthPolicy(d->fieldGrowthPolicy);
0
1380 }-
1381}-
1382void QFormLayout::setRowWrapPolicy(RowWrapPolicy policy)-
1383{-
1384 QFormLayoutPrivate * const d = d_func();-
1385 if (RowWrapPolicy(d->rowWrapPolicy) != policy
RowWrapPolicy(...icy) != policyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1386 d->rowWrapPolicy = policy;-
1387 invalidate();-
1388 }
never executed: end of block
0
1389}
never executed: end of block
0
1390-
1391QFormLayout::RowWrapPolicy QFormLayout::rowWrapPolicy() const-
1392{-
1393 const QFormLayoutPrivate * const d = d_func();-
1394 if (d->rowWrapPolicy == DefaultRowWrapPolicy
d->rowWrapPoli...tRowWrapPolicyDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1395 return
never executed: return QFormLayout::RowWrapPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutWrapPolicy));
QFormLayout::RowWrapPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutWrapPolicy));
never executed: return QFormLayout::RowWrapPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutWrapPolicy));
0
1396 } else {-
1397 return
never executed: return QFormLayout::RowWrapPolicy(d->rowWrapPolicy);
QFormLayout::RowWrapPolicy(d->rowWrapPolicy);
never executed: return QFormLayout::RowWrapPolicy(d->rowWrapPolicy);
0
1398 }-
1399}-
1400void QFormLayout::setLabelAlignment(Qt::Alignment alignment)-
1401{-
1402 QFormLayoutPrivate * const d = d_func();-
1403 if (d->labelAlignment != alignment
d->labelAlignment != alignmentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1404 d->labelAlignment = alignment;-
1405 invalidate();-
1406 }
never executed: end of block
0
1407}
never executed: end of block
0
1408-
1409Qt::Alignment QFormLayout::labelAlignment() const-
1410{-
1411 const QFormLayoutPrivate * const d = d_func();-
1412 if (!d->labelAlignment
!d->labelAlignmentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1413 return
never executed: return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
never executed: return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
0
1414 } else {-
1415 return
never executed: return d->labelAlignment;
d->labelAlignment;
never executed: return d->labelAlignment;
0
1416 }-
1417}-
1418void QFormLayout::setFormAlignment(Qt::Alignment alignment)-
1419{-
1420 QFormLayoutPrivate * const d = d_func();-
1421 if (d->formAlignment != alignment
d->formAlignment != alignmentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1422 d->formAlignment = alignment;-
1423 invalidate();-
1424 }
never executed: end of block
0
1425}
never executed: end of block
0
1426-
1427Qt::Alignment QFormLayout::formAlignment() const-
1428{-
1429 const QFormLayoutPrivate * const d = d_func();-
1430 if (!d->formAlignment
!d->formAlignmentDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1431 return
never executed: return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutFormAlignment));
Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutFormAlignment));
never executed: return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutFormAlignment));
0
1432 } else {-
1433 return
never executed: return d->formAlignment;
d->formAlignment;
never executed: return d->formAlignment;
0
1434 }-
1435}-
1436void QFormLayout::setHorizontalSpacing(int spacing)-
1437{-
1438 QFormLayoutPrivate * const d = d_func();-
1439 if (spacing != d->hSpacing
spacing != d->hSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1440 d->hSpacing = spacing;-
1441 invalidate();-
1442 }
never executed: end of block
0
1443}
never executed: end of block
0
1444-
1445int QFormLayout::horizontalSpacing() const-
1446{-
1447 const QFormLayoutPrivate * const d = d_func();-
1448 if (d->hSpacing >= 0
d->hSpacing >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1449 return
never executed: return d->hSpacing;
d->hSpacing;
never executed: return d->hSpacing;
0
1450 } else {-
1451 return
never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);
0
1452 }-
1453}-
1454void QFormLayout::setVerticalSpacing(int spacing)-
1455{-
1456 QFormLayoutPrivate * const d = d_func();-
1457 if (spacing != d->vSpacing
spacing != d->vSpacingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1458 d->vSpacing = spacing;-
1459 invalidate();-
1460 }
never executed: end of block
0
1461}
never executed: end of block
0
1462-
1463int QFormLayout::verticalSpacing() const-
1464{-
1465 const QFormLayoutPrivate * const d = d_func();-
1466 if (d->vSpacing >= 0
d->vSpacing >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1467 return
never executed: return d->vSpacing;
d->vSpacing;
never executed: return d->vSpacing;
0
1468 } else {-
1469 return
never executed: return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing);
qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing);
never executed: return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing);
0
1470 }-
1471}-
1472-
1473-
1474-
1475-
1476-
1477-
1478-
1479void QFormLayout::setSpacing(int spacing)-
1480{-
1481 QFormLayoutPrivate * const d = d_func();-
1482 d->vSpacing = d->hSpacing = spacing;-
1483 invalidate();-
1484}
never executed: end of block
0
1485-
1486-
1487-
1488-
1489-
1490-
1491-
1492int QFormLayout::spacing() const-
1493{-
1494 int hSpacing = horizontalSpacing();-
1495 if (hSpacing == verticalSpacing()
hSpacing == verticalSpacing()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1496 return
never executed: return hSpacing;
hSpacing;
never executed: return hSpacing;
0
1497 } else {-
1498 return
never executed: return -1;
-1;
never executed: return -1;
0
1499 }-
1500}-
1501-
1502void QFormLayoutPrivate::arrangeWidgets(const QVector<QLayoutStruct>& layouts, QRect &rect)-
1503{-
1504 QFormLayout * const q = q_func();-
1505-
1506 int i;-
1507 const int rr = m_matrix.rowCount();-
1508 QWidget *w = q->parentWidget();-
1509 Qt::LayoutDirection layoutDirection = w
wDescription
TRUEnever evaluated
FALSEnever evaluated
? w->layoutDirection() : QApplication::layoutDirection();
0
1510-
1511 Qt::Alignment formAlignment = fixedAlignment(q->formAlignment(), layoutDirection);-
1512 int leftOffset = 0;-
1513 int delta = rect.width() - formMaxWidth;-
1514 if (formAlignment & (Qt::AlignHCenter | Qt::AlignRight)
formAlignment ...t::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
&& delta > 0
delta > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1515 leftOffset = delta;-
1516 if (formAlignment & Qt::AlignHCenter
formAlignment ...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1517 leftOffset >>= 1;
never executed: leftOffset >>= 1;
0
1518 }
never executed: end of block
0
1519-
1520 for (i = 0; i < rr
i < rrDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1521 QFormLayoutItem *label = m_matrix(i, 0);-
1522 QFormLayoutItem *field = m_matrix(i, 1);-
1523-
1524 if (label
labelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1525 int height = layouts.at(label->vLayoutIndex).size;-
1526 if ((
(label->expand...Vertical) == 0Description
TRUEnever evaluated
FALSEnever evaluated
label->expandingDirections() & Qt::Vertical) == 0
(label->expand...Vertical) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1527-
1528-
1529-
1530-
1531-
1532-
1533 height = qMin(height,-
1534 qMin(label->sizeHint.height() * 7 / 4,-
1535 label->maxSize.height()));-
1536 }
never executed: end of block
0
1537-
1538 QSize sz(qMin(label->layoutWidth, label->sizeHint.width()), height);-
1539 int x = leftOffset + rect.x() + label->layoutPos;-
1540 if (fixedAlignment(q->labelAlignment(), layoutDirection) & Qt::AlignRight
fixedAlignment...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1541 x += label->layoutWidth - sz.width();
never executed: x += label->layoutWidth - sz.width();
0
1542 QPoint p(x, layouts.at(label->vLayoutIndex).pos);-
1543-
1544-
1545 label->setGeometry(QStyle::visualRect(layoutDirection, rect, QRect(p, sz)));-
1546 }
never executed: end of block
0
1547-
1548 if (field
fieldDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1549 QSize sz(field->layoutWidth, layouts.at(field->vLayoutIndex).size);-
1550 QPoint p(field->layoutPos + leftOffset + rect.x(), layouts.at(field->vLayoutIndex).pos);-
1551-
1552-
1553-
1554-
1555-
1556-
1557 if (field->maxSize.isValid()
field->maxSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1558 sz = sz.boundedTo(field->maxSize);
never executed: sz = sz.boundedTo(field->maxSize);
0
1559-
1560 field->setGeometry(QStyle::visualRect(layoutDirection, rect, QRect(p, sz)));-
1561 }
never executed: end of block
0
1562 }
never executed: end of block
0
1563}
never executed: end of block
0
1564void QFormLayout::setWidget(int row, ItemRole role, QWidget *widget)-
1565{-
1566 QFormLayoutPrivate * const d = d_func();-
1567 int rowCnt = rowCount();-
1568 if (row >= rowCnt
row >= rowCntDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1569 d->insertRows(rowCnt, row - rowCnt + 1);
never executed: d->insertRows(rowCnt, row - rowCnt + 1);
0
1570 d->setWidget(row, role, widget);-
1571}
never executed: end of block
0
1572void QFormLayout::setLayout(int row, ItemRole role, QLayout *layout)-
1573{-
1574 QFormLayoutPrivate * const d = d_func();-
1575 int rowCnt = rowCount();-
1576 if (row >= rowCnt
row >= rowCntDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1577 d->insertRows(rowCnt, row - rowCnt + 1);
never executed: d->insertRows(rowCnt, row - rowCnt + 1);
0
1578 d->setLayout(row, role, layout);-
1579}
never executed: end of block
0
1580void QFormLayout::setItem(int row, ItemRole role, QLayoutItem *item)-
1581{-
1582 QFormLayoutPrivate * const d = d_func();-
1583 int rowCnt = rowCount();-
1584 if (row >= rowCnt
row >= rowCntDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1585 d->insertRows(rowCnt, row - rowCnt + 1);
never executed: d->insertRows(rowCnt, row - rowCnt + 1);
0
1586 d->setItem(row, role, item);-
1587}
never executed: end of block
0
1588-
1589-
1590-
1591-
1592-
1593void QFormLayout::resetFieldGrowthPolicy()-
1594{-
1595 QFormLayoutPrivate * const d = d_func();-
1596 d->fieldGrowthPolicy = DefaultFieldGrowthPolicy;-
1597}
never executed: end of block
0
1598-
1599-
1600-
1601-
1602-
1603void QFormLayout::resetRowWrapPolicy()-
1604{-
1605 QFormLayoutPrivate * const d = d_func();-
1606 d->rowWrapPolicy = DefaultRowWrapPolicy;-
1607}
never executed: end of block
0
1608-
1609-
1610-
1611-
1612-
1613void QFormLayout::resetFormAlignment()-
1614{-
1615 QFormLayoutPrivate * const d = d_func();-
1616 d->formAlignment = 0;-
1617}
never executed: end of block
0
1618-
1619-
1620-
1621-
1622-
1623void QFormLayout::resetLabelAlignment()-
1624{-
1625 QFormLayoutPrivate * const d = d_func();-
1626 d->labelAlignment = 0;-
1627}
never executed: end of block
0
1628-
1629-
Switch to Source codePreprocessed file

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