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/qgraphicsscene_bsp.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**
     
    7171public:
    7272    QList<QGraphicsItem *> *foundItems;
     73
    7374
    7475    void visit(QList<QGraphicsItem *> *items)
     
    7677        for (int i = 0; i < items->size(); ++i) {
    7778            QGraphicsItem *item = items->at(i);
    78             if (!item->d_func()->itemDiscovered && item->isVisible()) {
     79            if (onlyTopLevelItems && item->d_ptr->parent)
     80                item = item->topLevelItem();
     81            if (!item->d_func()->itemDiscovered && item->d_ptr->visible) {
    7982                item->d_func()->itemDiscovered = 1;
    8083                foundItems->prepend(item);
     
    144147}
    145148
    146 QList<QGraphicsItem *> QGraphicsSceneBspTree::items(const QRectF &rect)
     149QList<QGraphicsItem *> QGraphicsSceneBspTree::items(const QRectF &rect
    147150{
    148151    QList<QGraphicsItem *> tmp;
    149152    findVisitor->foundItems = &tmp;
     153
    150154    climbTree(findVisitor, rect);
    151     return tmp;
    152 }
    153 
    154 QList<QGraphicsItem *> QGraphicsSceneBspTree::items(const QPointF &pos)
    155 {
    156     QList<QGraphicsItem *> tmp;
    157     findVisitor->foundItems = &tmp;
    158     climbTree(findVisitor, pos);
     155    // Reset discovery bits.
     156    for (int i = 0; i < tmp.size(); ++i)
     157        tmp.at(i)->d_ptr->itemDiscovered = 0;
    159158    return tmp;
    160159}
     
    236235}
    237236
    238 void QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor *visitor, const QPointF &pos, int index)
     237void QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor *visitor, const Q
    239238{
    240239    if (nodes.isEmpty())
     
    242241
    243242    const Node &node = nodes.at(index);
    244     int childIndex = firstChildIndex(index);
     243    int childIndex = firstChildIndex(index);
    245244
    246245    switch (node.type) {
    247246    case Node::Leaf: {
    248         visitor->visit(&leaves[node.leafIndex]);
    249         break;
    250     }
    251     case Node::Vertical:
    252         if (pos.x() < node.offset) {
    253             climbTree(visitor, pos, childIndex);
    254         } else {
    255             climbTree(visitor, pos, childIndex + 1);
    256         }
    257         break;
    258     case Node::Horizontal:
    259         if (pos.y() < node.offset) {
    260             climbTree(visitor, pos, childIndex);
    261         } else {
    262             climbTree(visitor, pos, childIndex + 1);
    263         }
    264         break;
    265     }
    266 }
    267 
    268 void QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor *visitor, const QRectF &rect, int index)
    269 {
    270     if (nodes.isEmpty())
    271         return;
    272 
    273     const Node &node = nodes.at(index);
    274     int childIndex = firstChildIndex(index);
    275 
    276     switch (node.type) {
    277     case Node::Leaf: {
    278         visitor->visit(&leaves[node.leafIndex]);
     247        visitor->visit(const_cast<QList<QGraphicsItem*>*>(&leaves[node.leafIndex]));
    279248        break;
    280249    }
     
    289258        break;
    290259    case Node::Horizontal:
    291         int childIndex = firstChildIndex(index);
    292260        if (rect.top() < node.offset) {
    293261            climbTree(visitor, rect, childIndex);
Note: See TracChangeset for help on using the changeset viewer.