/*! \reimp */ void QGraphicsLinearLayout::setGeometry(const QRectF &rect) { Q_D(QGraphicsLinearLayout); QGraphicsLayout::setGeometry(rect); QRectF effectiveRect = geometry(); qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); Qt::LayoutDirection visualDir = d->visualDirection(); d->engine.setVisualDirection(visualDir); if (visualDir == Qt::RightToLeft) qSwap(left, right); effectiveRect.adjust(+left, +top, -right, -bottom); #ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { static int counter = 0; qDebug() << counter++ << "QGraphicsLinearLayout::setGeometry - " << rect; dump(1); } #endif d->engine.setGeometries(d->styleInfo(), effectiveRect); #ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { qDebug() << "post dump"; dump(1); } #endif }
QT_BEGIN_NAMESPACE /*! \internal \a mw is the new parent. all items in the layout will be a child of \a mw. */ void QGraphicsLayoutPrivate::reparentChildItems(QGraphicsItem *newParent) { Q_Q(QGraphicsLayout); int n = q->count(); //bool mwVisible = mw && mw->isVisible(); for (int i = 0; i < n; ++i) { QGraphicsLayoutItem *layoutChild = q->itemAt(i); if (!layoutChild) { // Skip stretch items continue; } if (layoutChild->isLayout()) { QGraphicsLayout *l = static_cast<QGraphicsLayout*>(layoutChild); l->d_func()->reparentChildItems(newParent); } else if (QGraphicsItem *itemChild = layoutChild->graphicsItem()){ QGraphicsItem *childParent = itemChild->parentItem(); #ifdef QT_DEBUG if (childParent && childParent != newParent && itemChild->isWidget() && qt_graphicsLayoutDebug()) { QGraphicsWidget *w = static_cast<QGraphicsWidget*>(layoutChild); qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); } #endif if (childParent != newParent) itemChild->setParentItem(newParent); } } }
/*! \internal \a mw is the new parent. all items in the layout will be a child of \a mw. */ void QGraphicsLayoutPrivate::reparentChildWidgets(QGraphicsWidget *mw) { Q_Q(QGraphicsLayout); int n = q->count(); //bool mwVisible = mw && mw->isVisible(); for (int i = 0; i < n; ++i) { QGraphicsLayoutItem *item = q->itemAt(i); if (item->isLayout()) { QGraphicsLayout *l = static_cast<QGraphicsLayout*>(item); l->d_func()->reparentChildWidgets(mw); } else { QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item); QGraphicsWidget *pw = w->parentWidget(); #ifdef QT_DEBUG if (pw && pw != mw && qt_graphicsLayoutDebug()) { qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); } #endif //bool needShow = mwVisible && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide)); if (pw != mw) w->setParentItem(mw); //if (needShow) // QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later } } }
void QGraphicsLinearLayout::dump(int indent) const { if (qt_graphicsLayoutDebug()) { Q_D(const QGraphicsLinearLayout); qDebug("%*s%s layout", indent, "", d->orientation == Qt::Horizontal ? "Horizontal" : "Vertical"); d->engine.dump(indent + 1); } }
/*! \internal */ void QGraphicsLinearLayout::dump(int indent) const { #ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { Q_D(const QGraphicsLinearLayout); qDebug("%*s%s layout", indent, "", d->orientation == Qt::Horizontal ? "Horizontal" : "Vertical"); d->engine.dump(indent + 1); } #else Q_UNUSED(indent); #endif }
/*! Sets the bounding geometry of the grid layout to \a rect. */ void QGraphicsGridLayout::setGeometry(const QRectF &rect) { Q_D(QGraphicsGridLayout); QGraphicsLayout::setGeometry(rect); QRectF effectiveRect = geometry(); qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); Qt::LayoutDirection visualDir = d->visualDirection(); d->engine.setVisualDirection(visualDir); if (visualDir == Qt::RightToLeft) qSwap(left, right); effectiveRect.adjust(+left, +top, -right, -bottom); d->engine.setGeometries(d->styleInfo(), effectiveRect); #ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { static int counter = 0; qDebug("==== BEGIN DUMP OF QGraphicsGridLayout (%d)====", counter++); d->dump(1); qDebug("==== END DUMP OF QGraphicsGridLayout ===="); } #endif }
void QGraphicsGridLayoutPrivate::dump(int indent) const { if (qt_graphicsLayoutDebug()) { engine.dump(indent + 1); } }