| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qformlayout.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 | #include "qapplication.h" | - | ||||||||||||||||||||||||||||||
| 35 | #include "qdebug.h" | - | ||||||||||||||||||||||||||||||
| 36 | #include "qformlayout.h" | - | ||||||||||||||||||||||||||||||
| 37 | #include "qlabel.h" | - | ||||||||||||||||||||||||||||||
| 38 | #include "qlayout_p.h" | - | ||||||||||||||||||||||||||||||
| 39 | #include "qlayoutengine_p.h" | - | ||||||||||||||||||||||||||||||
| 40 | #include "qrect.h" | - | ||||||||||||||||||||||||||||||
| 41 | #include "qvector.h" | - | ||||||||||||||||||||||||||||||
| 42 | #include "qwidget.h" | - | ||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||
| 44 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||||||||
| 46 | namespace { | - | ||||||||||||||||||||||||||||||
| 47 | // Fixed column matrix, stores items as [i11, i12, i21, i22...], | - | ||||||||||||||||||||||||||||||
| 48 | // with FORTRAN-style index operator(r, c). | - | ||||||||||||||||||||||||||||||
| 49 | template <class T, int NumColumns> | - | ||||||||||||||||||||||||||||||
| 50 | class FixedColumnMatrix { | - | ||||||||||||||||||||||||||||||
| 51 | public: | - | ||||||||||||||||||||||||||||||
| 52 | typedef QVector<T> Storage; | - | ||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||
| 54 | FixedColumnMatrix() { } | - | ||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||
| 56 | void clear() { m_storage.clear(); } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 | const T &operator()(int r, int c) const { return m_storage[r * NumColumns + c]; } never executed: return m_storage[r * NumColumns + c]; | 0 | ||||||||||||||||||||||||||||||
| 59 | T &operator()(int r, int c) { return m_storage[r * NumColumns + c]; } never executed: return m_storage[r * NumColumns + c]; | 0 | ||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | int rowCount() const { return m_storage.size() / NumColumns; } never executed: return m_storage.size() / NumColumns; | 0 | ||||||||||||||||||||||||||||||
| 62 | void addRow(const T &value); | - | ||||||||||||||||||||||||||||||
| 63 | void insertRow(int r, const T &value); | - | ||||||||||||||||||||||||||||||
| 64 | void removeRow(int r); | - | ||||||||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||||||||
| 66 | bool find(const T &value, int *rowPtr, int *colPtr) const ; | - | ||||||||||||||||||||||||||||||
| 67 | int count(const T &value) const { return m_storage.count(value); } never executed: return m_storage.count(value); | 0 | ||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | // Hmmpf.. Some things are faster that way. | - | ||||||||||||||||||||||||||||||
| 70 | const Storage &storage() const { return m_storage; } never executed: return m_storage; | 0 | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | static void storageIndexToPosition(int idx, int *rowPtr, int *colPtr); | - | ||||||||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||||||||
| 74 | private: | - | ||||||||||||||||||||||||||||||
| 75 | Storage m_storage; | - | ||||||||||||||||||||||||||||||
| 76 | }; | - | ||||||||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||||||||
| 78 | template <class T, int NumColumns> | - | ||||||||||||||||||||||||||||||
| 79 | void FixedColumnMatrix<T, NumColumns>::addRow(const T &value) | - | ||||||||||||||||||||||||||||||
| 80 | { | - | ||||||||||||||||||||||||||||||
| 81 | for (int i = 0; i < NumColumns; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 82 | m_storage.append(value); never executed: m_storage.append(value); | 0 | ||||||||||||||||||||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||||||||
| 85 | template <class T, int NumColumns> | - | ||||||||||||||||||||||||||||||
| 86 | void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value) | - | ||||||||||||||||||||||||||||||
| 87 | { | - | ||||||||||||||||||||||||||||||
| 88 | typename Storage::iterator it = m_storage.begin(); | - | ||||||||||||||||||||||||||||||
| 89 | it += r * NumColumns; | - | ||||||||||||||||||||||||||||||
| 90 | m_storage.insert(it, NumColumns, value); | - | ||||||||||||||||||||||||||||||
| 91 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | template <class T, int NumColumns> | - | ||||||||||||||||||||||||||||||
| 94 | void FixedColumnMatrix<T, NumColumns>::removeRow(int r) | - | ||||||||||||||||||||||||||||||
| 95 | { | - | ||||||||||||||||||||||||||||||
| 96 | m_storage.remove(r * NumColumns, NumColumns); | - | ||||||||||||||||||||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||||||||
| 99 | template <class T, int NumColumns> | - | ||||||||||||||||||||||||||||||
| 100 | bool FixedColumnMatrix<T, NumColumns>::find(const T &value, int *rowPtr, int *colPtr) const | - | ||||||||||||||||||||||||||||||
| 101 | { | - | ||||||||||||||||||||||||||||||
| 102 | const int idx = m_storage.indexOf(value); | - | ||||||||||||||||||||||||||||||
| 103 | if (idx == -1)
| 0 | ||||||||||||||||||||||||||||||
| 104 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 105 | storageIndexToPosition(idx, rowPtr, colPtr); | - | ||||||||||||||||||||||||||||||
| 106 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 107 | } | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | template <class T, int NumColumns> | - | ||||||||||||||||||||||||||||||
| 110 | void FixedColumnMatrix<T, NumColumns>::storageIndexToPosition(int idx, int *rowPtr, int *colPtr) | - | ||||||||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||||||||
| 112 | *rowPtr = idx / NumColumns; | - | ||||||||||||||||||||||||||||||
| 113 | *colPtr = idx % NumColumns; | - | ||||||||||||||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 115 | } // namespace | - | ||||||||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||||||||
| 117 | // special values for unset fields; must not clash with values of FieldGrowthPolicy or | - | ||||||||||||||||||||||||||||||
| 118 | // RowWrapPolicy | - | ||||||||||||||||||||||||||||||
| 119 | const uint DefaultFieldGrowthPolicy = 255; | - | ||||||||||||||||||||||||||||||
| 120 | const uint DefaultRowWrapPolicy = 255; | - | ||||||||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||||||||
| 122 | enum { ColumnCount = 2 }; | - | ||||||||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||||||||
| 124 | // -- our data structure for our items | - | ||||||||||||||||||||||||||||||
| 125 | // This owns the QLayoutItem | - | ||||||||||||||||||||||||||||||
| 126 | struct QFormLayoutItem | - | ||||||||||||||||||||||||||||||
| 127 | { | - | ||||||||||||||||||||||||||||||
| 128 | QFormLayoutItem(QLayoutItem* i) : item(i), fullRow(false), isHfw(false) { } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 129 | ~QFormLayoutItem() { delete item; } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||||||||
| 131 | // Wrappers | - | ||||||||||||||||||||||||||||||
| 132 | QWidget *widget() const { return item->widget(); } never executed: return item->widget(); | 0 | ||||||||||||||||||||||||||||||
| 133 | QLayout *layout() const { return item->layout(); } never executed: return item->layout(); | 0 | ||||||||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||||||||
| 135 | bool hasHeightForWidth() const { return item->hasHeightForWidth(); } never executed: return item->hasHeightForWidth(); | 0 | ||||||||||||||||||||||||||||||
| 136 | int heightForWidth(int width) const { return item->heightForWidth(width); } never executed: return item->heightForWidth(width); | 0 | ||||||||||||||||||||||||||||||
| 137 | int minimumHeightForWidth(int width) const { return item->minimumHeightForWidth(width); } never executed: return item->minimumHeightForWidth(width); | 0 | ||||||||||||||||||||||||||||||
| 138 | Qt::Orientations expandingDirections() const { return item->expandingDirections(); } never executed: return item->expandingDirections(); | 0 | ||||||||||||||||||||||||||||||
| 139 | QSizePolicy::ControlTypes controlTypes() const { return item->controlTypes(); } never executed: return item->controlTypes(); | 0 | ||||||||||||||||||||||||||||||
| 140 | int vStretch() const { return widget() ? widget()->sizePolicy().verticalStretch() : 0; } never executed: return widget() ? widget()->sizePolicy().verticalStretch() : 0;
| 0 | ||||||||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||||||||
| 142 | void setGeometry(const QRect& r) { item->setGeometry(r); } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 143 | QRect geometry() const { return item->geometry(); } never executed: return item->geometry(); | 0 | ||||||||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||||||||
| 145 | // For use with FixedColumnMatrix | - | ||||||||||||||||||||||||||||||
| 146 | bool operator==(const QFormLayoutItem& other) { return item == other.item; } never executed: return item == other.item; | 0 | ||||||||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||||||||
| 148 | QLayoutItem *item; | - | ||||||||||||||||||||||||||||||
| 149 | bool fullRow; | - | ||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | // set by updateSizes | - | ||||||||||||||||||||||||||||||
| 152 | bool isHfw; | - | ||||||||||||||||||||||||||||||
| 153 | QSize minSize; | - | ||||||||||||||||||||||||||||||
| 154 | QSize sizeHint; | - | ||||||||||||||||||||||||||||||
| 155 | QSize maxSize; | - | ||||||||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||||||||
| 157 | // also set by updateSizes | - | ||||||||||||||||||||||||||||||
| 158 | int sbsHSpace; // only used for side by side, for the field item only (not label) | - | ||||||||||||||||||||||||||||||
| 159 | int vSpace; // This is the spacing to the item in the row above | - | ||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | // set by setupVerticalLayoutData | - | ||||||||||||||||||||||||||||||
| 162 | bool sideBySide; | - | ||||||||||||||||||||||||||||||
| 163 | int vLayoutIndex; | - | ||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | // set by setupHorizontalLayoutData | - | ||||||||||||||||||||||||||||||
| 166 | int layoutPos; | - | ||||||||||||||||||||||||||||||
| 167 | int layoutWidth; | - | ||||||||||||||||||||||||||||||
| 168 | }; | - | ||||||||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||||||||
| 170 | class QFormLayoutPrivate : public QLayoutPrivate | - | ||||||||||||||||||||||||||||||
| 171 | { | - | ||||||||||||||||||||||||||||||
| 172 | Q_DECLARE_PUBLIC(QFormLayout) | - | ||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||
| 174 | public: | - | ||||||||||||||||||||||||||||||
| 175 | typedef FixedColumnMatrix<QFormLayoutItem *, ColumnCount> ItemMatrix; | - | ||||||||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||||||||
| 177 | QFormLayoutPrivate(); | - | ||||||||||||||||||||||||||||||
| 178 | ~QFormLayoutPrivate() { } | - | ||||||||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||||||||
| 180 | int insertRow(int row); | - | ||||||||||||||||||||||||||||||
| 181 | void insertRows(int row, int count); | - | ||||||||||||||||||||||||||||||
| 182 | bool setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item); | - | ||||||||||||||||||||||||||||||
| 183 | void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout); | - | ||||||||||||||||||||||||||||||
| 184 | void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget); | - | ||||||||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||||||||
| 186 | void arrangeWidgets(const QVector<QLayoutStruct>& layouts, QRect &rect); | - | ||||||||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||||||||
| 188 | void updateSizes(); | - | ||||||||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||||||||
| 190 | void setupVerticalLayoutData(int width); | - | ||||||||||||||||||||||||||||||
| 191 | void setupHorizontalLayoutData(int width); | - | ||||||||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||||||||
| 193 | QStyle* getStyle() const; | - | ||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||
| 195 | inline bool haveHfwCached(int width) const | - | ||||||||||||||||||||||||||||||
| 196 | { | - | ||||||||||||||||||||||||||||||
| 197 | return (hfw_width == width) || (width == sh_width && hfw_sh_height >= 0); never executed: return (hfw_width == width) || (width == sh_width && hfw_sh_height >= 0);
| 0 | ||||||||||||||||||||||||||||||
| 198 | } | - | ||||||||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||||||||
| 200 | void recalcHFW(int w); | - | ||||||||||||||||||||||||||||||
| 201 | void setupHfwLayoutData(); | - | ||||||||||||||||||||||||||||||
| 202 | - | |||||||||||||||||||||||||||||||
| 203 | uint fieldGrowthPolicy : 8; | - | ||||||||||||||||||||||||||||||
| 204 | uint rowWrapPolicy : 8; | - | ||||||||||||||||||||||||||||||
| 205 | uint has_hfw : 2; | - | ||||||||||||||||||||||||||||||
| 206 | uint dirty : 2; // have we laid out yet? | - | ||||||||||||||||||||||||||||||
| 207 | uint sizesDirty : 2; // have we (not) gathered layout item sizes? | - | ||||||||||||||||||||||||||||||
| 208 | uint expandVertical : 1; // Do we expand vertically? | - | ||||||||||||||||||||||||||||||
| 209 | uint expandHorizontal : 1; // Do we expand horizonally? | - | ||||||||||||||||||||||||||||||
| 210 | Qt::Alignment labelAlignment; | - | ||||||||||||||||||||||||||||||
| 211 | Qt::Alignment formAlignment; | - | ||||||||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||||||||
| 213 | ItemMatrix m_matrix; | - | ||||||||||||||||||||||||||||||
| 214 | QList<QFormLayoutItem *> m_things; | - | ||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | int layoutWidth; // the last width that we called setupVerticalLayoutData on (for vLayouts) | - | ||||||||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||||||||
| 218 | int hfw_width; // the last width we calculated HFW for | - | ||||||||||||||||||||||||||||||
| 219 | int hfw_height; // what that height was | - | ||||||||||||||||||||||||||||||
| 220 | int hfw_minheight; // what that minheight was | - | ||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||
| 222 | int hfw_sh_height; // the hfw for sh_width | - | ||||||||||||||||||||||||||||||
| 223 | int hfw_sh_minheight; // the minhfw for sh_width | - | ||||||||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||||||||
| 225 | int min_width; // the width that gets turned into minSize (from updateSizes) | - | ||||||||||||||||||||||||||||||
| 226 | int sh_width; // the width that gets turned into prefSize (from updateSizes) | - | ||||||||||||||||||||||||||||||
| 227 | int thresh_width; // the width that we start splitting label/field pairs at (from updateSizes) | - | ||||||||||||||||||||||||||||||
| 228 | QSize minSize; | - | ||||||||||||||||||||||||||||||
| 229 | QSize prefSize; | - | ||||||||||||||||||||||||||||||
| 230 | int formMaxWidth; | - | ||||||||||||||||||||||||||||||
| 231 | void calcSizeHints(); | - | ||||||||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||||||||
| 233 | QVector<QLayoutStruct> vLayouts; // set by setupVerticalLayoutData; | - | ||||||||||||||||||||||||||||||
| 234 | int vLayoutCount; // Number of rows we calculated in setupVerticalLayoutData | - | ||||||||||||||||||||||||||||||
| 235 | int maxLabelWidth; // the label width we calculated in setupVerticalLayoutData | - | ||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | QVector<QLayoutStruct> hfwLayouts; | - | ||||||||||||||||||||||||||||||
| 238 | - | |||||||||||||||||||||||||||||||
| 239 | int hSpacing; | - | ||||||||||||||||||||||||||||||
| 240 | int vSpacing; | - | ||||||||||||||||||||||||||||||
| 241 | QLayoutItem* replaceAt(int index, QLayoutItem*) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||||||||
| 242 | }; | - | ||||||||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||||||||
| 244 | QFormLayoutPrivate::QFormLayoutPrivate() | - | ||||||||||||||||||||||||||||||
| 245 | : fieldGrowthPolicy(DefaultFieldGrowthPolicy), | - | ||||||||||||||||||||||||||||||
| 246 | rowWrapPolicy(DefaultRowWrapPolicy), has_hfw(false), dirty(true), sizesDirty(true), | - | ||||||||||||||||||||||||||||||
| 247 | expandVertical(0), expandHorizontal(0), labelAlignment(0), formAlignment(0), | - | ||||||||||||||||||||||||||||||
| 248 | layoutWidth(-1), hfw_width(-1), hfw_sh_height(-1), min_width(-1), | - | ||||||||||||||||||||||||||||||
| 249 | sh_width(-1), thresh_width(QLAYOUTSIZE_MAX), hSpacing(-1), vSpacing(-1) | - | ||||||||||||||||||||||||||||||
| 250 | { | - | ||||||||||||||||||||||||||||||
| 251 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | static Qt::Alignment fixedAlignment(Qt::Alignment alignment, Qt::LayoutDirection layoutDirection) | - | ||||||||||||||||||||||||||||||
| 254 | { | - | ||||||||||||||||||||||||||||||
| 255 | if (layoutDirection == Qt::RightToLeft && alignment & Qt::AlignAbsolute) {
| 0 | ||||||||||||||||||||||||||||||
| 256 | // swap left and right, and eliminate absolute flag | - | ||||||||||||||||||||||||||||||
| 257 | return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0)); | 0 | ||||||||||||||||||||||||||||||
| 258 | | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0)); | 0 | ||||||||||||||||||||||||||||||
| 259 | | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0)); never executed: return Qt::Alignment((alignment & ~(Qt::AlignLeft | Qt::AlignRight | Qt::AlignAbsolute)) | ((alignment & Qt::AlignRight) ? Qt::AlignLeft : 0) | ((alignment & Qt::AlignLeft) ? Qt::AlignRight : 0)); | 0 | ||||||||||||||||||||||||||||||
| 260 | } else { | - | ||||||||||||||||||||||||||||||
| 261 | return alignment & ~Qt::AlignAbsolute; never executed: return alignment & ~Qt::AlignAbsolute; | 0 | ||||||||||||||||||||||||||||||
| 262 | } | - | ||||||||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||||||||
| 265 | static int storageIndexFromLayoutItem(const QFormLayoutPrivate::ItemMatrix &m, | - | ||||||||||||||||||||||||||||||
| 266 | QFormLayoutItem *item) | - | ||||||||||||||||||||||||||||||
| 267 | { | - | ||||||||||||||||||||||||||||||
| 268 | if (item) {
| 0 | ||||||||||||||||||||||||||||||
| 269 | return m.storage().indexOf(item); never executed: return m.storage().indexOf(item); | 0 | ||||||||||||||||||||||||||||||
| 270 | } else { | - | ||||||||||||||||||||||||||||||
| 271 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||||||||
| 275 | static void updateFormLayoutItem(QFormLayoutItem *item, int userVSpacing, | - | ||||||||||||||||||||||||||||||
| 276 | QFormLayout::FieldGrowthPolicy fieldGrowthPolicy, | - | ||||||||||||||||||||||||||||||
| 277 | bool fullRow) | - | ||||||||||||||||||||||||||||||
| 278 | { | - | ||||||||||||||||||||||||||||||
| 279 | item->minSize = item->item->minimumSize(); | - | ||||||||||||||||||||||||||||||
| 280 | item->sizeHint = item->item->sizeHint(); | - | ||||||||||||||||||||||||||||||
| 281 | item->maxSize = item->item->maximumSize(); | - | ||||||||||||||||||||||||||||||
| 282 | - | |||||||||||||||||||||||||||||||
| 283 | if (!fullRow && (fieldGrowthPolicy == QFormLayout::FieldsStayAtSizeHint
| 0 | ||||||||||||||||||||||||||||||
| 284 | || (fieldGrowthPolicy == QFormLayout::ExpandingFieldsGrow
| 0 | ||||||||||||||||||||||||||||||
| 285 | && !(item->item->expandingDirections() & Qt::Horizontal))))
| 0 | ||||||||||||||||||||||||||||||
| 286 | item->maxSize.setWidth(item->sizeHint.width()); never executed: item->maxSize.setWidth(item->sizeHint.width()); | 0 | ||||||||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||||||||
| 288 | item->isHfw = item->item->hasHeightForWidth(); | - | ||||||||||||||||||||||||||||||
| 289 | item->vSpace = userVSpacing; | - | ||||||||||||||||||||||||||||||
| 290 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 | /* | - | ||||||||||||||||||||||||||||||
| 293 | Iterate over all the controls and gather their size information | - | ||||||||||||||||||||||||||||||
| 294 | (min, sizeHint and max). Also work out what the spacing between | - | ||||||||||||||||||||||||||||||
| 295 | pairs of controls should be, and figure out the min and sizeHint | - | ||||||||||||||||||||||||||||||
| 296 | widths. | - | ||||||||||||||||||||||||||||||
| 297 | */ | - | ||||||||||||||||||||||||||||||
| 298 | void QFormLayoutPrivate::updateSizes() | - | ||||||||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||||||||
| 300 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||||||||
| 302 | if (sizesDirty) {
| 0 | ||||||||||||||||||||||||||||||
| 303 | QFormLayout::RowWrapPolicy wrapPolicy = q->rowWrapPolicy(); | - | ||||||||||||||||||||||||||||||
| 304 | bool wrapAllRows = (wrapPolicy == QFormLayout::WrapAllRows); | - | ||||||||||||||||||||||||||||||
| 305 | bool dontWrapRows = (wrapPolicy == QFormLayout::DontWrapRows); | - | ||||||||||||||||||||||||||||||
| 306 | int rr = m_matrix.rowCount(); | - | ||||||||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||||||||
| 308 | has_hfw = false; | - | ||||||||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||||||||
| 310 | // If any control can expand, so can this layout | - | ||||||||||||||||||||||||||||||
| 311 | // Wrapping doesn't affect expansion, though, just the minsize | - | ||||||||||||||||||||||||||||||
| 312 | bool expandH = false; | - | ||||||||||||||||||||||||||||||
| 313 | bool expandV = false; | - | ||||||||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||||||||
| 315 | QFormLayoutItem *prevLbl = 0; | - | ||||||||||||||||||||||||||||||
| 316 | QFormLayoutItem *prevFld = 0; | - | ||||||||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||||||||
| 318 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||||||||
| 319 | QStyle *style = parent ? parent->style() : 0;
| 0 | ||||||||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||||||||
| 321 | int userVSpacing = q->verticalSpacing(); | - | ||||||||||||||||||||||||||||||
| 322 | int userHSpacing = wrapAllRows ? 0 : q->horizontalSpacing();
| 0 | ||||||||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||||||||
| 324 | int maxMinLblWidth = 0; | - | ||||||||||||||||||||||||||||||
| 325 | int maxMinFldWidth = 0; // field with label | - | ||||||||||||||||||||||||||||||
| 326 | int maxMinIfldWidth = 0; // independent field | - | ||||||||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||||||||
| 328 | int maxShLblWidth = 0; | - | ||||||||||||||||||||||||||||||
| 329 | int maxShFldWidth = 0; | - | ||||||||||||||||||||||||||||||
| 330 | int maxShIfldWidth = 0; | - | ||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | for (int i = 0; i < rr; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 333 | QFormLayoutItem *label = m_matrix(i, 0); | - | ||||||||||||||||||||||||||||||
| 334 | QFormLayoutItem *field = m_matrix(i, 1); | - | ||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||
| 336 | // Skip empty rows | - | ||||||||||||||||||||||||||||||
| 337 | if (!label && !field)
| 0 | ||||||||||||||||||||||||||||||
| 338 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||||||||
| 340 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 341 | updateFormLayoutItem(label, userVSpacing, q->fieldGrowthPolicy(), false); | - | ||||||||||||||||||||||||||||||
| 342 | if (label->isHfw)
| 0 | ||||||||||||||||||||||||||||||
| 343 | has_hfw = true; never executed: has_hfw = true; | 0 | ||||||||||||||||||||||||||||||
| 344 | Qt::Orientations o = label->expandingDirections(); | - | ||||||||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||||||||
| 346 | if (o & Qt::Vertical)
| 0 | ||||||||||||||||||||||||||||||
| 347 | expandV = true; never executed: expandV = true; | 0 | ||||||||||||||||||||||||||||||
| 348 | if (o & Qt::Horizontal)
| 0 | ||||||||||||||||||||||||||||||
| 349 | expandH = true; never executed: expandH = true; | 0 | ||||||||||||||||||||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 351 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 352 | updateFormLayoutItem(field, userVSpacing, q->fieldGrowthPolicy(), !label && field->fullRow); | - | ||||||||||||||||||||||||||||||
| 353 | field->sbsHSpace = (!label && field->fullRow) ? 0 : userHSpacing;
| 0 | ||||||||||||||||||||||||||||||
| 354 | if (field->isHfw)
| 0 | ||||||||||||||||||||||||||||||
| 355 | has_hfw = true; never executed: has_hfw = true; | 0 | ||||||||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||||||||
| 357 | Qt::Orientations o = field->expandingDirections(); | - | ||||||||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||||||||
| 359 | if (o & Qt::Vertical)
| 0 | ||||||||||||||||||||||||||||||
| 360 | expandV = true; never executed: expandV = true; | 0 | ||||||||||||||||||||||||||||||
| 361 | if (o & Qt::Horizontal)
| 0 | ||||||||||||||||||||||||||||||
| 362 | expandH = true; never executed: expandH = true; | 0 | ||||||||||||||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||
| 365 | // See if we need to calculate default spacings | - | ||||||||||||||||||||||||||||||
| 366 | if ((userHSpacing < 0 || userVSpacing < 0) && style) {
| 0 | ||||||||||||||||||||||||||||||
| 367 | QSizePolicy::ControlTypes lbltypes = | - | ||||||||||||||||||||||||||||||
| 368 | QSizePolicy::ControlTypes(label ? label->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 369 | QSizePolicy::ControlTypes fldtypes = | - | ||||||||||||||||||||||||||||||
| 370 | QSizePolicy::ControlTypes(field ? field->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | // VSpacing | - | ||||||||||||||||||||||||||||||
| 373 | if (userVSpacing < 0) {
| 0 | ||||||||||||||||||||||||||||||
| 374 | if (wrapAllRows) {
| 0 | ||||||||||||||||||||||||||||||
| 375 | // label spacing is to a previous item | - | ||||||||||||||||||||||||||||||
| 376 | QFormLayoutItem *lbltop = prevFld ? prevFld : prevLbl;
| 0 | ||||||||||||||||||||||||||||||
| 377 | // field spacing is to the label (or a previous item) | - | ||||||||||||||||||||||||||||||
| 378 | QFormLayoutItem *fldtop = label ? label : lbltop;
| 0 | ||||||||||||||||||||||||||||||
| 379 | QSizePolicy::ControlTypes lbltoptypes = | - | ||||||||||||||||||||||||||||||
| 380 | QSizePolicy::ControlTypes(lbltop ? lbltop->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 381 | QSizePolicy::ControlTypes fldtoptypes = | - | ||||||||||||||||||||||||||||||
| 382 | QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 383 | if (label && lbltop)
| 0 | ||||||||||||||||||||||||||||||
| 384 | label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); never executed: label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 385 | if (field && fldtop)
| 0 | ||||||||||||||||||||||||||||||
| 386 | field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); never executed: field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 387 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 388 | // Side by side.. we have to also consider the spacings to empty cells, which can strangely be more than | - | ||||||||||||||||||||||||||||||
| 389 | // non empty cells.. | - | ||||||||||||||||||||||||||||||
| 390 | QFormLayoutItem *lbltop = prevLbl ? prevLbl : prevFld;
| 0 | ||||||||||||||||||||||||||||||
| 391 | QFormLayoutItem *fldtop = prevFld; | - | ||||||||||||||||||||||||||||||
| 392 | QSizePolicy::ControlTypes lbltoptypes = | - | ||||||||||||||||||||||||||||||
| 393 | QSizePolicy::ControlTypes(lbltop ? lbltop->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 394 | QSizePolicy::ControlTypes fldtoptypes = | - | ||||||||||||||||||||||||||||||
| 395 | QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||||||||
| 397 | // To be compatible to QGridLayout, we have to compare solitary labels & fields with both predecessors | - | ||||||||||||||||||||||||||||||
| 398 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 399 | if (!field) {
| 0 | ||||||||||||||||||||||||||||||
| 400 | int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); | - | ||||||||||||||||||||||||||||||
| 401 | int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, 0, parent); | - | ||||||||||||||||||||||||||||||
| 402 | label->vSpace = qMax(lblspacing, fldspacing); | - | ||||||||||||||||||||||||||||||
| 403 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 404 | label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); never executed: label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 405 | } | - | ||||||||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||||||||
| 407 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 408 | // check spacing against both the previous label and field | - | ||||||||||||||||||||||||||||||
| 409 | if (!label) {
| 0 | ||||||||||||||||||||||||||||||
| 410 | int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, 0, parent); | - | ||||||||||||||||||||||||||||||
| 411 | int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); | - | ||||||||||||||||||||||||||||||
| 412 | field->vSpace = qMax(lblspacing, fldspacing); | - | ||||||||||||||||||||||||||||||
| 413 | } else never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 414 | field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); never executed: field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 415 | } | - | ||||||||||||||||||||||||||||||
| 416 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 417 | } | - | ||||||||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||||||||
| 419 | // HSpacing | - | ||||||||||||||||||||||||||||||
| 420 | // hard-coded the left and right control types so that all the rows have the same | - | ||||||||||||||||||||||||||||||
| 421 | // inter-column spacing (otherwise the right column isn't always left aligned) | - | ||||||||||||||||||||||||||||||
| 422 | if (userHSpacing < 0 && !wrapAllRows && (label || !field->fullRow) && field)
| 0 | ||||||||||||||||||||||||||||||
| 423 | field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent); never executed: field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 424 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||||||||
| 426 | // Now update our min/sizehint widths | - | ||||||||||||||||||||||||||||||
| 427 | // We choose to put the spacing in the field side in sbs, so | - | ||||||||||||||||||||||||||||||
| 428 | // the right edge of the labels will align, but fields may | - | ||||||||||||||||||||||||||||||
| 429 | // be a little ragged.. since different controls may have | - | ||||||||||||||||||||||||||||||
| 430 | // different appearances, a slight raggedness in the left | - | ||||||||||||||||||||||||||||||
| 431 | // edges of fields can be tolerated. | - | ||||||||||||||||||||||||||||||
| 432 | // (Note - field->sbsHSpace is 0 for WrapAllRows mode) | - | ||||||||||||||||||||||||||||||
| 433 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 434 | maxMinLblWidth = qMax(maxMinLblWidth, label->minSize.width()); | - | ||||||||||||||||||||||||||||||
| 435 | maxShLblWidth = qMax(maxShLblWidth, label->sizeHint.width()); | - | ||||||||||||||||||||||||||||||
| 436 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 437 | maxMinFldWidth = qMax(maxMinFldWidth, field->minSize.width() + field->sbsHSpace); | - | ||||||||||||||||||||||||||||||
| 438 | maxShFldWidth = qMax(maxShFldWidth, field->sizeHint.width() + field->sbsHSpace); | - | ||||||||||||||||||||||||||||||
| 439 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 440 | } else if (field) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 441 | maxMinIfldWidth = qMax(maxMinIfldWidth, field->minSize.width()); | - | ||||||||||||||||||||||||||||||
| 442 | maxShIfldWidth = qMax(maxShIfldWidth, field->sizeHint.width()); | - | ||||||||||||||||||||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||||||||
| 445 | prevLbl = label; | - | ||||||||||||||||||||||||||||||
| 446 | prevFld = field; | - | ||||||||||||||||||||||||||||||
| 447 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||||||||
| 449 | // Now, finally update the min/sizeHint widths | - | ||||||||||||||||||||||||||||||
| 450 | if (wrapAllRows) {
| 0 | ||||||||||||||||||||||||||||||
| 451 | sh_width = qMax(maxShLblWidth, qMax(maxShIfldWidth, maxShFldWidth)); | - | ||||||||||||||||||||||||||||||
| 452 | min_width = qMax(maxMinLblWidth, qMax(maxMinIfldWidth, maxMinFldWidth)); | - | ||||||||||||||||||||||||||||||
| 453 | // in two line, we don't care as much about the threshold width | - | ||||||||||||||||||||||||||||||
| 454 | thresh_width = 0; | - | ||||||||||||||||||||||||||||||
| 455 | } else if (dontWrapRows) { never executed: end of block
| 0 | ||||||||||||||||||||||||||||||
| 456 | // This is just the max widths glommed together | - | ||||||||||||||||||||||||||||||
| 457 | sh_width = qMax(maxShLblWidth + maxShFldWidth, maxShIfldWidth); | - | ||||||||||||||||||||||||||||||
| 458 | min_width = qMax(maxMinLblWidth + maxMinFldWidth, maxMinIfldWidth); | - | ||||||||||||||||||||||||||||||
| 459 | thresh_width = QWIDGETSIZE_MAX; | - | ||||||||||||||||||||||||||||||
| 460 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 461 | // This is just the max widths glommed together | - | ||||||||||||||||||||||||||||||
| 462 | sh_width = qMax(maxShLblWidth + maxShFldWidth, maxShIfldWidth); | - | ||||||||||||||||||||||||||||||
| 463 | // min width needs to be the min when everything is wrapped, | - | ||||||||||||||||||||||||||||||
| 464 | // otherwise we'll never get set with a width that causes wrapping | - | ||||||||||||||||||||||||||||||
| 465 | min_width = qMax(maxMinLblWidth, qMax(maxMinIfldWidth, maxMinFldWidth)); | - | ||||||||||||||||||||||||||||||
| 466 | // We split a pair at label sh + field min (### for now..) | - | ||||||||||||||||||||||||||||||
| 467 | thresh_width = maxShLblWidth + maxMinFldWidth; | - | ||||||||||||||||||||||||||||||
| 468 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||||||||
| 470 | // Update the expansions | - | ||||||||||||||||||||||||||||||
| 471 | expandVertical = expandV; | - | ||||||||||||||||||||||||||||||
| 472 | expandHorizontal = expandH; | - | ||||||||||||||||||||||||||||||
| 473 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 474 | sizesDirty = false; | - | ||||||||||||||||||||||||||||||
| 475 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||||||||
| 477 | void QFormLayoutPrivate::recalcHFW(int w) | - | ||||||||||||||||||||||||||||||
| 478 | { | - | ||||||||||||||||||||||||||||||
| 479 | setupHfwLayoutData(); | - | ||||||||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||||||||
| 481 | int h = 0; | - | ||||||||||||||||||||||||||||||
| 482 | int mh = 0; | - | ||||||||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||||||||
| 484 | for (int r = 0; r < vLayoutCount; ++r) {
| 0 | ||||||||||||||||||||||||||||||
| 485 | int spacing = hfwLayouts.at(r).spacing; | - | ||||||||||||||||||||||||||||||
| 486 | h += hfwLayouts.at(r).sizeHint + spacing; | - | ||||||||||||||||||||||||||||||
| 487 | mh += hfwLayouts.at(r).minimumSize + spacing; | - | ||||||||||||||||||||||||||||||
| 488 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||||||||
| 490 | if (sh_width > 0 && sh_width == w) {
| 0 | ||||||||||||||||||||||||||||||
| 491 | hfw_sh_height = qMin(QLAYOUTSIZE_MAX, h); | - | ||||||||||||||||||||||||||||||
| 492 | hfw_sh_minheight = qMin(QLAYOUTSIZE_MAX, mh); | - | ||||||||||||||||||||||||||||||
| 493 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 494 | hfw_width = w; | - | ||||||||||||||||||||||||||||||
| 495 | hfw_height = qMin(QLAYOUTSIZE_MAX, h); | - | ||||||||||||||||||||||||||||||
| 496 | hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh); | - | ||||||||||||||||||||||||||||||
| 497 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 498 | } | - | ||||||||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||||||||
| 500 | void QFormLayoutPrivate::setupHfwLayoutData() | - | ||||||||||||||||||||||||||||||
| 501 | { | - | ||||||||||||||||||||||||||||||
| 502 | // setupVerticalLayoutData must be called before this | - | ||||||||||||||||||||||||||||||
| 503 | // setupHorizontalLayoutData must also be called before this | - | ||||||||||||||||||||||||||||||
| 504 | // copies non hfw data into hfw | - | ||||||||||||||||||||||||||||||
| 505 | // then updates size and min | - | ||||||||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||||||||
| 508 | // Note: QGridLayout doesn't call minimumHeightForWidth, | - | ||||||||||||||||||||||||||||||
| 509 | // but instead uses heightForWidth for both min and sizeHint. | - | ||||||||||||||||||||||||||||||
| 510 | // For the common case where minimumHeightForWidth just calls | - | ||||||||||||||||||||||||||||||
| 511 | // heightForWidth, we do the calculation twice, which can be | - | ||||||||||||||||||||||||||||||
| 512 | // very expensive for word wrapped QLabels/QTextEdits, for example. | - | ||||||||||||||||||||||||||||||
| 513 | // So we just use heightForWidth as well. | - | ||||||||||||||||||||||||||||||
| 514 | int i; | - | ||||||||||||||||||||||||||||||
| 515 | int rr = m_matrix.rowCount(); | - | ||||||||||||||||||||||||||||||
| 516 | - | |||||||||||||||||||||||||||||||
| 517 | hfwLayouts.clear(); | - | ||||||||||||||||||||||||||||||
| 518 | hfwLayouts.resize(vLayoutCount); | - | ||||||||||||||||||||||||||||||
| 519 | for (i = 0; i < vLayoutCount; ++i)
| 0 | ||||||||||||||||||||||||||||||
| 520 | hfwLayouts[i] = vLayouts.at(i); never executed: hfwLayouts[i] = vLayouts.at(i); | 0 | ||||||||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||||||||
| 522 | for (i = 0; i < rr; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 523 | QFormLayoutItem *label = m_matrix(i, 0); | - | ||||||||||||||||||||||||||||||
| 524 | QFormLayoutItem *field = m_matrix(i, 1); | - | ||||||||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||||||||
| 526 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 527 | if (label->isHfw) {
| 0 | ||||||||||||||||||||||||||||||
| 528 | // We don't check sideBySide here, since a label is only | - | ||||||||||||||||||||||||||||||
| 529 | // ever side by side with its field | - | ||||||||||||||||||||||||||||||
| 530 | int hfw = label->heightForWidth(label->layoutWidth); | - | ||||||||||||||||||||||||||||||
| 531 | hfwLayouts[label->vLayoutIndex].minimumSize = hfw; | - | ||||||||||||||||||||||||||||||
| 532 | hfwLayouts[label->vLayoutIndex].sizeHint = hfw; | - | ||||||||||||||||||||||||||||||
| 533 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 534 | // Reset these here, so the field can do a qMax below (the previous value may have | - | ||||||||||||||||||||||||||||||
| 535 | // been the fields non-hfw values, which are often larger than hfw) | - | ||||||||||||||||||||||||||||||
| 536 | hfwLayouts[label->vLayoutIndex].sizeHint = label->sizeHint.height(); | - | ||||||||||||||||||||||||||||||
| 537 | hfwLayouts[label->vLayoutIndex].minimumSize = label->minSize.height(); | - | ||||||||||||||||||||||||||||||
| 538 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 539 | } | - | ||||||||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||||||||
| 541 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 542 | int hfw = field->isHfw ? field->heightForWidth(field->layoutWidth) : 0;
| 0 | ||||||||||||||||||||||||||||||
| 543 | int h = field->isHfw ? hfw : field->sizeHint.height();
| 0 | ||||||||||||||||||||||||||||||
| 544 | int mh = field->isHfw ? hfw : field->minSize.height();
| 0 | ||||||||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||||||||
| 546 | if (field->sideBySide) {
| 0 | ||||||||||||||||||||||||||||||
| 547 | int oh = hfwLayouts.at(field->vLayoutIndex).sizeHint; | - | ||||||||||||||||||||||||||||||
| 548 | int omh = hfwLayouts.at(field->vLayoutIndex).minimumSize; | - | ||||||||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||||||||
| 550 | hfwLayouts[field->vLayoutIndex].sizeHint = qMax(h, oh); | - | ||||||||||||||||||||||||||||||
| 551 | hfwLayouts[field->vLayoutIndex].minimumSize = qMax(mh, omh); | - | ||||||||||||||||||||||||||||||
| 552 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 553 | hfwLayouts[field->vLayoutIndex].sizeHint = h; | - | ||||||||||||||||||||||||||||||
| 554 | hfwLayouts[field->vLayoutIndex].minimumSize = mh; | - | ||||||||||||||||||||||||||||||
| 555 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 556 | } | - | ||||||||||||||||||||||||||||||
| 557 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 558 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||||||||
| 560 | /* | - | ||||||||||||||||||||||||||||||
| 561 | Given up to four items involved in a vertical spacing calculation | - | ||||||||||||||||||||||||||||||
| 562 | (two rows * two columns), return the max vertical spacing for the | - | ||||||||||||||||||||||||||||||
| 563 | row containing item1 (which may also include item2) | - | ||||||||||||||||||||||||||||||
| 564 | We assume parent and item1 are not null. | - | ||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | If a particular row is split, then the spacings for that row and | - | ||||||||||||||||||||||||||||||
| 567 | the following row are affected, and this function should be | - | ||||||||||||||||||||||||||||||
| 568 | called with recalculate = true for both rows (note: only rows with both | - | ||||||||||||||||||||||||||||||
| 569 | a label and a field can be split). | - | ||||||||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||||||||
| 571 | In particular: | - | ||||||||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||||||||
| 573 | 1) the split label's row vspace needs to be changed to qMax(label/prevLabel, label/prevField) | - | ||||||||||||||||||||||||||||||
| 574 | [call with item1 = label, item2 = null, prevItem1 & prevItem2 as before] | - | ||||||||||||||||||||||||||||||
| 575 | 2) the split field's row vspace needs to be changed to the label/field spacing | - | ||||||||||||||||||||||||||||||
| 576 | [call with item1 = field, item2 = null, prevItem1 = label, prevItem2 = null] | - | ||||||||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||||||||
| 578 | [if the next row has one item, 'item'] | - | ||||||||||||||||||||||||||||||
| 579 | 3a) the following row's vspace needs to be changed to item/field spacing (would | - | ||||||||||||||||||||||||||||||
| 580 | previously been the qMax(item/label, item/field) spacings) | - | ||||||||||||||||||||||||||||||
| 581 | [call with item1 = item, item2 = null, prevItem1 = field, prevItem2 = null] | - | ||||||||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||||||||
| 583 | [if the next row has two items, 'label2' and 'field2'] | - | ||||||||||||||||||||||||||||||
| 584 | 3b) the following row's vspace needs to be changed to be qMax(field/label2, field/field2) spacing | - | ||||||||||||||||||||||||||||||
| 585 | [call with item1 = label2, item2 = field2, prevItem1 = field, prevItem2 = null] | - | ||||||||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||||||||
| 587 | In the (common) non split case, we can just use the precalculated vspace (possibly qMaxed between | - | ||||||||||||||||||||||||||||||
| 588 | label and field). | - | ||||||||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||||||||
| 590 | If recalculate is true, we expect: | - | ||||||||||||||||||||||||||||||
| 591 | - parent != null | - | ||||||||||||||||||||||||||||||
| 592 | - item1 != null | - | ||||||||||||||||||||||||||||||
| 593 | - item2 can be null | - | ||||||||||||||||||||||||||||||
| 594 | - prevItem1 can be null | - | ||||||||||||||||||||||||||||||
| 595 | - if item2 is not null, prevItem2 will be null (e.g. steps 1 or 3 above) | - | ||||||||||||||||||||||||||||||
| 596 | - if prevItem1 is null, prevItem2 will be null | - | ||||||||||||||||||||||||||||||
| 597 | */ | - | ||||||||||||||||||||||||||||||
| 598 | static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing, bool recalculate, QFormLayoutItem* item1, QFormLayoutItem* item2, QFormLayoutItem* prevItem1, QFormLayoutItem *prevItem2) | - | ||||||||||||||||||||||||||||||
| 599 | { | - | ||||||||||||||||||||||||||||||
| 600 | int spacing = userVSpacing; | - | ||||||||||||||||||||||||||||||
| 601 | if (spacing < 0) {
| 0 | ||||||||||||||||||||||||||||||
| 602 | if (!recalculate) {
| 0 | ||||||||||||||||||||||||||||||
| 603 | if (item1)
| 0 | ||||||||||||||||||||||||||||||
| 604 | spacing = item1->vSpace; never executed: spacing = item1->vSpace; | 0 | ||||||||||||||||||||||||||||||
| 605 | if (item2)
| 0 | ||||||||||||||||||||||||||||||
| 606 | spacing = qMax(spacing, item2->vSpace); never executed: spacing = qMax(spacing, item2->vSpace); | 0 | ||||||||||||||||||||||||||||||
| 607 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 608 | if (style && prevItem1) {
| 0 | ||||||||||||||||||||||||||||||
| 609 | QSizePolicy::ControlTypes itemtypes = | - | ||||||||||||||||||||||||||||||
| 610 | QSizePolicy::ControlTypes(item1 ? item1->controlTypes() : QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||||||||
| 611 | int spacing2 = 0; | - | ||||||||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||||||||
| 613 | spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, 0, parent); | - | ||||||||||||||||||||||||||||||
| 614 | - | |||||||||||||||||||||||||||||||
| 615 | // At most of one of item2 and prevItem2 will be nonnull | - | ||||||||||||||||||||||||||||||
| 616 | if (item2)
| 0 | ||||||||||||||||||||||||||||||
| 617 | spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent); never executed: spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 618 | else if (prevItem2)
| 0 | ||||||||||||||||||||||||||||||
| 619 | spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent); never executed: spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent); | 0 | ||||||||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||||||||
| 621 | spacing = qMax(spacing, spacing2); | - | ||||||||||||||||||||||||||||||
| 622 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 623 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 624 | } else { | - | ||||||||||||||||||||||||||||||
| 625 | if (prevItem1) {
| 0 | ||||||||||||||||||||||||||||||
| 626 | QWidget *wid = prevItem1->item->widget(); | - | ||||||||||||||||||||||||||||||
| 627 | if (wid)
| 0 | ||||||||||||||||||||||||||||||
| 628 | spacing = qMax(spacing, prevItem1->geometry().top() - wid->geometry().top() ); never executed: spacing = qMax(spacing, prevItem1->geometry().top() - wid->geometry().top() ); | 0 | ||||||||||||||||||||||||||||||
| 629 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 630 | if (prevItem2) {
| 0 | ||||||||||||||||||||||||||||||
| 631 | QWidget *wid = prevItem2->item->widget(); | - | ||||||||||||||||||||||||||||||
| 632 | if (wid)
| 0 | ||||||||||||||||||||||||||||||
| 633 | spacing = qMax(spacing, prevItem2->geometry().top() - wid->geometry().top() ); never executed: spacing = qMax(spacing, prevItem2->geometry().top() - wid->geometry().top() ); | 0 | ||||||||||||||||||||||||||||||
| 634 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 635 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 636 | return qMax(spacing, 0); never executed: return qMax(spacing, 0); | 0 | ||||||||||||||||||||||||||||||
| 637 | } | - | ||||||||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||||||||
| 639 | static inline void initLayoutStruct(QLayoutStruct& sl, QFormLayoutItem* item) | - | ||||||||||||||||||||||||||||||
| 640 | { | - | ||||||||||||||||||||||||||||||
| 641 | sl.init(item->vStretch(), item->minSize.height()); | - | ||||||||||||||||||||||||||||||
| 642 | sl.sizeHint = item->sizeHint.height(); | - | ||||||||||||||||||||||||||||||
| 643 | sl.maximumSize = item->maxSize.height(); | - | ||||||||||||||||||||||||||||||
| 644 | sl.expansive = (item->expandingDirections() & Qt::Vertical); | - | ||||||||||||||||||||||||||||||
| 645 | sl.empty = false; | - | ||||||||||||||||||||||||||||||
| 646 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||||||||
| 648 | void QFormLayoutPrivate::setupVerticalLayoutData(int width) | - | ||||||||||||||||||||||||||||||
| 649 | { | - | ||||||||||||||||||||||||||||||
| 650 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||||||||
| 652 | // Early out if we have no changes that would cause a change in vertical layout | - | ||||||||||||||||||||||||||||||
| 653 | if ((width == layoutWidth || (width >= thresh_width && layoutWidth >= thresh_width)) && !dirty && !sizesDirty)
| 0 | ||||||||||||||||||||||||||||||
| 654 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 655 | - | |||||||||||||||||||||||||||||||
| 656 | layoutWidth = width; | - | ||||||||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||||||||
| 658 | int rr = m_matrix.rowCount(); | - | ||||||||||||||||||||||||||||||
| 659 | int vidx = 1; | - | ||||||||||||||||||||||||||||||
| 660 | QFormLayout::RowWrapPolicy rowWrapPolicy = q->rowWrapPolicy(); | - | ||||||||||||||||||||||||||||||
| 661 | bool wrapAllRows = (rowWrapPolicy == QFormLayout::WrapAllRows); | - | ||||||||||||||||||||||||||||||
| 662 | bool addTopBottomStretch = true; | - | ||||||||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||||||||
| 664 | vLayouts.clear(); | - | ||||||||||||||||||||||||||||||
| 665 | vLayouts.resize((2 * rr) + 2); // a max, some may be unused | - | ||||||||||||||||||||||||||||||
| 666 | - | |||||||||||||||||||||||||||||||
| 667 | QStyle *style = 0; | - | ||||||||||||||||||||||||||||||
| 668 | - | |||||||||||||||||||||||||||||||
| 669 | int userVSpacing = q->verticalSpacing(); | - | ||||||||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||||||||
| 671 | if (userVSpacing < 0) {
| 0 | ||||||||||||||||||||||||||||||
| 672 | if (QWidget *widget = q->parentWidget())
| 0 | ||||||||||||||||||||||||||||||
| 673 | style = widget->style(); never executed: style = widget->style(); | 0 | ||||||||||||||||||||||||||||||
| 674 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 675 | - | |||||||||||||||||||||||||||||||
| 676 | // make sure our sizes are up to date | - | ||||||||||||||||||||||||||||||
| 677 | updateSizes(); | - | ||||||||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||||||||
| 679 | // Grab the widest label width here | - | ||||||||||||||||||||||||||||||
| 680 | // This might be different from the value computed during | - | ||||||||||||||||||||||||||||||
| 681 | // sizeHint/minSize, since we don't count label/field pairs that | - | ||||||||||||||||||||||||||||||
| 682 | // are split. | - | ||||||||||||||||||||||||||||||
| 683 | maxLabelWidth = 0; | - | ||||||||||||||||||||||||||||||
| 684 | if (!wrapAllRows) {
| 0 | ||||||||||||||||||||||||||||||
| 685 | for (int i = 0; i < rr; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 686 | const QFormLayoutItem *label = m_matrix(i, 0); | - | ||||||||||||||||||||||||||||||
| 687 | const QFormLayoutItem *field = m_matrix(i, 1); | - | ||||||||||||||||||||||||||||||
| 688 | if (label && (label->sizeHint.width() + (field ? field->minSize.width() : 0) <= width))
| 0 | ||||||||||||||||||||||||||||||
| 689 | maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width()); never executed: maxLabelWidth = qMax(maxLabelWidth, label->sizeHint.width()); | 0 | ||||||||||||||||||||||||||||||
| 690 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 691 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 692 | maxLabelWidth = width; | - | ||||||||||||||||||||||||||||||
| 693 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||||||||
| 695 | QFormLayoutItem *prevItem1 = 0; | - | ||||||||||||||||||||||||||||||
| 696 | QFormLayoutItem *prevItem2 = 0; | - | ||||||||||||||||||||||||||||||
| 697 | bool prevRowSplit = false; | - | ||||||||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||||||||
| 699 | for (int i = 0; i < rr; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 700 | QFormLayoutItem *label = m_matrix(i, 0); | - | ||||||||||||||||||||||||||||||
| 701 | QFormLayoutItem *field = m_matrix(i, 1); | - | ||||||||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||||||||
| 703 | // Totally ignore empty rows... | - | ||||||||||||||||||||||||||||||
| 704 | if (!label && !field)
| 0 | ||||||||||||||||||||||||||||||
| 705 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||||||||
| 707 | QSize min1; | - | ||||||||||||||||||||||||||||||
| 708 | QSize min2; | - | ||||||||||||||||||||||||||||||
| 709 | QSize sh1; | - | ||||||||||||||||||||||||||||||
| 710 | QSize sh2; | - | ||||||||||||||||||||||||||||||
| 711 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 712 | min1 = label->minSize; | - | ||||||||||||||||||||||||||||||
| 713 | sh1 = label->sizeHint; | - | ||||||||||||||||||||||||||||||
| 714 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 715 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 716 | min2 = field->minSize; | - | ||||||||||||||||||||||||||||||
| 717 | sh2 = field->sizeHint; | - | ||||||||||||||||||||||||||||||
| 718 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||||||||
| 720 | // In separate lines, we make a vLayout for everything that isn't null | - | ||||||||||||||||||||||||||||||
| 721 | // in side by side, we only separate label/field if we're going to wrap it | - | ||||||||||||||||||||||||||||||
| 722 | bool splitSideBySide = (rowWrapPolicy == QFormLayout::WrapLongRows)
| 0 | ||||||||||||||||||||||||||||||
| 723 | && ((maxLabelWidth < sh1.width()) || (width < (maxLabelWidth + min2.width())));
| 0 | ||||||||||||||||||||||||||||||
| 724 | - | |||||||||||||||||||||||||||||||
| 725 | if (wrapAllRows || splitSideBySide) {
| 0 | ||||||||||||||||||||||||||||||
| 726 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 727 | initLayoutStruct(vLayouts[vidx], label); | - | ||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | if (vidx > 1)
| 0 | ||||||||||||||||||||||||||||||
| 730 | vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2); never executed: vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2); | 0 | ||||||||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||||||||
| 732 | label->vLayoutIndex = vidx; | - | ||||||||||||||||||||||||||||||
| 733 | label->sideBySide = false; | - | ||||||||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||||||||
| 735 | prevItem1 = label; | - | ||||||||||||||||||||||||||||||
| 736 | prevItem2 = 0; | - | ||||||||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||||||||
| 738 | if (vLayouts[vidx].stretch > 0)
| 0 | ||||||||||||||||||||||||||||||
| 739 | addTopBottomStretch = false; never executed: addTopBottomStretch = false; | 0 | ||||||||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||||||||
| 741 | ++vidx; | - | ||||||||||||||||||||||||||||||
| 742 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||||||||
| 744 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 745 | initLayoutStruct(vLayouts[vidx], field); | - | ||||||||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||||||||
| 747 | if (vidx > 1)
| 0 | ||||||||||||||||||||||||||||||
| 748 | vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2); never executed: vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2); | 0 | ||||||||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||||||||
| 750 | field->vLayoutIndex = vidx; | - | ||||||||||||||||||||||||||||||
| 751 | field->sideBySide = false; | - | ||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||
| 753 | prevItem1 = field; | - | ||||||||||||||||||||||||||||||
| 754 | prevItem2 = 0; | - | ||||||||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||||||||
| 756 | if (vLayouts[vidx].stretch > 0)
| 0 | ||||||||||||||||||||||||||||||
| 757 | addTopBottomStretch = false; never executed: addTopBottomStretch = false; | 0 | ||||||||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||||||||
| 759 | ++vidx; | - | ||||||||||||||||||||||||||||||
| 760 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||||||||
| 762 | prevRowSplit = splitSideBySide; | - | ||||||||||||||||||||||||||||||
| 763 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 764 | // we're in side by side mode, and we have enough space to do that | - | ||||||||||||||||||||||||||||||
| 765 | QSize max1(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 766 | QSize max2(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||||||||
| 768 | int stretch1 = 0; | - | ||||||||||||||||||||||||||||||
| 769 | int stretch2 = 0; | - | ||||||||||||||||||||||||||||||
| 770 | bool expanding = false; | - | ||||||||||||||||||||||||||||||
| 771 | - | |||||||||||||||||||||||||||||||
| 772 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 773 | max1 = label->maxSize; | - | ||||||||||||||||||||||||||||||
| 774 | if (label->expandingDirections() & Qt::Vertical)
| 0 | ||||||||||||||||||||||||||||||
| 775 | expanding = true; never executed: expanding = true; | 0 | ||||||||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||||||||
| 777 | label->sideBySide = (field != 0); | - | ||||||||||||||||||||||||||||||
| 778 | label->vLayoutIndex = vidx; | - | ||||||||||||||||||||||||||||||
| 779 | stretch1 = label->vStretch(); | - | ||||||||||||||||||||||||||||||
| 780 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||||||||
| 782 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 783 | max2 = field->maxSize; | - | ||||||||||||||||||||||||||||||
| 784 | if (field->expandingDirections() & Qt::Vertical)
| 0 | ||||||||||||||||||||||||||||||
| 785 | expanding = true; never executed: expanding = true; | 0 | ||||||||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||||||||
| 787 | field->sideBySide = (label || !field->fullRow);
| 0 | ||||||||||||||||||||||||||||||
| 788 | field->vLayoutIndex = vidx; | - | ||||||||||||||||||||||||||||||
| 789 | stretch2 = field->vStretch(); | - | ||||||||||||||||||||||||||||||
| 790 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 791 | - | |||||||||||||||||||||||||||||||
| 792 | vLayouts[vidx].init(qMax(stretch1, stretch2), qMax(min1.height(), min2.height())); | - | ||||||||||||||||||||||||||||||
| 793 | vLayouts[vidx].sizeHint = qMax(sh1.height(), sh2.height()); | - | ||||||||||||||||||||||||||||||
| 794 | vLayouts[vidx].maximumSize = qMin(max1.height(), max2.height()); | - | ||||||||||||||||||||||||||||||
| 795 | vLayouts[vidx].expansive = expanding || (vLayouts[vidx].stretch > 0);
| 0 | ||||||||||||||||||||||||||||||
| 796 | vLayouts[vidx].empty = false; | - | ||||||||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||||||||
| 798 | if (vLayouts[vidx].stretch > 0)
| 0 | ||||||||||||||||||||||||||||||
| 799 | addTopBottomStretch = false; never executed: addTopBottomStretch = false; | 0 | ||||||||||||||||||||||||||||||
| 800 | - | |||||||||||||||||||||||||||||||
| 801 | if (vidx > 1)
| 0 | ||||||||||||||||||||||||||||||
| 802 | vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, prevRowSplit, label, field, prevItem1, prevItem2); never executed: vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, prevRowSplit, label, field, prevItem1, prevItem2); | 0 | ||||||||||||||||||||||||||||||
| 803 | - | |||||||||||||||||||||||||||||||
| 804 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 805 | prevItem1 = label; | - | ||||||||||||||||||||||||||||||
| 806 | prevItem2 = field; | - | ||||||||||||||||||||||||||||||
| 807 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 808 | prevItem1 = field; | - | ||||||||||||||||||||||||||||||
| 809 | prevItem2 = 0; | - | ||||||||||||||||||||||||||||||
| 810 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 811 | - | |||||||||||||||||||||||||||||||
| 812 | prevRowSplit = false; | - | ||||||||||||||||||||||||||||||
| 813 | ++vidx; | - | ||||||||||||||||||||||||||||||
| 814 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 815 | } | - | ||||||||||||||||||||||||||||||
| 816 | - | |||||||||||||||||||||||||||||||
| 817 | if (addTopBottomStretch) {
| 0 | ||||||||||||||||||||||||||||||
| 818 | Qt::Alignment formAlignment = q->formAlignment(); | - | ||||||||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||||||||
| 820 | if (!(formAlignment & Qt::AlignBottom)) {
| 0 | ||||||||||||||||||||||||||||||
| 821 | // AlignTop (default if unspecified) or AlignVCenter: We add a stretch at the bottom | - | ||||||||||||||||||||||||||||||
| 822 | vLayouts[vidx].init(1, 0); | - | ||||||||||||||||||||||||||||||
| 823 | vLayouts[vidx].expansive = true; | - | ||||||||||||||||||||||||||||||
| 824 | ++vidx; | - | ||||||||||||||||||||||||||||||
| 825 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||||||||
| 827 | if (formAlignment & (Qt::AlignVCenter | Qt::AlignBottom)) {
| 0 | ||||||||||||||||||||||||||||||
| 828 | // AlignVCenter or AlignBottom: We add a stretch at the top | - | ||||||||||||||||||||||||||||||
| 829 | vLayouts[0].init(1, 0); | - | ||||||||||||||||||||||||||||||
| 830 | vLayouts[0].expansive = true; | - | ||||||||||||||||||||||||||||||
| 831 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 832 | vLayouts[0].init(0, 0); | - | ||||||||||||||||||||||||||||||
| 833 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 834 | } else { | - | ||||||||||||||||||||||||||||||
| 835 | vLayouts[0].init(0, 0); | - | ||||||||||||||||||||||||||||||
| 836 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||||||||
| 838 | vLayoutCount = vidx; | - | ||||||||||||||||||||||||||||||
| 839 | dirty = false; | - | ||||||||||||||||||||||||||||||
| 840 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||||||||
| 842 | void QFormLayoutPrivate::setupHorizontalLayoutData(int width) | - | ||||||||||||||||||||||||||||||
| 843 | { | - | ||||||||||||||||||||||||||||||
| 844 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||||||||
| 846 | // requires setupVerticalLayoutData to be called first | - | ||||||||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||||||||
| 848 | int fieldMaxWidth = 0; | - | ||||||||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||||||||
| 850 | int rr = m_matrix.rowCount(); | - | ||||||||||||||||||||||||||||||
| 851 | bool wrapAllRows = (q->rowWrapPolicy() == QFormLayout::WrapAllRows); | - | ||||||||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||||||||
| 853 | for (int i = 0; i < rr; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 854 | QFormLayoutItem *label = m_matrix(i, 0); | - | ||||||||||||||||||||||||||||||
| 855 | QFormLayoutItem *field = m_matrix(i, 1); | - | ||||||||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||||||||
| 857 | // Totally ignore empty rows... | - | ||||||||||||||||||||||||||||||
| 858 | if (!label && !field)
| 0 | ||||||||||||||||||||||||||||||
| 859 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||||||||
| 861 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 862 | // if there is a field, and we're side by side, we use maxLabelWidth | - | ||||||||||||||||||||||||||||||
| 863 | // otherwise we just use the sizehint | - | ||||||||||||||||||||||||||||||
| 864 | label->layoutWidth = (field && label->sideBySide) ? maxLabelWidth : label->sizeHint.width();
| 0 | ||||||||||||||||||||||||||||||
| 865 | label->layoutPos = 0; | - | ||||||||||||||||||||||||||||||
| 866 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||||||||
| 868 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 869 | // This is the default amount allotted to fields in sbs | - | ||||||||||||||||||||||||||||||
| 870 | int fldwidth = width - maxLabelWidth - field->sbsHSpace; | - | ||||||||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||||||||
| 872 | // If we've split a row, we still decide to align | - | ||||||||||||||||||||||||||||||
| 873 | // the field with all the other field if it will fit | - | ||||||||||||||||||||||||||||||
| 874 | // Fields in sbs mode get the remnants of the maxLabelWidth | - | ||||||||||||||||||||||||||||||
| 875 | if (!field->sideBySide) {
| 0 | ||||||||||||||||||||||||||||||
| 876 | if (wrapAllRows || (!label && field->fullRow) || field->sizeHint.width() > fldwidth) {
| 0 | ||||||||||||||||||||||||||||||
| 877 | field->layoutWidth = width; | - | ||||||||||||||||||||||||||||||
| 878 | field->layoutPos = 0; | - | ||||||||||||||||||||||||||||||
| 879 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 880 | field->layoutWidth = fldwidth; | - | ||||||||||||||||||||||||||||||
| 881 | field->layoutPos = width - fldwidth; | - | ||||||||||||||||||||||||||||||
| 882 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 883 | } else { | - | ||||||||||||||||||||||||||||||
| 884 | // We're sbs, so we should have a label | - | ||||||||||||||||||||||||||||||
| 885 | field->layoutWidth = fldwidth; | - | ||||||||||||||||||||||||||||||
| 886 | field->layoutPos = width - fldwidth; | - | ||||||||||||||||||||||||||||||
| 887 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||||||||
| 889 | fieldMaxWidth = qMax(fieldMaxWidth, field->maxSize.width()); | - | ||||||||||||||||||||||||||||||
| 890 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 891 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||||||||
| 893 | formMaxWidth = maxLabelWidth + fieldMaxWidth; | - | ||||||||||||||||||||||||||||||
| 894 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||||||||
| 896 | void QFormLayoutPrivate::calcSizeHints() | - | ||||||||||||||||||||||||||||||
| 897 | { | - | ||||||||||||||||||||||||||||||
| 898 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 899 | - | |||||||||||||||||||||||||||||||
| 900 | int leftMargin, topMargin, rightMargin, bottomMargin; | - | ||||||||||||||||||||||||||||||
| 901 | q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | - | ||||||||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||||||||
| 903 | updateSizes(); | - | ||||||||||||||||||||||||||||||
| 904 | setupVerticalLayoutData(QLAYOUTSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 905 | // Don't need to call setupHorizontal here | - | ||||||||||||||||||||||||||||||
| 906 | - | |||||||||||||||||||||||||||||||
| 907 | int h = topMargin + bottomMargin; | - | ||||||||||||||||||||||||||||||
| 908 | int mh = topMargin + bottomMargin; | - | ||||||||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||||||||
| 910 | // The following are set in updateSizes | - | ||||||||||||||||||||||||||||||
| 911 | int w = sh_width + leftMargin + rightMargin; | - | ||||||||||||||||||||||||||||||
| 912 | int mw = min_width + leftMargin + rightMargin; | - | ||||||||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||||||||
| 914 | for (int i = 0; i < vLayoutCount; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 915 | int spacing = vLayouts.at(i).spacing; | - | ||||||||||||||||||||||||||||||
| 916 | h += vLayouts.at(i).sizeHint + spacing; | - | ||||||||||||||||||||||||||||||
| 917 | mh += vLayouts.at(i).minimumSize + spacing; | - | ||||||||||||||||||||||||||||||
| 918 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||||||||
| 920 | minSize.rwidth() = qMin(mw, QLAYOUTSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 921 | minSize.rheight() = qMin(mh, QLAYOUTSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 922 | prefSize.rwidth() = qMin(w, QLAYOUTSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 923 | prefSize.rheight() = qMin(h, QLAYOUTSIZE_MAX); | - | ||||||||||||||||||||||||||||||
| 924 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||||||||
| 926 | int QFormLayoutPrivate::insertRow(int row) | - | ||||||||||||||||||||||||||||||
| 927 | { | - | ||||||||||||||||||||||||||||||
| 928 | int rowCnt = m_matrix.rowCount(); | - | ||||||||||||||||||||||||||||||
| 929 | if (uint(row) > uint(rowCnt))
| 0 | ||||||||||||||||||||||||||||||
| 930 | row = rowCnt; never executed: row = rowCnt; | 0 | ||||||||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||||||||
| 932 | insertRows(row, 1); | - | ||||||||||||||||||||||||||||||
| 933 | return row; never executed: return row; | 0 | ||||||||||||||||||||||||||||||
| 934 | } | - | ||||||||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||||||||
| 936 | void QFormLayoutPrivate::insertRows(int row, int count) | - | ||||||||||||||||||||||||||||||
| 937 | { | - | ||||||||||||||||||||||||||||||
| 938 | while (count > 0) {
| 0 | ||||||||||||||||||||||||||||||
| 939 | m_matrix.insertRow(row, 0); | - | ||||||||||||||||||||||||||||||
| 940 | --count; | - | ||||||||||||||||||||||||||||||
| 941 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 942 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 943 | - | |||||||||||||||||||||||||||||||
| 944 | bool QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item) | - | ||||||||||||||||||||||||||||||
| 945 | { | - | ||||||||||||||||||||||||||||||
| 946 | const bool fullRow = role == QFormLayout::SpanningRole; | - | ||||||||||||||||||||||||||||||
| 947 | const int column = role == QFormLayout::SpanningRole ? 1 : static_cast<int>(role);
| 0 | ||||||||||||||||||||||||||||||
| 948 | if (uint(row) >= uint(m_matrix.rowCount()) || uint(column) > 1U) {
| 0 | ||||||||||||||||||||||||||||||
| 949 | qWarning("QFormLayoutPrivate::setItem: Invalid cell (%d, %d)", row, column); | - | ||||||||||||||||||||||||||||||
| 950 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 951 | } | - | ||||||||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||||||||
| 953 | if (!item)
| 0 | ||||||||||||||||||||||||||||||
| 954 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||||||||
| 956 | if (m_matrix(row, column)) {
| 0 | ||||||||||||||||||||||||||||||
| 957 | qWarning("QFormLayoutPrivate::setItem: Cell (%d, %d) already occupied", row, column); | - | ||||||||||||||||||||||||||||||
| 958 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 959 | } | - | ||||||||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||||||||
| 961 | QFormLayoutItem *i = new QFormLayoutItem(item); | - | ||||||||||||||||||||||||||||||
| 962 | i->fullRow = fullRow; | - | ||||||||||||||||||||||||||||||
| 963 | m_matrix(row, column) = i; | - | ||||||||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||||||||
| 965 | m_things.append(i); | - | ||||||||||||||||||||||||||||||
| 966 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 967 | } | - | ||||||||||||||||||||||||||||||
| 968 | - | |||||||||||||||||||||||||||||||
| 969 | void QFormLayoutPrivate::setLayout(int row, QFormLayout::ItemRole role, QLayout *layout) | - | ||||||||||||||||||||||||||||||
| 970 | { | - | ||||||||||||||||||||||||||||||
| 971 | if (layout) {
| 0 | ||||||||||||||||||||||||||||||
| 972 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 973 | if (q->adoptLayout(layout))
| 0 | ||||||||||||||||||||||||||||||
| 974 | setItem(row, role, layout); never executed: setItem(row, role, layout); | 0 | ||||||||||||||||||||||||||||||
| 975 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 976 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||||||||
| 978 | void QFormLayoutPrivate::setWidget(int row, QFormLayout::ItemRole role, QWidget *widget) | - | ||||||||||||||||||||||||||||||
| 979 | { | - | ||||||||||||||||||||||||||||||
| 980 | if (widget) {
| 0 | ||||||||||||||||||||||||||||||
| 981 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 982 | q->addChildWidget(widget); | - | ||||||||||||||||||||||||||||||
| 983 | QWidgetItem *item = QLayoutPrivate::createWidgetItem(q, widget); | - | ||||||||||||||||||||||||||||||
| 984 | if (!setItem(row, role, item))
| 0 | ||||||||||||||||||||||||||||||
| 985 | delete item; never executed: delete item; | 0 | ||||||||||||||||||||||||||||||
| 986 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 987 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 988 | - | |||||||||||||||||||||||||||||||
| 989 | QStyle* QFormLayoutPrivate::getStyle() const | - | ||||||||||||||||||||||||||||||
| 990 | { | - | ||||||||||||||||||||||||||||||
| 991 | Q_Q(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||||||||
| 993 | // ### cache | - | ||||||||||||||||||||||||||||||
| 994 | if (QWidget *parentWidget = q->parentWidget())
| 0 | ||||||||||||||||||||||||||||||
| 995 | return parentWidget->style(); never executed: return parentWidget->style(); | 0 | ||||||||||||||||||||||||||||||
| 996 | else | - | ||||||||||||||||||||||||||||||
| 997 | return QApplication::style(); never executed: return QApplication::style(); | 0 | ||||||||||||||||||||||||||||||
| 998 | } | - | ||||||||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||||||||
| 1000 | QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) | - | ||||||||||||||||||||||||||||||
| 1001 | { | - | ||||||||||||||||||||||||||||||
| 1002 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1003 | if (!newitem)
| 0 | ||||||||||||||||||||||||||||||
| 1004 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1005 | const int storageIndex = storageIndexFromLayoutItem(m_matrix, m_things.value(index)); | - | ||||||||||||||||||||||||||||||
| 1006 | if (storageIndex == -1) {
| 0 | ||||||||||||||||||||||||||||||
| 1007 | // ### Qt6 - fix warning too when this class becomes public | - | ||||||||||||||||||||||||||||||
| 1008 | qWarning("QFormLayoutPrivate::replaceAt: Invalid index %d", index); | - | ||||||||||||||||||||||||||||||
| 1009 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1010 | } | - | ||||||||||||||||||||||||||||||
| 1011 | - | |||||||||||||||||||||||||||||||
| 1012 | int row, col; | - | ||||||||||||||||||||||||||||||
| 1013 | QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col); | - | ||||||||||||||||||||||||||||||
| 1014 | Q_ASSERT(m_matrix(row, col)); | - | ||||||||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||||||||
| 1016 | QFormLayoutItem *item = m_matrix(row, col); | - | ||||||||||||||||||||||||||||||
| 1017 | Q_ASSERT(item); | - | ||||||||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||||||||
| 1019 | QLayoutItem *olditem = item->item; | - | ||||||||||||||||||||||||||||||
| 1020 | item->item = newitem; | - | ||||||||||||||||||||||||||||||
| 1021 | - | |||||||||||||||||||||||||||||||
| 1022 | q->invalidate(); | - | ||||||||||||||||||||||||||||||
| 1023 | return olditem; never executed: return olditem; | 0 | ||||||||||||||||||||||||||||||
| 1024 | } | - | ||||||||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||||||||
| 1026 | /*! | - | ||||||||||||||||||||||||||||||
| 1027 | \class QFormLayout | - | ||||||||||||||||||||||||||||||
| 1028 | \since 4.4 | - | ||||||||||||||||||||||||||||||
| 1029 | \brief The QFormLayout class manages forms of input widgets and their associated labels. | - | ||||||||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||||||||
| 1031 | \ingroup geomanagement | - | ||||||||||||||||||||||||||||||
| 1032 | \inmodule QtWidgets | - | ||||||||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||||||||
| 1034 | QFormLayout is a convenience layout class that lays out its | - | ||||||||||||||||||||||||||||||
| 1035 | children in a two-column form. The left column consists of labels | - | ||||||||||||||||||||||||||||||
| 1036 | and the right column consists of "field" widgets (line editors, | - | ||||||||||||||||||||||||||||||
| 1037 | spin boxes, etc.). | - | ||||||||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||||||||
| 1039 | Traditionally, such two-column form layouts were achieved using | - | ||||||||||||||||||||||||||||||
| 1040 | QGridLayout. QFormLayout is a higher-level alternative that | - | ||||||||||||||||||||||||||||||
| 1041 | provides the following advantages: | - | ||||||||||||||||||||||||||||||
| 1042 | - | |||||||||||||||||||||||||||||||
| 1043 | \list | - | ||||||||||||||||||||||||||||||
| 1044 | \li \b{Adherence to the different platform's look and feel guidelines.} | - | ||||||||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||||||||
| 1046 | For example, the | - | ||||||||||||||||||||||||||||||
| 1047 | \l{http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html}{\macos Aqua} and KDE guidelines specify that the | - | ||||||||||||||||||||||||||||||
| 1048 | labels should be right-aligned, whereas Windows and GNOME | - | ||||||||||||||||||||||||||||||
| 1049 | applications normally use left-alignment. | - | ||||||||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||||||||
| 1051 | \li \b{Support for wrapping long rows.} | - | ||||||||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||||||||
| 1053 | For devices with small displays, QFormLayout can be set to | - | ||||||||||||||||||||||||||||||
| 1054 | \l{WrapLongRows}{wrap long rows}, or even to | - | ||||||||||||||||||||||||||||||
| 1055 | \l{WrapAllRows}{wrap all rows}. | - | ||||||||||||||||||||||||||||||
| 1056 | - | |||||||||||||||||||||||||||||||
| 1057 | \li \b{Convenient API for creating label--field pairs.} | - | ||||||||||||||||||||||||||||||
| 1058 | - | |||||||||||||||||||||||||||||||
| 1059 | The addRow() overload that takes a QString and a QWidget * | - | ||||||||||||||||||||||||||||||
| 1060 | creates a QLabel behind the scenes and automatically set up | - | ||||||||||||||||||||||||||||||
| 1061 | its buddy. We can then write code like this: | - | ||||||||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||||||||
| 1063 | \snippet code/src_gui_kernel_qformlayout.cpp 0 | - | ||||||||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||||||||
| 1065 | Compare this with the following code, written using QGridLayout: | - | ||||||||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||||||||
| 1067 | \snippet code/src_gui_kernel_qformlayout.cpp 1 | - | ||||||||||||||||||||||||||||||
| 1068 | \endlist | - | ||||||||||||||||||||||||||||||
| 1069 | - | |||||||||||||||||||||||||||||||
| 1070 | The table below shows the default appearance in different styles. | - | ||||||||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||||||||
| 1072 | \table | - | ||||||||||||||||||||||||||||||
| 1073 | \header | - | ||||||||||||||||||||||||||||||
| 1074 | \li QCommonStyle derived styles (except QPlastiqueStyle) | - | ||||||||||||||||||||||||||||||
| 1075 | \li QMacStyle | - | ||||||||||||||||||||||||||||||
| 1076 | \li QPlastiqueStyle | - | ||||||||||||||||||||||||||||||
| 1077 | \li Qt Extended styles | - | ||||||||||||||||||||||||||||||
| 1078 | \row | - | ||||||||||||||||||||||||||||||
| 1079 | \li \inlineimage qformlayout-win.png | - | ||||||||||||||||||||||||||||||
| 1080 | \li \inlineimage qformlayout-mac.png | - | ||||||||||||||||||||||||||||||
| 1081 | \li \inlineimage qformlayout-kde.png | - | ||||||||||||||||||||||||||||||
| 1082 | \li \inlineimage qformlayout-qpe.png | - | ||||||||||||||||||||||||||||||
| 1083 | \row | - | ||||||||||||||||||||||||||||||
| 1084 | \li Traditional style used for Windows, GNOME, and earlier | - | ||||||||||||||||||||||||||||||
| 1085 | versions of KDE. Labels are left aligned, and expanding | - | ||||||||||||||||||||||||||||||
| 1086 | fields grow to fill the available space. (This normally | - | ||||||||||||||||||||||||||||||
| 1087 | corresponds to what we would get using a two-column | - | ||||||||||||||||||||||||||||||
| 1088 | QGridLayout.) | - | ||||||||||||||||||||||||||||||
| 1089 | \li Style based on the | - | ||||||||||||||||||||||||||||||
| 1090 | \l{http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html}{\macos Aqua} guidelines. Labels are right-aligned, | - | ||||||||||||||||||||||||||||||
| 1091 | the fields don't grow beyond their size hint, and the | - | ||||||||||||||||||||||||||||||
| 1092 | form is horizontally centered. | - | ||||||||||||||||||||||||||||||
| 1093 | \li Recommended style for | - | ||||||||||||||||||||||||||||||
| 1094 | \l{KDE applications}. Similar to MacStyle, except that the form | - | ||||||||||||||||||||||||||||||
| 1095 | is left-aligned and all fields grow to fill the available | - | ||||||||||||||||||||||||||||||
| 1096 | space. | - | ||||||||||||||||||||||||||||||
| 1097 | \li Default style for Qt Extended styles. Labels are right-aligned, | - | ||||||||||||||||||||||||||||||
| 1098 | expanding fields grow to fill the available space, and row | - | ||||||||||||||||||||||||||||||
| 1099 | wrapping is enabled for long lines. | - | ||||||||||||||||||||||||||||||
| 1100 | \endtable | - | ||||||||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||||||||
| 1102 | The form styles can be also be overridden individually by calling | - | ||||||||||||||||||||||||||||||
| 1103 | setLabelAlignment(), setFormAlignment(), setFieldGrowthPolicy(), | - | ||||||||||||||||||||||||||||||
| 1104 | and setRowWrapPolicy(). For example, to simulate the form layout | - | ||||||||||||||||||||||||||||||
| 1105 | appearance of QMacStyle on all platforms, but with left-aligned | - | ||||||||||||||||||||||||||||||
| 1106 | labels, you could write: | - | ||||||||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||||||||
| 1108 | \snippet code/src_gui_kernel_qformlayout.cpp 2 | - | ||||||||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||||||||
| 1110 | \sa QGridLayout, QBoxLayout, QStackedLayout | - | ||||||||||||||||||||||||||||||
| 1111 | */ | - | ||||||||||||||||||||||||||||||
| 1112 | - | |||||||||||||||||||||||||||||||
| 1113 | - | |||||||||||||||||||||||||||||||
| 1114 | /*! | - | ||||||||||||||||||||||||||||||
| 1115 | \enum QFormLayout::FieldGrowthPolicy | - | ||||||||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||||||||
| 1117 | This enum specifies the different policies that can be used to | - | ||||||||||||||||||||||||||||||
| 1118 | control the way in which the form's fields grow. | - | ||||||||||||||||||||||||||||||
| 1119 | - | |||||||||||||||||||||||||||||||
| 1120 | \value FieldsStayAtSizeHint | - | ||||||||||||||||||||||||||||||
| 1121 | The fields never grow beyond their | - | ||||||||||||||||||||||||||||||
| 1122 | \l{QWidgetItem::sizeHint()}{effective size hint}. This is | - | ||||||||||||||||||||||||||||||
| 1123 | the default for QMacStyle. | - | ||||||||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||||||||
| 1125 | \value ExpandingFieldsGrow | - | ||||||||||||||||||||||||||||||
| 1126 | Fields with an horizontal \l{QSizePolicy}{size policy} of | - | ||||||||||||||||||||||||||||||
| 1127 | \l{QSizePolicy::}{Expanding} or | - | ||||||||||||||||||||||||||||||
| 1128 | \l{QSizePolicy::}{MinimumExpanding} will grow to fill the | - | ||||||||||||||||||||||||||||||
| 1129 | available space. The other fields will not grow beyond | - | ||||||||||||||||||||||||||||||
| 1130 | their effective size hint. This is the default policy for | - | ||||||||||||||||||||||||||||||
| 1131 | Plastique. | - | ||||||||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||||||||
| 1133 | \value AllNonFixedFieldsGrow | - | ||||||||||||||||||||||||||||||
| 1134 | All fields with a size policy that allows them to grow | - | ||||||||||||||||||||||||||||||
| 1135 | will grow to fill the available space. This is the default | - | ||||||||||||||||||||||||||||||
| 1136 | policy for most styles. | - | ||||||||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||||||||
| 1138 | \sa fieldGrowthPolicy | - | ||||||||||||||||||||||||||||||
| 1139 | */ | - | ||||||||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||||||||
| 1141 | /*! | - | ||||||||||||||||||||||||||||||
| 1142 | \enum QFormLayout::RowWrapPolicy | - | ||||||||||||||||||||||||||||||
| 1143 | - | |||||||||||||||||||||||||||||||
| 1144 | This enum specifies the different policies that can be used to | - | ||||||||||||||||||||||||||||||
| 1145 | control the way in which the form's rows wrap. | - | ||||||||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||||||||
| 1147 | \value DontWrapRows | - | ||||||||||||||||||||||||||||||
| 1148 | Fields are always laid out next to their label. This is | - | ||||||||||||||||||||||||||||||
| 1149 | the default policy for all styles except Qt Extended styles. | - | ||||||||||||||||||||||||||||||
| 1150 | - | |||||||||||||||||||||||||||||||
| 1151 | \value WrapLongRows | - | ||||||||||||||||||||||||||||||
| 1152 | Labels are given enough horizontal space to fit the widest label, | - | ||||||||||||||||||||||||||||||
| 1153 | and the rest of the space is given to the fields. If the minimum | - | ||||||||||||||||||||||||||||||
| 1154 | size of a field pair is wider than the available space, the field | - | ||||||||||||||||||||||||||||||
| 1155 | is wrapped to the next line. This is the default policy for | - | ||||||||||||||||||||||||||||||
| 1156 | Qt Extended styles. | - | ||||||||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||||||||
| 1158 | \value WrapAllRows | - | ||||||||||||||||||||||||||||||
| 1159 | Fields are always laid out below their label. | - | ||||||||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||||||||
| 1161 | \sa rowWrapPolicy | - | ||||||||||||||||||||||||||||||
| 1162 | */ | - | ||||||||||||||||||||||||||||||
| 1163 | - | |||||||||||||||||||||||||||||||
| 1164 | /*! | - | ||||||||||||||||||||||||||||||
| 1165 | \enum QFormLayout::ItemRole | - | ||||||||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||||||||
| 1167 | This enum specifies the types of widgets (or other layout items) | - | ||||||||||||||||||||||||||||||
| 1168 | that may appear in a row. | - | ||||||||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||||||||
| 1170 | \value LabelRole A label widget. | - | ||||||||||||||||||||||||||||||
| 1171 | \value FieldRole A field widget. | - | ||||||||||||||||||||||||||||||
| 1172 | \value SpanningRole A widget that spans label and field columns. | - | ||||||||||||||||||||||||||||||
| 1173 | - | |||||||||||||||||||||||||||||||
| 1174 | \sa itemAt(), getItemPosition() | - | ||||||||||||||||||||||||||||||
| 1175 | */ | - | ||||||||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||||||||
| 1177 | /*! | - | ||||||||||||||||||||||||||||||
| 1178 | Constructs a new form layout with the given \a parent widget. | - | ||||||||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||||||||
| 1180 | \sa QWidget::setLayout() | - | ||||||||||||||||||||||||||||||
| 1181 | */ | - | ||||||||||||||||||||||||||||||
| 1182 | QFormLayout::QFormLayout(QWidget *parent) | - | ||||||||||||||||||||||||||||||
| 1183 | : QLayout(*new QFormLayoutPrivate, 0, parent) | - | ||||||||||||||||||||||||||||||
| 1184 | { | - | ||||||||||||||||||||||||||||||
| 1185 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1186 | - | |||||||||||||||||||||||||||||||
| 1187 | /*! | - | ||||||||||||||||||||||||||||||
| 1188 | Destroys the form layout. | - | ||||||||||||||||||||||||||||||
| 1189 | */ | - | ||||||||||||||||||||||||||||||
| 1190 | QFormLayout::~QFormLayout() | - | ||||||||||||||||||||||||||||||
| 1191 | { | - | ||||||||||||||||||||||||||||||
| 1192 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||||||||
| 1194 | /* | - | ||||||||||||||||||||||||||||||
| 1195 | The clearing and destruction order here is important. We start by clearing | - | ||||||||||||||||||||||||||||||
| 1196 | m_things so that QLayout and the rest of the world know that we don't babysit | - | ||||||||||||||||||||||||||||||
| 1197 | the layout items anymore and don't care if they are destroyed. | - | ||||||||||||||||||||||||||||||
| 1198 | */ | - | ||||||||||||||||||||||||||||||
| 1199 | d->m_things.clear(); | - | ||||||||||||||||||||||||||||||
| 1200 | qDeleteAll(d->m_matrix.storage()); | - | ||||||||||||||||||||||||||||||
| 1201 | d->m_matrix.clear(); | - | ||||||||||||||||||||||||||||||
| 1202 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||||||||
| 1204 | /*! | - | ||||||||||||||||||||||||||||||
| 1205 | Adds a new row to the bottom of this form layout, with the given | - | ||||||||||||||||||||||||||||||
| 1206 | \a label and \a field. | - | ||||||||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||||||||
| 1208 | \sa insertRow() | - | ||||||||||||||||||||||||||||||
| 1209 | */ | - | ||||||||||||||||||||||||||||||
| 1210 | void QFormLayout::addRow(QWidget *label, QWidget *field) | - | ||||||||||||||||||||||||||||||
| 1211 | { | - | ||||||||||||||||||||||||||||||
| 1212 | insertRow(-1, label, field); | - | ||||||||||||||||||||||||||||||
| 1213 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||||||||
| 1215 | /*! | - | ||||||||||||||||||||||||||||||
| 1216 | \overload | - | ||||||||||||||||||||||||||||||
| 1217 | */ | - | ||||||||||||||||||||||||||||||
| 1218 | void QFormLayout::addRow(QWidget *label, QLayout *field) | - | ||||||||||||||||||||||||||||||
| 1219 | { | - | ||||||||||||||||||||||||||||||
| 1220 | insertRow(-1, label, field); | - | ||||||||||||||||||||||||||||||
| 1221 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1222 | - | |||||||||||||||||||||||||||||||
| 1223 | /*! | - | ||||||||||||||||||||||||||||||
| 1224 | \overload | - | ||||||||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||||||||
| 1226 | This overload automatically creates a QLabel behind the scenes | - | ||||||||||||||||||||||||||||||
| 1227 | with \a labelText as its text. The \a field is set as the new | - | ||||||||||||||||||||||||||||||
| 1228 | QLabel's \l{QLabel::setBuddy()}{buddy}. | - | ||||||||||||||||||||||||||||||
| 1229 | */ | - | ||||||||||||||||||||||||||||||
| 1230 | void QFormLayout::addRow(const QString &labelText, QWidget *field) | - | ||||||||||||||||||||||||||||||
| 1231 | { | - | ||||||||||||||||||||||||||||||
| 1232 | insertRow(-1, labelText, field); | - | ||||||||||||||||||||||||||||||
| 1233 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||||||||
| 1235 | /*! | - | ||||||||||||||||||||||||||||||
| 1236 | \overload | - | ||||||||||||||||||||||||||||||
| 1237 | - | |||||||||||||||||||||||||||||||
| 1238 | This overload automatically creates a QLabel behind the scenes | - | ||||||||||||||||||||||||||||||
| 1239 | with \a labelText as its text. | - | ||||||||||||||||||||||||||||||
| 1240 | */ | - | ||||||||||||||||||||||||||||||
| 1241 | void QFormLayout::addRow(const QString &labelText, QLayout *field) | - | ||||||||||||||||||||||||||||||
| 1242 | { | - | ||||||||||||||||||||||||||||||
| 1243 | insertRow(-1, labelText, field); | - | ||||||||||||||||||||||||||||||
| 1244 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||||||||
| 1246 | /*! | - | ||||||||||||||||||||||||||||||
| 1247 | \overload | - | ||||||||||||||||||||||||||||||
| 1248 | - | |||||||||||||||||||||||||||||||
| 1249 | Adds the specified \a widget at the end of this form layout. The | - | ||||||||||||||||||||||||||||||
| 1250 | \a widget spans both columns. | - | ||||||||||||||||||||||||||||||
| 1251 | */ | - | ||||||||||||||||||||||||||||||
| 1252 | void QFormLayout::addRow(QWidget *widget) | - | ||||||||||||||||||||||||||||||
| 1253 | { | - | ||||||||||||||||||||||||||||||
| 1254 | insertRow(-1, widget); | - | ||||||||||||||||||||||||||||||
| 1255 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1256 | - | |||||||||||||||||||||||||||||||
| 1257 | /*! | - | ||||||||||||||||||||||||||||||
| 1258 | \overload | - | ||||||||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||||||||
| 1260 | Adds the specified \a layout at the end of this form layout. The | - | ||||||||||||||||||||||||||||||
| 1261 | \a layout spans both columns. | - | ||||||||||||||||||||||||||||||
| 1262 | */ | - | ||||||||||||||||||||||||||||||
| 1263 | void QFormLayout::addRow(QLayout *layout) | - | ||||||||||||||||||||||||||||||
| 1264 | { | - | ||||||||||||||||||||||||||||||
| 1265 | insertRow(-1, layout); | - | ||||||||||||||||||||||||||||||
| 1266 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||||||||
| 1268 | /*! | - | ||||||||||||||||||||||||||||||
| 1269 | Inserts a new row at position \a row in this form layout, with | - | ||||||||||||||||||||||||||||||
| 1270 | the given \a label and \a field. If \a row is out of bounds, the | - | ||||||||||||||||||||||||||||||
| 1271 | new row is added at the end. | - | ||||||||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||||||||
| 1273 | \sa addRow() | - | ||||||||||||||||||||||||||||||
| 1274 | */ | - | ||||||||||||||||||||||||||||||
| 1275 | void QFormLayout::insertRow(int row, QWidget *label, QWidget *field) | - | ||||||||||||||||||||||||||||||
| 1276 | { | - | ||||||||||||||||||||||||||||||
| 1277 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1278 | if ((label && !d->checkWidget(label)) || (field && !d->checkWidget(field)))
| 0 | ||||||||||||||||||||||||||||||
| 1279 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1280 | - | |||||||||||||||||||||||||||||||
| 1281 | row = d->insertRow(row); | - | ||||||||||||||||||||||||||||||
| 1282 | if (label)
| 0 | ||||||||||||||||||||||||||||||
| 1283 | d->setWidget(row, LabelRole, label); never executed: d->setWidget(row, LabelRole, label); | 0 | ||||||||||||||||||||||||||||||
| 1284 | if (field)
| 0 | ||||||||||||||||||||||||||||||
| 1285 | d->setWidget(row, FieldRole, field); never executed: d->setWidget(row, FieldRole, field); | 0 | ||||||||||||||||||||||||||||||
| 1286 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1287 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||||||||
| 1289 | /*! | - | ||||||||||||||||||||||||||||||
| 1290 | \overload | - | ||||||||||||||||||||||||||||||
| 1291 | */ | - | ||||||||||||||||||||||||||||||
| 1292 | void QFormLayout::insertRow(int row, QWidget *label, QLayout *field) | - | ||||||||||||||||||||||||||||||
| 1293 | { | - | ||||||||||||||||||||||||||||||
| 1294 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1295 | if ((label && !d->checkWidget(label)) || (field && !d->checkLayout(field)))
| 0 | ||||||||||||||||||||||||||||||
| 1296 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||||||||
| 1298 | row = d->insertRow(row); | - | ||||||||||||||||||||||||||||||
| 1299 | if (label)
| 0 | ||||||||||||||||||||||||||||||
| 1300 | d->setWidget(row, LabelRole, label); never executed: d->setWidget(row, LabelRole, label); | 0 | ||||||||||||||||||||||||||||||
| 1301 | if (field)
| 0 | ||||||||||||||||||||||||||||||
| 1302 | d->setLayout(row, FieldRole, field); never executed: d->setLayout(row, FieldRole, field); | 0 | ||||||||||||||||||||||||||||||
| 1303 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1304 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1305 | - | |||||||||||||||||||||||||||||||
| 1306 | /*! | - | ||||||||||||||||||||||||||||||
| 1307 | \overload | - | ||||||||||||||||||||||||||||||
| 1308 | - | |||||||||||||||||||||||||||||||
| 1309 | This overload automatically creates a QLabel behind the scenes | - | ||||||||||||||||||||||||||||||
| 1310 | with \a labelText as its text. The \a field is set as the new | - | ||||||||||||||||||||||||||||||
| 1311 | QLabel's \l{QLabel::setBuddy()}{buddy}. | - | ||||||||||||||||||||||||||||||
| 1312 | */ | - | ||||||||||||||||||||||||||||||
| 1313 | void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field) | - | ||||||||||||||||||||||||||||||
| 1314 | { | - | ||||||||||||||||||||||||||||||
| 1315 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1316 | if (field && !d->checkWidget(field))
| 0 | ||||||||||||||||||||||||||||||
| 1317 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1318 | - | |||||||||||||||||||||||||||||||
| 1319 | QLabel *label = 0; | - | ||||||||||||||||||||||||||||||
| 1320 | if (!labelText.isEmpty()) {
| 0 | ||||||||||||||||||||||||||||||
| 1321 | label = new QLabel(labelText); | - | ||||||||||||||||||||||||||||||
| 1322 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||||||||
| 1323 | label->setBuddy(field); | - | ||||||||||||||||||||||||||||||
| 1324 | #endif | - | ||||||||||||||||||||||||||||||
| 1325 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1326 | insertRow(row, label, field); | - | ||||||||||||||||||||||||||||||
| 1327 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1328 | - | |||||||||||||||||||||||||||||||
| 1329 | /*! | - | ||||||||||||||||||||||||||||||
| 1330 | \overload | - | ||||||||||||||||||||||||||||||
| 1331 | - | |||||||||||||||||||||||||||||||
| 1332 | This overload automatically creates a QLabel behind the scenes | - | ||||||||||||||||||||||||||||||
| 1333 | with \a labelText as its text. | - | ||||||||||||||||||||||||||||||
| 1334 | */ | - | ||||||||||||||||||||||||||||||
| 1335 | void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field) | - | ||||||||||||||||||||||||||||||
| 1336 | { | - | ||||||||||||||||||||||||||||||
| 1337 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1338 | if (field && !d->checkLayout(field))
| 0 | ||||||||||||||||||||||||||||||
| 1339 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||||||||
| 1341 | insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field); | - | ||||||||||||||||||||||||||||||
| 1342 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||||||||
| 1344 | /*! | - | ||||||||||||||||||||||||||||||
| 1345 | \overload | - | ||||||||||||||||||||||||||||||
| 1346 | - | |||||||||||||||||||||||||||||||
| 1347 | Inserts the specified \a widget at position \a row in this form | - | ||||||||||||||||||||||||||||||
| 1348 | layout. The \a widget spans both columns. If \a row is out of | - | ||||||||||||||||||||||||||||||
| 1349 | bounds, the widget is added at the end. | - | ||||||||||||||||||||||||||||||
| 1350 | */ | - | ||||||||||||||||||||||||||||||
| 1351 | void QFormLayout::insertRow(int row, QWidget *widget) | - | ||||||||||||||||||||||||||||||
| 1352 | { | - | ||||||||||||||||||||||||||||||
| 1353 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1354 | if (!d->checkWidget(widget))
| 0 | ||||||||||||||||||||||||||||||
| 1355 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1356 | - | |||||||||||||||||||||||||||||||
| 1357 | row = d->insertRow(row); | - | ||||||||||||||||||||||||||||||
| 1358 | d->setWidget(row, SpanningRole, widget); | - | ||||||||||||||||||||||||||||||
| 1359 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1360 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1361 | - | |||||||||||||||||||||||||||||||
| 1362 | /*! | - | ||||||||||||||||||||||||||||||
| 1363 | \overload | - | ||||||||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||||||||
| 1365 | Inserts the specified \a layout at position \a row in this form | - | ||||||||||||||||||||||||||||||
| 1366 | layout. The \a layout spans both columns. If \a row is out of | - | ||||||||||||||||||||||||||||||
| 1367 | bounds, the widget is added at the end. | - | ||||||||||||||||||||||||||||||
| 1368 | */ | - | ||||||||||||||||||||||||||||||
| 1369 | void QFormLayout::insertRow(int row, QLayout *layout) | - | ||||||||||||||||||||||||||||||
| 1370 | { | - | ||||||||||||||||||||||||||||||
| 1371 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1372 | if (!d->checkLayout(layout))
| 0 | ||||||||||||||||||||||||||||||
| 1373 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||||||||
| 1375 | row = d->insertRow(row); | - | ||||||||||||||||||||||||||||||
| 1376 | d->setLayout(row, SpanningRole, layout); | - | ||||||||||||||||||||||||||||||
| 1377 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1378 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1379 | - | |||||||||||||||||||||||||||||||
| 1380 | /*! | - | ||||||||||||||||||||||||||||||
| 1381 | \reimp | - | ||||||||||||||||||||||||||||||
| 1382 | */ | - | ||||||||||||||||||||||||||||||
| 1383 | void QFormLayout::addItem(QLayoutItem *item) | - | ||||||||||||||||||||||||||||||
| 1384 | { | - | ||||||||||||||||||||||||||||||
| 1385 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1386 | - | |||||||||||||||||||||||||||||||
| 1387 | int row = d->insertRow(d->m_matrix.rowCount()); | - | ||||||||||||||||||||||||||||||
| 1388 | d->setItem(row, FieldRole, item); | - | ||||||||||||||||||||||||||||||
| 1389 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1390 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||||||||
| 1392 | /*! | - | ||||||||||||||||||||||||||||||
| 1393 | \reimp | - | ||||||||||||||||||||||||||||||
| 1394 | */ | - | ||||||||||||||||||||||||||||||
| 1395 | int QFormLayout::count() const | - | ||||||||||||||||||||||||||||||
| 1396 | { | - | ||||||||||||||||||||||||||||||
| 1397 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1398 | return d->m_things.count(); never executed: return d->m_things.count(); | 0 | ||||||||||||||||||||||||||||||
| 1399 | } | - | ||||||||||||||||||||||||||||||
| 1400 | - | |||||||||||||||||||||||||||||||
| 1401 | /*! | - | ||||||||||||||||||||||||||||||
| 1402 | \reimp | - | ||||||||||||||||||||||||||||||
| 1403 | */ | - | ||||||||||||||||||||||||||||||
| 1404 | QLayoutItem *QFormLayout::itemAt(int index) const | - | ||||||||||||||||||||||||||||||
| 1405 | { | - | ||||||||||||||||||||||||||||||
| 1406 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1407 | if (QFormLayoutItem *formItem = d->m_things.value(index))
| 0 | ||||||||||||||||||||||||||||||
| 1408 | return formItem->item; never executed: return formItem->item; | 0 | ||||||||||||||||||||||||||||||
| 1409 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1410 | } | - | ||||||||||||||||||||||||||||||
| 1411 | - | |||||||||||||||||||||||||||||||
| 1412 | /*! | - | ||||||||||||||||||||||||||||||
| 1413 | \reimp | - | ||||||||||||||||||||||||||||||
| 1414 | */ | - | ||||||||||||||||||||||||||||||
| 1415 | QLayoutItem *QFormLayout::takeAt(int index) | - | ||||||||||||||||||||||||||||||
| 1416 | { | - | ||||||||||||||||||||||||||||||
| 1417 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1418 | - | |||||||||||||||||||||||||||||||
| 1419 | const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index)); | - | ||||||||||||||||||||||||||||||
| 1420 | if (storageIndex == -1) {
| 0 | ||||||||||||||||||||||||||||||
| 1421 | qWarning("QFormLayout::takeAt: Invalid index %d", index); | - | ||||||||||||||||||||||||||||||
| 1422 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1423 | } | - | ||||||||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||||||||
| 1425 | int row, col; | - | ||||||||||||||||||||||||||||||
| 1426 | QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col); | - | ||||||||||||||||||||||||||||||
| 1427 | Q_ASSERT(d->m_matrix(row, col)); | - | ||||||||||||||||||||||||||||||
| 1428 | - | |||||||||||||||||||||||||||||||
| 1429 | QFormLayoutItem *item = d->m_matrix(row, col); | - | ||||||||||||||||||||||||||||||
| 1430 | Q_ASSERT(item); | - | ||||||||||||||||||||||||||||||
| 1431 | d->m_things.removeAt(index); | - | ||||||||||||||||||||||||||||||
| 1432 | d->m_matrix(row, col) = 0; | - | ||||||||||||||||||||||||||||||
| 1433 | - | |||||||||||||||||||||||||||||||
| 1434 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1435 | - | |||||||||||||||||||||||||||||||
| 1436 | // grab ownership back from the QFormLayoutItem | - | ||||||||||||||||||||||||||||||
| 1437 | QLayoutItem *i = item->item; | - | ||||||||||||||||||||||||||||||
| 1438 | item->item = 0; | - | ||||||||||||||||||||||||||||||
| 1439 | delete item; | - | ||||||||||||||||||||||||||||||
| 1440 | - | |||||||||||||||||||||||||||||||
| 1441 | if (QLayout *l = i->layout()) {
| 0 | ||||||||||||||||||||||||||||||
| 1442 | // sanity check in case the user passed something weird to QObject::setParent() | - | ||||||||||||||||||||||||||||||
| 1443 | if (l->parent() == this)
| 0 | ||||||||||||||||||||||||||||||
| 1444 | l->setParent(0); never executed: l->setParent(0); | 0 | ||||||||||||||||||||||||||||||
| 1445 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1446 | - | |||||||||||||||||||||||||||||||
| 1447 | return i; never executed: return i; | 0 | ||||||||||||||||||||||||||||||
| 1448 | } | - | ||||||||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||||||||
| 1450 | /*! | - | ||||||||||||||||||||||||||||||
| 1451 | \reimp | - | ||||||||||||||||||||||||||||||
| 1452 | */ | - | ||||||||||||||||||||||||||||||
| 1453 | Qt::Orientations QFormLayout::expandingDirections() const | - | ||||||||||||||||||||||||||||||
| 1454 | { | - | ||||||||||||||||||||||||||||||
| 1455 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1456 | QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d); | - | ||||||||||||||||||||||||||||||
| 1457 | e->updateSizes(); | - | ||||||||||||||||||||||||||||||
| 1458 | - | |||||||||||||||||||||||||||||||
| 1459 | Qt::Orientations o = 0; | - | ||||||||||||||||||||||||||||||
| 1460 | if (e->expandHorizontal)
| 0 | ||||||||||||||||||||||||||||||
| 1461 | o = Qt::Horizontal; never executed: o = Qt::Horizontal; | 0 | ||||||||||||||||||||||||||||||
| 1462 | if (e->expandVertical)
| 0 | ||||||||||||||||||||||||||||||
| 1463 | o |= Qt::Vertical; never executed: o |= Qt::Vertical; | 0 | ||||||||||||||||||||||||||||||
| 1464 | return o; never executed: return o; | 0 | ||||||||||||||||||||||||||||||
| 1465 | } | - | ||||||||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||||||||
| 1467 | /*! | - | ||||||||||||||||||||||||||||||
| 1468 | \reimp | - | ||||||||||||||||||||||||||||||
| 1469 | */ | - | ||||||||||||||||||||||||||||||
| 1470 | bool QFormLayout::hasHeightForWidth() const | - | ||||||||||||||||||||||||||||||
| 1471 | { | - | ||||||||||||||||||||||||||||||
| 1472 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1473 | QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d); | - | ||||||||||||||||||||||||||||||
| 1474 | e->updateSizes(); | - | ||||||||||||||||||||||||||||||
| 1475 | return (d->has_hfw || rowWrapPolicy() == WrapLongRows); never executed: return (d->has_hfw || rowWrapPolicy() == WrapLongRows);
| 0 | ||||||||||||||||||||||||||||||
| 1476 | } | - | ||||||||||||||||||||||||||||||
| 1477 | - | |||||||||||||||||||||||||||||||
| 1478 | /*! | - | ||||||||||||||||||||||||||||||
| 1479 | \reimp | - | ||||||||||||||||||||||||||||||
| 1480 | */ | - | ||||||||||||||||||||||||||||||
| 1481 | int QFormLayout::heightForWidth(int width) const | - | ||||||||||||||||||||||||||||||
| 1482 | { | - | ||||||||||||||||||||||||||||||
| 1483 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1484 | if (!hasHeightForWidth())
| 0 | ||||||||||||||||||||||||||||||
| 1485 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 1486 | - | |||||||||||||||||||||||||||||||
| 1487 | int leftMargin, topMargin, rightMargin, bottomMargin; | - | ||||||||||||||||||||||||||||||
| 1488 | getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | - | ||||||||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||||||||
| 1490 | int targetWidth = width - leftMargin - rightMargin; | - | ||||||||||||||||||||||||||||||
| 1491 | - | |||||||||||||||||||||||||||||||
| 1492 | if (!d->haveHfwCached(targetWidth)) {
| 0 | ||||||||||||||||||||||||||||||
| 1493 | QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d); | - | ||||||||||||||||||||||||||||||
| 1494 | dat->setupVerticalLayoutData(targetWidth); | - | ||||||||||||||||||||||||||||||
| 1495 | dat->setupHorizontalLayoutData(targetWidth); | - | ||||||||||||||||||||||||||||||
| 1496 | dat->recalcHFW(targetWidth); | - | ||||||||||||||||||||||||||||||
| 1497 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1498 | if (targetWidth == d->sh_width)
| 0 | ||||||||||||||||||||||||||||||
| 1499 | return d->hfw_sh_height + topMargin + bottomMargin; never executed: return d->hfw_sh_height + topMargin + bottomMargin; | 0 | ||||||||||||||||||||||||||||||
| 1500 | else | - | ||||||||||||||||||||||||||||||
| 1501 | return d->hfw_height + topMargin + bottomMargin; never executed: return d->hfw_height + topMargin + bottomMargin; | 0 | ||||||||||||||||||||||||||||||
| 1502 | } | - | ||||||||||||||||||||||||||||||
| 1503 | - | |||||||||||||||||||||||||||||||
| 1504 | /*! | - | ||||||||||||||||||||||||||||||
| 1505 | \reimp | - | ||||||||||||||||||||||||||||||
| 1506 | */ | - | ||||||||||||||||||||||||||||||
| 1507 | void QFormLayout::setGeometry(const QRect &rect) | - | ||||||||||||||||||||||||||||||
| 1508 | { | - | ||||||||||||||||||||||||||||||
| 1509 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1510 | if (d->dirty || rect != geometry()) {
| 0 | ||||||||||||||||||||||||||||||
| 1511 | QRect cr = rect; | - | ||||||||||||||||||||||||||||||
| 1512 | int leftMargin, topMargin, rightMargin, bottomMargin; | - | ||||||||||||||||||||||||||||||
| 1513 | getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | - | ||||||||||||||||||||||||||||||
| 1514 | cr.adjust(+leftMargin, +topMargin, -rightMargin, -bottomMargin); | - | ||||||||||||||||||||||||||||||
| 1515 | - | |||||||||||||||||||||||||||||||
| 1516 | bool hfw = hasHeightForWidth(); | - | ||||||||||||||||||||||||||||||
| 1517 | d->setupVerticalLayoutData(cr.width()); | - | ||||||||||||||||||||||||||||||
| 1518 | d->setupHorizontalLayoutData(cr.width()); | - | ||||||||||||||||||||||||||||||
| 1519 | if (hfw && (!d->haveHfwCached(cr.width()) || d->hfwLayouts.size() != d->vLayoutCount))
| 0 | ||||||||||||||||||||||||||||||
| 1520 | d->recalcHFW(cr.width()); never executed: d->recalcHFW(cr.width()); | 0 | ||||||||||||||||||||||||||||||
| 1521 | if (hfw) {
| 0 | ||||||||||||||||||||||||||||||
| 1522 | qGeomCalc(d->hfwLayouts, 0, d->vLayoutCount, cr.y(), cr.height()); | - | ||||||||||||||||||||||||||||||
| 1523 | d->arrangeWidgets(d->hfwLayouts, cr); | - | ||||||||||||||||||||||||||||||
| 1524 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1525 | qGeomCalc(d->vLayouts, 0, d->vLayoutCount, cr.y(), cr.height()); | - | ||||||||||||||||||||||||||||||
| 1526 | d->arrangeWidgets(d->vLayouts, cr); | - | ||||||||||||||||||||||||||||||
| 1527 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1528 | QLayout::setGeometry(rect); | - | ||||||||||||||||||||||||||||||
| 1529 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1530 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||||||||
| 1532 | /*! | - | ||||||||||||||||||||||||||||||
| 1533 | \reimp | - | ||||||||||||||||||||||||||||||
| 1534 | */ | - | ||||||||||||||||||||||||||||||
| 1535 | QSize QFormLayout::sizeHint() const | - | ||||||||||||||||||||||||||||||
| 1536 | { | - | ||||||||||||||||||||||||||||||
| 1537 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1538 | if (!d->prefSize.isValid()) {
| 0 | ||||||||||||||||||||||||||||||
| 1539 | QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d); | - | ||||||||||||||||||||||||||||||
| 1540 | dat->calcSizeHints(); | - | ||||||||||||||||||||||||||||||
| 1541 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1542 | return d->prefSize; never executed: return d->prefSize; | 0 | ||||||||||||||||||||||||||||||
| 1543 | } | - | ||||||||||||||||||||||||||||||
| 1544 | - | |||||||||||||||||||||||||||||||
| 1545 | /*! | - | ||||||||||||||||||||||||||||||
| 1546 | \reimp | - | ||||||||||||||||||||||||||||||
| 1547 | */ | - | ||||||||||||||||||||||||||||||
| 1548 | QSize QFormLayout::minimumSize() const | - | ||||||||||||||||||||||||||||||
| 1549 | { | - | ||||||||||||||||||||||||||||||
| 1550 | // ### fix minimumSize if hfw | - | ||||||||||||||||||||||||||||||
| 1551 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1552 | if (!d->minSize.isValid()) {
| 0 | ||||||||||||||||||||||||||||||
| 1553 | QFormLayoutPrivate *dat = const_cast<QFormLayoutPrivate *>(d); | - | ||||||||||||||||||||||||||||||
| 1554 | dat->calcSizeHints(); | - | ||||||||||||||||||||||||||||||
| 1555 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1556 | return d->minSize; never executed: return d->minSize; | 0 | ||||||||||||||||||||||||||||||
| 1557 | } | - | ||||||||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||||||||
| 1559 | /*! | - | ||||||||||||||||||||||||||||||
| 1560 | \reimp | - | ||||||||||||||||||||||||||||||
| 1561 | */ | - | ||||||||||||||||||||||||||||||
| 1562 | void QFormLayout::invalidate() | - | ||||||||||||||||||||||||||||||
| 1563 | { | - | ||||||||||||||||||||||||||||||
| 1564 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1565 | d->dirty = true; | - | ||||||||||||||||||||||||||||||
| 1566 | d->sizesDirty = true; | - | ||||||||||||||||||||||||||||||
| 1567 | d->minSize = QSize(); | - | ||||||||||||||||||||||||||||||
| 1568 | d->prefSize = QSize(); | - | ||||||||||||||||||||||||||||||
| 1569 | d->formMaxWidth = -1; | - | ||||||||||||||||||||||||||||||
| 1570 | d->hfw_width = -1; | - | ||||||||||||||||||||||||||||||
| 1571 | d->sh_width = -1; | - | ||||||||||||||||||||||||||||||
| 1572 | d->layoutWidth = -1; | - | ||||||||||||||||||||||||||||||
| 1573 | d->hfw_sh_height = -1; | - | ||||||||||||||||||||||||||||||
| 1574 | QLayout::invalidate(); | - | ||||||||||||||||||||||||||||||
| 1575 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1576 | - | |||||||||||||||||||||||||||||||
| 1577 | /*! | - | ||||||||||||||||||||||||||||||
| 1578 | Returns the number of rows in the form. | - | ||||||||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||||||||
| 1580 | \sa QLayout::count() | - | ||||||||||||||||||||||||||||||
| 1581 | */ | - | ||||||||||||||||||||||||||||||
| 1582 | int QFormLayout::rowCount() const | - | ||||||||||||||||||||||||||||||
| 1583 | { | - | ||||||||||||||||||||||||||||||
| 1584 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1585 | return d->m_matrix.rowCount(); never executed: return d->m_matrix.rowCount(); | 0 | ||||||||||||||||||||||||||||||
| 1586 | } | - | ||||||||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||||||||
| 1588 | /*! | - | ||||||||||||||||||||||||||||||
| 1589 | Returns the layout item in the given \a row with the specified \a | - | ||||||||||||||||||||||||||||||
| 1590 | role (column). Returns 0 if there is no such item. | - | ||||||||||||||||||||||||||||||
| 1591 | - | |||||||||||||||||||||||||||||||
| 1592 | \sa QLayout::itemAt(), setItem() | - | ||||||||||||||||||||||||||||||
| 1593 | */ | - | ||||||||||||||||||||||||||||||
| 1594 | QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const | - | ||||||||||||||||||||||||||||||
| 1595 | { | - | ||||||||||||||||||||||||||||||
| 1596 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1597 | if (uint(row) >= uint(d->m_matrix.rowCount()))
| 0 | ||||||||||||||||||||||||||||||
| 1598 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1599 | switch (role) { | - | ||||||||||||||||||||||||||||||
| 1600 | case SpanningRole: never executed: case SpanningRole: | 0 | ||||||||||||||||||||||||||||||
| 1601 | if (QFormLayoutItem *item = d->m_matrix(row, 1))
| 0 | ||||||||||||||||||||||||||||||
| 1602 | if (item->fullRow)
| 0 | ||||||||||||||||||||||||||||||
| 1603 | return item->item; never executed: return item->item; | 0 | ||||||||||||||||||||||||||||||
| 1604 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1605 | case LabelRole: never executed: case LabelRole: | 0 | ||||||||||||||||||||||||||||||
| 1606 | case FieldRole: never executed: case FieldRole: | 0 | ||||||||||||||||||||||||||||||
| 1607 | if (QFormLayoutItem *item = d->m_matrix(row, (role == LabelRole) ? 0 : 1))
| 0 | ||||||||||||||||||||||||||||||
| 1608 | return item->item; never executed: return item->item; | 0 | ||||||||||||||||||||||||||||||
| 1609 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1610 | } | - | ||||||||||||||||||||||||||||||
| 1611 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1612 | } | - | ||||||||||||||||||||||||||||||
| 1613 | - | |||||||||||||||||||||||||||||||
| 1614 | /*! | - | ||||||||||||||||||||||||||||||
| 1615 | Retrieves the row and role (column) of the item at the specified | - | ||||||||||||||||||||||||||||||
| 1616 | \a index. If \a index is out of bounds, *\a rowPtr is set to -1; | - | ||||||||||||||||||||||||||||||
| 1617 | otherwise the row is stored in *\a rowPtr and the role is stored | - | ||||||||||||||||||||||||||||||
| 1618 | in *\a rolePtr. | - | ||||||||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||||||||
| 1620 | \sa itemAt(), count(), getLayoutPosition(), getWidgetPosition() | - | ||||||||||||||||||||||||||||||
| 1621 | */ | - | ||||||||||||||||||||||||||||||
| 1622 | void QFormLayout::getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const | - | ||||||||||||||||||||||||||||||
| 1623 | { | - | ||||||||||||||||||||||||||||||
| 1624 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1625 | int col = -1; | - | ||||||||||||||||||||||||||||||
| 1626 | int row = -1; | - | ||||||||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||||||||
| 1628 | const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index)); | - | ||||||||||||||||||||||||||||||
| 1629 | if (storageIndex != -1)
| 0 | ||||||||||||||||||||||||||||||
| 1630 | QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col); never executed: QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &row, &col); | 0 | ||||||||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||||||||
| 1632 | if (rowPtr)
| 0 | ||||||||||||||||||||||||||||||
| 1633 | *rowPtr = row; never executed: *rowPtr = row; | 0 | ||||||||||||||||||||||||||||||
| 1634 | if (rolePtr && col != -1) {
| 0 | ||||||||||||||||||||||||||||||
| 1635 | const bool spanning = col == 1 && d->m_matrix(row, col)->fullRow;
| 0 | ||||||||||||||||||||||||||||||
| 1636 | if (spanning) {
| 0 | ||||||||||||||||||||||||||||||
| 1637 | *rolePtr = SpanningRole; | - | ||||||||||||||||||||||||||||||
| 1638 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1639 | *rolePtr = ItemRole(col); | - | ||||||||||||||||||||||||||||||
| 1640 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1641 | } | - | ||||||||||||||||||||||||||||||
| 1642 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1643 | - | |||||||||||||||||||||||||||||||
| 1644 | /*! | - | ||||||||||||||||||||||||||||||
| 1645 | Retrieves the row and role (column) of the specified child \a | - | ||||||||||||||||||||||||||||||
| 1646 | layout. If \a layout is not in the form layout, *\a rowPtr is set | - | ||||||||||||||||||||||||||||||
| 1647 | to -1; otherwise the row is stored in *\a rowPtr and the role is stored | - | ||||||||||||||||||||||||||||||
| 1648 | in *\a rolePtr. | - | ||||||||||||||||||||||||||||||
| 1649 | */ | - | ||||||||||||||||||||||||||||||
| 1650 | void QFormLayout::getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const | - | ||||||||||||||||||||||||||||||
| 1651 | { | - | ||||||||||||||||||||||||||||||
| 1652 | int n = count(); | - | ||||||||||||||||||||||||||||||
| 1653 | int index = 0; | - | ||||||||||||||||||||||||||||||
| 1654 | while (index < n) {
| 0 | ||||||||||||||||||||||||||||||
| 1655 | if (itemAt(index) == layout)
| 0 | ||||||||||||||||||||||||||||||
| 1656 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1657 | ++index; | - | ||||||||||||||||||||||||||||||
| 1658 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1659 | getItemPosition(index, rowPtr, rolePtr); | - | ||||||||||||||||||||||||||||||
| 1660 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1661 | - | |||||||||||||||||||||||||||||||
| 1662 | /*! | - | ||||||||||||||||||||||||||||||
| 1663 | Retrieves the row and role (column) of the specified \a widget in | - | ||||||||||||||||||||||||||||||
| 1664 | the layout. If \a widget is not in the layout, *\a rowPtr is set | - | ||||||||||||||||||||||||||||||
| 1665 | to -1; otherwise the row is stored in *\a rowPtr and the role is stored | - | ||||||||||||||||||||||||||||||
| 1666 | in *\a rolePtr. | - | ||||||||||||||||||||||||||||||
| 1667 | - | |||||||||||||||||||||||||||||||
| 1668 | \sa getItemPosition(), itemAt() | - | ||||||||||||||||||||||||||||||
| 1669 | */ | - | ||||||||||||||||||||||||||||||
| 1670 | void QFormLayout::getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const | - | ||||||||||||||||||||||||||||||
| 1671 | { | - | ||||||||||||||||||||||||||||||
| 1672 | getItemPosition(indexOf(widget), rowPtr, rolePtr); | - | ||||||||||||||||||||||||||||||
| 1673 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1674 | - | |||||||||||||||||||||||||||||||
| 1675 | // ### eliminate labelForField() | - | ||||||||||||||||||||||||||||||
| 1676 | - | |||||||||||||||||||||||||||||||
| 1677 | /*! | - | ||||||||||||||||||||||||||||||
| 1678 | Returns the label associated with the given \a field. | - | ||||||||||||||||||||||||||||||
| 1679 | - | |||||||||||||||||||||||||||||||
| 1680 | \sa itemAt() | - | ||||||||||||||||||||||||||||||
| 1681 | */ | - | ||||||||||||||||||||||||||||||
| 1682 | QWidget *QFormLayout::labelForField(QWidget *field) const | - | ||||||||||||||||||||||||||||||
| 1683 | { | - | ||||||||||||||||||||||||||||||
| 1684 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||||||||
| 1686 | int row; | - | ||||||||||||||||||||||||||||||
| 1687 | ItemRole role = LabelRole; | - | ||||||||||||||||||||||||||||||
| 1688 | - | |||||||||||||||||||||||||||||||
| 1689 | getWidgetPosition(field, &row, &role); | - | ||||||||||||||||||||||||||||||
| 1690 | - | |||||||||||||||||||||||||||||||
| 1691 | if (row != -1 && role == FieldRole) {
| 0 | ||||||||||||||||||||||||||||||
| 1692 | if (QFormLayoutItem *label = d->m_matrix(row, LabelRole))
| 0 | ||||||||||||||||||||||||||||||
| 1693 | return label->widget(); never executed: return label->widget(); | 0 | ||||||||||||||||||||||||||||||
| 1694 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1695 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1696 | } | - | ||||||||||||||||||||||||||||||
| 1697 | - | |||||||||||||||||||||||||||||||
| 1698 | /*! | - | ||||||||||||||||||||||||||||||
| 1699 | \overload | - | ||||||||||||||||||||||||||||||
| 1700 | */ | - | ||||||||||||||||||||||||||||||
| 1701 | QWidget *QFormLayout::labelForField(QLayout *field) const | - | ||||||||||||||||||||||||||||||
| 1702 | { | - | ||||||||||||||||||||||||||||||
| 1703 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1704 | - | |||||||||||||||||||||||||||||||
| 1705 | int row; | - | ||||||||||||||||||||||||||||||
| 1706 | ItemRole role; | - | ||||||||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||||||||
| 1708 | getLayoutPosition(field, &row, &role); | - | ||||||||||||||||||||||||||||||
| 1709 | - | |||||||||||||||||||||||||||||||
| 1710 | if (row != -1 && role == FieldRole) {
| 0 | ||||||||||||||||||||||||||||||
| 1711 | if (QFormLayoutItem *label = d->m_matrix(row, LabelRole))
| 0 | ||||||||||||||||||||||||||||||
| 1712 | return label->widget(); never executed: return label->widget(); | 0 | ||||||||||||||||||||||||||||||
| 1713 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1714 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 1715 | } | - | ||||||||||||||||||||||||||||||
| 1716 | - | |||||||||||||||||||||||||||||||
| 1717 | /*! | - | ||||||||||||||||||||||||||||||
| 1718 | \property QFormLayout::fieldGrowthPolicy | - | ||||||||||||||||||||||||||||||
| 1719 | \brief the way in which the form's fields grow | - | ||||||||||||||||||||||||||||||
| 1720 | - | |||||||||||||||||||||||||||||||
| 1721 | The default value depends on the widget or application style. For | - | ||||||||||||||||||||||||||||||
| 1722 | QMacStyle, the default is FieldsStayAtSizeHint; for QCommonStyle | - | ||||||||||||||||||||||||||||||
| 1723 | derived styles (like Plastique and Windows), the default | - | ||||||||||||||||||||||||||||||
| 1724 | is ExpandingFieldsGrow; for Qt Extended styles, the default is | - | ||||||||||||||||||||||||||||||
| 1725 | AllNonFixedFieldsGrow. | - | ||||||||||||||||||||||||||||||
| 1726 | - | |||||||||||||||||||||||||||||||
| 1727 | If none of the fields can grow and the form is resized, extra | - | ||||||||||||||||||||||||||||||
| 1728 | space is distributed according to the current | - | ||||||||||||||||||||||||||||||
| 1729 | \l{formAlignment}{form alignment}. | - | ||||||||||||||||||||||||||||||
| 1730 | - | |||||||||||||||||||||||||||||||
| 1731 | \sa formAlignment, rowWrapPolicy | - | ||||||||||||||||||||||||||||||
| 1732 | */ | - | ||||||||||||||||||||||||||||||
| 1733 | - | |||||||||||||||||||||||||||||||
| 1734 | void QFormLayout::setFieldGrowthPolicy(FieldGrowthPolicy policy) | - | ||||||||||||||||||||||||||||||
| 1735 | { | - | ||||||||||||||||||||||||||||||
| 1736 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1737 | if (FieldGrowthPolicy(d->fieldGrowthPolicy) != policy) {
| 0 | ||||||||||||||||||||||||||||||
| 1738 | d->fieldGrowthPolicy = policy; | - | ||||||||||||||||||||||||||||||
| 1739 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1740 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1741 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1742 | - | |||||||||||||||||||||||||||||||
| 1743 | QFormLayout::FieldGrowthPolicy QFormLayout::fieldGrowthPolicy() const | - | ||||||||||||||||||||||||||||||
| 1744 | { | - | ||||||||||||||||||||||||||||||
| 1745 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1746 | if (d->fieldGrowthPolicy == DefaultFieldGrowthPolicy) {
| 0 | ||||||||||||||||||||||||||||||
| 1747 | return QFormLayout::FieldGrowthPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutFieldGrowthPolicy)); never executed: return QFormLayout::FieldGrowthPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutFieldGrowthPolicy)); | 0 | ||||||||||||||||||||||||||||||
| 1748 | } else { | - | ||||||||||||||||||||||||||||||
| 1749 | return QFormLayout::FieldGrowthPolicy(d->fieldGrowthPolicy); never executed: return QFormLayout::FieldGrowthPolicy(d->fieldGrowthPolicy); | 0 | ||||||||||||||||||||||||||||||
| 1750 | } | - | ||||||||||||||||||||||||||||||
| 1751 | } | - | ||||||||||||||||||||||||||||||
| 1752 | - | |||||||||||||||||||||||||||||||
| 1753 | /*! | - | ||||||||||||||||||||||||||||||
| 1754 | \property QFormLayout::rowWrapPolicy | - | ||||||||||||||||||||||||||||||
| 1755 | \brief the way in which the form's rows wrap | - | ||||||||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||||||||
| 1757 | The default value depends on the widget or application style. For | - | ||||||||||||||||||||||||||||||
| 1758 | Qt Extended styles, the default is WrapLongRows; | - | ||||||||||||||||||||||||||||||
| 1759 | for the other styles, the default is DontWrapRows. | - | ||||||||||||||||||||||||||||||
| 1760 | - | |||||||||||||||||||||||||||||||
| 1761 | If you want to display each label above its associated field | - | ||||||||||||||||||||||||||||||
| 1762 | (instead of next to it), set this property to WrapAllRows. | - | ||||||||||||||||||||||||||||||
| 1763 | - | |||||||||||||||||||||||||||||||
| 1764 | \sa fieldGrowthPolicy | - | ||||||||||||||||||||||||||||||
| 1765 | */ | - | ||||||||||||||||||||||||||||||
| 1766 | - | |||||||||||||||||||||||||||||||
| 1767 | void QFormLayout::setRowWrapPolicy(RowWrapPolicy policy) | - | ||||||||||||||||||||||||||||||
| 1768 | { | - | ||||||||||||||||||||||||||||||
| 1769 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1770 | if (RowWrapPolicy(d->rowWrapPolicy) != policy) {
| 0 | ||||||||||||||||||||||||||||||
| 1771 | d->rowWrapPolicy = policy; | - | ||||||||||||||||||||||||||||||
| 1772 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1773 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1774 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||||||||
| 1776 | QFormLayout::RowWrapPolicy QFormLayout::rowWrapPolicy() const | - | ||||||||||||||||||||||||||||||
| 1777 | { | - | ||||||||||||||||||||||||||||||
| 1778 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1779 | if (d->rowWrapPolicy == DefaultRowWrapPolicy) {
| 0 | ||||||||||||||||||||||||||||||
| 1780 | return QFormLayout::RowWrapPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutWrapPolicy)); never executed: return QFormLayout::RowWrapPolicy(d->getStyle()->styleHint(QStyle::SH_FormLayoutWrapPolicy)); | 0 | ||||||||||||||||||||||||||||||
| 1781 | } else { | - | ||||||||||||||||||||||||||||||
| 1782 | return QFormLayout::RowWrapPolicy(d->rowWrapPolicy); never executed: return QFormLayout::RowWrapPolicy(d->rowWrapPolicy); | 0 | ||||||||||||||||||||||||||||||
| 1783 | } | - | ||||||||||||||||||||||||||||||
| 1784 | } | - | ||||||||||||||||||||||||||||||
| 1785 | - | |||||||||||||||||||||||||||||||
| 1786 | /*! | - | ||||||||||||||||||||||||||||||
| 1787 | \property QFormLayout::labelAlignment | - | ||||||||||||||||||||||||||||||
| 1788 | \brief the horizontal alignment of the labels | - | ||||||||||||||||||||||||||||||
| 1789 | - | |||||||||||||||||||||||||||||||
| 1790 | The default value depends on the widget or application style. For | - | ||||||||||||||||||||||||||||||
| 1791 | QCommonStyle derived styles, except for QPlastiqueStyle, the | - | ||||||||||||||||||||||||||||||
| 1792 | default is Qt::AlignLeft; for the other styles, the default is | - | ||||||||||||||||||||||||||||||
| 1793 | Qt::AlignRight. | - | ||||||||||||||||||||||||||||||
| 1794 | - | |||||||||||||||||||||||||||||||
| 1795 | \sa formAlignment | - | ||||||||||||||||||||||||||||||
| 1796 | */ | - | ||||||||||||||||||||||||||||||
| 1797 | - | |||||||||||||||||||||||||||||||
| 1798 | void QFormLayout::setLabelAlignment(Qt::Alignment alignment) | - | ||||||||||||||||||||||||||||||
| 1799 | { | - | ||||||||||||||||||||||||||||||
| 1800 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1801 | if (d->labelAlignment != alignment) {
| 0 | ||||||||||||||||||||||||||||||
| 1802 | d->labelAlignment = alignment; | - | ||||||||||||||||||||||||||||||
| 1803 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1804 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1805 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1806 | - | |||||||||||||||||||||||||||||||
| 1807 | Qt::Alignment QFormLayout::labelAlignment() const | - | ||||||||||||||||||||||||||||||
| 1808 | { | - | ||||||||||||||||||||||||||||||
| 1809 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1810 | if (!d->labelAlignment) {
| 0 | ||||||||||||||||||||||||||||||
| 1811 | return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutLabelAlignment)); never executed: return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutLabelAlignment)); | 0 | ||||||||||||||||||||||||||||||
| 1812 | } else { | - | ||||||||||||||||||||||||||||||
| 1813 | return d->labelAlignment; never executed: return d->labelAlignment; | 0 | ||||||||||||||||||||||||||||||
| 1814 | } | - | ||||||||||||||||||||||||||||||
| 1815 | } | - | ||||||||||||||||||||||||||||||
| 1816 | - | |||||||||||||||||||||||||||||||
| 1817 | /*! | - | ||||||||||||||||||||||||||||||
| 1818 | \property QFormLayout::formAlignment | - | ||||||||||||||||||||||||||||||
| 1819 | \brief the alignment of the form layout's contents within the layout's geometry | - | ||||||||||||||||||||||||||||||
| 1820 | - | |||||||||||||||||||||||||||||||
| 1821 | The default value depends on the widget or application style. For | - | ||||||||||||||||||||||||||||||
| 1822 | QMacStyle, the default is Qt::AlignHCenter | Qt::AlignTop; for the | - | ||||||||||||||||||||||||||||||
| 1823 | other styles, the default is Qt::AlignLeft | Qt::AlignTop. | - | ||||||||||||||||||||||||||||||
| 1824 | - | |||||||||||||||||||||||||||||||
| 1825 | \sa labelAlignment, rowWrapPolicy | - | ||||||||||||||||||||||||||||||
| 1826 | */ | - | ||||||||||||||||||||||||||||||
| 1827 | - | |||||||||||||||||||||||||||||||
| 1828 | void QFormLayout::setFormAlignment(Qt::Alignment alignment) | - | ||||||||||||||||||||||||||||||
| 1829 | { | - | ||||||||||||||||||||||||||||||
| 1830 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1831 | if (d->formAlignment != alignment) {
| 0 | ||||||||||||||||||||||||||||||
| 1832 | d->formAlignment = alignment; | - | ||||||||||||||||||||||||||||||
| 1833 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1834 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1835 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1836 | - | |||||||||||||||||||||||||||||||
| 1837 | Qt::Alignment QFormLayout::formAlignment() const | - | ||||||||||||||||||||||||||||||
| 1838 | { | - | ||||||||||||||||||||||||||||||
| 1839 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1840 | if (!d->formAlignment) {
| 0 | ||||||||||||||||||||||||||||||
| 1841 | return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutFormAlignment)); never executed: return Qt::Alignment(d->getStyle()->styleHint(QStyle::SH_FormLayoutFormAlignment)); | 0 | ||||||||||||||||||||||||||||||
| 1842 | } else { | - | ||||||||||||||||||||||||||||||
| 1843 | return d->formAlignment; never executed: return d->formAlignment; | 0 | ||||||||||||||||||||||||||||||
| 1844 | } | - | ||||||||||||||||||||||||||||||
| 1845 | } | - | ||||||||||||||||||||||||||||||
| 1846 | - | |||||||||||||||||||||||||||||||
| 1847 | /*! | - | ||||||||||||||||||||||||||||||
| 1848 | \property QFormLayout::horizontalSpacing | - | ||||||||||||||||||||||||||||||
| 1849 | \brief the spacing between widgets that are laid out side by side | - | ||||||||||||||||||||||||||||||
| 1850 | - | |||||||||||||||||||||||||||||||
| 1851 | By default, if no value is explicitly set, the layout's horizontal | - | ||||||||||||||||||||||||||||||
| 1852 | spacing is inherited from the parent layout, or from the style settings | - | ||||||||||||||||||||||||||||||
| 1853 | for the parent widget. | - | ||||||||||||||||||||||||||||||
| 1854 | - | |||||||||||||||||||||||||||||||
| 1855 | \sa verticalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing} | - | ||||||||||||||||||||||||||||||
| 1856 | */ | - | ||||||||||||||||||||||||||||||
| 1857 | void QFormLayout::setHorizontalSpacing(int spacing) | - | ||||||||||||||||||||||||||||||
| 1858 | { | - | ||||||||||||||||||||||||||||||
| 1859 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1860 | if (spacing != d->hSpacing) {
| 0 | ||||||||||||||||||||||||||||||
| 1861 | d->hSpacing = spacing; | - | ||||||||||||||||||||||||||||||
| 1862 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1863 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1864 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1865 | - | |||||||||||||||||||||||||||||||
| 1866 | int QFormLayout::horizontalSpacing() const | - | ||||||||||||||||||||||||||||||
| 1867 | { | - | ||||||||||||||||||||||||||||||
| 1868 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1869 | if (d->hSpacing >= 0) {
| 0 | ||||||||||||||||||||||||||||||
| 1870 | return d->hSpacing; never executed: return d->hSpacing; | 0 | ||||||||||||||||||||||||||||||
| 1871 | } else { | - | ||||||||||||||||||||||||||||||
| 1872 | return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing); never executed: return qSmartSpacing(this, QStyle::PM_LayoutHorizontalSpacing); | 0 | ||||||||||||||||||||||||||||||
| 1873 | } | - | ||||||||||||||||||||||||||||||
| 1874 | } | - | ||||||||||||||||||||||||||||||
| 1875 | - | |||||||||||||||||||||||||||||||
| 1876 | /*! | - | ||||||||||||||||||||||||||||||
| 1877 | \property QFormLayout::verticalSpacing | - | ||||||||||||||||||||||||||||||
| 1878 | \brief the spacing between widgets that are laid out vertically | - | ||||||||||||||||||||||||||||||
| 1879 | - | |||||||||||||||||||||||||||||||
| 1880 | By default, if no value is explicitly set, the layout's vertical spacing is | - | ||||||||||||||||||||||||||||||
| 1881 | inherited from the parent layout, or from the style settings for the parent | - | ||||||||||||||||||||||||||||||
| 1882 | widget. | - | ||||||||||||||||||||||||||||||
| 1883 | - | |||||||||||||||||||||||||||||||
| 1884 | \sa horizontalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing} | - | ||||||||||||||||||||||||||||||
| 1885 | */ | - | ||||||||||||||||||||||||||||||
| 1886 | void QFormLayout::setVerticalSpacing(int spacing) | - | ||||||||||||||||||||||||||||||
| 1887 | { | - | ||||||||||||||||||||||||||||||
| 1888 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1889 | if (spacing != d->vSpacing) {
| 0 | ||||||||||||||||||||||||||||||
| 1890 | d->vSpacing = spacing; | - | ||||||||||||||||||||||||||||||
| 1891 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1892 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1893 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1894 | - | |||||||||||||||||||||||||||||||
| 1895 | int QFormLayout::verticalSpacing() const | - | ||||||||||||||||||||||||||||||
| 1896 | { | - | ||||||||||||||||||||||||||||||
| 1897 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1898 | if (d->vSpacing >= 0) {
| 0 | ||||||||||||||||||||||||||||||
| 1899 | return d->vSpacing; never executed: return d->vSpacing; | 0 | ||||||||||||||||||||||||||||||
| 1900 | } else { | - | ||||||||||||||||||||||||||||||
| 1901 | return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing); never executed: return qSmartSpacing(this, QStyle::PM_LayoutVerticalSpacing); | 0 | ||||||||||||||||||||||||||||||
| 1902 | } | - | ||||||||||||||||||||||||||||||
| 1903 | } | - | ||||||||||||||||||||||||||||||
| 1904 | - | |||||||||||||||||||||||||||||||
| 1905 | /*! | - | ||||||||||||||||||||||||||||||
| 1906 | This function sets both the vertical and horizontal spacing to | - | ||||||||||||||||||||||||||||||
| 1907 | \a spacing. | - | ||||||||||||||||||||||||||||||
| 1908 | - | |||||||||||||||||||||||||||||||
| 1909 | \sa setVerticalSpacing(), setHorizontalSpacing() | - | ||||||||||||||||||||||||||||||
| 1910 | */ | - | ||||||||||||||||||||||||||||||
| 1911 | void QFormLayout::setSpacing(int spacing) | - | ||||||||||||||||||||||||||||||
| 1912 | { | - | ||||||||||||||||||||||||||||||
| 1913 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1914 | d->vSpacing = d->hSpacing = spacing; | - | ||||||||||||||||||||||||||||||
| 1915 | invalidate(); | - | ||||||||||||||||||||||||||||||
| 1916 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1917 | - | |||||||||||||||||||||||||||||||
| 1918 | /*! | - | ||||||||||||||||||||||||||||||
| 1919 | If the vertical spacing is equal to the horizontal spacing, | - | ||||||||||||||||||||||||||||||
| 1920 | this function returns that value; otherwise it returns -1. | - | ||||||||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||||||||
| 1922 | \sa setSpacing(), verticalSpacing(), horizontalSpacing() | - | ||||||||||||||||||||||||||||||
| 1923 | */ | - | ||||||||||||||||||||||||||||||
| 1924 | int QFormLayout::spacing() const | - | ||||||||||||||||||||||||||||||
| 1925 | { | - | ||||||||||||||||||||||||||||||
| 1926 | int hSpacing = horizontalSpacing(); | - | ||||||||||||||||||||||||||||||
| 1927 | if (hSpacing == verticalSpacing()) {
| 0 | ||||||||||||||||||||||||||||||
| 1928 | return hSpacing; never executed: return hSpacing; | 0 | ||||||||||||||||||||||||||||||
| 1929 | } else { | - | ||||||||||||||||||||||||||||||
| 1930 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 1931 | } | - | ||||||||||||||||||||||||||||||
| 1932 | } | - | ||||||||||||||||||||||||||||||
| 1933 | - | |||||||||||||||||||||||||||||||
| 1934 | void QFormLayoutPrivate::arrangeWidgets(const QVector<QLayoutStruct>& layouts, QRect &rect) | - | ||||||||||||||||||||||||||||||
| 1935 | { | - | ||||||||||||||||||||||||||||||
| 1936 | Q_Q(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 1937 | - | |||||||||||||||||||||||||||||||
| 1938 | int i; | - | ||||||||||||||||||||||||||||||
| 1939 | const int rr = m_matrix.rowCount(); | - | ||||||||||||||||||||||||||||||
| 1940 | QWidget *w = q->parentWidget(); | - | ||||||||||||||||||||||||||||||
| 1941 | Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QApplication::layoutDirection();
| 0 | ||||||||||||||||||||||||||||||
| 1942 | - | |||||||||||||||||||||||||||||||
| 1943 | Qt::Alignment formAlignment = fixedAlignment(q->formAlignment(), layoutDirection); | - | ||||||||||||||||||||||||||||||
| 1944 | int leftOffset = 0; | - | ||||||||||||||||||||||||||||||
| 1945 | int delta = rect.width() - formMaxWidth; | - | ||||||||||||||||||||||||||||||
| 1946 | if (formAlignment & (Qt::AlignHCenter | Qt::AlignRight) && delta > 0) {
| 0 | ||||||||||||||||||||||||||||||
| 1947 | leftOffset = delta; | - | ||||||||||||||||||||||||||||||
| 1948 | if (formAlignment & Qt::AlignHCenter)
| 0 | ||||||||||||||||||||||||||||||
| 1949 | leftOffset >>= 1; never executed: leftOffset >>= 1; | 0 | ||||||||||||||||||||||||||||||
| 1950 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1951 | - | |||||||||||||||||||||||||||||||
| 1952 | for (i = 0; i < rr; ++i) {
| 0 | ||||||||||||||||||||||||||||||
| 1953 | QFormLayoutItem *label = m_matrix(i, 0); | - | ||||||||||||||||||||||||||||||
| 1954 | QFormLayoutItem *field = m_matrix(i, 1); | - | ||||||||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||||||||
| 1956 | if (label) {
| 0 | ||||||||||||||||||||||||||||||
| 1957 | int height = layouts.at(label->vLayoutIndex).size; | - | ||||||||||||||||||||||||||||||
| 1958 | if ((label->expandingDirections() & Qt::Vertical) == 0) {
| 0 | ||||||||||||||||||||||||||||||
| 1959 | /* | - | ||||||||||||||||||||||||||||||
| 1960 | If the field on the right-hand side is tall, | - | ||||||||||||||||||||||||||||||
| 1961 | we want the label to be top-aligned, but not too | - | ||||||||||||||||||||||||||||||
| 1962 | much. So we introduce a 7 / 4 factor so that it | - | ||||||||||||||||||||||||||||||
| 1963 | gets some extra pixels at the top. | - | ||||||||||||||||||||||||||||||
| 1964 | */ | - | ||||||||||||||||||||||||||||||
| 1965 | height = qMin(height, | - | ||||||||||||||||||||||||||||||
| 1966 | qMin(label->sizeHint.height() * 7 / 4, | - | ||||||||||||||||||||||||||||||
| 1967 | label->maxSize.height())); | - | ||||||||||||||||||||||||||||||
| 1968 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1969 | - | |||||||||||||||||||||||||||||||
| 1970 | QSize sz(qMin(label->layoutWidth, label->sizeHint.width()), height); | - | ||||||||||||||||||||||||||||||
| 1971 | int x = leftOffset + rect.x() + label->layoutPos; | - | ||||||||||||||||||||||||||||||
| 1972 | if (fixedAlignment(q->labelAlignment(), layoutDirection) & Qt::AlignRight)
| 0 | ||||||||||||||||||||||||||||||
| 1973 | x += label->layoutWidth - sz.width(); never executed: x += label->layoutWidth - sz.width(); | 0 | ||||||||||||||||||||||||||||||
| 1974 | QPoint p(x, layouts.at(label->vLayoutIndex).pos); | - | ||||||||||||||||||||||||||||||
| 1975 | // ### expansion & sizepolicy stuff | - | ||||||||||||||||||||||||||||||
| 1976 | - | |||||||||||||||||||||||||||||||
| 1977 | label->setGeometry(QStyle::visualRect(layoutDirection, rect, QRect(p, sz))); | - | ||||||||||||||||||||||||||||||
| 1978 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1979 | - | |||||||||||||||||||||||||||||||
| 1980 | if (field) {
| 0 | ||||||||||||||||||||||||||||||
| 1981 | QSize sz(field->layoutWidth, layouts.at(field->vLayoutIndex).size); | - | ||||||||||||||||||||||||||||||
| 1982 | QPoint p(field->layoutPos + leftOffset + rect.x(), layouts.at(field->vLayoutIndex).pos); | - | ||||||||||||||||||||||||||||||
| 1983 | /* | - | ||||||||||||||||||||||||||||||
| 1984 | if ((field->widget() && field->widget()->sizePolicy().horizontalPolicy() & (QSizePolicy::GrowFlag | QSizePolicy::ExpandFlag | QSizePolicy::IgnoreFlag)) | - | ||||||||||||||||||||||||||||||
| 1985 | || (field->layout() && sz.width() < field->maxSize.width())) { | - | ||||||||||||||||||||||||||||||
| 1986 | sz.rwidth() = field->layoutWidth; | - | ||||||||||||||||||||||||||||||
| 1987 | } | - | ||||||||||||||||||||||||||||||
| 1988 | */ | - | ||||||||||||||||||||||||||||||
| 1989 | if (field->maxSize.isValid())
| 0 | ||||||||||||||||||||||||||||||
| 1990 | sz = sz.boundedTo(field->maxSize); never executed: sz = sz.boundedTo(field->maxSize); | 0 | ||||||||||||||||||||||||||||||
| 1991 | - | |||||||||||||||||||||||||||||||
| 1992 | field->setGeometry(QStyle::visualRect(layoutDirection, rect, QRect(p, sz))); | - | ||||||||||||||||||||||||||||||
| 1993 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1994 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1995 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1996 | - | |||||||||||||||||||||||||||||||
| 1997 | /*! | - | ||||||||||||||||||||||||||||||
| 1998 | Sets the widget in the given \a row for the given \a role to \a widget, extending the | - | ||||||||||||||||||||||||||||||
| 1999 | layout with empty rows if necessary. | - | ||||||||||||||||||||||||||||||
| 2000 | - | |||||||||||||||||||||||||||||||
| 2001 | If the cell is already occupied, the \a widget is not inserted and an error message is | - | ||||||||||||||||||||||||||||||
| 2002 | sent to the console. | - | ||||||||||||||||||||||||||||||
| 2003 | - | |||||||||||||||||||||||||||||||
| 2004 | \b{Note:} For most applications, addRow() or insertRow() should be used instead of setWidget(). | - | ||||||||||||||||||||||||||||||
| 2005 | - | |||||||||||||||||||||||||||||||
| 2006 | \sa setLayout() | - | ||||||||||||||||||||||||||||||
| 2007 | */ | - | ||||||||||||||||||||||||||||||
| 2008 | void QFormLayout::setWidget(int row, ItemRole role, QWidget *widget) | - | ||||||||||||||||||||||||||||||
| 2009 | { | - | ||||||||||||||||||||||||||||||
| 2010 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2011 | int rowCnt = rowCount(); | - | ||||||||||||||||||||||||||||||
| 2012 | if (row >= rowCnt)
| 0 | ||||||||||||||||||||||||||||||
| 2013 | d->insertRows(rowCnt, row - rowCnt + 1); never executed: d->insertRows(rowCnt, row - rowCnt + 1); | 0 | ||||||||||||||||||||||||||||||
| 2014 | d->setWidget(row, role, widget); | - | ||||||||||||||||||||||||||||||
| 2015 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2016 | - | |||||||||||||||||||||||||||||||
| 2017 | /*! | - | ||||||||||||||||||||||||||||||
| 2018 | Sets the sub-layout in the given \a row for the given \a role to \a layout, extending the | - | ||||||||||||||||||||||||||||||
| 2019 | form layout with empty rows if necessary. | - | ||||||||||||||||||||||||||||||
| 2020 | - | |||||||||||||||||||||||||||||||
| 2021 | If the cell is already occupied, the \a layout is not inserted and an error message is | - | ||||||||||||||||||||||||||||||
| 2022 | sent to the console. | - | ||||||||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||||||||
| 2024 | \b{Note:} For most applications, addRow() or insertRow() should be used instead of setLayout(). | - | ||||||||||||||||||||||||||||||
| 2025 | - | |||||||||||||||||||||||||||||||
| 2026 | \sa setWidget() | - | ||||||||||||||||||||||||||||||
| 2027 | */ | - | ||||||||||||||||||||||||||||||
| 2028 | void QFormLayout::setLayout(int row, ItemRole role, QLayout *layout) | - | ||||||||||||||||||||||||||||||
| 2029 | { | - | ||||||||||||||||||||||||||||||
| 2030 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2031 | int rowCnt = rowCount(); | - | ||||||||||||||||||||||||||||||
| 2032 | if (row >= rowCnt)
| 0 | ||||||||||||||||||||||||||||||
| 2033 | d->insertRows(rowCnt, row - rowCnt + 1); never executed: d->insertRows(rowCnt, row - rowCnt + 1); | 0 | ||||||||||||||||||||||||||||||
| 2034 | d->setLayout(row, role, layout); | - | ||||||||||||||||||||||||||||||
| 2035 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2036 | - | |||||||||||||||||||||||||||||||
| 2037 | /*! | - | ||||||||||||||||||||||||||||||
| 2038 | Sets the item in the given \a row for the given \a role to \a item, extending the | - | ||||||||||||||||||||||||||||||
| 2039 | layout with empty rows if necessary. | - | ||||||||||||||||||||||||||||||
| 2040 | - | |||||||||||||||||||||||||||||||
| 2041 | If the cell is already occupied, the \a item is not inserted and an error message is | - | ||||||||||||||||||||||||||||||
| 2042 | sent to the console. | - | ||||||||||||||||||||||||||||||
| 2043 | The \a item spans both columns. | - | ||||||||||||||||||||||||||||||
| 2044 | - | |||||||||||||||||||||||||||||||
| 2045 | \warning Do not use this function to add child layouts or child | - | ||||||||||||||||||||||||||||||
| 2046 | widget items. Use setLayout() or setWidget() instead. | - | ||||||||||||||||||||||||||||||
| 2047 | - | |||||||||||||||||||||||||||||||
| 2048 | \sa setLayout() | - | ||||||||||||||||||||||||||||||
| 2049 | */ | - | ||||||||||||||||||||||||||||||
| 2050 | void QFormLayout::setItem(int row, ItemRole role, QLayoutItem *item) | - | ||||||||||||||||||||||||||||||
| 2051 | { | - | ||||||||||||||||||||||||||||||
| 2052 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2053 | int rowCnt = rowCount(); | - | ||||||||||||||||||||||||||||||
| 2054 | if (row >= rowCnt)
| 0 | ||||||||||||||||||||||||||||||
| 2055 | d->insertRows(rowCnt, row - rowCnt + 1); never executed: d->insertRows(rowCnt, row - rowCnt + 1); | 0 | ||||||||||||||||||||||||||||||
| 2056 | d->setItem(row, role, item); | - | ||||||||||||||||||||||||||||||
| 2057 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2058 | - | |||||||||||||||||||||||||||||||
| 2059 | /*! | - | ||||||||||||||||||||||||||||||
| 2060 | \internal | - | ||||||||||||||||||||||||||||||
| 2061 | */ | - | ||||||||||||||||||||||||||||||
| 2062 | - | |||||||||||||||||||||||||||||||
| 2063 | void QFormLayout::resetFieldGrowthPolicy() | - | ||||||||||||||||||||||||||||||
| 2064 | { | - | ||||||||||||||||||||||||||||||
| 2065 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2066 | d->fieldGrowthPolicy = DefaultFieldGrowthPolicy; | - | ||||||||||||||||||||||||||||||
| 2067 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2068 | - | |||||||||||||||||||||||||||||||
| 2069 | /*! | - | ||||||||||||||||||||||||||||||
| 2070 | \internal | - | ||||||||||||||||||||||||||||||
| 2071 | */ | - | ||||||||||||||||||||||||||||||
| 2072 | - | |||||||||||||||||||||||||||||||
| 2073 | void QFormLayout::resetRowWrapPolicy() | - | ||||||||||||||||||||||||||||||
| 2074 | { | - | ||||||||||||||||||||||||||||||
| 2075 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2076 | d->rowWrapPolicy = DefaultRowWrapPolicy; | - | ||||||||||||||||||||||||||||||
| 2077 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2078 | - | |||||||||||||||||||||||||||||||
| 2079 | /*! | - | ||||||||||||||||||||||||||||||
| 2080 | \internal | - | ||||||||||||||||||||||||||||||
| 2081 | */ | - | ||||||||||||||||||||||||||||||
| 2082 | - | |||||||||||||||||||||||||||||||
| 2083 | void QFormLayout::resetFormAlignment() | - | ||||||||||||||||||||||||||||||
| 2084 | { | - | ||||||||||||||||||||||||||||||
| 2085 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2086 | d->formAlignment = 0; | - | ||||||||||||||||||||||||||||||
| 2087 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2088 | - | |||||||||||||||||||||||||||||||
| 2089 | /*! | - | ||||||||||||||||||||||||||||||
| 2090 | \internal | - | ||||||||||||||||||||||||||||||
| 2091 | */ | - | ||||||||||||||||||||||||||||||
| 2092 | - | |||||||||||||||||||||||||||||||
| 2093 | void QFormLayout::resetLabelAlignment() | - | ||||||||||||||||||||||||||||||
| 2094 | { | - | ||||||||||||||||||||||||||||||
| 2095 | Q_D(QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2096 | d->labelAlignment = 0; | - | ||||||||||||||||||||||||||||||
| 2097 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2098 | - | |||||||||||||||||||||||||||||||
| 2099 | #if 0 | - | ||||||||||||||||||||||||||||||
| 2100 | void QFormLayout::dump() const | - | ||||||||||||||||||||||||||||||
| 2101 | { | - | ||||||||||||||||||||||||||||||
| 2102 | Q_D(const QFormLayout); | - | ||||||||||||||||||||||||||||||
| 2103 | for (int i = 0; i < rowCount(); ++i) { | - | ||||||||||||||||||||||||||||||
| 2104 | for (int j = 0; j < 2; ++j) { | - | ||||||||||||||||||||||||||||||
| 2105 | qDebug("m_matrix(%d, %d) = %p", i, j, d->m_matrix(i, j)); | - | ||||||||||||||||||||||||||||||
| 2106 | } | - | ||||||||||||||||||||||||||||||
| 2107 | } | - | ||||||||||||||||||||||||||||||
| 2108 | for (int i = 0; i < d->m_things.count(); ++i) | - | ||||||||||||||||||||||||||||||
| 2109 | qDebug("m_things[%d] = %p", i, d->m_things.at(i)); | - | ||||||||||||||||||||||||||||||
| 2110 | } | - | ||||||||||||||||||||||||||||||
| 2111 | #endif | - | ||||||||||||||||||||||||||||||
| 2112 | - | |||||||||||||||||||||||||||||||
| 2113 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||
| 2114 | - | |||||||||||||||||||||||||||||||
| 2115 | #include "moc_qformlayout.cpp" | - | ||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |