Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 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/qgraphicslinearlayout.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    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 have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545    layout for managing widgets in Graphics View.
    4646    \since 4.4
    47     \ingroup multimedia
    4847    \ingroup graphicsview-api
    4948
     
    6160    You can add widgets, layouts, stretches (addStretch(), insertStretch() or
    6261    setStretchFactor()), and spacings (setItemSpacing()) to a linear
    63     layout. The layout takes ownership of the items. In some cases when the layout 
     62    layout. The layout takes ownership of the items. In some cases when the layout
    6463    item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a
    6564    ambiguity in ownership because the layout item belongs to two ownership hierarchies.
     
    179178        wid = new QWidget;
    180179    QGraphicsItem *item = parentItem();
    181     QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : qApp->style();
     180    QStyle *style = (item && item->isWidget()) ? static_cast<QGraphicsWidget*>(item)->style() : QApplication::style();
    182181    return QLayoutStyleInfo(style, wid);
    183182}
     
    210209        QGraphicsLayoutItem *item = itemAt(i);
    211210        // The following lines can be removed, but this removes the item
    212         // from the layout more efficiently than the implementation of 
     211        // from the layout more efficiently than the implementation of
    213212        // ~QGraphicsLayoutItem.
    214213        removeAt(i);
     
    274273        return;
    275274    }
     275    if (item == this) {
     276        qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself");
     277        return;
     278    }
    276279    d->addChildLayoutItem(item);
    277280
     
    279282    d->fixIndex(&index);
    280283    d->engine.insertRow(index, d->orientation);
    281     new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index));
     284    new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index);
    282285    invalidate();
    283286}
     
    324327{
    325328    Q_D(QGraphicsLinearLayout);
    326     if (QGridLayoutItem *gridItem = d->engine.itemAt(d->gridRow(index), d->gridColumn(index))) {
     329    if (index < 0 || index >= d->engine.itemCount()) {
     330        qWarning("QGraphicsLinearLayout::removeAt: invalid index %d", index);
     331        return;
     332    }
     333    if (QGridLayoutItem *gridItem = d->engine.itemAt(index)) {
    327334        if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
    328335            layoutItem->setParentLayoutItem(0);
     
    464471{
    465472    Q_D(const QGraphicsLinearLayout);
    466     return d->engine.rowCount(d->orientation);
     473    return d->engine.itemCount();
    467474}
    468475
    469476/*!
    470477    \reimp
     478    When iterating from 0 and up, it will return the items in the visual arranged order.
    471479*/
    472480QGraphicsLayoutItem *QGraphicsLinearLayout::itemAt(int index) const
    473481{
    474482    Q_D(const QGraphicsLinearLayout);
     483    if (index < 0 || index >= d->engine.itemCount()) {
     484        qWarning("QGraphicsLinearLayout::itemAt: invalid index %d", index);
     485        return 0;
     486    }
    475487    QGraphicsLayoutItem *item = 0;
    476     if (QGridLayoutItem *gridItem = d->engine.itemAt(d->gridRow(index), d->gridColumn(index)))
     488    if (QGridLayoutItem *gridItem = d->engine.itemAt(index))
    477489        item = gridItem->layoutItem();
    478490    return item;
     
    531543}
    532544
     545/*!
     546    \internal
     547*/
     548void QGraphicsLinearLayout::dump(int indent) const
     549{
    533550#ifdef QT_DEBUG
    534 void QGraphicsLinearLayout::dump(int indent) const
    535 {
    536551    if (qt_graphicsLayoutDebug()) {
    537552        Q_D(const QGraphicsLinearLayout);
     
    540555        d->engine.dump(indent + 1);
    541556    }
    542 }
    543557#endif
     558}
    544559
    545560QT_END_NAMESPACE
    546        
     561
    547562#endif //QT_NO_GRAPHICSVIEW
Note: See TracChangeset for help on using the changeset viewer.