Пример #1
0
SEXP qt_qsetMinimumSize_QGraphicsLayoutItem(SEXP ritem, SEXP rsize)
{
  QGraphicsLayoutItem *item =
    unwrapQGraphicsLayoutItem(ritem, QGraphicsLayoutItem);
  item->setMinimumSize(asQSizeF(rsize));
  return ritem;
}
void MMessageBoxViewPrivate::updateLayout()
{
    clearLayout();
    prepareLayout();

    if (centralWidget) {
        contentsLayout->insertItem(0, centralWidget);
    }

    if (textLabel) {
        contentsLayout->insertItem(0, textLabel);
        contentsLayout->setAlignment(textLabel, Qt::AlignCenter);
    }

    if (titleLabel) {
        contentsLayout->insertItem(0, titleLabel);
        contentsLayout->setAlignment(titleLabel, Qt::AlignCenter);
    }

    if (iconImage) {
        contentsLayout->insertItem(0, iconImage);
        contentsLayout->setAlignment(iconImage, Qt::AlignCenter);
    }

    if (!QGraphicsLayout::instantInvalidatePropagation()) {
        /* Update the geometry of the parents immediately. This simply makes the layout have the correct sizehint
         * immediately instead of one frame later, removing a single frame of 'flicker'.
         */
        QGraphicsLayoutItem *item = contents;
        do {
            item->updateGeometry();
        } while( (item = item->parentLayoutItem()) );
    }
}
Пример #3
0
/*!
    \reimp
*/
void QGraphicsLayout::updateGeometry()
{
    Q_D(QGraphicsLayout);
    if (QGraphicsLayout::instantInvalidatePropagation()) {
        d->activated = false;
        QGraphicsLayoutItem::updateGeometry();

        QGraphicsLayoutItem *parentItem = parentLayoutItem();
        if (!parentItem)
            return;

        if (parentItem->isLayout())
            static_cast<QGraphicsLayout *>(parentItem)->invalidate();
        else
            parentItem->updateGeometry();
    } else {
        QGraphicsLayoutItem::updateGeometry();
        if (QGraphicsLayoutItem *parentItem = parentLayoutItem()) {
            if (parentItem->isLayout()) {
                parentItem->updateGeometry();
            } else {
                invalidate();
            }
        }
    }
}
/*!
    \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
        }
    }
}
Пример #5
0
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);
        }
    }
}
qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const
{
    qreal left, top, right, bottom;
    getContentsMargins(&left, &top, &right, &bottom);
    const qreal maxw = geom.width() - left - right;

    qreal x = 0;
    qreal y = 0;
    qreal maxRowHeight = 0;
    QSizeF pref;
    for (int i = 0; i < m_items.count(); ++i) {
        QGraphicsLayoutItem *item = m_items.at(i);
        pref = item->effectiveSizeHint(Qt::PreferredSize);
        maxRowHeight = qMax(maxRowHeight, pref.height());

        qreal next_x;
        next_x = x + pref.width();
        if (next_x > maxw) {
            if (x == 0) {
                pref.setWidth(maxw);
            } else {
                x = 0;
                next_x = pref.width();
            }
            y += maxRowHeight + spacing(Qt::Vertical);
            maxRowHeight = 0;
        }

        if (applyNewGeometry)
            item->setGeometry(QRectF(QPointF(left + x, top + y), pref));
        x = next_x + spacing(Qt::Horizontal);
    }
    maxRowHeight = qMax(maxRowHeight, pref.height());
    return top + y + maxRowHeight + bottom;
}
Пример #7
0
int GraphicsFlowLayout::doLayout(const QRectF &rect) {
	double x = rect.x();
	double y = rect.y();
	double lineHeight = 0;

	for(int i=0; i < count(); i++) {
		QGraphicsLayoutItem* item = itemAt(i);
		int nextX = x + item->preferredSize().width() + spacing();

		if (item->sizePolicy().horizontalPolicy() == QSizePolicy::Expanding) { 
			int myY = y + lineHeight + spacing() + SpaceBefore;
			QRectF r(QPoint(rect.x(), myY), item->preferredSize());
			item->setGeometry(r);
			x = rect.x();
			y = myY + item->preferredSize().height() + spacing() + SpaceAfter;
			continue;
		}
		
		if (nextX - spacing() > rect.right() && lineHeight > 0) {
			x = rect.x();
			y = y + lineHeight + spacing();
			nextX = x + item->preferredSize().width() + spacing();
			lineHeight = 0;
		}
		item->setGeometry(QRectF(QPoint(x, y), item->preferredSize()));

		x = nextX;
		// item->preferredSize().height() returns qreal, armel compiler complains
		lineHeight = qMax(lineHeight, (double) item->preferredSize().height());
	}

	m_lastWidth = rect.width();
	return y + lineHeight - rect.y();
}
Пример #8
0
/*!
    From QGraphicsLayout.
    Clears the parentLayoutItem of removed item.
 */
void HbListLayout::removeAt(int index)
{
    QGraphicsLayoutItem *item = itemAt(index);
    if ( item ) {
        d->mItems.removeAt(index);
        item->setParentLayoutItem(0);
        invalidate();
    }
}
Пример #9
0
QSizeF QGraphicsFlowLayout::minimumSize() const
{
	QSizeF size;
	QGraphicsLayoutItem *item;
	foreach (item, m_itemList)
		size = size.expandedTo(item->minimumSize());

	size += QSizeF(m_margins.left() + m_margins.right(), m_margins.top() + m_margins.bottom());
	return size;
}
Пример #10
0
/*!
    Clears any cached geometry and size hint information in the layout, and
    posts a \l{QEvent::LayoutRequest}{LayoutRequest} event to the managed
    parent QGraphicsLayoutItem.

    \sa activate(), setGeometry()
*/
void QGraphicsLayout::invalidate()
{
    // only mark layouts as invalid (activated = false) if we can post a LayoutRequest event.
    QGraphicsLayoutItem *layoutItem = this;
    while (layoutItem && layoutItem->isLayout()) {
        // we could call updateGeometry(), but what if that method
        // does not call the base implementation? In addition, updateGeometry()
        // does more than we need.
        layoutItem->d_func()->sizeHintCacheDirty = true;
        layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;
        layoutItem = layoutItem->parentLayoutItem();
    }
    if (layoutItem) {
        layoutItem->d_func()->sizeHintCacheDirty = true;
        layoutItem->d_func()->sizeHintWithConstraintCacheDirty = true;
    }

    bool postIt = layoutItem ? !layoutItem->isLayout() : false;
    if (postIt) {
        layoutItem = this;
        while (layoutItem && layoutItem->isLayout()
                && static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated) {
            static_cast<QGraphicsLayout*>(layoutItem)->d_func()->activated = false;
            layoutItem = layoutItem->parentLayoutItem();
        }
        if (layoutItem && !layoutItem->isLayout()) {
            // If a layout has a parent that is not a layout it must be a QGraphicsWidget.
            QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest));
        }
    }
}
Пример #11
0
/*!
    Destroys the QGraphicsLayoutItem object.
*/
QGraphicsLayoutItem::~QGraphicsLayoutItem()
{
    QGraphicsLayoutItem *parentLI = parentLayoutItem();
    if (parentLI && parentLI->isLayout()) {
        QGraphicsLayout *lay = static_cast<QGraphicsLayout*>(parentLI);
        // this is not optimal
        for (int i = lay->count() - 1; i >= 0; --i) {
            if (lay->itemAt(i) == this) {
                lay->removeAt(i);
                break;
            }
        }
    }
}
Пример #12
0
/*!
    Destroys the QGraphicsGridLayout object.
*/
QGraphicsGridLayout::~QGraphicsGridLayout()
{
    for (int i = count() - 1; i >= 0; --i) {
        QGraphicsLayoutItem *item = itemAt(i);
        // The following lines can be removed, but this removes the item
        // from the layout more efficiently than the implementation of
        // ~QGraphicsLayoutItem.
        removeAt(i);
        if (item) {
            item->setParentLayoutItem(0);
            if (item->ownedByLayout())
                delete item;
        }
    }
}
void MToolBarLayoutPolicy::activateMiddleSpacers(bool activate)
{
    int base = 1+(leftSpacer ? 1 : 0);
    for (int i=base; i<MLinearLayoutPolicy::count()-1; i += 2) {
        QGraphicsLayoutItem *item = MLinearLayoutPolicy::itemAt(i);
        if (item) {
            if (activate) {
                item->setMaximumWidth(-1);
                item->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
            } else {
                item->setMaximumWidth(0);
                item->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
            }
        }
    }
}
static PyObject *meth_QGraphicsLayoutItem_setSizePolicy(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = NULL;

    {
        const QSizePolicy* a0;
        QGraphicsLayoutItem *sipCpp;

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, NULL, NULL, "BJ9", &sipSelf, sipType_QGraphicsLayoutItem, &sipCpp, sipType_QSizePolicy, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->setSizePolicy(*a0);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        QSizePolicy::Policy a0;
        QSizePolicy::Policy a1;
        QSizePolicy::ControlType a2 = QSizePolicy::DefaultType;
        QGraphicsLayoutItem *sipCpp;

        static const char *sipKwdList[] = {
            NULL,
            NULL,
            sipName_controlType,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "BEE|E", &sipSelf, sipType_QGraphicsLayoutItem, &sipCpp, sipType_QSizePolicy_Policy, &a0, sipType_QSizePolicy_Policy, &a1, sipType_QSizePolicy_ControlType, &a2))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->setSizePolicy(a0,a1,a2);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QGraphicsLayoutItem, sipName_setSizePolicy, doc_QGraphicsLayoutItem_setSizePolicy);

    return NULL;
}
Пример #15
0
/*!
    Removes the layout item at \a index without destroying it. Ownership of
    the item is transferred to the caller.

    Removing an item will also remove any of the anchors associated with it.

    \sa itemAt(), count()
*/
void QGraphicsAnchorLayout::removeAt(int index)
{
    Q_D(QGraphicsAnchorLayout);
    QGraphicsLayoutItem *item = d->items.value(index);

    if (!item)
        return;

    // Removing an item affects both horizontal and vertical graphs
    d->removeCenterConstraints(item, QGraphicsAnchorLayoutPrivate::Horizontal);
    d->removeCenterConstraints(item, QGraphicsAnchorLayoutPrivate::Vertical);
    d->removeAnchors(item);
    d->items.remove(index);

    item->setParentLayoutItem(0);
    invalidate();
}
Пример #16
0
static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem *layoutItem)
{
    if (!lay)
        return false;

    for (int i = lay->count() - 1; i >= 0; --i) {
        QGraphicsLayoutItem *child = lay->itemAt(i);
        if (child && child->isLayout()) {
            if (removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(child), layoutItem))
                return true;
        } else if (child == layoutItem) {
            lay->removeAt(i);
            return true;
        }
    }
    return false;
}
static bool removeWidgetFromLayout(QGraphicsLayout *lay, QGraphicsWidget *wid)
{
    if (!lay)
        return false;

    QGraphicsLayoutItem *child;
    for (int i = 0; (child = lay->itemAt(i)); ++i) {
        if (child->isLayout()) {
            if (removeWidgetFromLayout(static_cast<QGraphicsLayout*>(child), wid))
                return true;
        } else if (child == wid) {
            lay->removeAt(i);
            return true;
        }
    }
    return false;
}
void QGraphicsLayoutPrivate::getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const
{
    if (!result)
        return;
    Q_Q(const QGraphicsLayout);

    QGraphicsLayoutItem *parent = q->parentLayoutItem();
    if (userMargin >= 0.0) {
        *result = userMargin;
    } else if (!parent) {
        *result = 0.0;
    } else if (parent->isLayout()) {    // sublayouts have 0 margin by default
        *result = 0.0;
    } else {
        *result = (qreal)static_cast<QGraphicsWidget*>(parent)->style()->pixelMetric(pm, 0);
    }
}
void PeopleGroupedView::scrollTo(const QString& name)
{
    Q_UNUSED(name);
    int i;
    for (i=0; i<m_numSections; i++) {
        if (!name.compare(m_headings[i], Qt::CaseInsensitive))
            break;
    }

    int section=0;
    //if Other section exists shift increase i by 1
    if(m_sectionCounts[1] > 0)
     section = (i == m_numSections) ? 1 : i + 2;
    else //account for mecard +1
     section = (i == m_numSections) ? 0 : i + 1;
    m_mainLayout->rowCount();

    // prevent looking in non-existent rows in the grid layout
    int numSections = m_numSections;
    if (m_mainLayout->rowCount() < m_numSections)
        numSections = m_mainLayout->rowCount() - 1;

    QGraphicsLayoutItem *item = NULL;
    int diff = 1;
    while (section <= numSections || (section - diff) >= 0) {
        // first check this section for an item
        if (section <= numSections) {
            item = m_mainLayout->itemAt(section, 0);
            if (item)
                break;
        }

        int alternate = section - diff;
        if (alternate >= 0 && alternate <= numSections) {
            item = m_mainLayout->itemAt(alternate, 0);
            if (item)
                break;
        }

        section++;
        diff += 2;
    }

    if (item)
        m_controller->scrollTo(item->geometry().top());
}
static PyObject *meth_QGraphicsLayoutItem_sizePolicy(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QGraphicsLayoutItem *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QGraphicsLayoutItem, &sipCpp))
        {
            QSizePolicy *sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = new QSizePolicy(sipCpp->sizePolicy());
            Py_END_ALLOW_THREADS

            return sipConvertFromNewType(sipRes,sipType_QSizePolicy,NULL);
        }
    }
QSizeF FlowLayout::minSize(const QSizeF &constraint) const
{
    QSizeF size(0, 0);
    qreal left, top, right, bottom;
    getContentsMargins(&left, &top, &right, &bottom);
    if (constraint.width() >= 0) {   // height for width
        const qreal height = doLayout(QRectF(QPointF(0,0), constraint), false);
        size = QSizeF(constraint.width(), height);
    } else if (constraint.height() >= 0) {  // width for height?
        // not supported
    } else {
        QGraphicsLayoutItem *item;
        foreach (item, m_items)
            size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize));
        size += QSize(left + right, top + bottom);
    }
    return size;
}
Пример #22
0
void MScenePrivate::sendEventToAllSubLayouts(QGraphicsLayout *layout, QEvent *event)
{
    for (int i = layout->count()-1; i >= 0; --i) {
        // QGraphicsLayout::itemAt allows the subclasses to assume that item index is valid (within the count boundaries).
        // The items might be removed from layout when it'll process the orientation change event.
        if (i >= layout->count())
            i = layout->count() - 1;
        // The layout may end up empty, thus we should early out if it happens
        if (i < 0)
            return;
        QGraphicsLayoutItem * layoutItem = layout->itemAt(i);
        if (layoutItem->isLayout()) {
            QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(layoutItem);
            layout->widgetEvent(event);
            MScenePrivate::sendEventToAllSubLayouts(layout, event);
        }
    }
}
Пример #23
0
/*!
    Calculates the smallest item height by taking the minimum of all items preferred heights.
*/
qreal HbListLayoutPrivate::calculateSmallestItemHeight() const
{
    qreal smallestHeight(0);
    if (uniformSizedItems()) {
        QGraphicsLayoutItem *firstItem = mItems.value(0);
        if (firstItem) {
            smallestHeight = firstItem->preferredHeight();  
        } 
    } else {  
        int itemCount = mItems.count();
        if (itemCount > 0) {
            smallestHeight = mItems.first()->preferredHeight();
        }
        for (int i = 1; i < itemCount; ++i) {       
            smallestHeight = qMin(smallestHeight, mItems.at(i)->preferredHeight());
        }
    }
    return smallestHeight;
}
QSizeF FlowLayout::maxSize() const
{
    QGraphicsLayoutItem *item;
    qreal totalWidth = 0;
    qreal totalHeight = 0;
    foreach (item, m_items) {
        if (totalWidth > 0)
            totalWidth += spacing(Qt::Horizontal);
        if (totalHeight > 0)
            totalHeight += spacing(Qt::Vertical);
        QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
        totalWidth += pref.width();
        totalHeight += pref.height();
    }

    qreal left, top, right, bottom;
    getContentsMargins(&left, &top, &right, &bottom);
    return QSizeF(left + totalWidth + right, top + totalHeight + bottom);
}
/*!
    \reimp

    Invalidates parent layout when ItemTransformHasChanged is received.
*/
QVariant HbAbstractViewItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
    switch (change) {
        case ItemTransformHasChanged: {
            QGraphicsLayoutItem *parentLayoutItem = this->parentLayoutItem();
            if (parentLayoutItem && parentLayoutItem->isLayout()) {
                QGraphicsLayout *parentLayout = static_cast<QGraphicsLayout *>(parentLayoutItem);
                parentLayout->invalidate();
            }
            break;
        }
        case ItemEnabledHasChanged: {
            updateChildItems();
            break;
        }
        default:
            break;
    }

    return HbWidget::itemChange(change, value);
}
Пример #26
0
static void clearAllCounters(TestGraphicsWidget *widget)
{
    if (!widget)
        return;
    widget->clearCounters();
    TestLayout *layout = static_cast<TestLayout *>(widget->layout());
    if (layout) {
        layout->clearCounters();
        for (int i = layout->count() - 1; i >=0; --i) {
            QGraphicsLayoutItem *item = layout->itemAt(i);
            if (item->isLayout()) {
                // ### Not used ATM
                //TestLayout *lay = static_cast<TestLayout*>(static_cast<QGraphicsLayout*>(item));
                //clearAllCounters(lay);
            } else {
                TestGraphicsWidget *wid = static_cast<TestGraphicsWidget *>(item);
                clearAllCounters(wid);
            }
        }
    }
}
Пример #27
0
/*!
    Activates the layout, causing all items in the layout to be immediately
    rearranged. This function is based on calling count() and itemAt(), and
    then calling setGeometry() on all items sequentially. When activated,
    the layout will adjust its geometry to its parent's contentsRect().
    The parent will then invalidate any layout of its own.

    If called in sequence or recursively, e.g., by one of the arranged items
    in response to being resized, this function will do nothing.

    Note that the layout is free to use geometry caching to optimize this
    process.  To forcefully invalidate any such cache, you can call
    invalidate() before calling activate().

    \sa invalidate()
*/
void QGraphicsLayout::activate()
{
    Q_D(QGraphicsLayout);
    if (d->activated)
        return;

    d->activateRecursive(this);

    // we don't call activate on a sublayout, but somebody might.
    // Therefore, we walk to the parentitem of the toplevel layout.
    QGraphicsLayoutItem *parentItem = this;
    while (parentItem && parentItem->isLayout())
        parentItem = parentItem->parentLayoutItem();
    if (!parentItem)
        return;
    Q_ASSERT(!parentItem->isLayout());

    if (QGraphicsLayout::instantInvalidatePropagation()) {
        QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem);
        if (!parentWidget->parentLayoutItem()) {
            // we've reached the topmost widget, resize it
            bool wasResized = parentWidget->testAttribute(Qt::WA_Resized);
            parentWidget->resize(parentWidget->size());
            parentWidget->setAttribute(Qt::WA_Resized, wasResized);
        }

        setGeometry(parentItem->contentsRect());    // relayout children
    } else {
        setGeometry(parentItem->contentsRect());    // relayout children
        parentLayoutItem()->updateGeometry();
    }
}
Пример #28
0
/*!
    Returns the minimum sizeHint.
*/
QSizeF HbListLayoutPrivate::minimumSizeHint()
{
    QSizeF sizeHint(0, 0);
    if (uniformSizedItems()) {
        QGraphicsLayoutItem *firstItem = mItems.value(0);
        if (firstItem) {
            sizeHint = firstItem->effectiveSizeHint(Qt::MinimumSize);
        }
    } else {
        int itemCount = mItems.count();
        for (int i = 0; i < itemCount; ++i) {       
            QSizeF itemSize(0, 0);  
            itemSize = mItems.at(i)->effectiveSizeHint(Qt::MinimumSize);

            if (itemSize.isValid()) {
                sizeHint.rwidth() = qMax(itemSize.width(), sizeHint.width());
                sizeHint.rheight() = qMax(sizeHint.height(), itemSize.height());
            }
        }
    }
    return sizeHint;
}
Пример #29
0
/*!
    Destroys the QGraphicsAnchorLayout object.
*/
QGraphicsAnchorLayout::~QGraphicsAnchorLayout()
{
    Q_D(QGraphicsAnchorLayout);

    for (int i = count() - 1; i >= 0; --i) {
        QGraphicsLayoutItem *item = d->items.at(i);
        removeAt(i);
        if (item) {
            if (item->ownedByLayout())
                delete item;
        }
    }

    d->removeCenterConstraints(this, QGraphicsAnchorLayoutPrivate::Horizontal);
    d->removeCenterConstraints(this, QGraphicsAnchorLayoutPrivate::Vertical);
    d->deleteLayoutEdges();

    Q_ASSERT(d->itemCenterConstraints[0].isEmpty());
    Q_ASSERT(d->itemCenterConstraints[1].isEmpty());
    Q_ASSERT(d->items.isEmpty());
    Q_ASSERT(d->m_vertexList.isEmpty());
}
Пример #30
0
/*!
    Activates the layout, causing all items in the layout to be immediately
    rearranged. This function is based on calling count() and itemAt(), and
    then calling setGeometry() on all items sequentially. When activated,
    the layout will adjust its geometry to its parent's contentsRect().
    The parent will then invalidate any layout of its own.

    If called in sequence or recursively, e.g., by one of the arranged items
    in response to being resized, this function will do nothing.

    Note that the layout is free to use geometry caching to optimize this
    process.  To forcefully invalidate any such cache, you can call
    invalidate() before calling activate().

    \sa invalidate()
*/
void QGraphicsLayout::activate()
{
    Q_D(QGraphicsLayout);
    if (d->activated)
        return;

    d->activateRecursive(this);

    // we don't call activate on a sublayout, but somebody might.
    // Therefore, we walk to the parentitem of the toplevel layout.
    QGraphicsLayoutItem *parentItem = this;
    while (parentItem && parentItem->isLayout())
        parentItem = parentItem->parentLayoutItem();
    if (!parentItem)
        return;
    Q_ASSERT(!parentItem->isLayout());

    setGeometry(parentItem->contentsRect());    // relayout children
    if (!QGraphicsLayout::instantInvalidatePropagation()) {
        parentLayoutItem()->updateGeometry();
    }
}