| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicslayout.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutItem *parent) | - | ||||||||||||||||||||||||
| 7 | : QGraphicsLayoutItem(*new QGraphicsLayoutPrivate) | - | ||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||
| 9 | setParentLayoutItem(parent); | - | ||||||||||||||||||||||||
| 10 |     if (parent
 
  | 0 | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | QGraphicsItem *itemParent = parent->graphicsItem(); | - | ||||||||||||||||||||||||
| 13 |         if (itemParent
 
  | 0 | ||||||||||||||||||||||||
| 14 | static_cast<QGraphicsWidget *>(itemParent)->d_func()->setLayout_helper(this); | - | ||||||||||||||||||||||||
| 15 |         } never executed:   else {end of block | 0 | ||||||||||||||||||||||||
| 16 | QMessageLogger(__FILE__, 163, __PRETTY_FUNCTION__).warning("QGraphicsLayout::QGraphicsLayout: Attempt to create a layout with a parent that is" | - | ||||||||||||||||||||||||
| 17 | " neither a QGraphicsWidget nor QGraphicsLayout"); | - | ||||||||||||||||||||||||
| 18 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 19 | } | - | ||||||||||||||||||||||||
| 20 | d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||
| 21 | setOwnedByLayout(true); | - | ||||||||||||||||||||||||
| 22 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | QGraphicsLayout::QGraphicsLayout(QGraphicsLayoutPrivate &dd, QGraphicsLayoutItem *parent) | - | ||||||||||||||||||||||||
| 28 | : QGraphicsLayoutItem(dd) | - | ||||||||||||||||||||||||
| 29 | { | - | ||||||||||||||||||||||||
| 30 | setParentLayoutItem(parent); | - | ||||||||||||||||||||||||
| 31 |     if (parent
 
  | 0 | ||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | QGraphicsItem *itemParent = parent->graphicsItem(); | - | ||||||||||||||||||||||||
| 34 |         if (itemParent
 
  | 0 | ||||||||||||||||||||||||
| 35 | static_cast<QGraphicsWidget *>(itemParent)->d_func()->setLayout_helper(this); | - | ||||||||||||||||||||||||
| 36 |         } never executed:   else {end of block | 0 | ||||||||||||||||||||||||
| 37 | QMessageLogger(__FILE__, 184, __PRETTY_FUNCTION__).warning("QGraphicsLayout::QGraphicsLayout: Attempt to create a layout with a parent that is" | - | ||||||||||||||||||||||||
| 38 | " neither a QGraphicsWidget nor QGraphicsLayout"); | - | ||||||||||||||||||||||||
| 39 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 40 | } | - | ||||||||||||||||||||||||
| 41 | d_func()->sizePolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, QSizePolicy::DefaultType); | - | ||||||||||||||||||||||||
| 42 | setOwnedByLayout(true); | - | ||||||||||||||||||||||||
| 43 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | QGraphicsLayout::~QGraphicsLayout() | - | ||||||||||||||||||||||||
| 49 | { | - | ||||||||||||||||||||||||
| 50 | } | - | ||||||||||||||||||||||||
| 51 | void QGraphicsLayout::setContentsMargins(qreal left, qreal top, qreal right, qreal bottom) | - | ||||||||||||||||||||||||
| 52 | { | - | ||||||||||||||||||||||||
| 53 | QGraphicsLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 54 |     if (d->left == left
 
 
 
  | 0 | ||||||||||||||||||||||||
| 55 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||
| 56 | d->left = left; | - | ||||||||||||||||||||||||
| 57 | d->right = right; | - | ||||||||||||||||||||||||
| 58 | d->top = top; | - | ||||||||||||||||||||||||
| 59 | d->bottom = bottom; | - | ||||||||||||||||||||||||
| 60 | invalidate(); | - | ||||||||||||||||||||||||
| 61 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | void QGraphicsLayout::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const | - | ||||||||||||||||||||||||
| 67 | { | - | ||||||||||||||||||||||||
| 68 | const QGraphicsLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 69 | d->getMargin(left, d->left, QStyle::PM_LayoutLeftMargin); | - | ||||||||||||||||||||||||
| 70 | d->getMargin(top, d->top, QStyle::PM_LayoutTopMargin); | - | ||||||||||||||||||||||||
| 71 | d->getMargin(right, d->right, QStyle::PM_LayoutRightMargin); | - | ||||||||||||||||||||||||
| 72 | d->getMargin(bottom, d->bottom, QStyle::PM_LayoutBottomMargin); | - | ||||||||||||||||||||||||
| 73 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 74 | void QGraphicsLayout::activate() | - | ||||||||||||||||||||||||
| 75 | { | - | ||||||||||||||||||||||||
| 76 | QGraphicsLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 77 |     if (d->activated
  | 0 | ||||||||||||||||||||||||
| 78 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | d->activateRecursive(this); | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||
| 84 | QGraphicsLayoutItem *parentItem = this; | - | ||||||||||||||||||||||||
| 85 |     while (parentItem
 
  | 0 | ||||||||||||||||||||||||
| 86 |         parentItem = parentItem->parentLayoutItem(); never executed:  parentItem = parentItem->parentLayoutItem(); | 0 | ||||||||||||||||||||||||
| 87 |     if (!parentItem
  | 0 | ||||||||||||||||||||||||
| 88 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||
| 89 | ((!(!parentItem->isLayout())) ? qt_assert("!parentItem->isLayout()",__FILE__,267) : qt_noop()); | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 |     if (QGraphicsLayout::instantInvalidatePropagation()
  | 0 | ||||||||||||||||||||||||
| 92 | QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem); | - | ||||||||||||||||||||||||
| 93 |         if (!parentWidget->parentLayoutItem()
  | 0 | ||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | bool wasResized = parentWidget->testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||
| 96 | parentWidget->resize(parentWidget->size()); | - | ||||||||||||||||||||||||
| 97 | parentWidget->setAttribute(Qt::WA_Resized, wasResized); | - | ||||||||||||||||||||||||
| 98 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||
| 100 | setGeometry(parentItem->contentsRect()); | - | ||||||||||||||||||||||||
| 101 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||
| 102 | setGeometry(parentItem->contentsRect()); | - | ||||||||||||||||||||||||
| 103 | parentLayoutItem()->updateGeometry(); | - | ||||||||||||||||||||||||
| 104 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 105 | } | - | ||||||||||||||||||||||||
| 106 | bool QGraphicsLayout::isActivated() const | - | ||||||||||||||||||||||||
| 107 | { | - | ||||||||||||||||||||||||
| 108 | const QGraphicsLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 109 |     return never executed:   d->activated;return d->activated;never executed:  return d->activated; | 0 | ||||||||||||||||||||||||
| 110 | } | - | ||||||||||||||||||||||||
| 111 | void QGraphicsLayout::invalidate() | - | ||||||||||||||||||||||||
| 112 | { | - | ||||||||||||||||||||||||
| 113 |     if (QGraphicsLayout::instantInvalidatePropagation()
  | 0 | ||||||||||||||||||||||||
| 114 | updateGeometry(); | - | ||||||||||||||||||||||||
| 115 |     } never executed:   else {end of block | 0 | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | QGraphicsLayoutItem *layoutItem = this; | - | ||||||||||||||||||||||||
| 118 |         while (layoutItem
 
  | 0 | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | layoutItem->d_func()->sizeHintCacheDirty = true; | - | ||||||||||||||||||||||||
| 123 | layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; | - | ||||||||||||||||||||||||
| 124 | layoutItem = layoutItem->parentLayoutItem(); | - | ||||||||||||||||||||||||
| 125 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 126 |         if (layoutItem
  | 0 | ||||||||||||||||||||||||
| 127 | layoutItem->d_func()->sizeHintCacheDirty = true; | - | ||||||||||||||||||||||||
| 128 | layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true; | - | ||||||||||||||||||||||||
| 129 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 |         bool postIt = layoutItem
  | 0 | ||||||||||||||||||||||||
| 132 |         if (postIt
  | 0 | ||||||||||||||||||||||||
| 133 | layoutItem = this; | - | ||||||||||||||||||||||||
| 134 |             while (layoutItem
 
  | 0 | ||||||||||||||||||||||||
| 135 |                     && static_cast<
 
  | 0 | ||||||||||||||||||||||||
| 136 | static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false; | - | ||||||||||||||||||||||||
| 137 | layoutItem = layoutItem->parentLayoutItem(); | - | ||||||||||||||||||||||||
| 138 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 139 |             if (layoutItem
 
  | 0 | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest)); | - | ||||||||||||||||||||||||
| 142 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 143 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 144 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 145 | } | - | ||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | void QGraphicsLayout::updateGeometry() | - | ||||||||||||||||||||||||
| 151 | { | - | ||||||||||||||||||||||||
| 152 | QGraphicsLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 153 |     if (QGraphicsLayout::instantInvalidatePropagation()
  | 0 | ||||||||||||||||||||||||
| 154 | d->activated = false; | - | ||||||||||||||||||||||||
| 155 | QGraphicsLayoutItem::updateGeometry(); | - | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | QGraphicsLayoutItem *parentItem = parentLayoutItem(); | - | ||||||||||||||||||||||||
| 158 |         if (!parentItem
  | 0 | ||||||||||||||||||||||||
| 159 |             return; never executed:  return; | 0 | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 |         if (parentItem->isLayout()
  | 0 | ||||||||||||||||||||||||
| 162 |             static_cast< never executed:  QGraphicsLayout *>(parentItem)->invalidate();static_cast<QGraphicsLayout *>(parentItem)->invalidate();never executed:  static_cast<QGraphicsLayout *>(parentItem)->invalidate(); | 0 | ||||||||||||||||||||||||
| 163 | else | - | ||||||||||||||||||||||||
| 164 |             parentItem->updateGeometry(); never executed:  parentItem->updateGeometry(); | 0 | ||||||||||||||||||||||||
| 165 | } else { | - | ||||||||||||||||||||||||
| 166 | QGraphicsLayoutItem::updateGeometry(); | - | ||||||||||||||||||||||||
| 167 |         if (QGraphicsLayoutItem *parentItem = parentLayoutItem()
  | 0 | ||||||||||||||||||||||||
| 168 |             if (parentItem->isLayout()
  | 0 | ||||||||||||||||||||||||
| 169 | parentItem->updateGeometry(); | - | ||||||||||||||||||||||||
| 170 |             } never executed:   else {end of block | 0 | ||||||||||||||||||||||||
| 171 | invalidate(); | - | ||||||||||||||||||||||||
| 172 |             } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||
| 174 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 175 | } | - | ||||||||||||||||||||||||
| 176 | void QGraphicsLayout::widgetEvent(QEvent *e) | - | ||||||||||||||||||||||||
| 177 | { | - | ||||||||||||||||||||||||
| 178 | switch (e->type()) { | - | ||||||||||||||||||||||||
| 179 |     case never executed:   QEvent::GraphicsSceneResize:case QEvent::GraphicsSceneResize:never executed:  case QEvent::GraphicsSceneResize: | 0 | ||||||||||||||||||||||||
| 180 |         if (isActivated()
  | 0 | ||||||||||||||||||||||||
| 181 | setGeometry(parentLayoutItem()->contentsRect()); | - | ||||||||||||||||||||||||
| 182 |         } never executed:   else {end of block | 0 | ||||||||||||||||||||||||
| 183 | activate(); | - | ||||||||||||||||||||||||
| 184 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 185 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 186 |     case never executed:   QEvent::LayoutRequest:case QEvent::LayoutRequest:never executed:  case QEvent::LayoutRequest: | 0 | ||||||||||||||||||||||||
| 187 | activate(); | - | ||||||||||||||||||||||||
| 188 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 189 |     case never executed:   QEvent::LayoutDirectionChange:case QEvent::LayoutDirectionChange:never executed:  case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||||||||
| 190 | invalidate(); | - | ||||||||||||||||||||||||
| 191 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 192 |     default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||||||||
| 193 |         break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 194 | } | - | ||||||||||||||||||||||||
| 195 | } | - | ||||||||||||||||||||||||
| 196 | void QGraphicsLayout::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) | - | ||||||||||||||||||||||||
| 197 | { | - | ||||||||||||||||||||||||
| 198 | QGraphicsLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 199 | d->addChildLayoutItem(layoutItem); | - | ||||||||||||||||||||||||
| 200 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | static bool g_instantInvalidatePropagation = false; | - | ||||||||||||||||||||||||
| 203 | void QGraphicsLayout::setInstantInvalidatePropagation(bool enable) | - | ||||||||||||||||||||||||
| 204 | { | - | ||||||||||||||||||||||||
| 205 | g_instantInvalidatePropagation = enable; | - | ||||||||||||||||||||||||
| 206 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 207 | bool QGraphicsLayout::instantInvalidatePropagation() | - | ||||||||||||||||||||||||
| 208 | { | - | ||||||||||||||||||||||||
| 209 |     return never executed:   g_instantInvalidatePropagation;return g_instantInvalidatePropagation;never executed:  return g_instantInvalidatePropagation; | 0 | ||||||||||||||||||||||||
| 210 | } | - | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |