| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicslayoutitem.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | static void combineSize(QSizeF &result, const QSizeF &size) | - | ||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||
| 9 | if (result.width() < 0
| 0 | ||||||||||||||||||||||||
| 10 | result.setWidth(size.width()); never executed: result.setWidth(size.width()); | 0 | ||||||||||||||||||||||||
| 11 | if (result.height() < 0
| 0 | ||||||||||||||||||||||||
| 12 | result.setHeight(size.height()); never executed: result.setHeight(size.height()); | 0 | ||||||||||||||||||||||||
| 13 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | static void boundSize(QSizeF &result, const QSizeF &size) | - | ||||||||||||||||||||||||
| 16 | { | - | ||||||||||||||||||||||||
| 17 | if (size.width() >= 0
| 0 | ||||||||||||||||||||||||
| 18 | result.setWidth(size.width()); never executed: result.setWidth(size.width()); | 0 | ||||||||||||||||||||||||
| 19 | if (size.height() >= 0
| 0 | ||||||||||||||||||||||||
| 20 | result.setHeight(size.height()); never executed: result.setHeight(size.height()); | 0 | ||||||||||||||||||||||||
| 21 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | static void expandSize(QSizeF &result, const QSizeF &size) | - | ||||||||||||||||||||||||
| 24 | { | - | ||||||||||||||||||||||||
| 25 | if (size.width() >= 0
| 0 | ||||||||||||||||||||||||
| 26 | result.setWidth(size.width()); never executed: result.setWidth(size.width()); | 0 | ||||||||||||||||||||||||
| 27 | if (size.height() >= 0
| 0 | ||||||||||||||||||||||||
| 28 | result.setHeight(size.height()); never executed: result.setHeight(size.height()); | 0 | ||||||||||||||||||||||||
| 29 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||
| 31 | static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qreal &descent) | - | ||||||||||||||||||||||||
| 32 | { | - | ||||||||||||||||||||||||
| 33 | if (minimum >= 0
| 0 | ||||||||||||||||||||||||
| 34 | minimum = maximum; never executed: minimum = maximum; | 0 | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | if (preferred >= 0
| 0 | ||||||||||||||||||||||||
| 37 | if (minimum >= 0
| 0 | ||||||||||||||||||||||||
| 38 | preferred = minimum; | - | ||||||||||||||||||||||||
| 39 | } never executed: else if (maximum >= 0end of block
| 0 | ||||||||||||||||||||||||
| 40 | preferred = maximum; | - | ||||||||||||||||||||||||
| 41 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 42 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | if (minimum >= 0
| 0 | ||||||||||||||||||||||||
| 45 | descent = minimum; never executed: descent = minimum; | 0 | ||||||||||||||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par, bool layout) | - | ||||||||||||||||||||||||
| 52 | : parent(par), userSizeHints(0), isLayout(layout), ownedByLayout(false), graphicsItem(0) | - | ||||||||||||||||||||||||
| 53 | { | - | ||||||||||||||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | QGraphicsLayoutItemPrivate::~QGraphicsLayoutItemPrivate() | - | ||||||||||||||||||||||||
| 60 | { | - | ||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | delete[] userSizeHints; | - | ||||||||||||||||||||||||
| 63 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | void QGraphicsLayoutItemPrivate::init() | - | ||||||||||||||||||||||||
| 69 | { | - | ||||||||||||||||||||||||
| 70 | sizeHintCacheDirty = true; | - | ||||||||||||||||||||||||
| 71 | sizeHintWithConstraintCacheDirty = true; | - | ||||||||||||||||||||||||
| 72 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) const | - | ||||||||||||||||||||||||
| 78 | { | - | ||||||||||||||||||||||||
| 79 | const QGraphicsLayoutItem * const q = q_func(); | - | ||||||||||||||||||||||||
| 80 | QSizeF *sizeHintCache; | - | ||||||||||||||||||||||||
| 81 | const bool hasConstraint = constraint.width() >= 0
| 0 | ||||||||||||||||||||||||
| 82 | if (hasConstraint
| 0 | ||||||||||||||||||||||||
| 83 | if (!sizeHintWithConstraintCacheDirty
| 0 | ||||||||||||||||||||||||
| 84 | return never executed: cachedSizeHintsWithConstraints;return cachedSizeHintsWithConstraints;never executed: return cachedSizeHintsWithConstraints; | 0 | ||||||||||||||||||||||||
| 85 | sizeHintCache = cachedSizeHintsWithConstraints; | - | ||||||||||||||||||||||||
| 86 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 87 | if (!sizeHintCacheDirty
| 0 | ||||||||||||||||||||||||
| 88 | return never executed: cachedSizeHints;return cachedSizeHints;never executed: return cachedSizeHints; | 0 | ||||||||||||||||||||||||
| 89 | sizeHintCache = cachedSizeHints; | - | ||||||||||||||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | for (int i = 0; i < Qt::NSizeHints
| 0 | ||||||||||||||||||||||||
| 93 | sizeHintCache[i] = constraint; | - | ||||||||||||||||||||||||
| 94 | if (userSizeHints
| 0 | ||||||||||||||||||||||||
| 95 | combineSize(sizeHintCache[i], userSizeHints[i]); never executed: combineSize(sizeHintCache[i], userSizeHints[i]); | 0 | ||||||||||||||||||||||||
| 96 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | QSizeF &minS = sizeHintCache[Qt::MinimumSize]; | - | ||||||||||||||||||||||||
| 99 | QSizeF &prefS = sizeHintCache[Qt::PreferredSize]; | - | ||||||||||||||||||||||||
| 100 | QSizeF &maxS = sizeHintCache[Qt::MaximumSize]; | - | ||||||||||||||||||||||||
| 101 | QSizeF &descentS = sizeHintCache[Qt::MinimumDescent]; | - | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | normalizeHints(minS.rwidth(), prefS.rwidth(), maxS.rwidth(), descentS.rwidth()); | - | ||||||||||||||||||||||||
| 104 | normalizeHints(minS.rheight(), prefS.rheight(), maxS.rheight(), descentS.rheight()); | - | ||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||
| 109 | do { if ((
never executed: } while (false);combineSize((maxS), (q->sizeHint(Qt::MaximumSize, maxS))); | 0 | ||||||||||||||||||||||||
| 110 | combineSize(maxS, QSizeF(((1<<24)-1), ((1<<24)-1))); | - | ||||||||||||||||||||||||
| 111 | expandSize(maxS, prefS); | - | ||||||||||||||||||||||||
| 112 | expandSize(maxS, minS); | - | ||||||||||||||||||||||||
| 113 | boundSize(maxS, QSizeF(((1<<24)-1), ((1<<24)-1))); | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | do { if ((
never executed: } while (false);combineSize((minS), (q->sizeHint(Qt::MinimumSize, minS))); | 0 | ||||||||||||||||||||||||
| 116 | expandSize(minS, QSizeF(0, 0)); | - | ||||||||||||||||||||||||
| 117 | boundSize(minS, prefS); | - | ||||||||||||||||||||||||
| 118 | boundSize(minS, maxS); | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | do { if ((
never executed: } while (false);combineSize((prefS), (q->sizeHint(Qt::PreferredSize, prefS))); | 0 | ||||||||||||||||||||||||
| 121 | expandSize(prefS, minS); | - | ||||||||||||||||||||||||
| 122 | boundSize(prefS, maxS); | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | if (hasConstraint
| 0 | ||||||||||||||||||||||||
| 128 | cachedConstraint = constraint; | - | ||||||||||||||||||||||||
| 129 | sizeHintWithConstraintCacheDirty = false; | - | ||||||||||||||||||||||||
| 130 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 131 | sizeHintCacheDirty = false; | - | ||||||||||||||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 133 | return never executed: sizeHintCache;return sizeHintCache;never executed: return sizeHintCache; | 0 | ||||||||||||||||||||||||
| 134 | } | - | ||||||||||||||||||||||||
| 135 | QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const | - | ||||||||||||||||||||||||
| 136 | { | - | ||||||||||||||||||||||||
| 137 | const QGraphicsLayoutItem * const q = q_func(); | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | const QGraphicsLayoutItem *parent = q; | - | ||||||||||||||||||||||||
| 140 | while (parent
| 0 | ||||||||||||||||||||||||
| 141 | parent = parent->parentLayoutItem(); | - | ||||||||||||||||||||||||
| 142 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 143 | return never executed: parentreturn parent ? parent->graphicsItem() : 0;
never executed: return parent ? parent->graphicsItem() : 0; | 0 | ||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | void QGraphicsLayoutItemPrivate::ensureUserSizeHints() | - | ||||||||||||||||||||||||
| 153 | { | - | ||||||||||||||||||||||||
| 154 | if (!userSizeHints
| 0 | ||||||||||||||||||||||||
| 155 | userSizeHints = new QSizeF[Qt::NSizeHints]; never executed: userSizeHints = new QSizeF[Qt::NSizeHints]; | 0 | ||||||||||||||||||||||||
| 156 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | void QGraphicsLayoutItemPrivate::setSize(Qt::SizeHint which, const QSizeF &size) | - | ||||||||||||||||||||||||
| 164 | { | - | ||||||||||||||||||||||||
| 165 | QGraphicsLayoutItem * const q = q_func(); | - | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | if (userSizeHints
| 0 | ||||||||||||||||||||||||
| 168 | if (size == userSizeHints[which]
| 0 | ||||||||||||||||||||||||
| 169 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 170 | } never executed: else if (size.width() < 0end of block
| 0 | ||||||||||||||||||||||||
| 171 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 172 | } | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | ensureUserSizeHints(); | - | ||||||||||||||||||||||||
| 175 | userSizeHints[which] = size; | - | ||||||||||||||||||||||||
| 176 | q->updateGeometry(); | - | ||||||||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| 184 | void QGraphicsLayoutItemPrivate::setSizeComponent( | - | ||||||||||||||||||||||||
| 185 | Qt::SizeHint which, SizeComponent component, qreal value) | - | ||||||||||||||||||||||||
| 186 | { | - | ||||||||||||||||||||||||
| 187 | QGraphicsLayoutItem * const q = q_func(); | - | ||||||||||||||||||||||||
| 188 | ensureUserSizeHints(); | - | ||||||||||||||||||||||||
| 189 | qreal &userValue = (
| 0 | ||||||||||||||||||||||||
| 190 | ? userSizeHints[which].rwidth() | - | ||||||||||||||||||||||||
| 191 | : userSizeHints[which].rheight(); | - | ||||||||||||||||||||||||
| 192 | if (value == userValue
| 0 | ||||||||||||||||||||||||
| 193 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 194 | userValue = value; | - | ||||||||||||||||||||||||
| 195 | q->updateGeometry(); | - | ||||||||||||||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | bool QGraphicsLayoutItemPrivate::hasHeightForWidth() const | - | ||||||||||||||||||||||||
| 200 | { | - | ||||||||||||||||||||||||
| 201 | const QGraphicsLayoutItem * const q = q_func(); | - | ||||||||||||||||||||||||
| 202 | if (isLayout
| 0 | ||||||||||||||||||||||||
| 203 | const QGraphicsLayout *l = static_cast<const QGraphicsLayout *>(q); | - | ||||||||||||||||||||||||
| 204 | for (int i = l->count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 205 | if (QGraphicsLayoutItemPrivate::get(l->itemAt(i))->hasHeightForWidth()
| 0 | ||||||||||||||||||||||||
| 206 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 207 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 208 | } never executed: else if (QGraphicsItem *item = q->graphicsItem()end of block
| 0 | ||||||||||||||||||||||||
| 209 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
| 210 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 211 | if (w->layout()
| 0 | ||||||||||||||||||||||||
| 212 | return never executed: QGraphicsLayoutItemPrivate::get(w->layout())->hasHeightForWidth();return QGraphicsLayoutItemPrivate::get(w->layout())->hasHeightForWidth();never executed: return QGraphicsLayoutItemPrivate::get(w->layout())->hasHeightForWidth(); | 0 | ||||||||||||||||||||||||
| 213 | } | - | ||||||||||||||||||||||||
| 214 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 216 | return never executed: q->sizePolicy().hasHeightForWidth();return q->sizePolicy().hasHeightForWidth();never executed: return q->sizePolicy().hasHeightForWidth(); | 0 | ||||||||||||||||||||||||
| 217 | } | - | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const | - | ||||||||||||||||||||||||
| 220 | { | - | ||||||||||||||||||||||||
| 221 | const QGraphicsLayoutItem * const q = q_func(); | - | ||||||||||||||||||||||||
| 222 | if (isLayout
| 0 | ||||||||||||||||||||||||
| 223 | const QGraphicsLayout *l = static_cast<const QGraphicsLayout *>(q); | - | ||||||||||||||||||||||||
| 224 | for (int i = l->count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 225 | if (QGraphicsLayoutItemPrivate::get(l->itemAt(i))->hasWidthForHeight()
| 0 | ||||||||||||||||||||||||
| 226 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 228 | } never executed: else if (QGraphicsItem *item = q->graphicsItem()end of block
| 0 | ||||||||||||||||||||||||
| 229 | if (item->isWidget()
| 0 | ||||||||||||||||||||||||
| 230 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); | - | ||||||||||||||||||||||||
| 231 | if (w->layout()
| 0 | ||||||||||||||||||||||||
| 232 | return never executed: QGraphicsLayoutItemPrivate::get(w->layout())->hasWidthForHeight();return QGraphicsLayoutItemPrivate::get(w->layout())->hasWidthForHeight();never executed: return QGraphicsLayoutItemPrivate::get(w->layout())->hasWidthForHeight(); | 0 | ||||||||||||||||||||||||
| 233 | } | - | ||||||||||||||||||||||||
| 234 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 236 | return never executed: q->sizePolicy().hasWidthForHeight();return q->sizePolicy().hasWidthForHeight();never executed: return q->sizePolicy().hasWidthForHeight(); | 0 | ||||||||||||||||||||||||
| 237 | } | - | ||||||||||||||||||||||||
| 238 | QGraphicsLayoutItem::QGraphicsLayoutItem(QGraphicsLayoutItem *parent, bool isLayout) | - | ||||||||||||||||||||||||
| 239 | : d_ptr(new QGraphicsLayoutItemPrivate(parent, isLayout)) | - | ||||||||||||||||||||||||
| 240 | { | - | ||||||||||||||||||||||||
| 241 | QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 242 | d->init(); | - | ||||||||||||||||||||||||
| 243 | d->sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); | - | ||||||||||||||||||||||||
| 244 | d->q_ptr = this; | - | ||||||||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | QGraphicsLayoutItem::QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd) | - | ||||||||||||||||||||||||
| 251 | : d_ptr(&dd) | - | ||||||||||||||||||||||||
| 252 | { | - | ||||||||||||||||||||||||
| 253 | QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 254 | d->init(); | - | ||||||||||||||||||||||||
| 255 | d->q_ptr = this; | - | ||||||||||||||||||||||||
| 256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | QGraphicsLayoutItem::~QGraphicsLayoutItem() | - | ||||||||||||||||||||||||
| 262 | { | - | ||||||||||||||||||||||||
| 263 | QGraphicsLayoutItem *parentLI = parentLayoutItem(); | - | ||||||||||||||||||||||||
| 264 | if (parentLI
| 0 | ||||||||||||||||||||||||
| 265 | QGraphicsLayout *lay = static_cast<QGraphicsLayout*>(parentLI); | - | ||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | for (int i = lay->count() - 1; i >= 0
| 0 | ||||||||||||||||||||||||
| 268 | if (lay->itemAt(i) == this
| 0 | ||||||||||||||||||||||||
| 269 | lay->removeAt(i); | - | ||||||||||||||||||||||||
| 270 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 271 | } | - | ||||||||||||||||||||||||
| 272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 273 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 274 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 275 | void QGraphicsLayoutItem::setSizePolicy(const QSizePolicy &policy) | - | ||||||||||||||||||||||||
| 276 | { | - | ||||||||||||||||||||||||
| 277 | QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 278 | if (d->sizePolicy == policy
| 0 | ||||||||||||||||||||||||
| 279 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 280 | d->sizePolicy = policy; | - | ||||||||||||||||||||||||
| 281 | updateGeometry(); | - | ||||||||||||||||||||||||
| 282 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 283 | void QGraphicsLayoutItem::setSizePolicy(QSizePolicy::Policy hPolicy, | - | ||||||||||||||||||||||||
| 284 | QSizePolicy::Policy vPolicy, | - | ||||||||||||||||||||||||
| 285 | QSizePolicy::ControlType controlType) | - | ||||||||||||||||||||||||
| 286 | { | - | ||||||||||||||||||||||||
| 287 | setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)); | - | ||||||||||||||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | QSizePolicy QGraphicsLayoutItem::sizePolicy() const | - | ||||||||||||||||||||||||
| 296 | { | - | ||||||||||||||||||||||||
| 297 | const QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 298 | return never executed: d->sizePolicy;return d->sizePolicy;never executed: return d->sizePolicy; | 0 | ||||||||||||||||||||||||
| 299 | } | - | ||||||||||||||||||||||||
| 300 | void QGraphicsLayoutItem::setMinimumSize(const QSizeF &size) | - | ||||||||||||||||||||||||
| 301 | { | - | ||||||||||||||||||||||||
| 302 | d_ptr->setSize(Qt::MinimumSize, size); | - | ||||||||||||||||||||||||
| 303 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 304 | QSizeF QGraphicsLayoutItem::minimumSize() const | - | ||||||||||||||||||||||||
| 305 | { | - | ||||||||||||||||||||||||
| 306 | return never executed: effectiveSizeHint(Qt::MinimumSize);return effectiveSizeHint(Qt::MinimumSize);never executed: return effectiveSizeHint(Qt::MinimumSize); | 0 | ||||||||||||||||||||||||
| 307 | } | - | ||||||||||||||||||||||||
| 308 | - | |||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | void QGraphicsLayoutItem::setMinimumWidth(qreal width) | - | ||||||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||||||||
| 316 | d_ptr->setSizeComponent(Qt::MinimumSize, d_ptr->Width, width); | - | ||||||||||||||||||||||||
| 317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | - | |||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||
| 324 | void QGraphicsLayoutItem::setMinimumHeight(qreal height) | - | ||||||||||||||||||||||||
| 325 | { | - | ||||||||||||||||||||||||
| 326 | d_ptr->setSizeComponent(Qt::MinimumSize, d_ptr->Height, height); | - | ||||||||||||||||||||||||
| 327 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 328 | void QGraphicsLayoutItem::setPreferredSize(const QSizeF &size) | - | ||||||||||||||||||||||||
| 329 | { | - | ||||||||||||||||||||||||
| 330 | d_ptr->setSize(Qt::PreferredSize, size); | - | ||||||||||||||||||||||||
| 331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 332 | QSizeF QGraphicsLayoutItem::preferredSize() const | - | ||||||||||||||||||||||||
| 333 | { | - | ||||||||||||||||||||||||
| 334 | return never executed: effectiveSizeHint(Qt::PreferredSize);return effectiveSizeHint(Qt::PreferredSize);never executed: return effectiveSizeHint(Qt::PreferredSize); | 0 | ||||||||||||||||||||||||
| 335 | } | - | ||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | - | |||||||||||||||||||||||||
| 342 | void QGraphicsLayoutItem::setPreferredHeight(qreal height) | - | ||||||||||||||||||||||||
| 343 | { | - | ||||||||||||||||||||||||
| 344 | d_ptr->setSizeComponent(Qt::PreferredSize, d_ptr->Height, height); | - | ||||||||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | void QGraphicsLayoutItem::setPreferredWidth(qreal width) | - | ||||||||||||||||||||||||
| 353 | { | - | ||||||||||||||||||||||||
| 354 | d_ptr->setSizeComponent(Qt::PreferredSize, d_ptr->Width, width); | - | ||||||||||||||||||||||||
| 355 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 356 | void QGraphicsLayoutItem::setMaximumSize(const QSizeF &size) | - | ||||||||||||||||||||||||
| 357 | { | - | ||||||||||||||||||||||||
| 358 | d_ptr->setSize(Qt::MaximumSize, size); | - | ||||||||||||||||||||||||
| 359 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 360 | QSizeF QGraphicsLayoutItem::maximumSize() const | - | ||||||||||||||||||||||||
| 361 | { | - | ||||||||||||||||||||||||
| 362 | return never executed: effectiveSizeHint(Qt::MaximumSize);return effectiveSizeHint(Qt::MaximumSize);never executed: return effectiveSizeHint(Qt::MaximumSize); | 0 | ||||||||||||||||||||||||
| 363 | } | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | void QGraphicsLayoutItem::setMaximumWidth(qreal width) | - | ||||||||||||||||||||||||
| 371 | { | - | ||||||||||||||||||||||||
| 372 | d_ptr->setSizeComponent(Qt::MaximumSize, d_ptr->Width, width); | - | ||||||||||||||||||||||||
| 373 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | void QGraphicsLayoutItem::setMaximumHeight(qreal height) | - | ||||||||||||||||||||||||
| 381 | { | - | ||||||||||||||||||||||||
| 382 | d_ptr->setSizeComponent(Qt::MaximumSize, d_ptr->Height, height); | - | ||||||||||||||||||||||||
| 383 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 384 | void QGraphicsLayoutItem::setGeometry(const QRectF &rect) | - | ||||||||||||||||||||||||
| 385 | { | - | ||||||||||||||||||||||||
| 386 | QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 387 | QSizeF effectiveSize = rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize)) | - | ||||||||||||||||||||||||
| 388 | .boundedTo(effectiveSizeHint(Qt::MaximumSize)); | - | ||||||||||||||||||||||||
| 389 | d->geom = QRectF(rect.topLeft(), effectiveSize); | - | ||||||||||||||||||||||||
| 390 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 391 | QRectF QGraphicsLayoutItem::geometry() const | - | ||||||||||||||||||||||||
| 392 | { | - | ||||||||||||||||||||||||
| 393 | const QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 394 | return never executed: d->geom;return d->geom;never executed: return d->geom; | 0 | ||||||||||||||||||||||||
| 395 | } | - | ||||||||||||||||||||||||
| 396 | void QGraphicsLayoutItem::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const | - | ||||||||||||||||||||||||
| 397 | { | - | ||||||||||||||||||||||||
| 398 | if (left
| 0 | ||||||||||||||||||||||||
| 399 | * never executed: left = 0;*left = 0;never executed: *left = 0; | 0 | ||||||||||||||||||||||||
| 400 | if (top
| 0 | ||||||||||||||||||||||||
| 401 | * never executed: top = 0;*top = 0;never executed: *top = 0; | 0 | ||||||||||||||||||||||||
| 402 | if (right
| 0 | ||||||||||||||||||||||||
| 403 | * never executed: right = 0;*right = 0;never executed: *right = 0; | 0 | ||||||||||||||||||||||||
| 404 | if (bottom
| 0 | ||||||||||||||||||||||||
| 405 | * never executed: bottom = 0;*bottom = 0;never executed: *bottom = 0; | 0 | ||||||||||||||||||||||||
| 406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 407 | QRectF QGraphicsLayoutItem::contentsRect() const | - | ||||||||||||||||||||||||
| 408 | { | - | ||||||||||||||||||||||||
| 409 | qreal left, top, right, bottom; | - | ||||||||||||||||||||||||
| 410 | getContentsMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||||||||
| 411 | return never executed: QRectF(QPointF(), geometry().size()).adjusted(+left, +top, -right, -bottom);return QRectF(QPointF(), geometry().size()).adjusted(+left, +top, -right, -bottom);never executed: return QRectF(QPointF(), geometry().size()).adjusted(+left, +top, -right, -bottom); | 0 | ||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||
| 413 | QSizeF QGraphicsLayoutItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint) const | - | ||||||||||||||||||||||||
| 414 | { | - | ||||||||||||||||||||||||
| 415 | const QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | if (!d->userSizeHints
| 0 | ||||||||||||||||||||||||
| 418 | return never executed: constraint;return constraint;never executed: return constraint; | 0 | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | return never executed: d_ptr->effectiveSizeHints(constraint)[which];return d_ptr->effectiveSizeHints(constraint)[which];never executed: return d_ptr->effectiveSizeHints(constraint)[which]; | 0 | ||||||||||||||||||||||||
| 422 | } | - | ||||||||||||||||||||||||
| 423 | void QGraphicsLayoutItem::updateGeometry() | - | ||||||||||||||||||||||||
| 424 | { | - | ||||||||||||||||||||||||
| 425 | QGraphicsLayoutItemPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 426 | d->sizeHintCacheDirty = true; | - | ||||||||||||||||||||||||
| 427 | d->sizeHintWithConstraintCacheDirty = true; | - | ||||||||||||||||||||||||
| 428 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 429 | QGraphicsLayoutItem *QGraphicsLayoutItem::parentLayoutItem() const | - | ||||||||||||||||||||||||
| 430 | { | - | ||||||||||||||||||||||||
| 431 | return never executed: d_func()->parent;return d_func()->parent;never executed: return d_func()->parent; | 0 | ||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||
| 439 | void QGraphicsLayoutItem::setParentLayoutItem(QGraphicsLayoutItem *parent) | - | ||||||||||||||||||||||||
| 440 | { | - | ||||||||||||||||||||||||
| 441 | d_func()->parent = parent; | - | ||||||||||||||||||||||||
| 442 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 443 | bool QGraphicsLayoutItem::isLayout() const | - | ||||||||||||||||||||||||
| 444 | { | - | ||||||||||||||||||||||||
| 445 | return never executed: d_func()->isLayout;return d_func()->isLayout;never executed: return d_func()->isLayout; | 0 | ||||||||||||||||||||||||
| 446 | } | - | ||||||||||||||||||||||||
| 447 | bool QGraphicsLayoutItem::ownedByLayout() const | - | ||||||||||||||||||||||||
| 448 | { | - | ||||||||||||||||||||||||
| 449 | return never executed: d_func()->ownedByLayout;return d_func()->ownedByLayout;never executed: return d_func()->ownedByLayout; | 0 | ||||||||||||||||||||||||
| 450 | } | - | ||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||
| 452 | - | |||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | void QGraphicsLayoutItem::setOwnedByLayout(bool ownership) | - | ||||||||||||||||||||||||
| 459 | { | - | ||||||||||||||||||||||||
| 460 | d_func()->ownedByLayout = ownership; | - | ||||||||||||||||||||||||
| 461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 462 | QGraphicsItem *QGraphicsLayoutItem::graphicsItem() const | - | ||||||||||||||||||||||||
| 463 | { | - | ||||||||||||||||||||||||
| 464 | return never executed: d_func()->graphicsItem;return d_func()->graphicsItem;never executed: return d_func()->graphicsItem; | 0 | ||||||||||||||||||||||||
| 465 | } | - | ||||||||||||||||||||||||
| 466 | void QGraphicsLayoutItem::setGraphicsItem(QGraphicsItem *item) | - | ||||||||||||||||||||||||
| 467 | { | - | ||||||||||||||||||||||||
| 468 | d_func()->graphicsItem = item; | - | ||||||||||||||||||||||||
| 469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 470 | - | |||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |