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

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