Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/graphicsview/qgraphicslayoutitem.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    109109*/
    110110QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par, bool layout)
    111     : parent(par), isLayout(layout), ownedByLayout(false), graphicsItem(0)
    112 {
     111    : parent(par), userSizeHints(0), isLayout(layout), ownedByLayout(false), graphicsItem(0)
     112{
     113}
     114
     115/*!
     116    \internal
     117*/
     118QGraphicsLayoutItemPrivate::~QGraphicsLayoutItemPrivate()
     119{
     120    // Remove any lazily allocated data
     121    delete[] userSizeHints;
    113122}
    114123
     
    133142    for (int i = 0; i < Qt::NSizeHints; ++i) {
    134143        cachedSizeHints[i] = constraint;
    135         combineSize(cachedSizeHints[i], userSizeHints[i]);
     144        if (userSizeHints)
     145            combineSize(cachedSizeHints[i], userSizeHints[i]);
    136146    }
    137147
     
    199209
    200210/*!
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
    201263    \class QGraphicsLayoutItem
    202264    \brief The QGraphicsLayoutItem class can be inherited to allow your custom
    203265    items to be managed by layouts.
    204266    \since 4.4
    205     \ingroup multimedia
    206267    \ingroup graphicsview-api
    207268
     
    256317    protected constructor, or by calling setParentLayoutItem(). The
    257318    parentLayoutItem() function returns a pointer to the item's layoutItem
    258     parent. If the item's parent is 0 or if the the parent does not inherit
     319    parent. If the item's parent is 0 or if the parent does not inherit
    259320    from QGraphicsItem, the parentLayoutItem() function then returns 0.
    260321    isLayout() returns true if the QGraphicsLayoutItem subclass is itself a
     
    308369        }
    309370    }
    310     delete d_ptr;
    311371}
    312372
     
    382442void QGraphicsLayoutItem::setMinimumSize(const QSizeF &size)
    383443{
    384     Q_D(QGraphicsLayoutItem);
    385     if (size == d->userSizeHints[Qt::MinimumSize])
    386         return;
    387 
    388     d->userSizeHints[Qt::MinimumSize] = size;
    389     updateGeometry();
     444    d_ptr->setSize(Qt::MinimumSize, size);
    390445}
    391446
     
    417472void QGraphicsLayoutItem::setMinimumWidth(qreal width)
    418473{
    419     Q_D(QGraphicsLayoutItem);
    420     qreal &userSizeHint = d->userSizeHints[Qt::MinimumSize].rwidth();
    421     if (width == userSizeHint)
    422         return;
    423     userSizeHint = width;
    424     updateGeometry();
     474    d_ptr->setSizeComponent(Qt::MinimumSize, d_ptr->Width, width);
    425475}
    426476
     
    432482void QGraphicsLayoutItem::setMinimumHeight(qreal height)
    433483{
    434     Q_D(QGraphicsLayoutItem);
    435     qreal &userSizeHint = d->userSizeHints[Qt::MinimumSize].rheight();
    436     if (height == userSizeHint)
    437         return;
    438     userSizeHint = height;
    439     updateGeometry();
     484    d_ptr->setSizeComponent(Qt::MinimumSize, d_ptr->Height, height);
    440485}
    441486
     
    451496void QGraphicsLayoutItem::setPreferredSize(const QSizeF &size)
    452497{
    453     Q_D(QGraphicsLayoutItem);
    454     if (size == d->userSizeHints[Qt::PreferredSize])
    455         return;
    456 
    457     d->userSizeHints[Qt::PreferredSize] = size;
    458     updateGeometry();
     498    d_ptr->setSize(Qt::PreferredSize, size);
    459499}
    460500
     
    486526void QGraphicsLayoutItem::setPreferredHeight(qreal height)
    487527{
    488     Q_D(QGraphicsLayoutItem);
    489     qreal &userSizeHint = d->userSizeHints[Qt::PreferredSize].rheight();
    490     if (height == userSizeHint)
    491         return;
    492     userSizeHint = height;
    493     updateGeometry();
     528    d_ptr->setSizeComponent(Qt::PreferredSize, d_ptr->Height, height);
    494529}
    495530
     
    501536void QGraphicsLayoutItem::setPreferredWidth(qreal width)
    502537{
    503     Q_D(QGraphicsLayoutItem);
    504     qreal &userSizeHint = d->userSizeHints[Qt::PreferredSize].rwidth();
    505     if (width == userSizeHint)
    506         return;
    507     userSizeHint = width;
    508     updateGeometry();
     538    d_ptr->setSizeComponent(Qt::PreferredSize, d_ptr->Width, width);
    509539}
    510540
     
    520550void QGraphicsLayoutItem::setMaximumSize(const QSizeF &size)
    521551{
    522     Q_D(QGraphicsLayoutItem);
    523     if (size == d->userSizeHints[Qt::MaximumSize])
    524         return;
    525 
    526     d->userSizeHints[Qt::MaximumSize] = size;
    527     updateGeometry();
     552    d_ptr->setSize(Qt::MaximumSize, size);
    528553}
    529554
     
    555580void QGraphicsLayoutItem::setMaximumWidth(qreal width)
    556581{
    557     Q_D(QGraphicsLayoutItem);
    558     qreal &userSizeHint = d->userSizeHints[Qt::MaximumSize].rwidth();
    559     if (width == userSizeHint)
    560         return;
    561     userSizeHint = width;
    562     updateGeometry();
     582    d_ptr->setSizeComponent(Qt::MaximumSize, d_ptr->Width, width);
    563583}
    564584
     
    570590void QGraphicsLayoutItem::setMaximumHeight(qreal height)
    571591{
    572     Q_D(QGraphicsLayoutItem);
    573     qreal &userSizeHint = d->userSizeHints[Qt::MaximumSize].rheight();
    574     if (height == userSizeHint)
    575         return;
    576     userSizeHint = height;
    577     updateGeometry();
     592    d_ptr->setSizeComponent(Qt::MaximumSize, d_ptr->Height, height);
    578593}
    579594
     
    733748QSizeF QGraphicsLayoutItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint) const
    734749{
     750
     751
     752
     753
     754
    735755    // ### should respect size policy???
    736756    return d_ptr->effectiveSizeHints(constraint)[which];
     
    787807
    788808/*!
     809
     810
    789811    Returns whether a layout should delete this item in its destructor.
    790812    If its true, then the layout will delete it. If its false, then it is
     
    813835}
    814836/*!
     837
     838
    815839    Sets whether a layout should delete this item in its destructor or not.
    816840    \a ownership must be true to in order for the layout to delete it.
Note: See TracChangeset for help on using the changeset viewer.