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