| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qgridlayout.h" | - |
| 43 | #include "qapplication.h" | - |
| 44 | #include "qwidget.h" | - |
| 45 | #include "qlist.h" | - |
| 46 | #include "qsizepolicy.h" | - |
| 47 | #include "qvector.h" | - |
| 48 | #include "qvarlengtharray.h" | - |
| 49 | #include "qlayoutengine_p.h" | - |
| 50 | #include "qlayout_p.h" | - |
| 51 | | - |
| 52 | QT_BEGIN_NAMESPACE | - |
| 53 | | - |
| 54 | struct QGridLayoutSizeTriple | - |
| 55 | { | - |
| 56 | QSize minS; | - |
| 57 | QSize hint; | - |
| 58 | QSize maxS; | - |
| 59 | }; | - |
| 60 | | - |
| 61 | /* | - |
| 62 | Three internal classes related to QGridLayout: (1) QGridBox is a | - |
| 63 | QLayoutItem with (row, column) information and (torow, tocolumn) information; (3) QGridLayoutData is | - |
| 64 | the internal representation of a QGridLayout. | - |
| 65 | */ | - |
| 66 | | - |
| 67 | class QGridBox | - |
| 68 | { | - |
| 69 | public: | - |
| 70 | QGridBox(QLayoutItem *lit) { item_ = lit; } executed: }Execution Count:778 | 778 |
| 71 | | - |
| 72 | QGridBox(const QLayout *l, QWidget *wid) { item_ = QLayoutPrivate::createWidgetItem(l, wid); } executed: }Execution Count:1682 | 1682 |
| 73 | ~QGridBox() { delete item_; } executed: }Execution Count:2460 | 2460 |
| 74 | | - |
| 75 | QSize sizeHint() const { return item_->sizeHint(); } executed: return item_->sizeHint();Execution Count:7580 | 7580 |
| 76 | QSize minimumSize() const { return item_->minimumSize(); } executed: return item_->minimumSize();Execution Count:7580 | 7580 |
| 77 | QSize maximumSize() const { return item_->maximumSize(); } executed: return item_->maximumSize();Execution Count:6729 | 6729 |
| 78 | Qt::Orientations expandingDirections() const { return item_->expandingDirections(); } executed: return item_->expandingDirections();Execution Count:11434 | 11434 |
| 79 | bool isEmpty() const { return item_->isEmpty(); } executed: return item_->isEmpty();Execution Count:22912 | 22912 |
| 80 | | - |
| 81 | bool hasHeightForWidth() const { return item_->hasHeightForWidth(); } executed: return item_->hasHeightForWidth();Execution Count:7914 | 7914 |
| 82 | int heightForWidth(int w) const { return item_->heightForWidth(w); } executed: return item_->heightForWidth(w);Execution Count:334 | 334 |
| 83 | | - |
| 84 | void setAlignment(Qt::Alignment a) { item_->setAlignment(a); } executed: }Execution Count:2460 | 2460 |
| 85 | void setGeometry(const QRect &r) { item_->setGeometry(r); } executed: }Execution Count:4378 | 4378 |
| 86 | Qt::Alignment alignment() const { return item_->alignment(); } never executed: return item_->alignment(); | 0 |
| 87 | QLayoutItem *item() { return item_; } executed: return item_;Execution Count:29441 | 29441 |
| 88 | QLayoutItem *takeItem() { QLayoutItem *i = item_; item_ = 0; return i; } executed: return i;Execution Count:264 | 264 |
| 89 | | - |
| 90 | int hStretch() { return item_->widget() ? executed: return item_->widget() ? item_->widget()->sizePolicy().horizontalStretch() : 0;Execution Count:6556 | 6556 |
| 91 | item_->widget()->sizePolicy().horizontalStretch() : 0; } executed: return item_->widget() ? item_->widget()->sizePolicy().horizontalStretch() : 0;Execution Count:6556 | 6556 |
| 92 | int vStretch() { return item_->widget() ? executed: return item_->widget() ? item_->widget()->sizePolicy().verticalStretch() : 0;Execution Count:6772 | 6772 |
| 93 | item_->widget()->sizePolicy().verticalStretch() : 0; } executed: return item_->widget() ? item_->widget()->sizePolicy().verticalStretch() : 0;Execution Count:6772 | 6772 |
| 94 | | - |
| 95 | private: | - |
| 96 | friend class QGridLayoutPrivate; | - |
| 97 | friend class QGridLayout; | - |
| 98 | | - |
| 99 | inline int toRow(int rr) const { return torow >= 0 ? torow : rr - 1; } executed: return torow >= 0 ? torow : rr - 1;Execution Count:33954 | 33954 |
| 100 | inline int toCol(int cc) const { return tocol >= 0 ? tocol : cc - 1; } executed: return tocol >= 0 ? tocol : cc - 1;Execution Count:37619 | 37619 |
| 101 | | - |
| 102 | QLayoutItem *item_; | - |
| 103 | int row, col; | - |
| 104 | int torow, tocol; | - |
| 105 | }; | - |
| 106 | | - |
| 107 | class QGridLayoutPrivate : public QLayoutPrivate | - |
| 108 | { | - |
| 109 | Q_DECLARE_PUBLIC(QGridLayout) | - |
| 110 | public: | - |
| 111 | QGridLayoutPrivate(); | - |
| 112 | | - |
| 113 | void add(QGridBox*, int row, int col); | - |
| 114 | void add(QGridBox*, int row1, int row2, int col1, int col2); | - |
| 115 | QSize sizeHint(int hSpacing, int vSpacing) const; | - |
| 116 | QSize minimumSize(int hSpacing, int vSpacing) const; | - |
| 117 | QSize maximumSize(int hSpacing, int vSpacing) const; | - |
| 118 | | - |
| 119 | Qt::Orientations expandingDirections(int hSpacing, int vSpacing) const; | - |
| 120 | | - |
| 121 | void distribute(QRect rect, int hSpacing, int vSpacing); | - |
| 122 | inline int numRows() const { return rr; } executed: return rr;Execution Count:94 | 94 |
| 123 | inline int numCols() const { return cc; } executed: return cc;Execution Count:94 | 94 |
| 124 | inline void expand(int rows, int cols) | - |
| 125 | { setSize(qMax(rows, rr), qMax(cols, cc)); } executed: }Execution Count:3600 | 3600 |
| 126 | inline void setRowStretch(int r, int s) | - |
| 127 | { expand(r + 1, 0); rStretch[r] = s; setDirty(); } executed: }Execution Count:23 | 23 |
| 128 | inline void setColStretch(int c, int s) | - |
| 129 | { expand(0, c + 1); cStretch[c] = s; setDirty(); } executed: }Execution Count:34 | 34 |
| 130 | inline int rowStretch(int r) const { return rStretch.at(r); } never executed: return rStretch.at(r); | 0 |
| 131 | inline int colStretch(int c) const { return cStretch.at(c); } never executed: return cStretch.at(c); | 0 |
| 132 | inline void setRowMinimumHeight(int r, int s) | - |
| 133 | { expand(r + 1, 0); rMinHeights[r] = s; setDirty(); } executed: }Execution Count:388 | 388 |
| 134 | inline void setColumnMinimumWidth(int c, int s) | - |
| 135 | { expand(0, c + 1); cMinWidths[c] = s; setDirty(); } executed: }Execution Count:291 | 291 |
| 136 | inline int rowSpacing(int r) const { return rMinHeights.at(r); } never executed: return rMinHeights.at(r); | 0 |
| 137 | inline int colSpacing(int c) const { return cMinWidths.at(c); } executed: return cMinWidths.at(c);Execution Count:1 | 1 |
| 138 | | - |
| 139 | inline void setReversed(bool r, bool c) { hReversed = c; vReversed = r; } | 0 |
| 140 | inline bool horReversed() const { return hReversed; } never executed: return hReversed; | 0 |
| 141 | inline bool verReversed() const { return vReversed; } never executed: return vReversed; | 0 |
| 142 | inline void setDirty() { needRecalc = true; hfw_width = -1; } executed: }Execution Count:24477 | 24477 |
| 143 | inline bool isDirty() const { return needRecalc; } executed: return needRecalc;Execution Count:1411 | 1411 |
| 144 | bool hasHeightForWidth(int hSpacing, int vSpacing); | - |
| 145 | int heightForWidth(int width, int hSpacing, int vSpacing); | - |
| 146 | int minimumHeightForWidth(int width, int hSpacing, int vSpacing); | - |
| 147 | | - |
| 148 | inline void getNextPos(int &row, int &col) { row = nextR; col = nextC; } executed: }Execution Count:1 | 1 |
| 149 | inline int count() const { return things.count(); } executed: return things.count();Execution Count:231 | 231 |
| 150 | QRect cellRect(int row, int col) const; | - |
| 151 | | - |
| 152 | inline QLayoutItem *itemAt(int index) const { | - |
| 153 | if (index < things.count()) evaluated: index < things.count()| yes Evaluation Count:6932 | yes Evaluation Count:1802 |
| 1802-6932 |
| 154 | return things.at(index)->item(); executed: return things.at(index)->item();Execution Count:6932 | 6932 |
| 155 | else | - |
| 156 | return 0; executed: return 0;Execution Count:1802 | 1802 |
| 157 | } | - |
| 158 | inline QLayoutItem *takeAt(int index) { | - |
| 159 | Q_Q(QGridLayout); executed (the execution status of this line is deduced): QGridLayout * const q = q_func(); | - |
| 160 | if (index < things.count()) { partially evaluated: index < things.count()| yes Evaluation Count:264 | no Evaluation Count:0 |
| 0-264 |
| 161 | if (QGridBox *b = things.takeAt(index)) { partially evaluated: QGridBox *b = things.takeAt(index)| yes Evaluation Count:264 | no Evaluation Count:0 |
| 0-264 |
| 162 | QLayoutItem *item = b->takeItem(); executed (the execution status of this line is deduced): QLayoutItem *item = b->takeItem(); | - |
| 163 | if (QLayout *l = item->layout()) { evaluated: QLayout *l = item->layout()| yes Evaluation Count:41 | yes Evaluation Count:223 |
| 41-223 |
| 164 | // sanity check in case the user passed something weird to QObject::setParent() | - |
| 165 | if (l->parent() == q) partially evaluated: l->parent() == q| yes Evaluation Count:41 | no Evaluation Count:0 |
| 0-41 |
| 166 | l->setParent(0); executed: l->setParent(0);Execution Count:41 | 41 |
| 167 | } executed: }Execution Count:41 | 41 |
| 168 | delete b; executed (the execution status of this line is deduced): delete b; | - |
| 169 | return item; executed: return item;Execution Count:264 | 264 |
| 170 | } | - |
| 171 | } | 0 |
| 172 | return 0; never executed: return 0; | 0 |
| 173 | } | - |
| 174 | | - |
| 175 | void getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const { | - |
| 176 | if (index < things.count()) { partially evaluated: index < things.count()| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 177 | const QGridBox *b = things.at(index); executed (the execution status of this line is deduced): const QGridBox *b = things.at(index); | - |
| 178 | int toRow = b->toRow(rr); executed (the execution status of this line is deduced): int toRow = b->toRow(rr); | - |
| 179 | int toCol = b->toCol(cc); executed (the execution status of this line is deduced): int toCol = b->toCol(cc); | - |
| 180 | *row = b->row; executed (the execution status of this line is deduced): *row = b->row; | - |
| 181 | *column = b->col; executed (the execution status of this line is deduced): *column = b->col; | - |
| 182 | *rowSpan = toRow - *row + 1; executed (the execution status of this line is deduced): *rowSpan = toRow - *row + 1; | - |
| 183 | *columnSpan = toCol - *column +1; executed (the execution status of this line is deduced): *columnSpan = toCol - *column +1; | - |
| 184 | } executed: }Execution Count:4 | 4 |
| 185 | } executed: }Execution Count:4 | 4 |
| 186 | void deleteAll(); | - |
| 187 | | - |
| 188 | private: | - |
| 189 | void setNextPosAfter(int r, int c); | - |
| 190 | void recalcHFW(int w); | - |
| 191 | void addHfwData(QGridBox *box, int width); | - |
| 192 | void init(); | - |
| 193 | QSize findSize(int QLayoutStruct::*, int hSpacing, int vSpacing) const; | - |
| 194 | void addData(QGridBox *b, const QGridLayoutSizeTriple &sizes, bool r, bool c); | - |
| 195 | void setSize(int rows, int cols); | - |
| 196 | void setupSpacings(QVector<QLayoutStruct> &chain, QGridBox *grid[], int fixedSpacing, | - |
| 197 | Qt::Orientation orientation); | - |
| 198 | void setupLayoutData(int hSpacing, int vSpacing); | - |
| 199 | void setupHfwLayoutData(); | - |
| 200 | void effectiveMargins(int *left, int *top, int *right, int *bottom) const; | - |
| 201 | | - |
| 202 | int rr; | - |
| 203 | int cc; | - |
| 204 | QVector<QLayoutStruct> rowData; | - |
| 205 | QVector<QLayoutStruct> colData; | - |
| 206 | QVector<QLayoutStruct> *hfwData; | - |
| 207 | QVector<int> rStretch; | - |
| 208 | QVector<int> cStretch; | - |
| 209 | QVector<int> rMinHeights; | - |
| 210 | QVector<int> cMinWidths; | - |
| 211 | QList<QGridBox *> things; | - |
| 212 | | - |
| 213 | int hfw_width; | - |
| 214 | int hfw_height; | - |
| 215 | int hfw_minheight; | - |
| 216 | int nextR; | - |
| 217 | int nextC; | - |
| 218 | | - |
| 219 | int horizontalSpacing; | - |
| 220 | int verticalSpacing; | - |
| 221 | int leftMargin; | - |
| 222 | int topMargin; | - |
| 223 | int rightMargin; | - |
| 224 | int bottomMargin; | - |
| 225 | | - |
| 226 | uint hReversed : 1; | - |
| 227 | uint vReversed : 1; | - |
| 228 | uint needRecalc : 1; | - |
| 229 | uint has_hfw : 1; | - |
| 230 | uint addVertical : 1; | - |
| 231 | }; | - |
| 232 | | - |
| 233 | void QGridLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int *bottom) const | - |
| 234 | { | - |
| 235 | int l = leftMargin; executed (the execution status of this line is deduced): int l = leftMargin; | - |
| 236 | int t = topMargin; executed (the execution status of this line is deduced): int t = topMargin; | - |
| 237 | int r = rightMargin; executed (the execution status of this line is deduced): int r = rightMargin; | - |
| 238 | int b = bottomMargin; executed (the execution status of this line is deduced): int b = bottomMargin; | - |
| 239 | #ifdef Q_OS_MAC | - |
| 240 | int leftMost = INT_MAX; | - |
| 241 | int topMost = INT_MAX; | - |
| 242 | int rightMost = 0; | - |
| 243 | int bottomMost = 0; | - |
| 244 | | - |
| 245 | QWidget *w = 0; | - |
| 246 | const int n = things.count(); | - |
| 247 | for (int i = 0; i < n; ++i) { | - |
| 248 | QGridBox *box = things.at(i); | - |
| 249 | QLayoutItem *itm = box->item(); | - |
| 250 | w = itm->widget(); | - |
| 251 | if (w) { | - |
| 252 | bool visualHReversed = hReversed != (w->layoutDirection() == Qt::RightToLeft); | - |
| 253 | QRect lir = itm->geometry(); | - |
| 254 | QRect wr = w->geometry(); | - |
| 255 | if (box->col <= leftMost) { | - |
| 256 | if (box->col < leftMost) { | - |
| 257 | // we found an item even closer to the margin, discard. | - |
| 258 | leftMost = box->col; | - |
| 259 | if (visualHReversed) | - |
| 260 | r = rightMargin; | - |
| 261 | else | - |
| 262 | l = leftMargin; | - |
| 263 | } | - |
| 264 | if (visualHReversed) { | - |
| 265 | r = qMax(r, wr.right() - lir.right()); | - |
| 266 | } else { | - |
| 267 | l = qMax(l, lir.left() - wr.left()); | - |
| 268 | } | - |
| 269 | } | - |
| 270 | if (box->row <= topMost) { | - |
| 271 | if (box->row < topMost) { | - |
| 272 | // we found an item even closer to the margin, discard. | - |
| 273 | topMost = box->row; | - |
| 274 | if (vReversed) | - |
| 275 | b = bottomMargin; | - |
| 276 | else | - |
| 277 | t = topMargin; | - |
| 278 | } | - |
| 279 | if (vReversed) | - |
| 280 | b = qMax(b, wr.bottom() - lir.bottom()); | - |
| 281 | else | - |
| 282 | t = qMax(t, lir.top() - wr.top()); | - |
| 283 | } | - |
| 284 | if (box->toCol(cc) >= rightMost) { | - |
| 285 | if (box->toCol(cc) > rightMost) { | - |
| 286 | // we found an item even closer to the margin, discard. | - |
| 287 | rightMost = box->toCol(cc); | - |
| 288 | if (visualHReversed) | - |
| 289 | l = leftMargin; | - |
| 290 | else | - |
| 291 | r = rightMargin; | - |
| 292 | } | - |
| 293 | if (visualHReversed) { | - |
| 294 | l = qMax(l, lir.left() - wr.left()); | - |
| 295 | } else { | - |
| 296 | r = qMax(r, wr.right() - lir.right()); | - |
| 297 | } | - |
| 298 | | - |
| 299 | } | - |
| 300 | if (box->toRow(rr) >= bottomMost) { | - |
| 301 | if (box->toRow(rr) > bottomMost) { | - |
| 302 | // we found an item even closer to the margin, discard. | - |
| 303 | bottomMost = box->toRow(rr); | - |
| 304 | if (vReversed) | - |
| 305 | t = topMargin; | - |
| 306 | else | - |
| 307 | b = bottomMargin; | - |
| 308 | } | - |
| 309 | if (vReversed) | - |
| 310 | t = qMax(t, lir.top() - wr.top()); | - |
| 311 | else | - |
| 312 | b = qMax(b, wr.bottom() - lir.bottom()); | - |
| 313 | } | - |
| 314 | } | - |
| 315 | } | - |
| 316 | | - |
| 317 | #endif | - |
| 318 | if (left) evaluated: left| yes Evaluation Count:3999 | yes Evaluation Count:9 |
| 9-3999 |
| 319 | *left = l; executed: *left = l;Execution Count:3999 | 3999 |
| 320 | if (top) partially evaluated: top| yes Evaluation Count:4008 | no Evaluation Count:0 |
| 0-4008 |
| 321 | *top = t; executed: *top = t;Execution Count:4008 | 4008 |
| 322 | if (right) evaluated: right| yes Evaluation Count:3999 | yes Evaluation Count:9 |
| 9-3999 |
| 323 | *right = r; executed: *right = r;Execution Count:3999 | 3999 |
| 324 | if (bottom) partially evaluated: bottom| yes Evaluation Count:4008 | no Evaluation Count:0 |
| 0-4008 |
| 325 | *bottom = b; executed: *bottom = b;Execution Count:4008 | 4008 |
| 326 | } executed: }Execution Count:4008 | 4008 |
| 327 | | - |
| 328 | QGridLayoutPrivate::QGridLayoutPrivate() | - |
| 329 | { | - |
| 330 | addVertical = false; executed (the execution status of this line is deduced): addVertical = false; | - |
| 331 | setDirty(); executed (the execution status of this line is deduced): setDirty(); | - |
| 332 | rr = cc = 0; executed (the execution status of this line is deduced): rr = cc = 0; | - |
| 333 | nextR = nextC = 0; executed (the execution status of this line is deduced): nextR = nextC = 0; | - |
| 334 | hfwData = 0; executed (the execution status of this line is deduced): hfwData = 0; | - |
| 335 | hReversed = false; executed (the execution status of this line is deduced): hReversed = false; | - |
| 336 | vReversed = false; executed (the execution status of this line is deduced): vReversed = false; | - |
| 337 | horizontalSpacing = -1; executed (the execution status of this line is deduced): horizontalSpacing = -1; | - |
| 338 | verticalSpacing = -1; executed (the execution status of this line is deduced): verticalSpacing = -1; | - |
| 339 | } executed: }Execution Count:404 | 404 |
| 340 | | - |
| 341 | #if 0 | - |
| 342 | QGridLayoutPrivate::QGridLayoutPrivate(int nRows, int nCols) | - |
| 343 | : rowData(0), colData(0) | - |
| 344 | { | - |
| 345 | init(); | - |
| 346 | if (nRows < 0) { | - |
| 347 | nRows = 1; | - |
| 348 | addVertical = false; | - |
| 349 | } | - |
| 350 | if (nCols < 0) { | - |
| 351 | nCols = 1; | - |
| 352 | addVertical = true; | - |
| 353 | } | - |
| 354 | setSize(nRows, nCols); | - |
| 355 | } | - |
| 356 | #endif | - |
| 357 | | - |
| 358 | void QGridLayoutPrivate::deleteAll() | - |
| 359 | { | - |
| 360 | while (!things.isEmpty()) evaluated: !things.isEmpty()| yes Evaluation Count:2196 | yes Evaluation Count:404 |
| 404-2196 |
| 361 | delete things.takeFirst(); executed: delete things.takeFirst();Execution Count:2196 | 2196 |
| 362 | delete hfwData; executed (the execution status of this line is deduced): delete hfwData; | - |
| 363 | } executed: }Execution Count:404 | 404 |
| 364 | | - |
| 365 | bool QGridLayoutPrivate::hasHeightForWidth(int hSpacing, int vSpacing) | - |
| 366 | { | - |
| 367 | setupLayoutData(hSpacing, vSpacing); executed (the execution status of this line is deduced): setupLayoutData(hSpacing, vSpacing); | - |
| 368 | return has_hfw; executed: return has_hfw;Execution Count:1660 | 1660 |
| 369 | } | - |
| 370 | | - |
| 371 | /* | - |
| 372 | Assumes that setupLayoutData() has been called, and that | - |
| 373 | qGeomCalc() has filled in colData with appropriate values. | - |
| 374 | */ | - |
| 375 | void QGridLayoutPrivate::recalcHFW(int w) | - |
| 376 | { | - |
| 377 | /* | - |
| 378 | Go through all children, using colData and heightForWidth() | - |
| 379 | and put the results in hfwData. | - |
| 380 | */ | - |
| 381 | if (!hfwData) evaluated: !hfwData| yes Evaluation Count:27 | yes Evaluation Count:271 |
| 27-271 |
| 382 | hfwData = new QVector<QLayoutStruct>(rr); executed: hfwData = new QVector<QLayoutStruct>(rr);Execution Count:27 | 27 |
| 383 | setupHfwLayoutData(); executed (the execution status of this line is deduced): setupHfwLayoutData(); | - |
| 384 | QVector<QLayoutStruct> &rData = *hfwData; executed (the execution status of this line is deduced): QVector<QLayoutStruct> &rData = *hfwData; | - |
| 385 | | - |
| 386 | int h = 0; executed (the execution status of this line is deduced): int h = 0; | - |
| 387 | int mh = 0; executed (the execution status of this line is deduced): int mh = 0; | - |
| 388 | for (int r = 0; r < rr; r++) { evaluated: r < rr| yes Evaluation Count:1583 | yes Evaluation Count:298 |
| 298-1583 |
| 389 | int spacing = rData.at(r).spacing; executed (the execution status of this line is deduced): int spacing = rData.at(r).spacing; | - |
| 390 | h += rData.at(r).sizeHint + spacing; executed (the execution status of this line is deduced): h += rData.at(r).sizeHint + spacing; | - |
| 391 | mh += rData.at(r).minimumSize + spacing; executed (the execution status of this line is deduced): mh += rData.at(r).minimumSize + spacing; | - |
| 392 | } executed: }Execution Count:1583 | 1583 |
| 393 | | - |
| 394 | hfw_width = w; executed (the execution status of this line is deduced): hfw_width = w; | - |
| 395 | hfw_height = qMin(QLAYOUTSIZE_MAX, h); executed (the execution status of this line is deduced): hfw_height = qMin(QLAYOUTSIZE_MAX, h); | - |
| 396 | hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh); executed (the execution status of this line is deduced): hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh); | - |
| 397 | } executed: }Execution Count:298 | 298 |
| 398 | | - |
| 399 | int QGridLayoutPrivate::heightForWidth(int w, int hSpacing, int vSpacing) | - |
| 400 | { | - |
| 401 | setupLayoutData(hSpacing, vSpacing); executed (the execution status of this line is deduced): setupLayoutData(hSpacing, vSpacing); | - |
| 402 | if (!has_hfw) partially evaluated: !has_hfw| no Evaluation Count:0 | yes Evaluation Count:235 |
| 0-235 |
| 403 | return -1; never executed: return -1; | 0 |
| 404 | int left, top, right, bottom; executed (the execution status of this line is deduced): int left, top, right, bottom; | - |
| 405 | effectiveMargins(&left, &top, &right, &bottom); executed (the execution status of this line is deduced): effectiveMargins(&left, &top, &right, &bottom); | - |
| 406 | | - |
| 407 | int hMargins = left + right; executed (the execution status of this line is deduced): int hMargins = left + right; | - |
| 408 | if (w - hMargins != hfw_width) { evaluated: w - hMargins != hfw_width| yes Evaluation Count:129 | yes Evaluation Count:106 |
| 106-129 |
| 409 | qGeomCalc(colData, 0, cc, 0, w - hMargins); executed (the execution status of this line is deduced): qGeomCalc(colData, 0, cc, 0, w - hMargins); | - |
| 410 | recalcHFW(w - hMargins); executed (the execution status of this line is deduced): recalcHFW(w - hMargins); | - |
| 411 | } executed: }Execution Count:129 | 129 |
| 412 | return hfw_height + top + bottom; executed: return hfw_height + top + bottom;Execution Count:235 | 235 |
| 413 | } | - |
| 414 | | - |
| 415 | int QGridLayoutPrivate::minimumHeightForWidth(int w, int hSpacing, int vSpacing) | - |
| 416 | { | - |
| 417 | (void)heightForWidth(w, hSpacing, vSpacing); executed (the execution status of this line is deduced): (void)heightForWidth(w, hSpacing, vSpacing); | - |
| 418 | if (!has_hfw) partially evaluated: !has_hfw| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 419 | return -1; never executed: return -1; | 0 |
| 420 | int top, bottom; executed (the execution status of this line is deduced): int top, bottom; | - |
| 421 | effectiveMargins(0, &top, 0, &bottom); executed (the execution status of this line is deduced): effectiveMargins(0, &top, 0, &bottom); | - |
| 422 | return hfw_minheight + top + bottom; executed: return hfw_minheight + top + bottom;Execution Count:9 | 9 |
| 423 | } | - |
| 424 | | - |
| 425 | QSize QGridLayoutPrivate::findSize(int QLayoutStruct::*size, int hSpacing, int vSpacing) const | - |
| 426 | { | - |
| 427 | QGridLayoutPrivate *that = const_cast<QGridLayoutPrivate*>(this); executed (the execution status of this line is deduced): QGridLayoutPrivate *that = const_cast<QGridLayoutPrivate*>(this); | - |
| 428 | that->setupLayoutData(hSpacing, vSpacing); executed (the execution status of this line is deduced): that->setupLayoutData(hSpacing, vSpacing); | - |
| 429 | | - |
| 430 | int w = 0; executed (the execution status of this line is deduced): int w = 0; | - |
| 431 | int h = 0; executed (the execution status of this line is deduced): int h = 0; | - |
| 432 | | - |
| 433 | for (int r = 0; r < rr; r++) evaluated: r < rr| yes Evaluation Count:8548 | yes Evaluation Count:2555 |
| 2555-8548 |
| 434 | h += rowData.at(r).*size + rowData.at(r).spacing; executed: h += rowData.at(r).*size + rowData.at(r).spacing;Execution Count:8548 | 8548 |
| 435 | for (int c = 0; c < cc; c++) evaluated: c < cc| yes Evaluation Count:4953 | yes Evaluation Count:2555 |
| 2555-4953 |
| 436 | w += colData.at(c).*size + colData.at(c).spacing; executed: w += colData.at(c).*size + colData.at(c).spacing;Execution Count:4953 | 4953 |
| 437 | | - |
| 438 | w = qMin(QLAYOUTSIZE_MAX, w); executed (the execution status of this line is deduced): w = qMin(QLAYOUTSIZE_MAX, w); | - |
| 439 | h = qMin(QLAYOUTSIZE_MAX, h); executed (the execution status of this line is deduced): h = qMin(QLAYOUTSIZE_MAX, h); | - |
| 440 | | - |
| 441 | return QSize(w, h); executed: return QSize(w, h);Execution Count:2555 | 2555 |
| 442 | } | - |
| 443 | | - |
| 444 | Qt::Orientations QGridLayoutPrivate::expandingDirections(int hSpacing, int vSpacing) const | - |
| 445 | { | - |
| 446 | QGridLayoutPrivate *that = const_cast<QGridLayoutPrivate*>(this); executed (the execution status of this line is deduced): QGridLayoutPrivate *that = const_cast<QGridLayoutPrivate*>(this); | - |
| 447 | that->setupLayoutData(hSpacing, vSpacing); executed (the execution status of this line is deduced): that->setupLayoutData(hSpacing, vSpacing); | - |
| 448 | Qt::Orientations ret; executed (the execution status of this line is deduced): Qt::Orientations ret; | - |
| 449 | | - |
| 450 | for (int r = 0; r < rr; r++) { evaluated: r < rr| yes Evaluation Count:814 | yes Evaluation Count:132 |
| 132-814 |
| 451 | if (rowData.at(r).expansive) { evaluated: rowData.at(r).expansive| yes Evaluation Count:135 | yes Evaluation Count:679 |
| 135-679 |
| 452 | ret |= Qt::Vertical; executed (the execution status of this line is deduced): ret |= Qt::Vertical; | - |
| 453 | break; executed: break;Execution Count:135 | 135 |
| 454 | } | - |
| 455 | } executed: }Execution Count:679 | 679 |
| 456 | for (int c = 0; c < cc; c++) { evaluated: c < cc| yes Evaluation Count:668 | yes Evaluation Count:116 |
| 116-668 |
| 457 | if (colData.at(c).expansive) { evaluated: colData.at(c).expansive| yes Evaluation Count:151 | yes Evaluation Count:517 |
| 151-517 |
| 458 | ret |= Qt::Horizontal; executed (the execution status of this line is deduced): ret |= Qt::Horizontal; | - |
| 459 | break; executed: break;Execution Count:151 | 151 |
| 460 | } | - |
| 461 | } executed: }Execution Count:517 | 517 |
| 462 | return ret; executed: return ret;Execution Count:267 | 267 |
| 463 | } | - |
| 464 | | - |
| 465 | QSize QGridLayoutPrivate::sizeHint(int hSpacing, int vSpacing) const | - |
| 466 | { | - |
| 467 | return findSize(&QLayoutStruct::sizeHint, hSpacing, vSpacing); executed: return findSize(&QLayoutStruct::sizeHint, hSpacing, vSpacing);Execution Count:1048 | 1048 |
| 468 | } | - |
| 469 | | - |
| 470 | QSize QGridLayoutPrivate::maximumSize(int hSpacing, int vSpacing) const | - |
| 471 | { | - |
| 472 | return findSize(&QLayoutStruct::maximumSize, hSpacing, vSpacing); executed: return findSize(&QLayoutStruct::maximumSize, hSpacing, vSpacing);Execution Count:499 | 499 |
| 473 | } | - |
| 474 | | - |
| 475 | QSize QGridLayoutPrivate::minimumSize(int hSpacing, int vSpacing) const | - |
| 476 | { | - |
| 477 | return findSize(&QLayoutStruct::minimumSize, hSpacing, vSpacing); executed: return findSize(&QLayoutStruct::minimumSize, hSpacing, vSpacing);Execution Count:1008 | 1008 |
| 478 | } | - |
| 479 | | - |
| 480 | void QGridLayoutPrivate::setSize(int r, int c) | - |
| 481 | { | - |
| 482 | if ((int)rowData.size() < r) { evaluated: (int)rowData.size() < r| yes Evaluation Count:1156 | yes Evaluation Count:2444 |
| 1156-2444 |
| 483 | int newR = qMax(r, rr * 2); executed (the execution status of this line is deduced): int newR = qMax(r, rr * 2); | - |
| 484 | rowData.resize(newR); executed (the execution status of this line is deduced): rowData.resize(newR); | - |
| 485 | rStretch.resize(newR); executed (the execution status of this line is deduced): rStretch.resize(newR); | - |
| 486 | rMinHeights.resize(newR); executed (the execution status of this line is deduced): rMinHeights.resize(newR); | - |
| 487 | for (int i = rr; i < newR; i++) { evaluated: i < newR| yes Evaluation Count:1698 | yes Evaluation Count:1156 |
| 1156-1698 |
| 488 | rowData[i].init(); executed (the execution status of this line is deduced): rowData[i].init(); | - |
| 489 | rowData[i].maximumSize = 0; executed (the execution status of this line is deduced): rowData[i].maximumSize = 0; | - |
| 490 | rowData[i].pos = 0; executed (the execution status of this line is deduced): rowData[i].pos = 0; | - |
| 491 | rowData[i].size = 0; executed (the execution status of this line is deduced): rowData[i].size = 0; | - |
| 492 | rStretch[i] = 0; executed (the execution status of this line is deduced): rStretch[i] = 0; | - |
| 493 | rMinHeights[i] = 0; executed (the execution status of this line is deduced): rMinHeights[i] = 0; | - |
| 494 | } executed: }Execution Count:1698 | 1698 |
| 495 | } executed: }Execution Count:1156 | 1156 |
| 496 | if ((int)colData.size() < c) { evaluated: (int)colData.size() < c| yes Evaluation Count:804 | yes Evaluation Count:2796 |
| 804-2796 |
| 497 | int newC = qMax(c, cc * 2); executed (the execution status of this line is deduced): int newC = qMax(c, cc * 2); | - |
| 498 | colData.resize(newC); executed (the execution status of this line is deduced): colData.resize(newC); | - |
| 499 | cStretch.resize(newC); executed (the execution status of this line is deduced): cStretch.resize(newC); | - |
| 500 | cMinWidths.resize(newC); executed (the execution status of this line is deduced): cMinWidths.resize(newC); | - |
| 501 | for (int i = cc; i < newC; i++) { evaluated: i < newC| yes Evaluation Count:1236 | yes Evaluation Count:804 |
| 804-1236 |
| 502 | colData[i].init(); executed (the execution status of this line is deduced): colData[i].init(); | - |
| 503 | colData[i].maximumSize = 0; executed (the execution status of this line is deduced): colData[i].maximumSize = 0; | - |
| 504 | colData[i].pos = 0; executed (the execution status of this line is deduced): colData[i].pos = 0; | - |
| 505 | colData[i].size = 0; executed (the execution status of this line is deduced): colData[i].size = 0; | - |
| 506 | cStretch[i] = 0; executed (the execution status of this line is deduced): cStretch[i] = 0; | - |
| 507 | cMinWidths[i] = 0; executed (the execution status of this line is deduced): cMinWidths[i] = 0; | - |
| 508 | } executed: }Execution Count:1236 | 1236 |
| 509 | } executed: }Execution Count:804 | 804 |
| 510 | | - |
| 511 | if (hfwData && (int)hfwData->size() < r) { evaluated: hfwData| yes Evaluation Count:462 | yes Evaluation Count:3138 |
evaluated: (int)hfwData->size() < r| yes Evaluation Count:3 | yes Evaluation Count:459 |
| 3-3138 |
| 512 | delete hfwData; executed (the execution status of this line is deduced): delete hfwData; | - |
| 513 | hfwData = 0; executed (the execution status of this line is deduced): hfwData = 0; | - |
| 514 | hfw_width = -1; executed (the execution status of this line is deduced): hfw_width = -1; | - |
| 515 | } executed: }Execution Count:3 | 3 |
| 516 | rr = r; executed (the execution status of this line is deduced): rr = r; | - |
| 517 | cc = c; executed (the execution status of this line is deduced): cc = c; | - |
| 518 | } executed: }Execution Count:3600 | 3600 |
| 519 | | - |
| 520 | void QGridLayoutPrivate::setNextPosAfter(int row, int col) | - |
| 521 | { | - |
| 522 | if (addVertical) { partially evaluated: addVertical| no Evaluation Count:0 | yes Evaluation Count:2460 |
| 0-2460 |
| 523 | if (col > nextC || (col == nextC && row >= nextR)) { never evaluated: col > nextC never evaluated: col == nextC never evaluated: row >= nextR | 0 |
| 524 | nextR = row + 1; never executed (the execution status of this line is deduced): nextR = row + 1; | - |
| 525 | nextC = col; never executed (the execution status of this line is deduced): nextC = col; | - |
| 526 | if (nextR >= rr) { never evaluated: nextR >= rr | 0 |
| 527 | nextR = 0; never executed (the execution status of this line is deduced): nextR = 0; | - |
| 528 | nextC++; never executed (the execution status of this line is deduced): nextC++; | - |
| 529 | } | 0 |
| 530 | } | 0 |
| 531 | } else { | 0 |
| 532 | if (row > nextR || (row == nextR && col >= nextC)) { evaluated: row > nextR| yes Evaluation Count:350 | yes Evaluation Count:2110 |
evaluated: row == nextR| yes Evaluation Count:1202 | yes Evaluation Count:908 |
evaluated: col >= nextC| yes Evaluation Count:1197 | yes Evaluation Count:5 |
| 5-2110 |
| 533 | nextR = row; executed (the execution status of this line is deduced): nextR = row; | - |
| 534 | nextC = col + 1; executed (the execution status of this line is deduced): nextC = col + 1; | - |
| 535 | if (nextC >= cc) { evaluated: nextC >= cc| yes Evaluation Count:1039 | yes Evaluation Count:508 |
| 508-1039 |
| 536 | nextC = 0; executed (the execution status of this line is deduced): nextC = 0; | - |
| 537 | nextR++; executed (the execution status of this line is deduced): nextR++; | - |
| 538 | } executed: }Execution Count:1039 | 1039 |
| 539 | } executed: }Execution Count:1547 | 1547 |
| 540 | } executed: }Execution Count:2460 | 2460 |
| 541 | } | - |
| 542 | | - |
| 543 | void QGridLayoutPrivate::add(QGridBox *box, int row, int col) | - |
| 544 | { | - |
| 545 | expand(row + 1, col + 1); executed (the execution status of this line is deduced): expand(row + 1, col + 1); | - |
| 546 | box->row = box->torow = row; executed (the execution status of this line is deduced): box->row = box->torow = row; | - |
| 547 | box->col = box->tocol = col; executed (the execution status of this line is deduced): box->col = box->tocol = col; | - |
| 548 | things.append(box); executed (the execution status of this line is deduced): things.append(box); | - |
| 549 | setDirty(); executed (the execution status of this line is deduced): setDirty(); | - |
| 550 | setNextPosAfter(row, col); executed (the execution status of this line is deduced): setNextPosAfter(row, col); | - |
| 551 | } executed: }Execution Count:1683 | 1683 |
| 552 | | - |
| 553 | void QGridLayoutPrivate::add(QGridBox *box, int row1, int row2, int col1, int col2) | - |
| 554 | { | - |
| 555 | if (row2 >= 0 && row2 < row1) evaluated: row2 >= 0| yes Evaluation Count:2456 | yes Evaluation Count:3 |
partially evaluated: row2 < row1| no Evaluation Count:0 | yes Evaluation Count:2456 |
| 0-2456 |
| 556 | qWarning("QGridLayout: Multi-cell fromRow greater than toRow"); never executed: QMessageLogger("kernel/qgridlayout.cpp", 556, __PRETTY_FUNCTION__).warning("QGridLayout: Multi-cell fromRow greater than toRow"); | 0 |
| 557 | if (col2 >= 0 && col2 < col1) partially evaluated: col2 >= 0| yes Evaluation Count:2459 | no Evaluation Count:0 |
partially evaluated: col2 < col1| no Evaluation Count:0 | yes Evaluation Count:2459 |
| 0-2459 |
| 558 | qWarning("QGridLayout: Multi-cell fromCol greater than toCol"); never executed: QMessageLogger("kernel/qgridlayout.cpp", 558, __PRETTY_FUNCTION__).warning("QGridLayout: Multi-cell fromCol greater than toCol"); | 0 |
| 559 | if (row1 == row2 && col1 == col2) { evaluated: row1 == row2| yes Evaluation Count:2172 | yes Evaluation Count:287 |
evaluated: col1 == col2| yes Evaluation Count:1682 | yes Evaluation Count:490 |
| 287-2172 |
| 560 | add(box, row1, col1); executed (the execution status of this line is deduced): add(box, row1, col1); | - |
| 561 | return; executed: return;Execution Count:1682 | 1682 |
| 562 | } | - |
| 563 | expand(row2 + 1, col2 + 1); executed (the execution status of this line is deduced): expand(row2 + 1, col2 + 1); | - |
| 564 | box->row = row1; executed (the execution status of this line is deduced): box->row = row1; | - |
| 565 | box->col = col1; executed (the execution status of this line is deduced): box->col = col1; | - |
| 566 | | - |
| 567 | box->torow = row2; executed (the execution status of this line is deduced): box->torow = row2; | - |
| 568 | box->tocol = col2; executed (the execution status of this line is deduced): box->tocol = col2; | - |
| 569 | | - |
| 570 | things.append(box); executed (the execution status of this line is deduced): things.append(box); | - |
| 571 | setDirty(); executed (the execution status of this line is deduced): setDirty(); | - |
| 572 | if (col2 < 0) partially evaluated: col2 < 0| no Evaluation Count:0 | yes Evaluation Count:777 |
| 0-777 |
| 573 | col2 = cc - 1; never executed: col2 = cc - 1; | 0 |
| 574 | | - |
| 575 | setNextPosAfter(row2, col2); executed (the execution status of this line is deduced): setNextPosAfter(row2, col2); | - |
| 576 | } executed: }Execution Count:777 | 777 |
| 577 | | - |
| 578 | void QGridLayoutPrivate::addData(QGridBox *box, const QGridLayoutSizeTriple &sizes, bool r, bool c) | - |
| 579 | { | - |
| 580 | const QWidget *widget = box->item()->widget(); executed (the execution status of this line is deduced): const QWidget *widget = box->item()->widget(); | - |
| 581 | | - |
| 582 | if (box->isEmpty() && widget) evaluated: box->isEmpty()| yes Evaluation Count:172 | yes Evaluation Count:11306 |
evaluated: widget| yes Evaluation Count:44 | yes Evaluation Count:128 |
| 44-11306 |
| 583 | return; executed: return;Execution Count:44 | 44 |
| 584 | | - |
| 585 | if (c) { evaluated: c| yes Evaluation Count:5484 | yes Evaluation Count:5950 |
| 5484-5950 |
| 586 | QLayoutStruct *data = &colData[box->col]; executed (the execution status of this line is deduced): QLayoutStruct *data = &colData[box->col]; | - |
| 587 | if (!cStretch.at(box->col)) evaluated: !cStretch.at(box->col)| yes Evaluation Count:5329 | yes Evaluation Count:155 |
| 155-5329 |
| 588 | data->stretch = qMax(data->stretch, box->hStretch()); executed: data->stretch = qMax(data->stretch, box->hStretch());Execution Count:5329 | 5329 |
| 589 | data->sizeHint = qMax(sizes.hint.width(), data->sizeHint); executed (the execution status of this line is deduced): data->sizeHint = qMax(sizes.hint.width(), data->sizeHint); | - |
| 590 | data->minimumSize = qMax(sizes.minS.width(), data->minimumSize); executed (the execution status of this line is deduced): data->minimumSize = qMax(sizes.minS.width(), data->minimumSize); | - |
| 591 | | - |
| 592 | qMaxExpCalc(data->maximumSize, data->expansive, data->empty, sizes.maxS.width(), executed (the execution status of this line is deduced): qMaxExpCalc(data->maximumSize, data->expansive, data->empty, sizes.maxS.width(), | - |
| 593 | box->expandingDirections() & Qt::Horizontal, box->isEmpty()); executed (the execution status of this line is deduced): box->expandingDirections() & Qt::Horizontal, box->isEmpty()); | - |
| 594 | } executed: }Execution Count:5484 | 5484 |
| 595 | if (r) { evaluated: r| yes Evaluation Count:5950 | yes Evaluation Count:5484 |
| 5484-5950 |
| 596 | QLayoutStruct *data = &rowData[box->row]; executed (the execution status of this line is deduced): QLayoutStruct *data = &rowData[box->row]; | - |
| 597 | if (!rStretch.at(box->row)) evaluated: !rStretch.at(box->row)| yes Evaluation Count:5867 | yes Evaluation Count:83 |
| 83-5867 |
| 598 | data->stretch = qMax(data->stretch, box->vStretch()); executed: data->stretch = qMax(data->stretch, box->vStretch());Execution Count:5867 | 5867 |
| 599 | data->sizeHint = qMax(sizes.hint.height(), data->sizeHint); executed (the execution status of this line is deduced): data->sizeHint = qMax(sizes.hint.height(), data->sizeHint); | - |
| 600 | data->minimumSize = qMax(sizes.minS.height(), data->minimumSize); executed (the execution status of this line is deduced): data->minimumSize = qMax(sizes.minS.height(), data->minimumSize); | - |
| 601 | | - |
| 602 | qMaxExpCalc(data->maximumSize, data->expansive, data->empty, sizes.maxS.height(), executed (the execution status of this line is deduced): qMaxExpCalc(data->maximumSize, data->expansive, data->empty, sizes.maxS.height(), | - |
| 603 | box->expandingDirections() & Qt::Vertical, box->isEmpty()); executed (the execution status of this line is deduced): box->expandingDirections() & Qt::Vertical, box->isEmpty()); | - |
| 604 | } executed: }Execution Count:5950 | 5950 |
| 605 | } executed: }Execution Count:11434 | 11434 |
| 606 | | - |
| 607 | static void initEmptyMultiBox(QVector<QLayoutStruct> &chain, int start, int end) | - |
| 608 | { | - |
| 609 | for (int i = start; i <= end; i++) { evaluated: i <= end| yes Evaluation Count:5325 | yes Evaluation Count:2132 |
| 2132-5325 |
| 610 | QLayoutStruct *data = &chain[i]; executed (the execution status of this line is deduced): QLayoutStruct *data = &chain[i]; | - |
| 611 | if (data->empty && data->maximumSize == 0) // truly empty box evaluated: data->empty| yes Evaluation Count:2211 | yes Evaluation Count:3114 |
evaluated: data->maximumSize == 0| yes Evaluation Count:1912 | yes Evaluation Count:299 |
| 299-3114 |
| 612 | data->maximumSize = QWIDGETSIZE_MAX; executed: data->maximumSize = ((1<<24)-1);Execution Count:1912 | 1912 |
| 613 | data->empty = false; executed (the execution status of this line is deduced): data->empty = false; | - |
| 614 | } executed: }Execution Count:5325 | 5325 |
| 615 | } executed: }Execution Count:2132 | 2132 |
| 616 | | - |
| 617 | static void distributeMultiBox(QVector<QLayoutStruct> &chain, int start, int end, int minSize, | - |
| 618 | int sizeHint, QVector<int> &stretchArray, int stretch) | - |
| 619 | { | - |
| 620 | int i; executed (the execution status of this line is deduced): int i; | - |
| 621 | int w = 0; executed (the execution status of this line is deduced): int w = 0; | - |
| 622 | int wh = 0; executed (the execution status of this line is deduced): int wh = 0; | - |
| 623 | int max = 0; executed (the execution status of this line is deduced): int max = 0; | - |
| 624 | | - |
| 625 | for (i = start; i <= end; i++) { evaluated: i <= end| yes Evaluation Count:5325 | yes Evaluation Count:2132 |
| 2132-5325 |
| 626 | QLayoutStruct *data = &chain[i]; executed (the execution status of this line is deduced): QLayoutStruct *data = &chain[i]; | - |
| 627 | w += data->minimumSize; executed (the execution status of this line is deduced): w += data->minimumSize; | - |
| 628 | wh += data->sizeHint; executed (the execution status of this line is deduced): wh += data->sizeHint; | - |
| 629 | max += data->maximumSize; executed (the execution status of this line is deduced): max += data->maximumSize; | - |
| 630 | if (stretchArray.at(i) == 0) evaluated: stretchArray.at(i) == 0| yes Evaluation Count:5087 | yes Evaluation Count:238 |
| 238-5087 |
| 631 | data->stretch = qMax(data->stretch, stretch); executed: data->stretch = qMax(data->stretch, stretch);Execution Count:5087 | 5087 |
| 632 | | - |
| 633 | if (i != end) { evaluated: i != end| yes Evaluation Count:3193 | yes Evaluation Count:2132 |
| 2132-3193 |
| 634 | int spacing = data->spacing; executed (the execution status of this line is deduced): int spacing = data->spacing; | - |
| 635 | w += spacing; executed (the execution status of this line is deduced): w += spacing; | - |
| 636 | wh += spacing; executed (the execution status of this line is deduced): wh += spacing; | - |
| 637 | max += spacing; executed (the execution status of this line is deduced): max += spacing; | - |
| 638 | } executed: }Execution Count:3193 | 3193 |
| 639 | } executed: }Execution Count:5325 | 5325 |
| 640 | | - |
| 641 | if (max < minSize) { // implies w < minSize evaluated: max < minSize| yes Evaluation Count:309 | yes Evaluation Count:1823 |
| 309-1823 |
| 642 | /* | - |
| 643 | We must increase the maximum size of at least one of the | - |
| 644 | items. qGeomCalc() will put the extra space in between the | - |
| 645 | items. We must recover that extra space and put it | - |
| 646 | somewhere. It does not really matter where, since the user | - |
| 647 | can always specify stretch factors and avoid this code. | - |
| 648 | */ | - |
| 649 | qGeomCalc(chain, start, end - start + 1, 0, minSize); executed (the execution status of this line is deduced): qGeomCalc(chain, start, end - start + 1, 0, minSize); | - |
| 650 | int pos = 0; executed (the execution status of this line is deduced): int pos = 0; | - |
| 651 | for (i = start; i <= end; i++) { evaluated: i <= end| yes Evaluation Count:618 | yes Evaluation Count:309 |
| 309-618 |
| 652 | QLayoutStruct *data = &chain[i]; executed (the execution status of this line is deduced): QLayoutStruct *data = &chain[i]; | - |
| 653 | int nextPos = (i == end) ? minSize : chain.at(i + 1).pos; evaluated: (i == end)| yes Evaluation Count:309 | yes Evaluation Count:309 |
| 309 |
| 654 | int realSize = nextPos - pos; executed (the execution status of this line is deduced): int realSize = nextPos - pos; | - |
| 655 | if (i != end) evaluated: i != end| yes Evaluation Count:309 | yes Evaluation Count:309 |
| 309 |
| 656 | realSize -= data->spacing; executed: realSize -= data->spacing;Execution Count:309 | 309 |
| 657 | if (data->minimumSize < realSize) partially evaluated: data->minimumSize < realSize| yes Evaluation Count:618 | no Evaluation Count:0 |
| 0-618 |
| 658 | data->minimumSize = realSize; executed: data->minimumSize = realSize;Execution Count:618 | 618 |
| 659 | if (data->maximumSize < data->minimumSize) partially evaluated: data->maximumSize < data->minimumSize| yes Evaluation Count:618 | no Evaluation Count:0 |
| 0-618 |
| 660 | data->maximumSize = data->minimumSize; executed: data->maximumSize = data->minimumSize;Execution Count:618 | 618 |
| 661 | pos = nextPos; executed (the execution status of this line is deduced): pos = nextPos; | - |
| 662 | } executed: }Execution Count:618 | 618 |
| 663 | } else if (w < minSize) { executed: }Execution Count:309 evaluated: w < minSize| yes Evaluation Count:808 | yes Evaluation Count:1015 |
| 309-1015 |
| 664 | qGeomCalc(chain, start, end - start + 1, 0, minSize); executed (the execution status of this line is deduced): qGeomCalc(chain, start, end - start + 1, 0, minSize); | - |
| 665 | for (i = start; i <= end; i++) { evaluated: i <= end| yes Evaluation Count:2005 | yes Evaluation Count:808 |
| 808-2005 |
| 666 | QLayoutStruct *data = &chain[i]; executed (the execution status of this line is deduced): QLayoutStruct *data = &chain[i]; | - |
| 667 | if (data->minimumSize < data->size) evaluated: data->minimumSize < data->size| yes Evaluation Count:926 | yes Evaluation Count:1079 |
| 926-1079 |
| 668 | data->minimumSize = data->size; executed: data->minimumSize = data->size;Execution Count:926 | 926 |
| 669 | } executed: }Execution Count:2005 | 2005 |
| 670 | } executed: }Execution Count:808 | 808 |
| 671 | | - |
| 672 | if (wh < sizeHint) { evaluated: wh < sizeHint| yes Evaluation Count:1470 | yes Evaluation Count:662 |
| 662-1470 |
| 673 | qGeomCalc(chain, start, end - start + 1, 0, sizeHint); executed (the execution status of this line is deduced): qGeomCalc(chain, start, end - start + 1, 0, sizeHint); | - |
| 674 | for (i = start; i <= end; i++) { evaluated: i <= end| yes Evaluation Count:3780 | yes Evaluation Count:1470 |
| 1470-3780 |
| 675 | QLayoutStruct *data = &chain[i]; executed (the execution status of this line is deduced): QLayoutStruct *data = &chain[i]; | - |
| 676 | if (data->sizeHint < data->size) evaluated: data->sizeHint < data->size| yes Evaluation Count:1945 | yes Evaluation Count:1835 |
| 1835-1945 |
| 677 | data->sizeHint = data->size; executed: data->sizeHint = data->size;Execution Count:1945 | 1945 |
| 678 | } executed: }Execution Count:3780 | 3780 |
| 679 | } executed: }Execution Count:1470 | 1470 |
| 680 | } executed: }Execution Count:2132 | 2132 |
| 681 | | - |
| 682 | static QGridBox *&gridAt(QGridBox *grid[], int r, int c, int cc, | - |
| 683 | Qt::Orientation orientation = Qt::Vertical) | - |
| 684 | { | - |
| 685 | if (orientation == Qt::Horizontal) evaluated: orientation == Qt::Horizontal| yes Evaluation Count:11882 | yes Evaluation Count:22302 |
| 11882-22302 |
| 686 | qSwap(r, c); executed: qSwap(r, c);Execution Count:11882 | 11882 |
| 687 | return grid[(r * cc) + c]; executed: return grid[(r * cc) + c];Execution Count:34184 | 34184 |
| 688 | } | - |
| 689 | | - |
| 690 | void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain, | - |
| 691 | QGridBox *grid[], int fixedSpacing, | - |
| 692 | Qt::Orientation orientation) | - |
| 693 | { | - |
| 694 | Q_Q(QGridLayout); executed (the execution status of this line is deduced): QGridLayout * const q = q_func(); | - |
| 695 | int numRows = rr; // or columns if orientation is horizontal executed (the execution status of this line is deduced): int numRows = rr; | - |
| 696 | int numColumns = cc; // or rows if orientation is horizontal executed (the execution status of this line is deduced): int numColumns = cc; | - |
| 697 | | - |
| 698 | if (orientation == Qt::Horizontal) { evaluated: orientation == Qt::Horizontal| yes Evaluation Count:1623 | yes Evaluation Count:1623 |
| 1623 |
| 699 | qSwap(numRows, numColumns); executed (the execution status of this line is deduced): qSwap(numRows, numColumns); | - |
| 700 | } executed: }Execution Count:1623 | 1623 |
| 701 | | - |
| 702 | QStyle *style = 0; executed (the execution status of this line is deduced): QStyle *style = 0; | - |
| 703 | if (fixedSpacing < 0) { evaluated: fixedSpacing < 0| yes Evaluation Count:220 | yes Evaluation Count:3026 |
| 220-3026 |
| 704 | if (QWidget *parentWidget = q->parentWidget()) partially evaluated: QWidget *parentWidget = q->parentWidget()| yes Evaluation Count:220 | no Evaluation Count:0 |
| 0-220 |
| 705 | style = parentWidget->style(); executed: style = parentWidget->style();Execution Count:220 | 220 |
| 706 | } executed: }Execution Count:220 | 220 |
| 707 | | - |
| 708 | for (int c = 0; c < numColumns; ++c) { evaluated: c < numColumns| yes Evaluation Count:9466 | yes Evaluation Count:3246 |
| 3246-9466 |
| 709 | QGridBox *previousBox = 0; executed (the execution status of this line is deduced): QGridBox *previousBox = 0; | - |
| 710 | int previousRow = -1; // previous *non-empty* row executed (the execution status of this line is deduced): int previousRow = -1; | - |
| 711 | | - |
| 712 | for (int r = 0; r < numRows; ++r) { evaluated: r < numRows| yes Evaluation Count:29542 | yes Evaluation Count:9466 |
| 9466-29542 |
| 713 | if (chain.at(r).empty) evaluated: chain.at(r).empty| yes Evaluation Count:4844 | yes Evaluation Count:24698 |
| 4844-24698 |
| 714 | continue; executed: continue;Execution Count:4844 | 4844 |
| 715 | | - |
| 716 | QGridBox *box = gridAt(grid, r, c, cc, orientation); executed (the execution status of this line is deduced): QGridBox *box = gridAt(grid, r, c, cc, orientation); | - |
| 717 | if (previousRow != -1 && (!box || previousBox != box)) { evaluated: previousRow != -1| yes Evaluation Count:15408 | yes Evaluation Count:9290 |
evaluated: !box| yes Evaluation Count:3970 | yes Evaluation Count:11438 |
evaluated: previousBox != box| yes Evaluation Count:8589 | yes Evaluation Count:2849 |
| 2849-15408 |
| 718 | int spacing = fixedSpacing; executed (the execution status of this line is deduced): int spacing = fixedSpacing; | - |
| 719 | if (spacing < 0) { evaluated: spacing < 0| yes Evaluation Count:2032 | yes Evaluation Count:10527 |
| 2032-10527 |
| 720 | QSizePolicy::ControlTypes controlTypes1 = QSizePolicy::DefaultType; executed (the execution status of this line is deduced): QSizePolicy::ControlTypes controlTypes1 = QSizePolicy::DefaultType; | - |
| 721 | QSizePolicy::ControlTypes controlTypes2 = QSizePolicy::DefaultType; executed (the execution status of this line is deduced): QSizePolicy::ControlTypes controlTypes2 = QSizePolicy::DefaultType; | - |
| 722 | if (previousBox) evaluated: previousBox| yes Evaluation Count:584 | yes Evaluation Count:1448 |
| 584-1448 |
| 723 | controlTypes1 = previousBox->item()->controlTypes(); executed: controlTypes1 = previousBox->item()->controlTypes();Execution Count:584 | 584 |
| 724 | if (box) evaluated: box| yes Evaluation Count:640 | yes Evaluation Count:1392 |
| 640-1392 |
| 725 | controlTypes2 = box->item()->controlTypes(); executed: controlTypes2 = box->item()->controlTypes();Execution Count:640 | 640 |
| 726 | | - |
| 727 | if ((orientation == Qt::Horizontal && hReversed) evaluated: orientation == Qt::Horizontal| yes Evaluation Count:804 | yes Evaluation Count:1228 |
partially evaluated: hReversed| no Evaluation Count:0 | yes Evaluation Count:804 |
| 0-1228 |
| 728 | || (orientation == Qt::Vertical && vReversed)) evaluated: orientation == Qt::Vertical| yes Evaluation Count:1228 | yes Evaluation Count:804 |
partially evaluated: vReversed| no Evaluation Count:0 | yes Evaluation Count:1228 |
| 0-1228 |
| 729 | qSwap(controlTypes1, controlTypes2); never executed: qSwap(controlTypes1, controlTypes2); | 0 |
| 730 | | - |
| 731 | if (style) partially evaluated: style| yes Evaluation Count:2032 | no Evaluation Count:0 |
| 0-2032 |
| 732 | spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2, executed: spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2, orientation, 0, q->parentWidget());Execution Count:2032 | 2032 |
| 733 | orientation, 0, q->parentWidget()); executed: spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2, orientation, 0, q->parentWidget());Execution Count:2032 | 2032 |
| 734 | } else { executed: }Execution Count:2032 | 2032 |
| 735 | if (orientation == Qt::Vertical) { evaluated: orientation == Qt::Vertical| yes Evaluation Count:6969 | yes Evaluation Count:3558 |
| 3558-6969 |
| 736 | QGridBox *sibling = vReversed ? previousBox : box; partially evaluated: vReversed| no Evaluation Count:0 | yes Evaluation Count:6969 |
| 0-6969 |
| 737 | if (sibling) { evaluated: sibling| yes Evaluation Count:5335 | yes Evaluation Count:1634 |
| 1634-5335 |
| 738 | QWidget *wid = sibling->item()->widget(); executed (the execution status of this line is deduced): QWidget *wid = sibling->item()->widget(); | - |
| 739 | if (wid) evaluated: wid| yes Evaluation Count:4463 | yes Evaluation Count:872 |
| 872-4463 |
| 740 | spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() ); executed: spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() );Execution Count:4463 | 4463 |
| 741 | } executed: }Execution Count:5335 | 5335 |
| 742 | } executed: }Execution Count:6969 | 6969 |
| 743 | } executed: }Execution Count:10527 | 10527 |
| 744 | | - |
| 745 | if (spacing > chain.at(previousRow).spacing) evaluated: spacing > chain.at(previousRow).spacing| yes Evaluation Count:3079 | yes Evaluation Count:9480 |
| 3079-9480 |
| 746 | chain[previousRow].spacing = spacing; executed: chain[previousRow].spacing = spacing;Execution Count:3079 | 3079 |
| 747 | } executed: }Execution Count:12559 | 12559 |
| 748 | | - |
| 749 | previousBox = box; executed (the execution status of this line is deduced): previousBox = box; | - |
| 750 | previousRow = r; executed (the execution status of this line is deduced): previousRow = r; | - |
| 751 | } executed: }Execution Count:24698 | 24698 |
| 752 | } executed: }Execution Count:9466 | 9466 |
| 753 | } executed: }Execution Count:3246 | 3246 |
| 754 | | - |
| 755 | //#define QT_LAYOUT_DISABLE_CACHING | - |
| 756 | | - |
| 757 | void QGridLayoutPrivate::setupLayoutData(int hSpacing, int vSpacing) | - |
| 758 | { | - |
| 759 | Q_Q(QGridLayout); executed (the execution status of this line is deduced): QGridLayout * const q = q_func(); | - |
| 760 | | - |
| 761 | #ifndef QT_LAYOUT_DISABLE_CACHING | - |
| 762 | if (!needRecalc) evaluated: !needRecalc| yes Evaluation Count:4303 | yes Evaluation Count:1623 |
| 1623-4303 |
| 763 | return; executed: return;Execution Count:4303 | 4303 |
| 764 | #endif | - |
| 765 | has_hfw = false; executed (the execution status of this line is deduced): has_hfw = false; | - |
| 766 | int i; executed (the execution status of this line is deduced): int i; | - |
| 767 | | - |
| 768 | for (i = 0; i < rr; i++) { evaluated: i < rr| yes Evaluation Count:5904 | yes Evaluation Count:1623 |
| 1623-5904 |
| 769 | rowData[i].init(rStretch.at(i), rMinHeights.at(i)); executed (the execution status of this line is deduced): rowData[i].init(rStretch.at(i), rMinHeights.at(i)); | - |
| 770 | rowData[i].maximumSize = rStretch.at(i) ? QLAYOUTSIZE_MAX : rMinHeights.at(i); evaluated: rStretch.at(i)| yes Evaluation Count:75 | yes Evaluation Count:5829 |
| 75-5829 |
| 771 | } executed: }Execution Count:5904 | 5904 |
| 772 | for (i = 0; i < cc; i++) { evaluated: i < cc| yes Evaluation Count:3562 | yes Evaluation Count:1623 |
| 1623-3562 |
| 773 | colData[i].init(cStretch.at(i), cMinWidths.at(i)); executed (the execution status of this line is deduced): colData[i].init(cStretch.at(i), cMinWidths.at(i)); | - |
| 774 | colData[i].maximumSize = cStretch.at(i) ? QLAYOUTSIZE_MAX : cMinWidths.at(i); evaluated: cStretch.at(i)| yes Evaluation Count:94 | yes Evaluation Count:3468 |
| 94-3468 |
| 775 | } executed: }Execution Count:3562 | 3562 |
| 776 | | - |
| 777 | int n = things.size(); executed (the execution status of this line is deduced): int n = things.size(); | - |
| 778 | QVarLengthArray<QGridLayoutSizeTriple> sizes(n); executed (the execution status of this line is deduced): QVarLengthArray<QGridLayoutSizeTriple> sizes(n); | - |
| 779 | | - |
| 780 | bool has_multi = false; executed (the execution status of this line is deduced): bool has_multi = false; | - |
| 781 | | - |
| 782 | /* | - |
| 783 | Grid of items. We use it to determine which items are | - |
| 784 | adjacent to which and compute the spacings correctly. | - |
| 785 | */ | - |
| 786 | QVarLengthArray<QGridBox *> grid(rr * cc); executed (the execution status of this line is deduced): QVarLengthArray<QGridBox *> grid(rr * cc); | - |
| 787 | memset(grid.data(), 0, rr * cc * sizeof(QGridBox *)); executed (the execution status of this line is deduced): memset(grid.data(), 0, rr * cc * sizeof(QGridBox *)); | - |
| 788 | | - |
| 789 | /* | - |
| 790 | Initialize 'sizes' and 'grid' data structures, and insert | - |
| 791 | non-spanning items to our row and column data structures. | - |
| 792 | */ | - |
| 793 | for (i = 0; i < n; ++i) { evaluated: i < n| yes Evaluation Count:6729 | yes Evaluation Count:1623 |
| 1623-6729 |
| 794 | QGridBox * const box = things.at(i); executed (the execution status of this line is deduced): QGridBox * const box = things.at(i); | - |
| 795 | sizes[i].minS = box->minimumSize(); executed (the execution status of this line is deduced): sizes[i].minS = box->minimumSize(); | - |
| 796 | sizes[i].hint = box->sizeHint(); executed (the execution status of this line is deduced): sizes[i].hint = box->sizeHint(); | - |
| 797 | sizes[i].maxS = box->maximumSize(); executed (the execution status of this line is deduced): sizes[i].maxS = box->maximumSize(); | - |
| 798 | | - |
| 799 | if (box->hasHeightForWidth()) evaluated: box->hasHeightForWidth()| yes Evaluation Count:266 | yes Evaluation Count:6463 |
| 266-6463 |
| 800 | has_hfw = true; executed: has_hfw = true;Execution Count:266 | 266 |
| 801 | | - |
| 802 | if (box->row == box->toRow(rr)) { evaluated: box->row == box->toRow(rr)| yes Evaluation Count:5976 | yes Evaluation Count:753 |
| 753-5976 |
| 803 | addData(box, sizes[i], true, false); executed (the execution status of this line is deduced): addData(box, sizes[i], true, false); | - |
| 804 | } else { executed: }Execution Count:5976 | 5976 |
| 805 | initEmptyMultiBox(rowData, box->row, box->toRow(rr)); executed (the execution status of this line is deduced): initEmptyMultiBox(rowData, box->row, box->toRow(rr)); | - |
| 806 | has_multi = true; executed (the execution status of this line is deduced): has_multi = true; | - |
| 807 | } executed: }Execution Count:753 | 753 |
| 808 | | - |
| 809 | if (box->col == box->toCol(cc)) { evaluated: box->col == box->toCol(cc)| yes Evaluation Count:5502 | yes Evaluation Count:1227 |
| 1227-5502 |
| 810 | addData(box, sizes[i], false, true); executed (the execution status of this line is deduced): addData(box, sizes[i], false, true); | - |
| 811 | } else { executed: }Execution Count:5502 | 5502 |
| 812 | initEmptyMultiBox(colData, box->col, box->toCol(cc)); executed (the execution status of this line is deduced): initEmptyMultiBox(colData, box->col, box->toCol(cc)); | - |
| 813 | has_multi = true; executed (the execution status of this line is deduced): has_multi = true; | - |
| 814 | } executed: }Execution Count:1227 | 1227 |
| 815 | | - |
| 816 | for (int r = box->row; r <= box->toRow(rr); ++r) { evaluated: r <= box->toRow(rr)| yes Evaluation Count:7777 | yes Evaluation Count:6729 |
| 6729-7777 |
| 817 | for (int c = box->col; c <= box->toCol(cc); ++c) { evaluated: c <= box->toCol(cc)| yes Evaluation Count:9486 | yes Evaluation Count:7777 |
| 7777-9486 |
| 818 | gridAt(grid.data(), r, c, cc) = box; executed (the execution status of this line is deduced): gridAt(grid.data(), r, c, cc) = box; | - |
| 819 | } executed: }Execution Count:9486 | 9486 |
| 820 | } executed: }Execution Count:7777 | 7777 |
| 821 | } executed: }Execution Count:6729 | 6729 |
| 822 | | - |
| 823 | setupSpacings(colData, grid.data(), hSpacing, Qt::Horizontal); executed (the execution status of this line is deduced): setupSpacings(colData, grid.data(), hSpacing, Qt::Horizontal); | - |
| 824 | setupSpacings(rowData, grid.data(), vSpacing, Qt::Vertical); executed (the execution status of this line is deduced): setupSpacings(rowData, grid.data(), vSpacing, Qt::Vertical); | - |
| 825 | | - |
| 826 | /* | - |
| 827 | Insert multicell items to our row and column data structures. | - |
| 828 | This must be done after the non-spanning items to obtain a | - |
| 829 | better distribution in distributeMultiBox(). | - |
| 830 | */ | - |
| 831 | if (has_multi) { evaluated: has_multi| yes Evaluation Count:799 | yes Evaluation Count:824 |
| 799-824 |
| 832 | for (i = 0; i < n; ++i) { evaluated: i < n| yes Evaluation Count:4400 | yes Evaluation Count:799 |
| 799-4400 |
| 833 | QGridBox * const box = things.at(i); executed (the execution status of this line is deduced): QGridBox * const box = things.at(i); | - |
| 834 | | - |
| 835 | if (box->row != box->toRow(rr)) evaluated: box->row != box->toRow(rr)| yes Evaluation Count:753 | yes Evaluation Count:3647 |
| 753-3647 |
| 836 | distributeMultiBox(rowData, box->row, box->toRow(rr), sizes[i].minS.height(), executed: distributeMultiBox(rowData, box->row, box->toRow(rr), sizes[i].minS.height(), sizes[i].hint.height(), rStretch, box->vStretch());Execution Count:753 | 753 |
| 837 | sizes[i].hint.height(), rStretch, box->vStretch()); executed: distributeMultiBox(rowData, box->row, box->toRow(rr), sizes[i].minS.height(), sizes[i].hint.height(), rStretch, box->vStretch());Execution Count:753 | 753 |
| 838 | if (box->col != box->toCol(cc)) evaluated: box->col != box->toCol(cc)| yes Evaluation Count:1227 | yes Evaluation Count:3173 |
| 1227-3173 |
| 839 | distributeMultiBox(colData, box->col, box->toCol(cc), sizes[i].minS.width(), executed: distributeMultiBox(colData, box->col, box->toCol(cc), sizes[i].minS.width(), sizes[i].hint.width(), cStretch, box->hStretch());Execution Count:1227 | 1227 |
| 840 | sizes[i].hint.width(), cStretch, box->hStretch()); executed: distributeMultiBox(colData, box->col, box->toCol(cc), sizes[i].minS.width(), sizes[i].hint.width(), cStretch, box->hStretch());Execution Count:1227 | 1227 |
| 841 | } executed: }Execution Count:4400 | 4400 |
| 842 | } executed: }Execution Count:799 | 799 |
| 843 | | - |
| 844 | for (i = 0; i < rr; i++) evaluated: i < rr| yes Evaluation Count:5904 | yes Evaluation Count:1623 |
| 1623-5904 |
| 845 | rowData[i].expansive = rowData.at(i).expansive || rowData.at(i).stretch > 0; executed: rowData[i].expansive = rowData.at(i).expansive || rowData.at(i).stretch > 0;Execution Count:5904 evaluated: rowData.at(i).expansive| yes Evaluation Count:465 | yes Evaluation Count:5439 |
evaluated: rowData.at(i).stretch > 0| yes Evaluation Count:73 | yes Evaluation Count:5366 |
| 73-5904 |
| 846 | for (i = 0; i < cc; i++) evaluated: i < cc| yes Evaluation Count:3562 | yes Evaluation Count:1623 |
| 1623-3562 |
| 847 | colData[i].expansive = colData.at(i).expansive || colData.at(i).stretch > 0; executed: colData[i].expansive = colData.at(i).expansive || colData.at(i).stretch > 0;Execution Count:3562 evaluated: colData.at(i).expansive| yes Evaluation Count:1056 | yes Evaluation Count:2506 |
evaluated: colData.at(i).stretch > 0| yes Evaluation Count:78 | yes Evaluation Count:2428 |
| 78-3562 |
| 848 | | - |
| 849 | q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); executed (the execution status of this line is deduced): q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | - |
| 850 | | - |
| 851 | needRecalc = false; executed (the execution status of this line is deduced): needRecalc = false; | - |
| 852 | } executed: }Execution Count:1623 | 1623 |
| 853 | | - |
| 854 | void QGridLayoutPrivate::addHfwData(QGridBox *box, int width) | - |
| 855 | { | - |
| 856 | QVector<QLayoutStruct> &rData = *hfwData; executed (the execution status of this line is deduced): QVector<QLayoutStruct> &rData = *hfwData; | - |
| 857 | if (box->hasHeightForWidth()) { evaluated: box->hasHeightForWidth()| yes Evaluation Count:334 | yes Evaluation Count:699 |
| 334-699 |
| 858 | int hint = box->heightForWidth(width); executed (the execution status of this line is deduced): int hint = box->heightForWidth(width); | - |
| 859 | rData[box->row].sizeHint = qMax(hint, rData.at(box->row).sizeHint); executed (the execution status of this line is deduced): rData[box->row].sizeHint = qMax(hint, rData.at(box->row).sizeHint); | - |
| 860 | rData[box->row].minimumSize = qMax(hint, rData.at(box->row).minimumSize); executed (the execution status of this line is deduced): rData[box->row].minimumSize = qMax(hint, rData.at(box->row).minimumSize); | - |
| 861 | } else { executed: }Execution Count:334 | 334 |
| 862 | QSize hint = box->sizeHint(); executed (the execution status of this line is deduced): QSize hint = box->sizeHint(); | - |
| 863 | QSize minS = box->minimumSize(); executed (the execution status of this line is deduced): QSize minS = box->minimumSize(); | - |
| 864 | rData[box->row].sizeHint = qMax(hint.height(), rData.at(box->row).sizeHint); executed (the execution status of this line is deduced): rData[box->row].sizeHint = qMax(hint.height(), rData.at(box->row).sizeHint); | - |
| 865 | rData[box->row].minimumSize = qMax(minS.height(), rData.at(box->row).minimumSize); executed (the execution status of this line is deduced): rData[box->row].minimumSize = qMax(minS.height(), rData.at(box->row).minimumSize); | - |
| 866 | } executed: }Execution Count:699 | 699 |
| 867 | } | - |
| 868 | | - |
| 869 | /* | - |
| 870 | Similar to setupLayoutData(), but uses heightForWidth(colData) | - |
| 871 | instead of sizeHint(). Assumes that setupLayoutData() and | - |
| 872 | qGeomCalc(colData) has been called. | - |
| 873 | */ | - |
| 874 | void QGridLayoutPrivate::setupHfwLayoutData() | - |
| 875 | { | - |
| 876 | QVector<QLayoutStruct> &rData = *hfwData; executed (the execution status of this line is deduced): QVector<QLayoutStruct> &rData = *hfwData; | - |
| 877 | for (int i = 0; i < rr; i++) { evaluated: i < rr| yes Evaluation Count:1583 | yes Evaluation Count:298 |
| 298-1583 |
| 878 | rData[i] = rowData.at(i); executed (the execution status of this line is deduced): rData[i] = rowData.at(i); | - |
| 879 | rData[i].minimumSize = rData[i].sizeHint = rMinHeights.at(i); executed (the execution status of this line is deduced): rData[i].minimumSize = rData[i].sizeHint = rMinHeights.at(i); | - |
| 880 | } executed: }Execution Count:1583 | 1583 |
| 881 | | - |
| 882 | for (int pass = 0; pass < 2; ++pass) { evaluated: pass < 2| yes Evaluation Count:596 | yes Evaluation Count:298 |
| 298-596 |
| 883 | for (int i = 0; i < things.size(); ++i) { evaluated: i < things.size()| yes Evaluation Count:2370 | yes Evaluation Count:596 |
| 596-2370 |
| 884 | QGridBox *box = things.at(i); executed (the execution status of this line is deduced): QGridBox *box = things.at(i); | - |
| 885 | int r1 = box->row; executed (the execution status of this line is deduced): int r1 = box->row; | - |
| 886 | int c1 = box->col; executed (the execution status of this line is deduced): int c1 = box->col; | - |
| 887 | int r2 = box->toRow(rr); executed (the execution status of this line is deduced): int r2 = box->toRow(rr); | - |
| 888 | int c2 = box->toCol(cc); executed (the execution status of this line is deduced): int c2 = box->toCol(cc); | - |
| 889 | int w = colData.at(c2).pos + colData.at(c2).size - colData.at(c1).pos; executed (the execution status of this line is deduced): int w = colData.at(c2).pos + colData.at(c2).size - colData.at(c1).pos; | - |
| 890 | | - |
| 891 | if (r1 == r2) { evaluated: r1 == r2| yes Evaluation Count:2066 | yes Evaluation Count:304 |
| 304-2066 |
| 892 | if (pass == 0) evaluated: pass == 0| yes Evaluation Count:1033 | yes Evaluation Count:1033 |
| 1033 |
| 893 | addHfwData(box, w); executed: addHfwData(box, w);Execution Count:1033 | 1033 |
| 894 | } else { executed: }Execution Count:2066 | 2066 |
| 895 | if (pass == 0) { evaluated: pass == 0| yes Evaluation Count:152 | yes Evaluation Count:152 |
| 152 |
| 896 | initEmptyMultiBox(rData, r1, r2); executed (the execution status of this line is deduced): initEmptyMultiBox(rData, r1, r2); | - |
| 897 | } else { executed: }Execution Count:152 | 152 |
| 898 | QSize hint = box->sizeHint(); executed (the execution status of this line is deduced): QSize hint = box->sizeHint(); | - |
| 899 | QSize min = box->minimumSize(); executed (the execution status of this line is deduced): QSize min = box->minimumSize(); | - |
| 900 | if (box->hasHeightForWidth()) { partially evaluated: box->hasHeightForWidth()| no Evaluation Count:0 | yes Evaluation Count:152 |
| 0-152 |
| 901 | int hfwh = box->heightForWidth(w); never executed (the execution status of this line is deduced): int hfwh = box->heightForWidth(w); | - |
| 902 | if (hfwh > hint.height()) never evaluated: hfwh > hint.height() | 0 |
| 903 | hint.setHeight(hfwh); never executed: hint.setHeight(hfwh); | 0 |
| 904 | if (hfwh > min.height()) never evaluated: hfwh > min.height() | 0 |
| 905 | min.setHeight(hfwh); never executed: min.setHeight(hfwh); | 0 |
| 906 | } | 0 |
| 907 | distributeMultiBox(rData, r1, r2, min.height(), hint.height(), executed (the execution status of this line is deduced): distributeMultiBox(rData, r1, r2, min.height(), hint.height(), | - |
| 908 | rStretch, box->vStretch()); executed (the execution status of this line is deduced): rStretch, box->vStretch()); | - |
| 909 | } executed: }Execution Count:152 | 152 |
| 910 | } | - |
| 911 | } | - |
| 912 | } executed: }Execution Count:596 | 596 |
| 913 | for (int i = 0; i < rr; i++) evaluated: i < rr| yes Evaluation Count:1583 | yes Evaluation Count:298 |
| 298-1583 |
| 914 | rData[i].expansive = rData.at(i).expansive || rData.at(i).stretch > 0; executed: rData[i].expansive = rData.at(i).expansive || rData.at(i).stretch > 0;Execution Count:1583 evaluated: rData.at(i).expansive| yes Evaluation Count:161 | yes Evaluation Count:1422 |
partially evaluated: rData.at(i).stretch > 0| no Evaluation Count:0 | yes Evaluation Count:1422 |
| 0-1583 |
| 915 | } executed: }Execution Count:298 | 298 |
| 916 | | - |
| 917 | void QGridLayoutPrivate::distribute(QRect r, int hSpacing, int vSpacing) | - |
| 918 | { | - |
| 919 | Q_Q(QGridLayout); executed (the execution status of this line is deduced): QGridLayout * const q = q_func(); | - |
| 920 | bool visualHReversed = hReversed; executed (the execution status of this line is deduced): bool visualHReversed = hReversed; | - |
| 921 | QWidget *parent = q->parentWidget(); executed (the execution status of this line is deduced): QWidget *parent = q->parentWidget(); | - |
| 922 | if (parent && parent->isRightToLeft()) partially evaluated: parent| yes Evaluation Count:1209 | no Evaluation Count:0 |
evaluated: parent->isRightToLeft()| yes Evaluation Count:30 | yes Evaluation Count:1179 |
| 0-1209 |
| 923 | visualHReversed = !visualHReversed; executed: visualHReversed = !visualHReversed;Execution Count:30 | 30 |
| 924 | | - |
| 925 | setupLayoutData(hSpacing, vSpacing); executed (the execution status of this line is deduced): setupLayoutData(hSpacing, vSpacing); | - |
| 926 | | - |
| 927 | int left, top, right, bottom; executed (the execution status of this line is deduced): int left, top, right, bottom; | - |
| 928 | effectiveMargins(&left, &top, &right, &bottom); executed (the execution status of this line is deduced): effectiveMargins(&left, &top, &right, &bottom); | - |
| 929 | r.adjust(+left, +top, -right, -bottom); executed (the execution status of this line is deduced): r.adjust(+left, +top, -right, -bottom); | - |
| 930 | | - |
| 931 | qGeomCalc(colData, 0, cc, r.x(), r.width()); executed (the execution status of this line is deduced): qGeomCalc(colData, 0, cc, r.x(), r.width()); | - |
| 932 | QVector<QLayoutStruct> *rDataPtr; executed (the execution status of this line is deduced): QVector<QLayoutStruct> *rDataPtr; | - |
| 933 | if (has_hfw) { evaluated: has_hfw| yes Evaluation Count:169 | yes Evaluation Count:1040 |
| 169-1040 |
| 934 | recalcHFW(r.width()); executed (the execution status of this line is deduced): recalcHFW(r.width()); | - |
| 935 | qGeomCalc(*hfwData, 0, rr, r.y(), r.height()); executed (the execution status of this line is deduced): qGeomCalc(*hfwData, 0, rr, r.y(), r.height()); | - |
| 936 | rDataPtr = hfwData; executed (the execution status of this line is deduced): rDataPtr = hfwData; | - |
| 937 | } else { executed: }Execution Count:169 | 169 |
| 938 | qGeomCalc(rowData, 0, rr, r.y(), r.height()); executed (the execution status of this line is deduced): qGeomCalc(rowData, 0, rr, r.y(), r.height()); | - |
| 939 | rDataPtr = &rowData; executed (the execution status of this line is deduced): rDataPtr = &rowData; | - |
| 940 | } executed: }Execution Count:1040 | 1040 |
| 941 | QVector<QLayoutStruct> &rData = *rDataPtr; executed (the execution status of this line is deduced): QVector<QLayoutStruct> &rData = *rDataPtr; | - |
| 942 | int i; executed (the execution status of this line is deduced): int i; | - |
| 943 | | - |
| 944 | bool reverse = ((r.bottom() > rect.bottom()) || (r.bottom() == rect.bottom() evaluated: (r.bottom() > rect.bottom())| yes Evaluation Count:1144 | yes Evaluation Count:65 |
evaluated: r.bottom() == rect.bottom()| yes Evaluation Count:2 | yes Evaluation Count:63 |
| 2-1144 |
| 945 | && ((r.right() > rect.right()) != visualHReversed))); evaluated: ((r.right() > rect.right()) != visualHReversed)| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 946 | int n = things.size(); executed (the execution status of this line is deduced): int n = things.size(); | - |
| 947 | for (i = 0; i < n; ++i) { evaluated: i < n| yes Evaluation Count:4378 | yes Evaluation Count:1209 |
| 1209-4378 |
| 948 | QGridBox *box = things.at(reverse ? n-i-1 : i); executed (the execution status of this line is deduced): QGridBox *box = things.at(reverse ? n-i-1 : i); | - |
| 949 | int r2 = box->toRow(rr); executed (the execution status of this line is deduced): int r2 = box->toRow(rr); | - |
| 950 | int c2 = box->toCol(cc); executed (the execution status of this line is deduced): int c2 = box->toCol(cc); | - |
| 951 | | - |
| 952 | int x = colData.at(box->col).pos; executed (the execution status of this line is deduced): int x = colData.at(box->col).pos; | - |
| 953 | int y = rData.at(box->row).pos; executed (the execution status of this line is deduced): int y = rData.at(box->row).pos; | - |
| 954 | int x2p = colData.at(c2).pos + colData.at(c2).size; // x2+1 executed (the execution status of this line is deduced): int x2p = colData.at(c2).pos + colData.at(c2).size; | - |
| 955 | int y2p = rData.at(r2).pos + rData.at(r2).size; // y2+1 executed (the execution status of this line is deduced): int y2p = rData.at(r2).pos + rData.at(r2).size; | - |
| 956 | int w = x2p - x; executed (the execution status of this line is deduced): int w = x2p - x; | - |
| 957 | int h = y2p - y; executed (the execution status of this line is deduced): int h = y2p - y; | - |
| 958 | | - |
| 959 | if (visualHReversed) evaluated: visualHReversed| yes Evaluation Count:84 | yes Evaluation Count:4294 |
| 84-4294 |
| 960 | x = r.left() + r.right() - x - w + 1; executed: x = r.left() + r.right() - x - w + 1;Execution Count:84 | 84 |
| 961 | if (vReversed) partially evaluated: vReversed| no Evaluation Count:0 | yes Evaluation Count:4378 |
| 0-4378 |
| 962 | y = r.top() + r.bottom() - y - h + 1; never executed: y = r.top() + r.bottom() - y - h + 1; | 0 |
| 963 | | - |
| 964 | box->setGeometry(QRect(x, y, w, h)); executed (the execution status of this line is deduced): box->setGeometry(QRect(x, y, w, h)); | - |
| 965 | } executed: }Execution Count:4378 | 4378 |
| 966 | } executed: }Execution Count:1209 | 1209 |
| 967 | | - |
| 968 | QRect QGridLayoutPrivate::cellRect(int row, int col) const | - |
| 969 | { | - |
| 970 | if (row < 0 || row >= rr || col < 0 || col >= cc) never evaluated: row < 0 never evaluated: row >= rr never evaluated: col < 0 never evaluated: col >= cc | 0 |
| 971 | return QRect(); never executed: return QRect(); | 0 |
| 972 | | - |
| 973 | const QVector<QLayoutStruct> *rDataPtr; never executed (the execution status of this line is deduced): const QVector<QLayoutStruct> *rDataPtr; | - |
| 974 | if (has_hfw && hfwData) never evaluated: has_hfw never evaluated: hfwData | 0 |
| 975 | rDataPtr = hfwData; never executed: rDataPtr = hfwData; | 0 |
| 976 | else | - |
| 977 | rDataPtr = &rowData; never executed: rDataPtr = &rowData; | 0 |
| 978 | return QRect(colData.at(col).pos, rDataPtr->at(row).pos, never executed: return QRect(colData.at(col).pos, rDataPtr->at(row).pos, colData.at(col).size, rDataPtr->at(row).size); | 0 |
| 979 | colData.at(col).size, rDataPtr->at(row).size); never executed: return QRect(colData.at(col).pos, rDataPtr->at(row).pos, colData.at(col).size, rDataPtr->at(row).size); | 0 |
| 980 | } | - |
| 981 | | - |
| 982 | /*! | - |
| 983 | \class QGridLayout | - |
| 984 | | - |
| 985 | \brief The QGridLayout class lays out widgets in a grid. | - |
| 986 | | - |
| 987 | \ingroup geomanagement | - |
| 988 | \inmodule QtWidgets | - |
| 989 | | - |
| 990 | QGridLayout takes the space made available to it (by its parent | - |
| 991 | layout or by the parentWidget()), divides it up into rows and | - |
| 992 | columns, and puts each widget it manages into the correct cell. | - |
| 993 | | - |
| 994 | Columns and rows behave identically; we will discuss columns, but | - |
| 995 | there are equivalent functions for rows. | - |
| 996 | | - |
| 997 | Each column has a minimum width and a stretch factor. The minimum | - |
| 998 | width is the greatest of that set using setColumnMinimumWidth() and the | - |
| 999 | minimum width of each widget in that column. The stretch factor is | - |
| 1000 | set using setColumnStretch() and determines how much of the available | - |
| 1001 | space the column will get over and above its necessary minimum. | - |
| 1002 | | - |
| 1003 | Normally, each managed widget or layout is put into a cell of its | - |
| 1004 | own using addWidget(). It is also possible for a widget to occupy | - |
| 1005 | multiple cells using the row and column spanning overloads of | - |
| 1006 | addItem() and addWidget(). If you do this, QGridLayout will guess | - |
| 1007 | how to distribute the size over the columns/rows (based on the | - |
| 1008 | stretch factors). | - |
| 1009 | | - |
| 1010 | To remove a widget from a layout, call removeWidget(). Calling | - |
| 1011 | QWidget::hide() on a widget also effectively removes the widget | - |
| 1012 | from the layout until QWidget::show() is called. | - |
| 1013 | | - |
| 1014 | This illustration shows a fragment of a dialog with a five-column, | - |
| 1015 | three-row grid (the grid is shown overlaid in magenta): | - |
| 1016 | | - |
| 1017 | \image gridlayout.png A grid layout | - |
| 1018 | | - |
| 1019 | Columns 0, 2 and 4 in this dialog fragment are made up of a | - |
| 1020 | QLabel, a QLineEdit, and a QListBox. Columns 1 and 3 are | - |
| 1021 | placeholders made with setColumnMinimumWidth(). Row 0 consists of three | - |
| 1022 | QLabel objects, row 1 of three QLineEdit objects and row 2 of | - |
| 1023 | three QListBox objects. We used placeholder columns (1 and 3) to | - |
| 1024 | get the right amount of space between the columns. | - |
| 1025 | | - |
| 1026 | Note that the columns and rows are not equally wide or tall. If | - |
| 1027 | you want two columns to have the same width, you must set their | - |
| 1028 | minimum widths and stretch factors to be the same yourself. You do | - |
| 1029 | this using setColumnMinimumWidth() and setColumnStretch(). | - |
| 1030 | | - |
| 1031 | If the QGridLayout is not the top-level layout (i.e. does not | - |
| 1032 | manage all of the widget's area and children), you must add it to | - |
| 1033 | its parent layout when you create it, but before you do anything | - |
| 1034 | with it. The normal way to add a layout is by calling | - |
| 1035 | addLayout() on the parent layout. | - |
| 1036 | | - |
| 1037 | Once you have added your layout you can start putting widgets and | - |
| 1038 | other layouts into the cells of your grid layout using | - |
| 1039 | addWidget(), addItem(), and addLayout(). | - |
| 1040 | | - |
| 1041 | QGridLayout also includes two margin widths: | - |
| 1042 | the \l{getContentsMargins()}{contents margin} and the spacing(). | - |
| 1043 | The contents margin is the width of the reserved space along each | - |
| 1044 | of the QGridLayout's four sides. The spacing() is the width of the | - |
| 1045 | automatically allocated spacing between neighboring boxes. | - |
| 1046 | | - |
| 1047 | The default contents margin values are provided by the | - |
| 1048 | \l{QStyle::pixelMetric()}{style}. The default value Qt styles specify | - |
| 1049 | is 9 for child widgets and 11 for windows. The spacing defaults to the same as | - |
| 1050 | the margin width for a top-level layout, or to the same as the | - |
| 1051 | parent layout. | - |
| 1052 | | - |
| 1053 | \sa QBoxLayout, QStackedLayout, {Layout Management}, {Basic Layouts Example} | - |
| 1054 | */ | - |
| 1055 | | - |
| 1056 | | - |
| 1057 | /*! | - |
| 1058 | Constructs a new QGridLayout with parent widget, \a parent. The | - |
| 1059 | layout has one row and one column initially, and will expand when | - |
| 1060 | new items are inserted. | - |
| 1061 | */ | - |
| 1062 | QGridLayout::QGridLayout(QWidget *parent) | - |
| 1063 | : QLayout(*new QGridLayoutPrivate, 0, parent) | - |
| 1064 | { | - |
| 1065 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1066 | d->expand(1, 1); executed (the execution status of this line is deduced): d->expand(1, 1); | - |
| 1067 | } executed: }Execution Count:311 | 311 |
| 1068 | | - |
| 1069 | /*! | - |
| 1070 | Constructs a new grid layout. | - |
| 1071 | | - |
| 1072 | You must insert this grid into another layout. You can insert | - |
| 1073 | widgets and layouts into this layout at any time, but laying out | - |
| 1074 | will not be performed before this is inserted into another layout. | - |
| 1075 | */ | - |
| 1076 | QGridLayout::QGridLayout() | - |
| 1077 | : QLayout(*new QGridLayoutPrivate, 0, 0) | - |
| 1078 | { | - |
| 1079 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1080 | d->expand(1, 1); executed (the execution status of this line is deduced): d->expand(1, 1); | - |
| 1081 | } executed: }Execution Count:93 | 93 |
| 1082 | | - |
| 1083 | | - |
| 1084 | | - |
| 1085 | | - |
| 1086 | /*! | - |
| 1087 | \internal (mostly) | - |
| 1088 | | - |
| 1089 | Sets the positioning mode used by addItem(). If \a orient is | - |
| 1090 | Qt::Horizontal, this layout is expanded to \a n columns, and items | - |
| 1091 | will be added columns-first. Otherwise it is expanded to \a n rows and | - |
| 1092 | items will be added rows-first. | - |
| 1093 | */ | - |
| 1094 | | - |
| 1095 | void QGridLayout::setDefaultPositioning(int n, Qt::Orientation orient) | - |
| 1096 | { | - |
| 1097 | Q_D(QGridLayout); never executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1098 | if (orient == Qt::Horizontal) { never evaluated: orient == Qt::Horizontal | 0 |
| 1099 | d->expand(1, n); never executed (the execution status of this line is deduced): d->expand(1, n); | - |
| 1100 | d->addVertical = false; never executed (the execution status of this line is deduced): d->addVertical = false; | - |
| 1101 | } else { | 0 |
| 1102 | d->expand(n,1); never executed (the execution status of this line is deduced): d->expand(n,1); | - |
| 1103 | d->addVertical = true; never executed (the execution status of this line is deduced): d->addVertical = true; | - |
| 1104 | } | 0 |
| 1105 | } | - |
| 1106 | | - |
| 1107 | | - |
| 1108 | /*! | - |
| 1109 | Destroys the grid layout. Geometry management is terminated if | - |
| 1110 | this is a top-level grid. | - |
| 1111 | | - |
| 1112 | The layout's widgets aren't destroyed. | - |
| 1113 | */ | - |
| 1114 | QGridLayout::~QGridLayout() | - |
| 1115 | { | - |
| 1116 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1117 | d->deleteAll(); executed (the execution status of this line is deduced): d->deleteAll(); | - |
| 1118 | } executed: }Execution Count:404 | 404 |
| 1119 | | - |
| 1120 | /*! | - |
| 1121 | \property QGridLayout::horizontalSpacing | - |
| 1122 | \brief the spacing between widgets that are laid out side by side | - |
| 1123 | \since 4.3 | - |
| 1124 | | - |
| 1125 | If no value is explicitly set, the layout's horizontal spacing is | - |
| 1126 | inherited from the parent layout, or from the style settings for | - |
| 1127 | the parent widget. | - |
| 1128 | | - |
| 1129 | \sa verticalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing} | - |
| 1130 | */ | - |
| 1131 | void QGridLayout::setHorizontalSpacing(int spacing) | - |
| 1132 | { | - |
| 1133 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1134 | d->horizontalSpacing = spacing; executed (the execution status of this line is deduced): d->horizontalSpacing = spacing; | - |
| 1135 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1136 | } executed: }Execution Count:15 | 15 |
| 1137 | | - |
| 1138 | int QGridLayout::horizontalSpacing() const | - |
| 1139 | { | - |
| 1140 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1141 | if (d->horizontalSpacing >= 0) { evaluated: d->horizontalSpacing >= 0| yes Evaluation Count:3119 | yes Evaluation Count:3137 |
| 3119-3137 |
| 1142 | return d->horizontalSpacing; executed: return d->horizontalSpacing;Execution Count:3119 | 3119 |
| 1143 | } else { | - |
| 1144 | return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing); executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing);Execution Count:3137 | 3137 |
| 1145 | } | - |
| 1146 | } | - |
| 1147 | | - |
| 1148 | /*! | - |
| 1149 | \property QGridLayout::verticalSpacing | - |
| 1150 | \brief the spacing between widgets that are laid out on top of each other | - |
| 1151 | \since 4.3 | - |
| 1152 | | - |
| 1153 | If no value is explicitly set, the layout's vertical spacing is | - |
| 1154 | inherited from the parent layout, or from the style settings for | - |
| 1155 | the parent widget. | - |
| 1156 | | - |
| 1157 | \sa horizontalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing} | - |
| 1158 | */ | - |
| 1159 | void QGridLayout::setVerticalSpacing(int spacing) | - |
| 1160 | { | - |
| 1161 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1162 | d->verticalSpacing = spacing; executed (the execution status of this line is deduced): d->verticalSpacing = spacing; | - |
| 1163 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1164 | } executed: }Execution Count:15 | 15 |
| 1165 | | - |
| 1166 | int QGridLayout::verticalSpacing() const | - |
| 1167 | { | - |
| 1168 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1169 | if (d->verticalSpacing >= 0) { evaluated: d->verticalSpacing >= 0| yes Evaluation Count:3118 | yes Evaluation Count:3138 |
| 3118-3138 |
| 1170 | return d->verticalSpacing; executed: return d->verticalSpacing;Execution Count:3118 | 3118 |
| 1171 | } else { | - |
| 1172 | return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing); executed: return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing);Execution Count:3138 | 3138 |
| 1173 | } | - |
| 1174 | } | - |
| 1175 | | - |
| 1176 | /*! | - |
| 1177 | This function sets both the vertical and horizontal spacing to | - |
| 1178 | \a spacing. | - |
| 1179 | | - |
| 1180 | \sa setVerticalSpacing(), setHorizontalSpacing() | - |
| 1181 | */ | - |
| 1182 | void QGridLayout::setSpacing(int spacing) | - |
| 1183 | { | - |
| 1184 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1185 | d->horizontalSpacing = d->verticalSpacing = spacing; executed (the execution status of this line is deduced): d->horizontalSpacing = d->verticalSpacing = spacing; | - |
| 1186 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1187 | } executed: }Execution Count:121 | 121 |
| 1188 | | - |
| 1189 | /*! | - |
| 1190 | If the vertical spacing is equal to the horizontal spacing, | - |
| 1191 | this function returns that value; otherwise it return -1. | - |
| 1192 | | - |
| 1193 | \sa setSpacing(), verticalSpacing(), horizontalSpacing() | - |
| 1194 | */ | - |
| 1195 | int QGridLayout::spacing() const | - |
| 1196 | { | - |
| 1197 | int hSpacing = horizontalSpacing(); executed (the execution status of this line is deduced): int hSpacing = horizontalSpacing(); | - |
| 1198 | if (hSpacing == verticalSpacing()) { evaluated: hSpacing == verticalSpacing()| yes Evaluation Count:323 | yes Evaluation Count:3 |
| 3-323 |
| 1199 | return hSpacing; executed: return hSpacing;Execution Count:323 | 323 |
| 1200 | } else { | - |
| 1201 | return -1; executed: return -1;Execution Count:3 | 3 |
| 1202 | } | - |
| 1203 | } | - |
| 1204 | | - |
| 1205 | /*! | - |
| 1206 | Returns the number of rows in this grid. | - |
| 1207 | */ | - |
| 1208 | int QGridLayout::rowCount() const | - |
| 1209 | { | - |
| 1210 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1211 | return d->numRows(); executed: return d->numRows();Execution Count:94 | 94 |
| 1212 | } | - |
| 1213 | | - |
| 1214 | /*! | - |
| 1215 | Returns the number of columns in this grid. | - |
| 1216 | */ | - |
| 1217 | int QGridLayout::columnCount() const | - |
| 1218 | { | - |
| 1219 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1220 | return d->numCols(); executed: return d->numCols();Execution Count:94 | 94 |
| 1221 | } | - |
| 1222 | | - |
| 1223 | /*! | - |
| 1224 | \reimp | - |
| 1225 | */ | - |
| 1226 | QSize QGridLayout::sizeHint() const | - |
| 1227 | { | - |
| 1228 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1229 | QSize result(d->sizeHint(horizontalSpacing(), verticalSpacing())); executed (the execution status of this line is deduced): QSize result(d->sizeHint(horizontalSpacing(), verticalSpacing())); | - |
| 1230 | int left, top, right, bottom; executed (the execution status of this line is deduced): int left, top, right, bottom; | - |
| 1231 | d->effectiveMargins(&left, &top, &right, &bottom); executed (the execution status of this line is deduced): d->effectiveMargins(&left, &top, &right, &bottom); | - |
| 1232 | result += QSize(left + right, top + bottom); executed (the execution status of this line is deduced): result += QSize(left + right, top + bottom); | - |
| 1233 | return result; executed: return result;Execution Count:1048 | 1048 |
| 1234 | } | - |
| 1235 | | - |
| 1236 | /*! | - |
| 1237 | \reimp | - |
| 1238 | */ | - |
| 1239 | QSize QGridLayout::minimumSize() const | - |
| 1240 | { | - |
| 1241 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1242 | QSize result(d->minimumSize(horizontalSpacing(), verticalSpacing())); executed (the execution status of this line is deduced): QSize result(d->minimumSize(horizontalSpacing(), verticalSpacing())); | - |
| 1243 | int left, top, right, bottom; executed (the execution status of this line is deduced): int left, top, right, bottom; | - |
| 1244 | d->effectiveMargins(&left, &top, &right, &bottom); executed (the execution status of this line is deduced): d->effectiveMargins(&left, &top, &right, &bottom); | - |
| 1245 | result += QSize(left + right, top + bottom); executed (the execution status of this line is deduced): result += QSize(left + right, top + bottom); | - |
| 1246 | return result; executed: return result;Execution Count:1008 | 1008 |
| 1247 | } | - |
| 1248 | | - |
| 1249 | /*! | - |
| 1250 | \reimp | - |
| 1251 | */ | - |
| 1252 | QSize QGridLayout::maximumSize() const | - |
| 1253 | { | - |
| 1254 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1255 | | - |
| 1256 | QSize s = d->maximumSize(horizontalSpacing(), verticalSpacing()); executed (the execution status of this line is deduced): QSize s = d->maximumSize(horizontalSpacing(), verticalSpacing()); | - |
| 1257 | int left, top, right, bottom; executed (the execution status of this line is deduced): int left, top, right, bottom; | - |
| 1258 | d->effectiveMargins(&left, &top, &right, &bottom); executed (the execution status of this line is deduced): d->effectiveMargins(&left, &top, &right, &bottom); | - |
| 1259 | s += QSize(left + right, top + bottom); executed (the execution status of this line is deduced): s += QSize(left + right, top + bottom); | - |
| 1260 | s = s.boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX)); executed (the execution status of this line is deduced): s = s.boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX)); | - |
| 1261 | if (alignment() & Qt::AlignHorizontal_Mask) partially evaluated: alignment() & Qt::AlignHorizontal_Mask| no Evaluation Count:0 | yes Evaluation Count:499 |
| 0-499 |
| 1262 | s.setWidth(QLAYOUTSIZE_MAX); never executed: s.setWidth(QLAYOUTSIZE_MAX); | 0 |
| 1263 | if (alignment() & Qt::AlignVertical_Mask) partially evaluated: alignment() & Qt::AlignVertical_Mask| no Evaluation Count:0 | yes Evaluation Count:499 |
| 0-499 |
| 1264 | s.setHeight(QLAYOUTSIZE_MAX); never executed: s.setHeight(QLAYOUTSIZE_MAX); | 0 |
| 1265 | return s; executed: return s;Execution Count:499 | 499 |
| 1266 | } | - |
| 1267 | | - |
| 1268 | /*! | - |
| 1269 | \reimp | - |
| 1270 | */ | - |
| 1271 | bool QGridLayout::hasHeightForWidth() const | - |
| 1272 | { | - |
| 1273 | return ((QGridLayout*)this)->d_func()->hasHeightForWidth(horizontalSpacing(), verticalSpacing()); executed: return ((QGridLayout*)this)->d_func()->hasHeightForWidth(horizontalSpacing(), verticalSpacing());Execution Count:1660 | 1660 |
| 1274 | } | - |
| 1275 | | - |
| 1276 | /*! | - |
| 1277 | \reimp | - |
| 1278 | */ | - |
| 1279 | int QGridLayout::heightForWidth(int w) const | - |
| 1280 | { | - |
| 1281 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1282 | QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d); executed (the execution status of this line is deduced): QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d); | - |
| 1283 | return dat->heightForWidth(w, horizontalSpacing(), verticalSpacing()); executed: return dat->heightForWidth(w, horizontalSpacing(), verticalSpacing());Execution Count:226 | 226 |
| 1284 | } | - |
| 1285 | | - |
| 1286 | /*! | - |
| 1287 | \reimp | - |
| 1288 | */ | - |
| 1289 | int QGridLayout::minimumHeightForWidth(int w) const | - |
| 1290 | { | - |
| 1291 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1292 | QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d); executed (the execution status of this line is deduced): QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d); | - |
| 1293 | return dat->minimumHeightForWidth(w, horizontalSpacing(), verticalSpacing()); executed: return dat->minimumHeightForWidth(w, horizontalSpacing(), verticalSpacing());Execution Count:9 | 9 |
| 1294 | } | - |
| 1295 | | - |
| 1296 | /*! | - |
| 1297 | \reimp | - |
| 1298 | */ | - |
| 1299 | int QGridLayout::count() const | - |
| 1300 | { | - |
| 1301 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1302 | return d->count(); executed: return d->count();Execution Count:231 | 231 |
| 1303 | } | - |
| 1304 | | - |
| 1305 | | - |
| 1306 | /*! | - |
| 1307 | \reimp | - |
| 1308 | */ | - |
| 1309 | QLayoutItem *QGridLayout::itemAt(int index) const | - |
| 1310 | { | - |
| 1311 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1312 | return d->itemAt(index); executed: return d->itemAt(index);Execution Count:8734 | 8734 |
| 1313 | } | - |
| 1314 | | - |
| 1315 | /*! | - |
| 1316 | \since 4.4 | - |
| 1317 | | - |
| 1318 | Returns the layout item that occupies cell (\a row, \a column), or 0 if | - |
| 1319 | the cell is empty. | - |
| 1320 | | - |
| 1321 | \sa getItemPosition(), indexOf() | - |
| 1322 | */ | - |
| 1323 | QLayoutItem *QGridLayout::itemAtPosition(int row, int column) const | - |
| 1324 | { | - |
| 1325 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1326 | int n = d->things.count(); executed (the execution status of this line is deduced): int n = d->things.count(); | - |
| 1327 | for (int i = 0; i < n; ++i) { evaluated: i < n| yes Evaluation Count:67 | yes Evaluation Count:11 |
| 11-67 |
| 1328 | QGridBox *box = d->things.at(i); executed (the execution status of this line is deduced): QGridBox *box = d->things.at(i); | - |
| 1329 | if (row >= box->row && row <= box->toRow(d->rr) evaluated: row >= box->row| yes Evaluation Count:61 | yes Evaluation Count:6 |
evaluated: row <= box->toRow(d->rr)| yes Evaluation Count:25 | yes Evaluation Count:36 |
| 6-61 |
| 1330 | && column >= box->col && column <= box->toCol(d->cc)) { evaluated: column >= box->col| yes Evaluation Count:21 | yes Evaluation Count:4 |
evaluated: column <= box->toCol(d->cc)| yes Evaluation Count:9 | yes Evaluation Count:12 |
| 4-21 |
| 1331 | return box->item(); executed: return box->item();Execution Count:9 | 9 |
| 1332 | } | - |
| 1333 | } executed: }Execution Count:58 | 58 |
| 1334 | return 0; executed: return 0;Execution Count:11 | 11 |
| 1335 | } | - |
| 1336 | | - |
| 1337 | /*! | - |
| 1338 | \reimp | - |
| 1339 | */ | - |
| 1340 | QLayoutItem *QGridLayout::takeAt(int index) | - |
| 1341 | { | - |
| 1342 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1343 | return d->takeAt(index); executed: return d->takeAt(index);Execution Count:264 | 264 |
| 1344 | } | - |
| 1345 | | - |
| 1346 | /*! | - |
| 1347 | Returns the position information of the item with the given \a index. | - |
| 1348 | | - |
| 1349 | The variables passed as \a row and \a column are updated with the position of the | - |
| 1350 | item in the layout, and the \a rowSpan and \a columnSpan variables are updated | - |
| 1351 | with the vertical and horizontal spans of the item. | - |
| 1352 | | - |
| 1353 | \sa itemAtPosition(), itemAt() | - |
| 1354 | */ | - |
| 1355 | void QGridLayout::getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const | - |
| 1356 | { | - |
| 1357 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1358 | d->getItemPosition(index, row, column, rowSpan, columnSpan); executed (the execution status of this line is deduced): d->getItemPosition(index, row, column, rowSpan, columnSpan); | - |
| 1359 | } executed: }Execution Count:4 | 4 |
| 1360 | | - |
| 1361 | | - |
| 1362 | /*! | - |
| 1363 | \reimp | - |
| 1364 | */ | - |
| 1365 | void QGridLayout::setGeometry(const QRect &rect) | - |
| 1366 | { | - |
| 1367 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1368 | if (d->isDirty() || rect != geometry()) { evaluated: d->isDirty()| yes Evaluation Count:810 | yes Evaluation Count:601 |
evaluated: rect != geometry()| yes Evaluation Count:399 | yes Evaluation Count:202 |
| 202-810 |
| 1369 | QRect cr = alignment() ? alignmentRect(rect) : rect; partially evaluated: alignment()| no Evaluation Count:0 | yes Evaluation Count:1209 |
| 0-1209 |
| 1370 | d->distribute(cr, horizontalSpacing(), verticalSpacing()); executed (the execution status of this line is deduced): d->distribute(cr, horizontalSpacing(), verticalSpacing()); | - |
| 1371 | QLayout::setGeometry(rect); executed (the execution status of this line is deduced): QLayout::setGeometry(rect); | - |
| 1372 | } executed: }Execution Count:1209 | 1209 |
| 1373 | } executed: }Execution Count:1411 | 1411 |
| 1374 | | - |
| 1375 | /*! | - |
| 1376 | Returns the geometry of the cell with row \a row and column \a column | - |
| 1377 | in the grid. Returns an invalid rectangle if \a row or \a column is | - |
| 1378 | outside the grid. | - |
| 1379 | | - |
| 1380 | \warning in the current version of Qt this function does not | - |
| 1381 | return valid results until setGeometry() has been called, i.e. | - |
| 1382 | after the parentWidget() is visible. | - |
| 1383 | */ | - |
| 1384 | QRect QGridLayout::cellRect(int row, int column) const | - |
| 1385 | { | - |
| 1386 | Q_D(const QGridLayout); never executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1387 | return d->cellRect(row, column); never executed: return d->cellRect(row, column); | 0 |
| 1388 | } | - |
| 1389 | | - |
| 1390 | /*! | - |
| 1391 | \reimp | - |
| 1392 | */ | - |
| 1393 | void QGridLayout::addItem(QLayoutItem *item) | - |
| 1394 | { | - |
| 1395 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1396 | int r, c; executed (the execution status of this line is deduced): int r, c; | - |
| 1397 | d->getNextPos(r, c); executed (the execution status of this line is deduced): d->getNextPos(r, c); | - |
| 1398 | addItem(item, r, c); executed (the execution status of this line is deduced): addItem(item, r, c); | - |
| 1399 | } executed: }Execution Count:1 | 1 |
| 1400 | | - |
| 1401 | /*! | - |
| 1402 | Adds \a item at position \a row, \a column, spanning \a rowSpan | - |
| 1403 | rows and \a columnSpan columns, and aligns it according to \a | - |
| 1404 | alignment. If \a rowSpan and/or \a columnSpan is -1, then the item | - |
| 1405 | will extend to the bottom and/or right edge, respectively. The | - |
| 1406 | layout takes ownership of the \a item. | - |
| 1407 | | - |
| 1408 | \warning Do not use this function to add child layouts or child | - |
| 1409 | widget items. Use addLayout() or addWidget() instead. | - |
| 1410 | */ | - |
| 1411 | void QGridLayout::addItem(QLayoutItem *item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment) | - |
| 1412 | { | - |
| 1413 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1414 | QGridBox *b = new QGridBox(item); executed (the execution status of this line is deduced): QGridBox *b = new QGridBox(item); | - |
| 1415 | b->setAlignment(alignment); executed (the execution status of this line is deduced): b->setAlignment(alignment); | - |
| 1416 | d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1); executed (the execution status of this line is deduced): d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1); | - |
| 1417 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1418 | } executed: }Execution Count:492 | 492 |
| 1419 | | - |
| 1420 | /* | - |
| 1421 | Returns true if the widget \a w can be added to the layout \a l; | - |
| 1422 | otherwise returns false. | - |
| 1423 | */ | - |
| 1424 | static bool checkWidget(QLayout *l, QWidget *w) | - |
| 1425 | { | - |
| 1426 | if (!w) { partially evaluated: !w| no Evaluation Count:0 | yes Evaluation Count:2134 |
| 0-2134 |
| 1427 | qWarning("QLayout: Cannot add null widget to %s/%s", l->metaObject()->className(), never executed (the execution status of this line is deduced): QMessageLogger("kernel/qgridlayout.cpp", 1427, __PRETTY_FUNCTION__).warning("QLayout: Cannot add null widget to %s/%s", l->metaObject()->className(), | - |
| 1428 | l->objectName().toLocal8Bit().data()); never executed (the execution status of this line is deduced): l->objectName().toLocal8Bit().data()); | - |
| 1429 | return false; never executed: return false; | 0 |
| 1430 | } | - |
| 1431 | return true; executed: return true;Execution Count:2134 | 2134 |
| 1432 | } | - |
| 1433 | | - |
| 1434 | /*! | - |
| 1435 | Adds the given \a widget to the cell grid at \a row, \a column. The | - |
| 1436 | top-left position is (0, 0) by default. | - |
| 1437 | | - |
| 1438 | The alignment is specified by \a alignment. The default | - |
| 1439 | alignment is 0, which means that the widget fills the entire cell. | - |
| 1440 | | - |
| 1441 | */ | - |
| 1442 | void QGridLayout::addWidget(QWidget *widget, int row, int column, Qt::Alignment alignment) | - |
| 1443 | { | - |
| 1444 | if (!checkWidget(this, widget)) partially evaluated: !checkWidget(this, widget)| no Evaluation Count:0 | yes Evaluation Count:452 |
| 0-452 |
| 1445 | return; | 0 |
| 1446 | if (row < 0 || column < 0) { partially evaluated: row < 0| no Evaluation Count:0 | yes Evaluation Count:452 |
partially evaluated: column < 0| no Evaluation Count:0 | yes Evaluation Count:452 |
| 0-452 |
| 1447 | qWarning("QGridLayout: Cannot add %s/%s to %s/%s at row %d column %d", never executed (the execution status of this line is deduced): QMessageLogger("kernel/qgridlayout.cpp", 1447, __PRETTY_FUNCTION__).warning("QGridLayout: Cannot add %s/%s to %s/%s at row %d column %d", | - |
| 1448 | widget->metaObject()->className(), widget->objectName().toLocal8Bit().data(), never executed (the execution status of this line is deduced): widget->metaObject()->className(), widget->objectName().toLocal8Bit().data(), | - |
| 1449 | metaObject()->className(), objectName().toLocal8Bit().data(), row, column); never executed (the execution status of this line is deduced): metaObject()->className(), objectName().toLocal8Bit().data(), row, column); | - |
| 1450 | return; | 0 |
| 1451 | } | - |
| 1452 | addChildWidget(widget); executed (the execution status of this line is deduced): addChildWidget(widget); | - |
| 1453 | QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget); executed (the execution status of this line is deduced): QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget); | - |
| 1454 | addItem(b, row, column, 1, 1, alignment); executed (the execution status of this line is deduced): addItem(b, row, column, 1, 1, alignment); | - |
| 1455 | } executed: }Execution Count:452 | 452 |
| 1456 | | - |
| 1457 | /*! | - |
| 1458 | \overload | - |
| 1459 | | - |
| 1460 | This version adds the given \a widget to the cell grid, spanning | - |
| 1461 | multiple rows/columns. The cell will start at \a fromRow, \a | - |
| 1462 | fromColumn spanning \a rowSpan rows and \a columnSpan columns. The | - |
| 1463 | \a widget will have the given \a alignment. | - |
| 1464 | | - |
| 1465 | If \a rowSpan and/or \a columnSpan is -1, then the widget will | - |
| 1466 | extend to the bottom and/or right edge, respectively. | - |
| 1467 | | - |
| 1468 | */ | - |
| 1469 | void QGridLayout::addWidget(QWidget *widget, int fromRow, int fromColumn, | - |
| 1470 | int rowSpan, int columnSpan, Qt::Alignment alignment) | - |
| 1471 | { | - |
| 1472 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1473 | if (!checkWidget(this, widget)) partially evaluated: !checkWidget(this, widget)| no Evaluation Count:0 | yes Evaluation Count:1682 |
| 0-1682 |
| 1474 | return; | 0 |
| 1475 | int toRow = (rowSpan < 0) ? -1 : fromRow + rowSpan - 1; evaluated: (rowSpan < 0)| yes Evaluation Count:3 | yes Evaluation Count:1679 |
| 3-1679 |
| 1476 | int toColumn = (columnSpan < 0) ? -1 : fromColumn + columnSpan - 1; partially evaluated: (columnSpan < 0)| no Evaluation Count:0 | yes Evaluation Count:1682 |
| 0-1682 |
| 1477 | addChildWidget(widget); executed (the execution status of this line is deduced): addChildWidget(widget); | - |
| 1478 | QGridBox *b = new QGridBox(this, widget); executed (the execution status of this line is deduced): QGridBox *b = new QGridBox(this, widget); | - |
| 1479 | b->setAlignment(alignment); executed (the execution status of this line is deduced): b->setAlignment(alignment); | - |
| 1480 | d->add(b, fromRow, toRow, fromColumn, toColumn); executed (the execution status of this line is deduced): d->add(b, fromRow, toRow, fromColumn, toColumn); | - |
| 1481 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1482 | } executed: }Execution Count:1682 | 1682 |
| 1483 | | - |
| 1484 | /*! | - |
| 1485 | \fn void QGridLayout::addWidget(QWidget *widget) | - |
| 1486 | | - |
| 1487 | \overload | - |
| 1488 | \internal | - |
| 1489 | */ | - |
| 1490 | | - |
| 1491 | /*! | - |
| 1492 | Places the \a layout at position (\a row, \a column) in the grid. The | - |
| 1493 | top-left position is (0, 0). | - |
| 1494 | | - |
| 1495 | The alignment is specified by \a alignment. The default | - |
| 1496 | alignment is 0, which means that the widget fills the entire cell. | - |
| 1497 | | - |
| 1498 | A non-zero alignment indicates that the layout should not grow to | - |
| 1499 | fill the available space but should be sized according to | - |
| 1500 | sizeHint(). | - |
| 1501 | | - |
| 1502 | | - |
| 1503 | \a layout becomes a child of the grid layout. | - |
| 1504 | */ | - |
| 1505 | void QGridLayout::addLayout(QLayout *layout, int row, int column, Qt::Alignment alignment) | - |
| 1506 | { | - |
| 1507 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1508 | addChildLayout(layout); executed (the execution status of this line is deduced): addChildLayout(layout); | - |
| 1509 | QGridBox *b = new QGridBox(layout); executed (the execution status of this line is deduced): QGridBox *b = new QGridBox(layout); | - |
| 1510 | b->setAlignment(alignment); executed (the execution status of this line is deduced): b->setAlignment(alignment); | - |
| 1511 | d->add(b, row, column); executed (the execution status of this line is deduced): d->add(b, row, column); | - |
| 1512 | } executed: }Execution Count:1 | 1 |
| 1513 | | - |
| 1514 | /*! | - |
| 1515 | \overload | - |
| 1516 | This version adds the layout \a layout to the cell grid, spanning multiple | - |
| 1517 | rows/columns. The cell will start at \a row, \a column spanning \a | - |
| 1518 | rowSpan rows and \a columnSpan columns. | - |
| 1519 | | - |
| 1520 | If \a rowSpan and/or \a columnSpan is -1, then the layout will extend to the bottom | - |
| 1521 | and/or right edge, respectively. | - |
| 1522 | */ | - |
| 1523 | void QGridLayout::addLayout(QLayout *layout, int row, int column, | - |
| 1524 | int rowSpan, int columnSpan, Qt::Alignment alignment) | - |
| 1525 | { | - |
| 1526 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1527 | addChildLayout(layout); executed (the execution status of this line is deduced): addChildLayout(layout); | - |
| 1528 | QGridBox *b = new QGridBox(layout); executed (the execution status of this line is deduced): QGridBox *b = new QGridBox(layout); | - |
| 1529 | b->setAlignment(alignment); executed (the execution status of this line is deduced): b->setAlignment(alignment); | - |
| 1530 | d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1); executed (the execution status of this line is deduced): d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1); | - |
| 1531 | } executed: }Execution Count:285 | 285 |
| 1532 | | - |
| 1533 | /*! | - |
| 1534 | Sets the stretch factor of row \a row to \a stretch. The first row | - |
| 1535 | is number 0. | - |
| 1536 | | - |
| 1537 | The stretch factor is relative to the other rows in this grid. | - |
| 1538 | Rows with a higher stretch factor take more of the available | - |
| 1539 | space. | - |
| 1540 | | - |
| 1541 | The default stretch factor is 0. If the stretch factor is 0 and no | - |
| 1542 | other row in this table can grow at all, the row may still grow. | - |
| 1543 | | - |
| 1544 | \sa rowStretch(), setRowMinimumHeight(), setColumnStretch() | - |
| 1545 | */ | - |
| 1546 | void QGridLayout::setRowStretch(int row, int stretch) | - |
| 1547 | { | - |
| 1548 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1549 | d->setRowStretch(row, stretch); executed (the execution status of this line is deduced): d->setRowStretch(row, stretch); | - |
| 1550 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1551 | } executed: }Execution Count:23 | 23 |
| 1552 | | - |
| 1553 | /*! | - |
| 1554 | Returns the stretch factor for row \a row. | - |
| 1555 | | - |
| 1556 | \sa setRowStretch() | - |
| 1557 | */ | - |
| 1558 | int QGridLayout::rowStretch(int row) const | - |
| 1559 | { | - |
| 1560 | Q_D(const QGridLayout); never executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1561 | return d->rowStretch(row); never executed: return d->rowStretch(row); | 0 |
| 1562 | } | - |
| 1563 | | - |
| 1564 | /*! | - |
| 1565 | Returns the stretch factor for column \a column. | - |
| 1566 | | - |
| 1567 | \sa setColumnStretch() | - |
| 1568 | */ | - |
| 1569 | int QGridLayout::columnStretch(int column) const | - |
| 1570 | { | - |
| 1571 | Q_D(const QGridLayout); never executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1572 | return d->colStretch(column); never executed: return d->colStretch(column); | 0 |
| 1573 | } | - |
| 1574 | | - |
| 1575 | /*! | - |
| 1576 | Sets the stretch factor of column \a column to \a stretch. The first | - |
| 1577 | column is number 0. | - |
| 1578 | | - |
| 1579 | The stretch factor is relative to the other columns in this grid. | - |
| 1580 | Columns with a higher stretch factor take more of the available | - |
| 1581 | space. | - |
| 1582 | | - |
| 1583 | The default stretch factor is 0. If the stretch factor is 0 and no | - |
| 1584 | other column in this table can grow at all, the column may still | - |
| 1585 | grow. | - |
| 1586 | | - |
| 1587 | An alternative approach is to add spacing using addItem() with a | - |
| 1588 | QSpacerItem. | - |
| 1589 | | - |
| 1590 | \sa columnStretch(), setRowStretch() | - |
| 1591 | */ | - |
| 1592 | void QGridLayout::setColumnStretch(int column, int stretch) | - |
| 1593 | { | - |
| 1594 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1595 | d->setColStretch(column, stretch); executed (the execution status of this line is deduced): d->setColStretch(column, stretch); | - |
| 1596 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1597 | } executed: }Execution Count:34 | 34 |
| 1598 | | - |
| 1599 | | - |
| 1600 | | - |
| 1601 | /*! | - |
| 1602 | Sets the minimum height of row \a row to \a minSize pixels. | - |
| 1603 | | - |
| 1604 | \sa rowMinimumHeight(), setColumnMinimumWidth() | - |
| 1605 | */ | - |
| 1606 | void QGridLayout::setRowMinimumHeight(int row, int minSize) | - |
| 1607 | { | - |
| 1608 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1609 | d->setRowMinimumHeight(row, minSize); executed (the execution status of this line is deduced): d->setRowMinimumHeight(row, minSize); | - |
| 1610 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1611 | } executed: }Execution Count:388 | 388 |
| 1612 | | - |
| 1613 | /*! | - |
| 1614 | Returns the minimum width set for row \a row. | - |
| 1615 | | - |
| 1616 | \sa setRowMinimumHeight() | - |
| 1617 | */ | - |
| 1618 | int QGridLayout::rowMinimumHeight(int row) const | - |
| 1619 | { | - |
| 1620 | Q_D(const QGridLayout); never executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1621 | return d->rowSpacing(row); never executed: return d->rowSpacing(row); | 0 |
| 1622 | } | - |
| 1623 | | - |
| 1624 | /*! | - |
| 1625 | Sets the minimum width of column \a column to \a minSize pixels. | - |
| 1626 | | - |
| 1627 | \sa columnMinimumWidth(), setRowMinimumHeight() | - |
| 1628 | */ | - |
| 1629 | void QGridLayout::setColumnMinimumWidth(int column, int minSize) | - |
| 1630 | { | - |
| 1631 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1632 | d->setColumnMinimumWidth(column, minSize); executed (the execution status of this line is deduced): d->setColumnMinimumWidth(column, minSize); | - |
| 1633 | invalidate(); executed (the execution status of this line is deduced): invalidate(); | - |
| 1634 | } executed: }Execution Count:291 | 291 |
| 1635 | | - |
| 1636 | /*! | - |
| 1637 | Returns the column spacing for column \a column. | - |
| 1638 | | - |
| 1639 | \sa setColumnMinimumWidth() | - |
| 1640 | */ | - |
| 1641 | int QGridLayout::columnMinimumWidth(int column) const | - |
| 1642 | { | - |
| 1643 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1644 | return d->colSpacing(column); executed: return d->colSpacing(column);Execution Count:1 | 1 |
| 1645 | } | - |
| 1646 | | - |
| 1647 | /*! | - |
| 1648 | \reimp | - |
| 1649 | */ | - |
| 1650 | Qt::Orientations QGridLayout::expandingDirections() const | - |
| 1651 | { | - |
| 1652 | Q_D(const QGridLayout); executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1653 | return d->expandingDirections(horizontalSpacing(), verticalSpacing()); executed: return d->expandingDirections(horizontalSpacing(), verticalSpacing());Execution Count:267 | 267 |
| 1654 | } | - |
| 1655 | | - |
| 1656 | /*! | - |
| 1657 | Sets the grid's origin corner, i.e. position (0, 0), to \a corner. | - |
| 1658 | */ | - |
| 1659 | void QGridLayout::setOriginCorner(Qt::Corner corner) | - |
| 1660 | { | - |
| 1661 | Q_D(QGridLayout); never executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1662 | d->setReversed(corner == Qt::BottomLeftCorner || corner == Qt::BottomRightCorner, never executed (the execution status of this line is deduced): d->setReversed(corner == Qt::BottomLeftCorner || corner == Qt::BottomRightCorner, | - |
| 1663 | corner == Qt::TopRightCorner || corner == Qt::BottomRightCorner); never executed (the execution status of this line is deduced): corner == Qt::TopRightCorner || corner == Qt::BottomRightCorner); | - |
| 1664 | } | 0 |
| 1665 | | - |
| 1666 | /*! | - |
| 1667 | Returns the corner that's used for the grid's origin, i.e. for | - |
| 1668 | position (0, 0). | - |
| 1669 | */ | - |
| 1670 | Qt::Corner QGridLayout::originCorner() const | - |
| 1671 | { | - |
| 1672 | Q_D(const QGridLayout); never executed (the execution status of this line is deduced): const QGridLayoutPrivate * const d = d_func(); | - |
| 1673 | if (d->horReversed()) { never evaluated: d->horReversed() | 0 |
| 1674 | return d->verReversed() ? Qt::BottomRightCorner : Qt::TopRightCorner; never executed: return d->verReversed() ? Qt::BottomRightCorner : Qt::TopRightCorner; | 0 |
| 1675 | } else { | - |
| 1676 | return d->verReversed() ? Qt::BottomLeftCorner : Qt::TopLeftCorner; never executed: return d->verReversed() ? Qt::BottomLeftCorner : Qt::TopLeftCorner; | 0 |
| 1677 | } | - |
| 1678 | } | - |
| 1679 | | - |
| 1680 | /*! | - |
| 1681 | \reimp | - |
| 1682 | */ | - |
| 1683 | void QGridLayout::invalidate() | - |
| 1684 | { | - |
| 1685 | Q_D(QGridLayout); executed (the execution status of this line is deduced): QGridLayoutPrivate * const d = d_func(); | - |
| 1686 | d->setDirty(); executed (the execution status of this line is deduced): d->setDirty(); | - |
| 1687 | QLayout::invalidate(); executed (the execution status of this line is deduced): QLayout::invalidate(); | - |
| 1688 | } executed: }Execution Count:20877 | 20877 |
| 1689 | | - |
| 1690 | QT_END_NAMESPACE | - |
| 1691 | | - |
| | |