graphicsview/qgraphicsgridlayout.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
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/*! -
43 \class QGraphicsGridLayout -
44 \brief The QGraphicsGridLayout class provides a grid layout for managing -
45 widgets in Graphics View. -
46 \since 4.4 -
47 -
48 \ingroup graphicsview-api -
49 \inmodule QtWidgets -
50 -
51 The most common way to use QGraphicsGridLayout is to construct an object -
52 on the heap with no parent, add widgets and layouts by calling addItem(), -
53 and finally assign the layout to a widget by calling -
54 QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes -
55 the dimensions of the grid as you add items. -
56 -
57 \snippet code/src_gui_graphicsview_qgraphicsgridlayout.cpp 0 -
58 -
59 The layout takes ownership of the items. In some cases when the layout -
60 item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a -
61 ambiguity in ownership because the layout item belongs to two ownership hierarchies. -
62 See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle -
63 this. -
64 You can access each item in the layout by calling count() and itemAt(). Calling -
65 removeAt() will remove an item from the layout, without -
66 destroying it. -
67 -
68 \section1 Size Hints and Size Policies in QGraphicsGridLayout -
69 -
70 QGraphicsGridLayout respects each item's size hints and size policies, -
71 and when a cell in the grid has more space than the items can fill, each item -
72 is arranged according to the layout's alignment for that item. You can set -
73 an alignment for each item by calling setAlignment(), and check the -
74 alignment for any item by calling alignment(). You can also set the alignment -
75 for an entire row or column by calling setRowAlignment() and setColumnAlignment() -
76 respectively. By default, items are aligned to the top left. -
77 -
78 -
79 \sa QGraphicsLinearLayout, QGraphicsWidget -
80*/ -
81 -
82#include "qglobal.h" -
83 -
84#ifndef QT_NO_GRAPHICSVIEW -
85 -
86#include "qapplication.h" -
87#include "qwidget.h" -
88#include "qgraphicslayout_p.h" -
89#include "qgraphicslayoutitem.h" -
90#include "qgraphicsgridlayout.h" -
91#include "qgraphicswidget.h" -
92#include "qgridlayoutengine_p.h" -
93#include <QtCore/qdebug.h> -
94 -
95QT_BEGIN_NAMESPACE -
96 -
97class QGraphicsGridLayoutPrivate : public QGraphicsLayoutPrivate -
98{ -
99public: -
100 QGraphicsGridLayoutPrivate() { } -
101 QLayoutStyleInfo styleInfo() const; -
102 -
103 QGridLayoutEngine engine; -
104#ifdef QT_DEBUG -
105 void dump(int indent) const; -
106#endif -
107}; -
108 -
109Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget);
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:770
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:769
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-770
110 -
111QLayoutStyleInfo QGraphicsGridLayoutPrivate::styleInfo() const -
112{ -
113 QGraphicsItem *item = parentItem();
executed (the execution status of this line is deduced): QGraphicsItem *item = parentItem();
-
114 QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style();
evaluated: item
TRUEFALSE
yes
Evaluation Count:645
yes
Evaluation Count:125
partially evaluated: item->isWidget()
TRUEFALSE
yes
Evaluation Count:645
no
Evaluation Count:0
0-645
115 return QLayoutStyleInfo(style, globalStyleInfoWidget());
executed: return QLayoutStyleInfo(style, globalStyleInfoWidget());
Execution Count:770
770
116} -
117 -
118/*! -
119 Constructs a QGraphicsGridLayout instance. \a parent is passed to -
120 QGraphicsLayout's constructor. -
121*/ -
122QGraphicsGridLayout::QGraphicsGridLayout(QGraphicsLayoutItem *parent) -
123 : QGraphicsLayout(*new QGraphicsGridLayoutPrivate(), parent) -
124{ -
125}
executed: }
Execution Count:265
265
126 -
127/*! -
128 Destroys the QGraphicsGridLayout object. -
129*/ -
130QGraphicsGridLayout::~QGraphicsGridLayout() -
131{ -
132 for (int i = count() - 1; i >= 0; --i) {
evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:476
yes
Evaluation Count:213
213-476
133 QGraphicsLayoutItem *item = itemAt(i);
executed (the execution status of this line is deduced): QGraphicsLayoutItem *item = itemAt(i);
-
134 // The following lines can be removed, but this removes the item -
135 // from the layout more efficiently than the implementation of -
136 // ~QGraphicsLayoutItem. -
137 removeAt(i);
executed (the execution status of this line is deduced): removeAt(i);
-
138 if (item) {
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:476
no
Evaluation Count:0
0-476
139 item->setParentLayoutItem(0);
executed (the execution status of this line is deduced): item->setParentLayoutItem(0);
-
140 if (item->ownedByLayout())
evaluated: item->ownedByLayout()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:475
1-475
141 delete item;
executed: delete item;
Execution Count:1
1
142 }
executed: }
Execution Count:476
476
143 }
executed: }
Execution Count:476
476
144}
executed: }
Execution Count:213
213
145 -
146/*! -
147 Adds \a item to the grid on \a row and \a column. You can specify a -
148 \a rowSpan and \a columnSpan and an optional \a alignment. -
149*/ -
150void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column, -
151 int rowSpan, int columnSpan, Qt::Alignment alignment) -
152{ -
153 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
154 if (row < 0 || column < 0) {
evaluated: row < 0
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:783
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:756
27-783
155 qWarning("QGraphicsGridLayout::addItem: invalid row/column: %d",
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 155, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::addItem: invalid row/column: %d",
-
156 row < 0 ? row : column);
executed (the execution status of this line is deduced): row < 0 ? row : column);
-
157 return;
executed: return;
Execution Count:54
54
158 } -
159 if (columnSpan < 1 || rowSpan < 1) {
evaluated: columnSpan < 1
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:719
evaluated: rowSpan < 1
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:707
12-719
160 qWarning("QGraphicsGridLayout::addItem: invalid row span/column span: %d",
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 160, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::addItem: invalid row span/column span: %d",
-
161 rowSpan < 1 ? rowSpan : columnSpan);
executed (the execution status of this line is deduced): rowSpan < 1 ? rowSpan : columnSpan);
-
162 return;
executed: return;
Execution Count:49
49
163 } -
164 if (!item) {
evaluated: !item
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:706
1-706
165 qWarning("QGraphicsGridLayout::addItem: cannot add null item");
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 165, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::addItem: cannot add null item");
-
166 return;
executed: return;
Execution Count:1
1
167 } -
168 if (item == this) {
evaluated: item == this
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:705
1-705
169 qWarning("QGraphicsGridLayout::addItem: cannot insert itself");
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 169, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::addItem: cannot insert itself");
-
170 return;
executed: return;
Execution Count:1
1
171 } -
172 -
173 d->addChildLayoutItem(item);
executed (the execution status of this line is deduced): d->addChildLayoutItem(item);
-
174 -
175 new QGridLayoutItem(&d->engine, item, row, column, rowSpan, columnSpan, alignment);
executed (the execution status of this line is deduced): new QGridLayoutItem(&d->engine, item, row, column, rowSpan, columnSpan, alignment);
-
176 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
177}
executed: }
Execution Count:705
705
178 -
179/*! -
180 \fn QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = 0) -
181 -
182 Adds \a item to the grid on \a row and \a column. You can specify -
183 an optional \a alignment for \a item. -
184*/ -
185 -
186/*! -
187 Sets the default horizontal spacing for the grid layout to \a spacing. -
188*/ -
189void QGraphicsGridLayout::setHorizontalSpacing(qreal spacing) -
190{ -
191 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
192 d->engine.setSpacing(spacing, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setSpacing(spacing, Qt::Horizontal);
-
193 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
194}
executed: }
Execution Count:3
3
195 -
196/*! -
197 Returns the default horizontal spacing for the grid layout. -
198*/ -
199qreal QGraphicsGridLayout::horizontalSpacing() const -
200{ -
201 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
202 return d->engine.spacing(d->styleInfo(), Qt::Horizontal);
executed: return d->engine.spacing(d->styleInfo(), Qt::Horizontal);
Execution Count:8
8
203} -
204 -
205/*! -
206 Sets the default vertical spacing for the grid layout to \a spacing. -
207*/ -
208void QGraphicsGridLayout::setVerticalSpacing(qreal spacing) -
209{ -
210 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
211 d->engine.setSpacing(spacing, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setSpacing(spacing, Qt::Vertical);
-
212 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
213}
executed: }
Execution Count:3
3
214 -
215/*! -
216 Returns the default vertical spacing for the grid layout. -
217*/ -
218qreal QGraphicsGridLayout::verticalSpacing() const -
219{ -
220 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
221 return d->engine.spacing(d->styleInfo(), Qt::Vertical);
executed: return d->engine.spacing(d->styleInfo(), Qt::Vertical);
Execution Count:7
7
222} -
223 -
224/*! -
225 Sets the grid layout's default spacing, both vertical and -
226 horizontal, to \a spacing. -
227 -
228 \sa rowSpacing(), columnSpacing() -
229*/ -
230void QGraphicsGridLayout::setSpacing(qreal spacing) -
231{ -
232 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
233 d->engine.setSpacing(spacing, Qt::Horizontal | Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setSpacing(spacing, Qt::Horizontal | Qt::Vertical);
-
234 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
235}
executed: }
Execution Count:135
135
236 -
237/*! -
238 Sets the spacing for \a row to \a spacing. -
239*/ -
240void QGraphicsGridLayout::setRowSpacing(int row, qreal spacing) -
241{ -
242 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
243 d->engine.setRowSpacing(row, spacing, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowSpacing(row, spacing, Qt::Vertical);
-
244 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
245}
executed: }
Execution Count:7
7
246 -
247/*! -
248 Returns the row spacing for \a row. -
249*/ -
250qreal QGraphicsGridLayout::rowSpacing(int row) const -
251{ -
252 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
253 return d->engine.rowSpacing(row, Qt::Vertical);
executed: return d->engine.rowSpacing(row, Qt::Vertical);
Execution Count:5
5
254} -
255 -
256/*! -
257 Sets the spacing for \a column to \a spacing. -
258*/ -
259void QGraphicsGridLayout::setColumnSpacing(int column, qreal spacing) -
260{ -
261 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
262 d->engine.setRowSpacing(column, spacing, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowSpacing(column, spacing, Qt::Horizontal);
-
263 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
264}
executed: }
Execution Count:13
13
265 -
266/*! -
267 Returns the column spacing for \a column. -
268*/ -
269qreal QGraphicsGridLayout::columnSpacing(int column) const -
270{ -
271 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
272 return d->engine.rowSpacing(column, Qt::Horizontal);
executed: return d->engine.rowSpacing(column, Qt::Horizontal);
Execution Count:7
7
273} -
274 -
275/*! -
276 Sets the stretch factor for \a row to \a stretch. -
277*/ -
278void QGraphicsGridLayout::setRowStretchFactor(int row, int stretch) -
279{ -
280 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
281 d->engine.setRowStretchFactor(row, stretch, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowStretchFactor(row, stretch, Qt::Vertical);
-
282 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
283}
executed: }
Execution Count:7
7
284 -
285/*! -
286 Returns the stretch factor for \a row. -
287*/ -
288int QGraphicsGridLayout::rowStretchFactor(int row) const -
289{ -
290 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
291 return d->engine.rowStretchFactor(row, Qt::Vertical);
executed: return d->engine.rowStretchFactor(row, Qt::Vertical);
Execution Count:1
1
292} -
293 -
294/*! -
295 Sets the stretch factor for \a column to \a stretch. -
296*/ -
297void QGraphicsGridLayout::setColumnStretchFactor(int column, int stretch) -
298{ -
299 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
300 d->engine.setRowStretchFactor(column, stretch, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowStretchFactor(column, stretch, Qt::Horizontal);
-
301 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
302}
executed: }
Execution Count:5
5
303 -
304/*! -
305 Returns the stretch factor for \a column. -
306*/ -
307int QGraphicsGridLayout::columnStretchFactor(int column) const -
308{ -
309 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
310 return d->engine.rowStretchFactor(column, Qt::Horizontal);
executed: return d->engine.rowStretchFactor(column, Qt::Horizontal);
Execution Count:1
1
311} -
312 -
313/*! -
314 Sets the minimum height for row, \a row, to \a height. -
315*/ -
316void QGraphicsGridLayout::setRowMinimumHeight(int row, qreal height) -
317{ -
318 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
319 d->engine.setRowSizeHint(Qt::MinimumSize, row, height, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MinimumSize, row, height, Qt::Vertical);
-
320 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
321}
executed: }
Execution Count:13
13
322 -
323/*! -
324 Returns the minimum height for row, \a row. -
325*/ -
326qreal QGraphicsGridLayout::rowMinimumHeight(int row) const -
327{ -
328 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
329 return d->engine.rowSizeHint(Qt::MinimumSize, row, Qt::Vertical);
executed: return d->engine.rowSizeHint(Qt::MinimumSize, row, Qt::Vertical);
Execution Count:11
11
330} -
331 -
332/*! -
333 Sets the preferred height for row, \a row, to \a height. -
334*/ -
335void QGraphicsGridLayout::setRowPreferredHeight(int row, qreal height) -
336{ -
337 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
338 d->engine.setRowSizeHint(Qt::PreferredSize, row, height, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::PreferredSize, row, height, Qt::Vertical);
-
339 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
340}
executed: }
Execution Count:5
5
341 -
342/*! -
343 Returns the preferred height for row, \a row. -
344*/ -
345qreal QGraphicsGridLayout::rowPreferredHeight(int row) const -
346{ -
347 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
348 return d->engine.rowSizeHint(Qt::PreferredSize, row, Qt::Vertical);
executed: return d->engine.rowSizeHint(Qt::PreferredSize, row, Qt::Vertical);
Execution Count:11
11
349} -
350 -
351/*! -
352 Sets the maximum height for row, \a row, to \a height. -
353*/ -
354void QGraphicsGridLayout::setRowMaximumHeight(int row, qreal height) -
355{ -
356 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
357 d->engine.setRowSizeHint(Qt::MaximumSize, row, height, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MaximumSize, row, height, Qt::Vertical);
-
358 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
359}
executed: }
Execution Count:5
5
360 -
361/*! -
362 Returns the maximum height for row, \a row. -
363*/ -
364qreal QGraphicsGridLayout::rowMaximumHeight(int row) const -
365{ -
366 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
367 return d->engine.rowSizeHint(Qt::MaximumSize, row, Qt::Vertical);
executed: return d->engine.rowSizeHint(Qt::MaximumSize, row, Qt::Vertical);
Execution Count:11
11
368} -
369 -
370/*! -
371 Sets the fixed height for row, \a row, to \a height. -
372*/ -
373void QGraphicsGridLayout::setRowFixedHeight(int row, qreal height) -
374{ -
375 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
376 d->engine.setRowSizeHint(Qt::MinimumSize, row, height, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MinimumSize, row, height, Qt::Vertical);
-
377 d->engine.setRowSizeHint(Qt::MaximumSize, row, height, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MaximumSize, row, height, Qt::Vertical);
-
378 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
379}
executed: }
Execution Count:3
3
380 -
381/*! -
382 Sets the minimum width for \a column to \a width. -
383*/ -
384void QGraphicsGridLayout::setColumnMinimumWidth(int column, qreal width) -
385{ -
386 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
387 d->engine.setRowSizeHint(Qt::MinimumSize, column, width, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MinimumSize, column, width, Qt::Horizontal);
-
388 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
389}
executed: }
Execution Count:23
23
390 -
391/*! -
392 Returns the minimum width for \a column. -
393*/ -
394qreal QGraphicsGridLayout::columnMinimumWidth(int column) const -
395{ -
396 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
397 return d->engine.rowSizeHint(Qt::MinimumSize, column, Qt::Horizontal);
executed: return d->engine.rowSizeHint(Qt::MinimumSize, column, Qt::Horizontal);
Execution Count:11
11
398} -
399 -
400/*! -
401 Sets the preferred width for \a column to \a width. -
402*/ -
403void QGraphicsGridLayout::setColumnPreferredWidth(int column, qreal width) -
404{ -
405 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
406 d->engine.setRowSizeHint(Qt::PreferredSize, column, width, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::PreferredSize, column, width, Qt::Horizontal);
-
407 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
408}
executed: }
Execution Count:5
5
409 -
410/*! -
411 Returns the preferred width for \a column. -
412*/ -
413qreal QGraphicsGridLayout::columnPreferredWidth(int column) const -
414{ -
415 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
416 return d->engine.rowSizeHint(Qt::PreferredSize, column, Qt::Horizontal);
executed: return d->engine.rowSizeHint(Qt::PreferredSize, column, Qt::Horizontal);
Execution Count:11
11
417} -
418 -
419/*! -
420 Sets the maximum width of \a column to \a width. -
421*/ -
422void QGraphicsGridLayout::setColumnMaximumWidth(int column, qreal width) -
423{ -
424 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
425 d->engine.setRowSizeHint(Qt::MaximumSize, column, width, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MaximumSize, column, width, Qt::Horizontal);
-
426 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
427}
executed: }
Execution Count:5
5
428 -
429/*! -
430 Returns the maximum width for \a column. -
431*/ -
432qreal QGraphicsGridLayout::columnMaximumWidth(int column) const -
433{ -
434 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
435 return d->engine.rowSizeHint(Qt::MaximumSize, column, Qt::Horizontal);
executed: return d->engine.rowSizeHint(Qt::MaximumSize, column, Qt::Horizontal);
Execution Count:11
11
436} -
437 -
438/*! -
439 Sets the fixed width of \a column to \a width. -
440*/ -
441void QGraphicsGridLayout::setColumnFixedWidth(int column, qreal width) -
442{ -
443 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
444 d->engine.setRowSizeHint(Qt::MinimumSize, column, width, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MinimumSize, column, width, Qt::Horizontal);
-
445 d->engine.setRowSizeHint(Qt::MaximumSize, column, width, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowSizeHint(Qt::MaximumSize, column, width, Qt::Horizontal);
-
446 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
447}
executed: }
Execution Count:3
3
448 -
449/*! -
450 Sets the alignment of \a row to \a alignment. -
451*/ -
452void QGraphicsGridLayout::setRowAlignment(int row, Qt::Alignment alignment) -
453{ -
454 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
455 d->engine.setRowAlignment(row, alignment, Qt::Vertical);
executed (the execution status of this line is deduced): d->engine.setRowAlignment(row, alignment, Qt::Vertical);
-
456 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
457}
executed: }
Execution Count:7
7
458 -
459/*! -
460 Returns the alignment of \a row. -
461*/ -
462Qt::Alignment QGraphicsGridLayout::rowAlignment(int row) const -
463{ -
464 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
465 return d->engine.rowAlignment(row, Qt::Vertical);
executed: return d->engine.rowAlignment(row, Qt::Vertical);
Execution Count:13
13
466} -
467 -
468/*! -
469 Sets the alignment for \a column to \a alignment. -
470*/ -
471void QGraphicsGridLayout::setColumnAlignment(int column, Qt::Alignment alignment) -
472{ -
473 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
474 d->engine.setRowAlignment(column, alignment, Qt::Horizontal);
executed (the execution status of this line is deduced): d->engine.setRowAlignment(column, alignment, Qt::Horizontal);
-
475 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
476}
executed: }
Execution Count:9
9
477 -
478/*! -
479 Returns the alignment for \a column. -
480*/ -
481Qt::Alignment QGraphicsGridLayout::columnAlignment(int column) const -
482{ -
483 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
484 return d->engine.rowAlignment(column, Qt::Horizontal);
executed: return d->engine.rowAlignment(column, Qt::Horizontal);
Execution Count:7
7
485} -
486 -
487/*! -
488 Sets the alignment for \a item to \a alignment. -
489*/ -
490void QGraphicsGridLayout::setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -
491{ -
492 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
493 d->engine.setAlignment(item, alignment);
executed (the execution status of this line is deduced): d->engine.setAlignment(item, alignment);
-
494 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
495}
executed: }
Execution Count:232
232
496 -
497/*! -
498 Returns the alignment for \a item. -
499*/ -
500Qt::Alignment QGraphicsGridLayout::alignment(QGraphicsLayoutItem *item) const -
501{ -
502 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
503 return d->engine.alignment(item);
executed: return d->engine.alignment(item);
Execution Count:7
7
504} -
505 -
506/*! -
507 Returns the number of rows in the grid layout. This is always one more -
508 than the index of the last row that is occupied by a layout item (empty -
509 rows are counted except for those at the end). -
510*/ -
511int QGraphicsGridLayout::rowCount() const -
512{ -
513 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
514 return d->engine.effectiveLastRow(Qt::Vertical) + 1;
executed: return d->engine.effectiveLastRow(Qt::Vertical) + 1;
Execution Count:288
288
515} -
516 -
517/*! -
518 Returns the number of columns in the grid layout. This is always one more -
519 than the index of the last column that is occupied by a layout item (empty -
520 columns are counted except for those at the end). -
521*/ -
522int QGraphicsGridLayout::columnCount() const -
523{ -
524 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
525 return d->engine.effectiveLastRow(Qt::Horizontal) + 1;
executed: return d->engine.effectiveLastRow(Qt::Horizontal) + 1;
Execution Count:311
311
526} -
527 -
528/*! -
529 Returns a pointer to the layout item at (\a row, \a column). -
530*/ -
531QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int row, int column) const -
532{ -
533 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
534 if (row < 0 || row >= rowCount() || column < 0 || column >= columnCount()) {
partially evaluated: row < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:283
evaluated: row >= rowCount()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:282
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:282
partially evaluated: column >= columnCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:282
0-283
535 qWarning("QGraphicsGridLayout::itemAt: invalid row, column %d, %d", row, column);
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 535, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::itemAt: invalid row, column %d, %d", row, column);
-
536 return 0;
executed: return 0;
Execution Count:1
1
537 } -
538 if (QGridLayoutItem *item = d->engine.itemAt(row, column))
evaluated: QGridLayoutItem *item = d->engine.itemAt(row, column)
TRUEFALSE
yes
Evaluation Count:280
yes
Evaluation Count:2
2-280
539 return item->layoutItem();
executed: return item->layoutItem();
Execution Count:280
280
540 return 0;
executed: return 0;
Execution Count:2
2
541} -
542 -
543/*! -
544 Returns the number of layout items in this grid layout. -
545*/ -
546int QGraphicsGridLayout::count() const -
547{ -
548 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
549 return d->engine.itemCount();
executed: return d->engine.itemCount();
Execution Count:524
524
550} -
551 -
552/*! -
553 Returns the layout item at \a index, or 0 if there is no layout item at -
554 this index. -
555*/ -
556QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int index) const -
557{ -
558 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
559 if (index < 0 || index >= d->engine.itemCount()) {
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1260
evaluated: index >= d->engine.itemCount()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1257
2-1260
560 qWarning("QGraphicsGridLayout::itemAt: invalid index %d", index);
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 560, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::itemAt: invalid index %d", index);
-
561 return 0;
executed: return 0;
Execution Count:5
5
562 } -
563 QGraphicsLayoutItem *item = 0;
executed (the execution status of this line is deduced): QGraphicsLayoutItem *item = 0;
-
564 if (QGridLayoutItem *gridItem = d->engine.itemAt(index))
partially evaluated: QGridLayoutItem *gridItem = d->engine.itemAt(index)
TRUEFALSE
yes
Evaluation Count:1257
no
Evaluation Count:0
0-1257
565 item = gridItem->layoutItem();
executed: item = gridItem->layoutItem();
Execution Count:1257
1257
566 return item;
executed: return item;
Execution Count:1257
1257
567} -
568 -
569/*! -
570 Removes the layout item at \a index without destroying it. Ownership of -
571 the item is transferred to the caller. -
572 -
573 \sa addItem() -
574*/ -
575void QGraphicsGridLayout::removeAt(int index) -
576{ -
577 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
578 if (index < 0 || index >= d->engine.itemCount()) {
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:507
evaluated: index >= d->engine.itemCount()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:505
2-507
579 qWarning("QGraphicsGridLayout::removeAt: invalid index %d", index);
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsgridlayout.cpp", 579, __PRETTY_FUNCTION__).warning("QGraphicsGridLayout::removeAt: invalid index %d", index);
-
580 return;
executed: return;
Execution Count:4
4
581 } -
582 if (QGridLayoutItem *gridItem = d->engine.itemAt(index)) {
partially evaluated: QGridLayoutItem *gridItem = d->engine.itemAt(index)
TRUEFALSE
yes
Evaluation Count:505
no
Evaluation Count:0
0-505
583 if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
partially evaluated: QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()
TRUEFALSE
yes
Evaluation Count:505
no
Evaluation Count:0
0-505
584 layoutItem->setParentLayoutItem(0);
executed: layoutItem->setParentLayoutItem(0);
Execution Count:505
505
585 d->engine.removeItem(gridItem);
executed (the execution status of this line is deduced): d->engine.removeItem(gridItem);
-
586 -
587 // recalculate rowInfo.count if we remove an item that is on the right/bottommost row -
588 for (int j = 0; j < NOrientations; ++j) {
evaluated: j < NOrientations
TRUEFALSE
yes
Evaluation Count:1010
yes
Evaluation Count:505
505-1010
589 // 0: Hor, 1: Ver -
590 const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical);
evaluated: j == 0
TRUEFALSE
yes
Evaluation Count:505
yes
Evaluation Count:505
505
591 const int oldCount = d->engine.rowCount(orient);
executed (the execution status of this line is deduced): const int oldCount = d->engine.rowCount(orient);
-
592 if (gridItem->lastRow(orient) == oldCount - 1) {
evaluated: gridItem->lastRow(orient) == oldCount - 1
TRUEFALSE
yes
Evaluation Count:839
yes
Evaluation Count:171
171-839
593 const int newCount = d->engine.effectiveLastRow(orient) + 1;
executed (the execution status of this line is deduced): const int newCount = d->engine.effectiveLastRow(orient) + 1;
-
594 d->engine.removeRows(newCount, oldCount - newCount, orient);
executed (the execution status of this line is deduced): d->engine.removeRows(newCount, oldCount - newCount, orient);
-
595 }
executed: }
Execution Count:839
839
596 }
executed: }
Execution Count:1010
1010
597 -
598 delete gridItem;
executed (the execution status of this line is deduced): delete gridItem;
-
599 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
600 }
executed: }
Execution Count:505
505
601}
executed: }
Execution Count:505
505
602 -
603/*! -
604 Removes the layout item \a item without destroying it. -
605 Ownership of the item is transferred to the caller. -
606 -
607 \sa addItem() -
608*/ -
609void QGraphicsGridLayout::removeItem(QGraphicsLayoutItem *item) -
610{ -
611 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
612 int index = d->engine.indexOf(item);
executed (the execution status of this line is deduced): int index = d->engine.indexOf(item);
-
613 removeAt(index);
executed (the execution status of this line is deduced): removeAt(index);
-
614}
executed: }
Execution Count:4
4
615/*! -
616 \reimp -
617*/ -
618void QGraphicsGridLayout::invalidate() -
619{ -
620 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
621 d->engine.invalidate();
executed (the execution status of this line is deduced): d->engine.invalidate();
-
622 QGraphicsLayout::invalidate();
executed (the execution status of this line is deduced): QGraphicsLayout::invalidate();
-
623}
executed: }
Execution Count:2052
2052
624 -
625#ifdef QT_DEBUG -
626void QGraphicsGridLayoutPrivate::dump(int indent) const -
627{ -
628 if (qt_graphicsLayoutDebug()) { -
629 engine.dump(indent + 1); -
630 } -
631} -
632#endif -
633 -
634/*! -
635 Sets the bounding geometry of the grid layout to \a rect. -
636*/ -
637void QGraphicsGridLayout::setGeometry(const QRectF &rect) -
638{ -
639 Q_D(QGraphicsGridLayout);
executed (the execution status of this line is deduced): QGraphicsGridLayoutPrivate * const d = d_func();
-
640 QGraphicsLayout::setGeometry(rect);
executed (the execution status of this line is deduced): QGraphicsLayout::setGeometry(rect);
-
641 QRectF effectiveRect = geometry();
executed (the execution status of this line is deduced): QRectF effectiveRect = geometry();
-
642 qreal left, top, right, bottom;
executed (the execution status of this line is deduced): qreal left, top, right, bottom;
-
643 getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): getContentsMargins(&left, &top, &right, &bottom);
-
644 Qt::LayoutDirection visualDir = d->visualDirection();
executed (the execution status of this line is deduced): Qt::LayoutDirection visualDir = d->visualDirection();
-
645 d->engine.setVisualDirection(visualDir);
executed (the execution status of this line is deduced): d->engine.setVisualDirection(visualDir);
-
646 if (visualDir == Qt::RightToLeft)
evaluated: visualDir == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:171
2-171
647 qSwap(left, right);
executed: qSwap(left, right);
Execution Count:2
2
648 effectiveRect.adjust(+left, +top, -right, -bottom);
executed (the execution status of this line is deduced): effectiveRect.adjust(+left, +top, -right, -bottom);
-
649 d->engine.setGeometries(d->styleInfo(), effectiveRect);
executed (the execution status of this line is deduced): d->engine.setGeometries(d->styleInfo(), effectiveRect);
-
650#ifdef QT_DEBUG -
651 if (qt_graphicsLayoutDebug()) { -
652 static int counter = 0; -
653 qDebug("==== BEGIN DUMP OF QGraphicsGridLayout (%d)====", counter++); -
654 d->dump(1); -
655 qDebug("==== END DUMP OF QGraphicsGridLayout ===="); -
656 } -
657#endif -
658}
executed: }
Execution Count:173
173
659 -
660/*! -
661 \reimp -
662*/ -
663QSizeF QGraphicsGridLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -
664{ -
665 Q_D(const QGraphicsGridLayout);
executed (the execution status of this line is deduced): const QGraphicsGridLayoutPrivate * const d = d_func();
-
666 qreal left, top, right, bottom;
executed (the execution status of this line is deduced): qreal left, top, right, bottom;
-
667 getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): getContentsMargins(&left, &top, &right, &bottom);
-
668 const QSizeF extraMargins(left + right, top + bottom);
executed (the execution status of this line is deduced): const QSizeF extraMargins(left + right, top + bottom);
-
669 return d->engine.sizeHint(d->styleInfo(), which , constraint - extraMargins) + extraMargins;
executed: return d->engine.sizeHint(d->styleInfo(), which , constraint - extraMargins) + extraMargins;
Execution Count:582
582
670} -
671 -
672 -
673#if 0 -
674// ### kill? (implement and kill?) -
675QRect QGraphicsGridLayout::cellRect(int row, int column, int rowSpan, int columnSpan) const -
676{ -
677 Q_D(const QGraphicsGridLayout); -
678 return QRect(); -
679// return d->engine.cellRect(parentLayoutable(), contentsGeometry(), row, column, rowSpan, columnSpan); -
680} -
681 -
682QSizePolicy::ControlTypes QGraphicsGridLayout::controlTypes(LayoutSide side) const -
683{ -
684 Q_D(const QGraphicsGridLayout); -
685 return d->engine.controlTypes(side); -
686} -
687#endif -
688 -
689QT_END_NAMESPACE -
690 -
691#endif //QT_NO_GRAPHICSVIEW -
692 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial