| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qlayoutitem.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | inline static QRect fromLayoutItemRect(QWidgetPrivate *priv, const QRect &rect) | - | ||||||||||||
| 6 | { | - | ||||||||||||
| 7 | return never executed: rect.adjusted(priv->leftLayoutItemMargin, priv->topLayoutItemMargin,return rect.adjusted(priv->leftLayoutItemMargin, priv->topLayoutItemMargin, -priv->rightLayoutItemMargin, -priv->bottomLayoutItemMargin);never executed: return rect.adjusted(priv->leftLayoutItemMargin, priv->topLayoutItemMargin, -priv->rightLayoutItemMargin, -priv->bottomLayoutItemMargin); | 0 | ||||||||||||
| 8 | -priv->rightLayoutItemMargin, -priv->bottomLayoutItemMargin); never executed: return rect.adjusted(priv->leftLayoutItemMargin, priv->topLayoutItemMargin, -priv->rightLayoutItemMargin, -priv->bottomLayoutItemMargin); | 0 | ||||||||||||
| 9 | } | - | ||||||||||||
| 10 | - | |||||||||||||
| 11 | inline static QSize fromLayoutItemSize(QWidgetPrivate *priv, const QSize &size) | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | return never executed: fromLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size();return fromLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size();never executed: return fromLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size(); | 0 | ||||||||||||
| 14 | } | - | ||||||||||||
| 15 | - | |||||||||||||
| 16 | inline static QRect toLayoutItemRect(QWidgetPrivate *priv, const QRect &rect) | - | ||||||||||||
| 17 | { | - | ||||||||||||
| 18 | return never executed: rect.adjusted(-priv->leftLayoutItemMargin, -priv->topLayoutItemMargin,return rect.adjusted(-priv->leftLayoutItemMargin, -priv->topLayoutItemMargin, priv->rightLayoutItemMargin, priv->bottomLayoutItemMargin);never executed: return rect.adjusted(-priv->leftLayoutItemMargin, -priv->topLayoutItemMargin, priv->rightLayoutItemMargin, priv->bottomLayoutItemMargin); | 0 | ||||||||||||
| 19 | priv->rightLayoutItemMargin, priv->bottomLayoutItemMargin); never executed: return rect.adjusted(-priv->leftLayoutItemMargin, -priv->topLayoutItemMargin, priv->rightLayoutItemMargin, priv->bottomLayoutItemMargin); | 0 | ||||||||||||
| 20 | } | - | ||||||||||||
| 21 | - | |||||||||||||
| 22 | inline static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size) | - | ||||||||||||
| 23 | { | - | ||||||||||||
| 24 | return never executed: toLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size();return toLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size();never executed: return toLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size(); | 0 | ||||||||||||
| 25 | } | - | ||||||||||||
| 26 | void QLayoutItem::setAlignment(Qt::Alignment alignment) | - | ||||||||||||
| 27 | { | - | ||||||||||||
| 28 | align = alignment; | - | ||||||||||||
| 29 | } never executed: end of block | 0 | ||||||||||||
| 30 | QSpacerItem::~QSpacerItem() {} | - | ||||||||||||
| 31 | void QSpacerItem::changeSize(int w, int h, QSizePolicy::Policy hPolicy, | - | ||||||||||||
| 32 | QSizePolicy::Policy vPolicy) | - | ||||||||||||
| 33 | { | - | ||||||||||||
| 34 | width = w; | - | ||||||||||||
| 35 | height = h; | - | ||||||||||||
| 36 | sizeP = QSizePolicy(hPolicy, vPolicy); | - | ||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||
| 38 | QWidgetItem::~QWidgetItem() {} | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | - | |||||||||||||
| 41 | - | |||||||||||||
| 42 | - | |||||||||||||
| 43 | QLayoutItem::~QLayoutItem() | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | } | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | - | |||||||||||||
| 48 | - | |||||||||||||
| 49 | - | |||||||||||||
| 50 | void QLayoutItem::invalidate() | - | ||||||||||||
| 51 | { | - | ||||||||||||
| 52 | } | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | - | |||||||||||||
| 55 | - | |||||||||||||
| 56 | - | |||||||||||||
| 57 | - | |||||||||||||
| 58 | - | |||||||||||||
| 59 | - | |||||||||||||
| 60 | QLayout * QLayoutItem::layout() | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | - | |||||||||||||
| 67 | - | |||||||||||||
| 68 | - | |||||||||||||
| 69 | - | |||||||||||||
| 70 | - | |||||||||||||
| 71 | QSpacerItem * QLayoutItem::spacerItem() | - | ||||||||||||
| 72 | { | - | ||||||||||||
| 73 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | - | |||||||||||||
| 77 | - | |||||||||||||
| 78 | - | |||||||||||||
| 79 | QLayout * QLayout::layout() | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | return never executed: this;return this;never executed: return this; | 0 | ||||||||||||
| 82 | } | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | - | |||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | QSpacerItem * QSpacerItem::spacerItem() | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | return never executed: this;return this;never executed: return this; | 0 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | QWidget * QLayoutItem::widget() | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 94 | } | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | - | |||||||||||||
| 97 | - | |||||||||||||
| 98 | - | |||||||||||||
| 99 | QWidget *QWidgetItem::widget() | - | ||||||||||||
| 100 | { | - | ||||||||||||
| 101 | return never executed: wid;return wid;never executed: return wid; | 0 | ||||||||||||
| 102 | } | - | ||||||||||||
| 103 | bool QLayoutItem::hasHeightForWidth() const | - | ||||||||||||
| 104 | { | - | ||||||||||||
| 105 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 106 | } | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | - | |||||||||||||
| 111 | - | |||||||||||||
| 112 | - | |||||||||||||
| 113 | int QLayoutItem::minimumHeightForWidth(int w) const | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | return never executed: heightForWidth(w);return heightForWidth(w);never executed: return heightForWidth(w); | 0 | ||||||||||||
| 116 | } | - | ||||||||||||
| 117 | int QLayoutItem::heightForWidth(int ) const | - | ||||||||||||
| 118 | { | - | ||||||||||||
| 119 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 120 | } | - | ||||||||||||
| 121 | QSizePolicy::ControlTypes QLayoutItem::controlTypes() const | - | ||||||||||||
| 122 | { | - | ||||||||||||
| 123 | return never executed: QSizePolicy::DefaultType;return QSizePolicy::DefaultType;never executed: return QSizePolicy::DefaultType; | 0 | ||||||||||||
| 124 | } | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | - | |||||||||||||
| 127 | - | |||||||||||||
| 128 | - | |||||||||||||
| 129 | void QSpacerItem::setGeometry(const QRect &r) | - | ||||||||||||
| 130 | { | - | ||||||||||||
| 131 | rect = r; | - | ||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | - | |||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | void QWidgetItem::setGeometry(const QRect &rect) | - | ||||||||||||
| 138 | { | - | ||||||||||||
| 139 | if (isEmpty()
| 0 | ||||||||||||
| 140 | return; never executed: return; | 0 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | QRect r = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
| 0 | ||||||||||||
| 143 | ? fromLayoutItemRect(wid->d_func(), rect) | - | ||||||||||||
| 144 | : rect; | - | ||||||||||||
| 145 | const QSize widgetRectSurplus = r.size() - rect.size(); | - | ||||||||||||
| 146 | QSize s = r.size().boundedTo(maximumSize() + widgetRectSurplus); | - | ||||||||||||
| 147 | int x = r.x(); | - | ||||||||||||
| 148 | int y = r.y(); | - | ||||||||||||
| 149 | if (align & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask)
| 0 | ||||||||||||
| 150 | QSize pref(sizeHint()); | - | ||||||||||||
| 151 | QSizePolicy sp = wid->sizePolicy(); | - | ||||||||||||
| 152 | if (sp.horizontalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||
| 153 | pref.setWidth(wid->sizeHint().expandedTo(wid->minimumSize()).width()); never executed: pref.setWidth(wid->sizeHint().expandedTo(wid->minimumSize()).width()); | 0 | ||||||||||||
| 154 | if (sp.verticalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||
| 155 | pref.setHeight(wid->sizeHint().expandedTo(wid->minimumSize()).height()); never executed: pref.setHeight(wid->sizeHint().expandedTo(wid->minimumSize()).height()); | 0 | ||||||||||||
| 156 | pref += widgetRectSurplus; | - | ||||||||||||
| 157 | if (align & Qt::AlignHorizontal_Mask
| 0 | ||||||||||||
| 158 | s.setWidth(qMin(s.width(), pref.width())); never executed: s.setWidth(qMin(s.width(), pref.width())); | 0 | ||||||||||||
| 159 | if (align & Qt::AlignVertical_Mask
| 0 | ||||||||||||
| 160 | if (hasHeightForWidth()
| 0 | ||||||||||||
| 161 | s.setHeight(qMin(s.height(), never executed: s.setHeight(qMin(s.height(), heightForWidth(s.width() - widgetRectSurplus.width()) + widgetRectSurplus.height())); | 0 | ||||||||||||
| 162 | heightForWidth(s.width() - widgetRectSurplus.width()) never executed: s.setHeight(qMin(s.height(), heightForWidth(s.width() - widgetRectSurplus.width()) + widgetRectSurplus.height())); | 0 | ||||||||||||
| 163 | + widgetRectSurplus.height())); never executed: s.setHeight(qMin(s.height(), heightForWidth(s.width() - widgetRectSurplus.width()) + widgetRectSurplus.height())); | 0 | ||||||||||||
| 164 | else | - | ||||||||||||
| 165 | s.setHeight(qMin(s.height(), pref.height())); never executed: s.setHeight(qMin(s.height(), pref.height())); | 0 | ||||||||||||
| 166 | } | - | ||||||||||||
| 167 | } never executed: end of block | 0 | ||||||||||||
| 168 | Qt::Alignment alignHoriz = QStyle::visualAlignment(wid->layoutDirection(), align); | - | ||||||||||||
| 169 | if (alignHoriz & Qt::AlignRight
| 0 | ||||||||||||
| 170 | x = x + (r.width() - s.width()); never executed: x = x + (r.width() - s.width()); | 0 | ||||||||||||
| 171 | else if (!(alignHoriz & Qt::AlignLeft)
| 0 | ||||||||||||
| 172 | x = x + (r.width() - s.width()) / 2; never executed: x = x + (r.width() - s.width()) / 2; | 0 | ||||||||||||
| 173 | - | |||||||||||||
| 174 | if (align & Qt::AlignBottom
| 0 | ||||||||||||
| 175 | y = y + (r.height() - s.height()); never executed: y = y + (r.height() - s.height()); | 0 | ||||||||||||
| 176 | else if (!(align & Qt::AlignTop)
| 0 | ||||||||||||
| 177 | y = y + (r.height() - s.height()) / 2; never executed: y = y + (r.height() - s.height()) / 2; | 0 | ||||||||||||
| 178 | - | |||||||||||||
| 179 | wid->setGeometry(x, y, s.width(), s.height()); | - | ||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||
| 181 | - | |||||||||||||
| 182 | - | |||||||||||||
| 183 | - | |||||||||||||
| 184 | - | |||||||||||||
| 185 | QRect QSpacerItem::geometry() const | - | ||||||||||||
| 186 | { | - | ||||||||||||
| 187 | return never executed: rect;return rect;never executed: return rect; | 0 | ||||||||||||
| 188 | } | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | - | |||||||||||||
| 191 | - | |||||||||||||
| 192 | - | |||||||||||||
| 193 | QRect QWidgetItem::geometry() const | - | ||||||||||||
| 194 | { | - | ||||||||||||
| 195 | return never executed: !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemRect(wid->d_func(), wid->geometry()) : wid->geometry();never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemRect(wid->d_func(), wid->geometry()) : wid->geometry(); | 0 | ||||||||||||
| 196 | ? toLayoutItemRect(wid->d_func(), wid->geometry()) never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemRect(wid->d_func(), wid->geometry()) : wid->geometry(); | 0 | ||||||||||||
| 197 | : wid->geometry(); never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemRect(wid->d_func(), wid->geometry()) : wid->geometry(); | 0 | ||||||||||||
| 198 | } | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | - | |||||||||||||
| 201 | - | |||||||||||||
| 202 | - | |||||||||||||
| 203 | - | |||||||||||||
| 204 | bool QWidgetItem::hasHeightForWidth() const | - | ||||||||||||
| 205 | { | - | ||||||||||||
| 206 | if (isEmpty()
| 0 | ||||||||||||
| 207 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 208 | return never executed: wid->hasHeightForWidth();return wid->hasHeightForWidth();never executed: return wid->hasHeightForWidth(); | 0 | ||||||||||||
| 209 | } | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | - | |||||||||||||
| 212 | - | |||||||||||||
| 213 | - | |||||||||||||
| 214 | int QWidgetItem::heightForWidth(int w) const | - | ||||||||||||
| 215 | { | - | ||||||||||||
| 216 | if (isEmpty()
| 0 | ||||||||||||
| 217 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 218 | - | |||||||||||||
| 219 | w = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
| 0 | ||||||||||||
| 220 | ? fromLayoutItemSize(wid->d_func(), QSize(w, 0)).width() | - | ||||||||||||
| 221 | : w; | - | ||||||||||||
| 222 | - | |||||||||||||
| 223 | int hfw; | - | ||||||||||||
| 224 | if (wid->layout()
| 0 | ||||||||||||
| 225 | hfw = wid->layout()->totalHeightForWidth(w); never executed: hfw = wid->layout()->totalHeightForWidth(w); | 0 | ||||||||||||
| 226 | else | - | ||||||||||||
| 227 | hfw = wid->heightForWidth(w); never executed: hfw = wid->heightForWidth(w); | 0 | ||||||||||||
| 228 | - | |||||||||||||
| 229 | if (hfw > wid->maximumHeight()
| 0 | ||||||||||||
| 230 | hfw = wid->maximumHeight(); never executed: hfw = wid->maximumHeight(); | 0 | ||||||||||||
| 231 | if (hfw < wid->minimumHeight()
| 0 | ||||||||||||
| 232 | hfw = wid->minimumHeight(); never executed: hfw = wid->minimumHeight(); | 0 | ||||||||||||
| 233 | - | |||||||||||||
| 234 | hfw = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
| 0 | ||||||||||||
| 235 | ? toLayoutItemSize(wid->d_func(), QSize(0, hfw)).height() | - | ||||||||||||
| 236 | : hfw; | - | ||||||||||||
| 237 | - | |||||||||||||
| 238 | if (hfw < 0
| 0 | ||||||||||||
| 239 | hfw = 0; never executed: hfw = 0; | 0 | ||||||||||||
| 240 | return never executed: hfw;return hfw;never executed: return hfw; | 0 | ||||||||||||
| 241 | } | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | - | |||||||||||||
| 244 | - | |||||||||||||
| 245 | - | |||||||||||||
| 246 | Qt::Orientations QSpacerItem::expandingDirections() const | - | ||||||||||||
| 247 | { | - | ||||||||||||
| 248 | return never executed: sizeP.expandingDirections();return sizeP.expandingDirections();never executed: return sizeP.expandingDirections(); | 0 | ||||||||||||
| 249 | } | - | ||||||||||||
| 250 | - | |||||||||||||
| 251 | - | |||||||||||||
| 252 | - | |||||||||||||
| 253 | - | |||||||||||||
| 254 | Qt::Orientations QWidgetItem::expandingDirections() const | - | ||||||||||||
| 255 | { | - | ||||||||||||
| 256 | if (isEmpty()
| 0 | ||||||||||||
| 257 | return never executed: Qt::Orientations(0);return Qt::Orientations(0);never executed: return Qt::Orientations(0); | 0 | ||||||||||||
| 258 | - | |||||||||||||
| 259 | Qt::Orientations e = wid->sizePolicy().expandingDirections(); | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | - | |||||||||||||
| 262 | - | |||||||||||||
| 263 | - | |||||||||||||
| 264 | if (wid->layout()
| 0 | ||||||||||||
| 265 | if (wid->sizePolicy().horizontalPolicy() & QSizePolicy::GrowFlag
| 0 | ||||||||||||
| 266 | && (
| 0 | ||||||||||||
| 267 | e |= Qt::Horizontal; never executed: e |= Qt::Horizontal; | 0 | ||||||||||||
| 268 | if (wid->sizePolicy().verticalPolicy() & QSizePolicy::GrowFlag
| 0 | ||||||||||||
| 269 | && (
| 0 | ||||||||||||
| 270 | e |= Qt::Vertical; never executed: e |= Qt::Vertical; | 0 | ||||||||||||
| 271 | } never executed: end of block | 0 | ||||||||||||
| 272 | - | |||||||||||||
| 273 | if (align & Qt::AlignHorizontal_Mask
| 0 | ||||||||||||
| 274 | e &= ~Qt::Horizontal; never executed: e &= ~Qt::Horizontal; | 0 | ||||||||||||
| 275 | if (align & Qt::AlignVertical_Mask
| 0 | ||||||||||||
| 276 | e &= ~Qt::Vertical; never executed: e &= ~Qt::Vertical; | 0 | ||||||||||||
| 277 | return never executed: e;return e;never executed: return e; | 0 | ||||||||||||
| 278 | } | - | ||||||||||||
| 279 | - | |||||||||||||
| 280 | - | |||||||||||||
| 281 | - | |||||||||||||
| 282 | - | |||||||||||||
| 283 | QSize QSpacerItem::minimumSize() const | - | ||||||||||||
| 284 | { | - | ||||||||||||
| 285 | return never executed: QSize(sizeP.horizontalPolicy() & QSizePolicy::ShrinkFlag ? 0 : width,return QSize(sizeP.horizontalPolicy() & QSizePolicy::ShrinkFlag ? 0 : width, sizeP.verticalPolicy() & QSizePolicy::ShrinkFlag ? 0 : height);never executed: return QSize(sizeP.horizontalPolicy() & QSizePolicy::ShrinkFlag ? 0 : width, sizeP.verticalPolicy() & QSizePolicy::ShrinkFlag ? 0 : height); | 0 | ||||||||||||
| 286 | sizeP.verticalPolicy() & QSizePolicy::ShrinkFlag ? 0 : height); never executed: return QSize(sizeP.horizontalPolicy() & QSizePolicy::ShrinkFlag ? 0 : width, sizeP.verticalPolicy() & QSizePolicy::ShrinkFlag ? 0 : height); | 0 | ||||||||||||
| 287 | } | - | ||||||||||||
| 288 | - | |||||||||||||
| 289 | - | |||||||||||||
| 290 | - | |||||||||||||
| 291 | - | |||||||||||||
| 292 | QSize QWidgetItem::minimumSize() const | - | ||||||||||||
| 293 | { | - | ||||||||||||
| 294 | if (isEmpty()
| 0 | ||||||||||||
| 295 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||
| 296 | return never executed: !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMinSize(this)) : qSmartMinSize(this);never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMinSize(this)) : qSmartMinSize(this); | 0 | ||||||||||||
| 297 | ? toLayoutItemSize(wid->d_func(), qSmartMinSize(this)) never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMinSize(this)) : qSmartMinSize(this); | 0 | ||||||||||||
| 298 | : qSmartMinSize(this); never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMinSize(this)) : qSmartMinSize(this); | 0 | ||||||||||||
| 299 | } | - | ||||||||||||
| 300 | - | |||||||||||||
| 301 | - | |||||||||||||
| 302 | - | |||||||||||||
| 303 | - | |||||||||||||
| 304 | QSize QSpacerItem::maximumSize() const | - | ||||||||||||
| 305 | { | - | ||||||||||||
| 306 | return never executed: QSize(sizeP.horizontalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : width,return QSize(sizeP.horizontalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : width, sizeP.verticalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : height);never executed: return QSize(sizeP.horizontalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : width, sizeP.verticalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : height); | 0 | ||||||||||||
| 307 | sizeP.verticalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : height); never executed: return QSize(sizeP.horizontalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : width, sizeP.verticalPolicy() & QSizePolicy::GrowFlag ? QLAYOUTSIZE_MAX : height); | 0 | ||||||||||||
| 308 | } | - | ||||||||||||
| 309 | - | |||||||||||||
| 310 | - | |||||||||||||
| 311 | - | |||||||||||||
| 312 | - | |||||||||||||
| 313 | QSize QWidgetItem::maximumSize() const | - | ||||||||||||
| 314 | { | - | ||||||||||||
| 315 | if (isEmpty()
| 0 | ||||||||||||
| 316 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||
| 317 | } else { | - | ||||||||||||
| 318 | return never executed: !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align)) : qSmartMaxSize(this, align);never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align)) : qSmartMaxSize(this, align); | 0 | ||||||||||||
| 319 | ? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align)) never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align)) : qSmartMaxSize(this, align); | 0 | ||||||||||||
| 320 | : qSmartMaxSize(this, align); never executed: return !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect) ? toLayoutItemSize(wid->d_func(), qSmartMaxSize(this, align)) : qSmartMaxSize(this, align); | 0 | ||||||||||||
| 321 | } | - | ||||||||||||
| 322 | } | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | - | |||||||||||||
| 325 | - | |||||||||||||
| 326 | - | |||||||||||||
| 327 | QSize QSpacerItem::sizeHint() const | - | ||||||||||||
| 328 | { | - | ||||||||||||
| 329 | return never executed: QSize(width, height);return QSize(width, height);never executed: return QSize(width, height); | 0 | ||||||||||||
| 330 | } | - | ||||||||||||
| 331 | - | |||||||||||||
| 332 | - | |||||||||||||
| 333 | - | |||||||||||||
| 334 | - | |||||||||||||
| 335 | QSize QWidgetItem::sizeHint() const | - | ||||||||||||
| 336 | { | - | ||||||||||||
| 337 | QSize s(0, 0); | - | ||||||||||||
| 338 | if (!isEmpty()
| 0 | ||||||||||||
| 339 | s = wid->sizeHint().expandedTo(wid->minimumSizeHint()); | - | ||||||||||||
| 340 | s = s.boundedTo(wid->maximumSize()) | - | ||||||||||||
| 341 | .expandedTo(wid->minimumSize()); | - | ||||||||||||
| 342 | s = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
| 0 | ||||||||||||
| 343 | ? toLayoutItemSize(wid->d_func(), s) | - | ||||||||||||
| 344 | : s; | - | ||||||||||||
| 345 | - | |||||||||||||
| 346 | if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||
| 347 | s.setWidth(0); never executed: s.setWidth(0); | 0 | ||||||||||||
| 348 | if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||
| 349 | s.setHeight(0); never executed: s.setHeight(0); | 0 | ||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||
| 351 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||
| 352 | } | - | ||||||||||||
| 353 | - | |||||||||||||
| 354 | - | |||||||||||||
| 355 | - | |||||||||||||
| 356 | - | |||||||||||||
| 357 | bool QSpacerItem::isEmpty() const | - | ||||||||||||
| 358 | { | - | ||||||||||||
| 359 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||
| 360 | } | - | ||||||||||||
| 361 | - | |||||||||||||
| 362 | - | |||||||||||||
| 363 | - | |||||||||||||
| 364 | - | |||||||||||||
| 365 | - | |||||||||||||
| 366 | - | |||||||||||||
| 367 | bool QWidgetItem::isEmpty() const | - | ||||||||||||
| 368 | { | - | ||||||||||||
| 369 | return never executed: (wid->isHidden() && !wid->sizePolicy().retainSizeWhenHidden()) || wid->isWindow();return (wid->isHidden() && !wid->sizePolicy().retainSizeWhenHidden()) || wid->isWindow();never executed: return (wid->isHidden() && !wid->sizePolicy().retainSizeWhenHidden()) || wid->isWindow(); | 0 | ||||||||||||
| 370 | } | - | ||||||||||||
| 371 | - | |||||||||||||
| 372 | - | |||||||||||||
| 373 | - | |||||||||||||
| 374 | - | |||||||||||||
| 375 | - | |||||||||||||
| 376 | - | |||||||||||||
| 377 | - | |||||||||||||
| 378 | QSizePolicy::ControlTypes QWidgetItem::controlTypes() const | - | ||||||||||||
| 379 | { | - | ||||||||||||
| 380 | return never executed: wid->sizePolicy().controlType();return wid->sizePolicy().controlType();never executed: return wid->sizePolicy().controlType(); | 0 | ||||||||||||
| 381 | } | - | ||||||||||||
| 382 | - | |||||||||||||
| 383 | - | |||||||||||||
| 384 | - | |||||||||||||
| 385 | - | |||||||||||||
| 386 | - | |||||||||||||
| 387 | - | |||||||||||||
| 388 | inline bool QWidgetItemV2::useSizeCache() const | - | ||||||||||||
| 389 | { | - | ||||||||||||
| 390 | return never executed: wid->d_func()->widgetItem == this;return wid->d_func()->widgetItem == this;never executed: return wid->d_func()->widgetItem == this; | 0 | ||||||||||||
| 391 | } | - | ||||||||||||
| 392 | - | |||||||||||||
| 393 | void QWidgetItemV2::updateCacheIfNecessary() const | - | ||||||||||||
| 394 | { | - | ||||||||||||
| 395 | if (q_cachedMinimumSize.width() != Dirty
| 0 | ||||||||||||
| 396 | return; never executed: return; | 0 | ||||||||||||
| 397 | - | |||||||||||||
| 398 | const QSize sizeHint(wid->sizeHint()); | - | ||||||||||||
| 399 | const QSize minimumSizeHint(wid->minimumSizeHint()); | - | ||||||||||||
| 400 | const QSize minimumSize(wid->minimumSize()); | - | ||||||||||||
| 401 | const QSize maximumSize(wid->maximumSize()); | - | ||||||||||||
| 402 | const QSizePolicy sizePolicy(wid->sizePolicy()); | - | ||||||||||||
| 403 | const QSize expandedSizeHint(sizeHint.expandedTo(minimumSizeHint)); | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | const QSize smartMinSize(qSmartMinSize(sizeHint, minimumSizeHint, minimumSize, maximumSize, sizePolicy)); | - | ||||||||||||
| 406 | const QSize smartMaxSize(qSmartMaxSize(expandedSizeHint, minimumSize, maximumSize, sizePolicy, align)); | - | ||||||||||||
| 407 | - | |||||||||||||
| 408 | const bool useLayoutItemRect = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect); | - | ||||||||||||
| 409 | - | |||||||||||||
| 410 | q_cachedMinimumSize = useLayoutItemRect
| 0 | ||||||||||||
| 411 | ? toLayoutItemSize(wid->d_func(), smartMinSize) | - | ||||||||||||
| 412 | : smartMinSize; | - | ||||||||||||
| 413 | - | |||||||||||||
| 414 | q_cachedSizeHint = expandedSizeHint; | - | ||||||||||||
| 415 | q_cachedSizeHint = q_cachedSizeHint.boundedTo(maximumSize) | - | ||||||||||||
| 416 | .expandedTo(minimumSize); | - | ||||||||||||
| 417 | q_cachedSizeHint = useLayoutItemRect
| 0 | ||||||||||||
| 418 | ? toLayoutItemSize(wid->d_func(), q_cachedSizeHint) | - | ||||||||||||
| 419 | : q_cachedSizeHint; | - | ||||||||||||
| 420 | - | |||||||||||||
| 421 | if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||
| 422 | q_cachedSizeHint.setWidth(0); never executed: q_cachedSizeHint.setWidth(0); | 0 | ||||||||||||
| 423 | if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored
| 0 | ||||||||||||
| 424 | q_cachedSizeHint.setHeight(0); never executed: q_cachedSizeHint.setHeight(0); | 0 | ||||||||||||
| 425 | - | |||||||||||||
| 426 | q_cachedMaximumSize = useLayoutItemRect
| 0 | ||||||||||||
| 427 | ? toLayoutItemSize(wid->d_func(), smartMaxSize) | - | ||||||||||||
| 428 | : smartMaxSize; | - | ||||||||||||
| 429 | } never executed: end of block | 0 | ||||||||||||
| 430 | - | |||||||||||||
| 431 | QWidgetItemV2::QWidgetItemV2(QWidget *widget) | - | ||||||||||||
| 432 | : QWidgetItem(widget), | - | ||||||||||||
| 433 | q_cachedMinimumSize(Dirty, Dirty), | - | ||||||||||||
| 434 | q_cachedSizeHint(Dirty, Dirty), | - | ||||||||||||
| 435 | q_cachedMaximumSize(Dirty, Dirty), | - | ||||||||||||
| 436 | q_firstCachedHfw(0), | - | ||||||||||||
| 437 | q_hfwCacheSize(0), | - | ||||||||||||
| 438 | d(0) | - | ||||||||||||
| 439 | { | - | ||||||||||||
| 440 | QWidgetPrivate *wd = wid->d_func(); | - | ||||||||||||
| 441 | if (!wd->widgetItem
| 0 | ||||||||||||
| 442 | wd->widgetItem = this; never executed: wd->widgetItem = this; | 0 | ||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||
| 444 | - | |||||||||||||
| 445 | QWidgetItemV2::~QWidgetItemV2() | - | ||||||||||||
| 446 | { | - | ||||||||||||
| 447 | if (wid
| 0 | ||||||||||||
| 448 | QWidgetPrivate *wd = wid->d_func(); | - | ||||||||||||
| 449 | if (wd->widgetItem == this
| 0 | ||||||||||||
| 450 | wd->widgetItem = 0; never executed: wd->widgetItem = 0; | 0 | ||||||||||||
| 451 | } never executed: end of block | 0 | ||||||||||||
| 452 | } never executed: end of block | 0 | ||||||||||||
| 453 | - | |||||||||||||
| 454 | QSize QWidgetItemV2::sizeHint() const | - | ||||||||||||
| 455 | { | - | ||||||||||||
| 456 | if (isEmpty()
| 0 | ||||||||||||
| 457 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||
| 458 | - | |||||||||||||
| 459 | if (useSizeCache()
| 0 | ||||||||||||
| 460 | updateCacheIfNecessary(); | - | ||||||||||||
| 461 | return never executed: q_cachedSizeHint;return q_cachedSizeHint;never executed: return q_cachedSizeHint; | 0 | ||||||||||||
| 462 | } else { | - | ||||||||||||
| 463 | return never executed: QWidgetItem::sizeHint();return QWidgetItem::sizeHint();never executed: return QWidgetItem::sizeHint(); | 0 | ||||||||||||
| 464 | } | - | ||||||||||||
| 465 | } | - | ||||||||||||
| 466 | - | |||||||||||||
| 467 | QSize QWidgetItemV2::minimumSize() const | - | ||||||||||||
| 468 | { | - | ||||||||||||
| 469 | if (isEmpty()
| 0 | ||||||||||||
| 470 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||
| 471 | - | |||||||||||||
| 472 | if (useSizeCache()
| 0 | ||||||||||||
| 473 | updateCacheIfNecessary(); | - | ||||||||||||
| 474 | return never executed: q_cachedMinimumSize;return q_cachedMinimumSize;never executed: return q_cachedMinimumSize; | 0 | ||||||||||||
| 475 | } else { | - | ||||||||||||
| 476 | return never executed: QWidgetItem::minimumSize();return QWidgetItem::minimumSize();never executed: return QWidgetItem::minimumSize(); | 0 | ||||||||||||
| 477 | } | - | ||||||||||||
| 478 | } | - | ||||||||||||
| 479 | - | |||||||||||||
| 480 | QSize QWidgetItemV2::maximumSize() const | - | ||||||||||||
| 481 | { | - | ||||||||||||
| 482 | if (isEmpty()
| 0 | ||||||||||||
| 483 | return never executed: QSize(0, 0);return QSize(0, 0);never executed: return QSize(0, 0); | 0 | ||||||||||||
| 484 | - | |||||||||||||
| 485 | if (useSizeCache()
| 0 | ||||||||||||
| 486 | updateCacheIfNecessary(); | - | ||||||||||||
| 487 | return never executed: q_cachedMaximumSize;return q_cachedMaximumSize;never executed: return q_cachedMaximumSize; | 0 | ||||||||||||
| 488 | } else { | - | ||||||||||||
| 489 | return never executed: QWidgetItem::maximumSize();return QWidgetItem::maximumSize();never executed: return QWidgetItem::maximumSize(); | 0 | ||||||||||||
| 490 | } | - | ||||||||||||
| 491 | } | - | ||||||||||||
| 492 | int QWidgetItemV2::heightForWidth(int width) const | - | ||||||||||||
| 493 | { | - | ||||||||||||
| 494 | if (isEmpty()
| 0 | ||||||||||||
| 495 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 496 | - | |||||||||||||
| 497 | for (int i = 0; i < q_hfwCacheSize
| 0 | ||||||||||||
| 498 | int offset = q_firstCachedHfw + i; | - | ||||||||||||
| 499 | const QSize &size = q_cachedHfws[offset % HfwCacheMaxSize]; | - | ||||||||||||
| 500 | if (size.width() == width
| 0 | ||||||||||||
| 501 | if (q_hfwCacheSize == HfwCacheMaxSize
| 0 | ||||||||||||
| 502 | q_firstCachedHfw = offset; never executed: q_firstCachedHfw = offset; | 0 | ||||||||||||
| 503 | return never executed: size.height();return size.height();never executed: return size.height(); | 0 | ||||||||||||
| 504 | } | - | ||||||||||||
| 505 | } never executed: end of block | 0 | ||||||||||||
| 506 | - | |||||||||||||
| 507 | if (q_hfwCacheSize < HfwCacheMaxSize
| 0 | ||||||||||||
| 508 | ++ never executed: q_hfwCacheSize;++q_hfwCacheSize;never executed: ++q_hfwCacheSize; | 0 | ||||||||||||
| 509 | q_firstCachedHfw = (q_firstCachedHfw + HfwCacheMaxSize - 1) % HfwCacheMaxSize; | - | ||||||||||||
| 510 | - | |||||||||||||
| 511 | int height = QWidgetItem::heightForWidth(width); | - | ||||||||||||
| 512 | q_cachedHfws[q_firstCachedHfw] = QSize(width, height); | - | ||||||||||||
| 513 | return never executed: height;return height;never executed: return height; | 0 | ||||||||||||
| 514 | } | - | ||||||||||||
| 515 | - | |||||||||||||
| 516 | - | |||||||||||||
| Switch to Source code | Preprocessed file |