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/itemviews/qtableview_p.h

    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**
     
    5454//
    5555
     56#include <QtCore/QList>
     57#include <QtCore/QLinkedList>
     58#include <QtCore/QMap>
     59#include <QtCore/QSet>
     60#include <QtCore/QDebug>
    5661#include "private/qabstractitemview_p.h"
    5762
     
    5964
    6065QT_BEGIN_NAMESPACE
     66
     67/** \internal
     68*
     69* This is a list of span with a binary index to look up quickly a span at a certain index.
     70*
     71* The index is a map of map.
     72* spans are mentaly divided into sub spans so that the start of any subspans doesn't overlap
     73* with any other subspans. There is no real representation of the subspans.
     74* The key of the first map is the row where the subspan starts, the value of the first map is
     75* a list (map) of all subspans that starts at the same row.  It is indexed with its row
     76*/
     77class Q_AUTOTEST_EXPORT QSpanCollection
     78{
     79public:
     80    struct Span
     81    {
     82        int m_top;
     83        int m_left;
     84        int m_bottom;
     85        int m_right;
     86        bool will_be_deleted;
     87        Span()
     88        : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1), will_be_deleted(false) { }
     89        Span(int row, int column, int rowCount, int columnCount)
     90        : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1), will_be_deleted(false) { }
     91        inline int top() const { return m_top; }
     92        inline int left() const { return m_left; }
     93        inline int bottom() const { return m_bottom; }
     94        inline int right() const { return m_right; }
     95        inline int height() const { return m_bottom - m_top + 1; }
     96        inline int width() const { return m_right - m_left + 1; }
     97    };
     98
     99    ~QSpanCollection()
     100    {
     101        qDeleteAll(spans);
     102    }
     103
     104    void addSpan(Span *span);
     105    void updateSpan(Span *span, int old_height);
     106    Span *spanAt(int x, int y) const;
     107    void clear();
     108    QList<Span *> spansInRect(int x, int y, int w, int h) const;
     109
     110    void updateInsertedRows(int start, int end);
     111    void updateInsertedColumns(int start, int end);
     112    void updateRemovedRows(int start, int end);
     113    void updateRemovedColumns(int start, int end);
     114
     115#ifdef QT_BUILD_INTERNAL
     116    bool checkConsistency() const;
     117#endif
     118
     119    typedef QLinkedList<Span *> SpanList;
     120    SpanList spans; //lists of all spans
     121private:
     122    //the indexes are negative so the QMap::lowerBound do what i need.
     123    typedef QMap<int, Span *> SubIndex;
     124    typedef QMap<int, SubIndex> Index;
     125    Index index;
     126
     127    bool cleanSpanSubIndex(SubIndex &subindex, int end, bool update = false);
     128};
     129
     130Q_DECLARE_TYPEINFO ( QSpanCollection::Span, Q_MOVABLE_TYPE);
     131
    61132
    62133class QTableViewPrivate : public QAbstractItemViewPrivate
     
    69140          columnResizeTimerID(0), rowResizeTimerID(0),
    70141          horizontalHeader(0), verticalHeader(0),
    71           sortingEnabled(false), geometryRecursionBlock(false)
     142          sortingEnabled(false), geometryRecursionBlock(false),
     143          visualCursor(QPoint())
    72144 {
    73145    wrapItemText = true;
     
    99171    int sectionSpanSize(const QHeaderView *header, int logical, int span) const;
    100172    bool spanContainsSection(const QHeaderView *header, int logical, int spanLogical, int span) const;
    101     bool spansIntersectColumn(int column) const;
    102     bool spansIntersectRow(int row) const;
    103     bool spansIntersectColumns(const QList<int> &columns) const;
    104     bool spansIntersectRows(const QList<int> &rows) const;
    105     void drawAndClipSpans(const QRect &area, QPainter *painter,
     173    void drawAndClipSpans(const QRegion &area, QPainter *painter,
    106174                          const QStyleOptionViewItemV4 &option, QBitArray *drawn,
    107175                          int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn);
     
    121189    bool sortingEnabled;
    122190    bool geometryRecursionBlock;
    123 
    124     struct Span
    125     {
    126         int m_top;
    127         int m_left;
    128         int m_bottom;
    129         int m_right;
    130         Span()
    131             : m_top(-1), m_left(-1), m_bottom(-1), m_right(-1) { }
    132         Span(int row, int column, int rowCount, int columnCount)
    133             : m_top(row), m_left(column), m_bottom(row+rowCount-1), m_right(column+columnCount-1) { }
    134         inline int top() const { return m_top; }
    135         inline int left() const { return m_left; }
    136         inline int bottom() const { return m_bottom; }
    137         inline int right() const { return m_right; }
    138         inline int height() const { return m_bottom - m_top + 1; }
    139         inline int width() const { return m_right - m_left + 1; }
    140     };
    141     QList<Span> spans;
     191    QPoint visualCursor;  // (Row,column) cell coordinates to track through span navigation.
     192
     193    QSpanCollection spans;
    142194
    143195    void setSpan(int row, int column, int rowSpan, int columnSpan);
    144     Span span(int row, int column) const;
     196    QSpanCollection::Span span(int row, int column) const;
    145197    inline int rowSpan(int row, int column) const {
    146198        return span(row, column).height();
     
    150202    }
    151203    inline bool hasSpans() const {
    152         return !spans.isEmpty();
    153     }
    154     inline bool spanContainsRow(int row, int spanRow, int span) const {
    155         return spanContainsSection(verticalHeader, row, spanRow, span);
    156     }
    157     inline bool spanContainsColumn(int column, int spanColumn, int span) const {
    158         return spanContainsSection(horizontalHeader, column, spanColumn, span);
    159     }
    160     inline bool isInSpan(int row, int column, const Span &span) const {
    161         return spanContainsRow(row, span.top(), span.height())
    162             && spanContainsColumn(column, span.left(), span.width());
     204        return !spans.spans.isEmpty();
    163205    }
    164206    inline int rowSpanHeight(int row, int span) const {
     
    195237    }
    196238
    197     QRect visualSpanRect(const Span &span) const;
     239    QRect visualSpanRect(const QSpanCollection::Span &span) const;
    198240
    199241    void _q_selectRow(int row);
     
    202244    void selectRow(int row, bool anchor);
    203245    void selectColumn(int column, bool anchor);
     246
     247    void _q_updateSpanInsertedRows(const QModelIndex &parent, int start, int end);
     248    void _q_updateSpanInsertedColumns(const QModelIndex &parent, int start, int end);
     249    void _q_updateSpanRemovedRows(const QModelIndex &parent, int start, int end);
     250    void _q_updateSpanRemovedColumns(const QModelIndex &parent, int start, int end);
    204251};
    205252
Note: See TracChangeset for help on using the changeset viewer.