Changeset 561 for trunk/src/gui/itemviews/qtableview_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/itemviews/qtableview_p.h
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 54 54 // 55 55 56 #include <QtCore/QList> 57 #include <QtCore/QLinkedList> 58 #include <QtCore/QMap> 59 #include <QtCore/QSet> 60 #include <QtCore/QDebug> 56 61 #include "private/qabstractitemview_p.h" 57 62 … … 59 64 60 65 QT_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 */ 77 class Q_AUTOTEST_EXPORT QSpanCollection 78 { 79 public: 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 121 private: 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 130 Q_DECLARE_TYPEINFO ( QSpanCollection::Span, Q_MOVABLE_TYPE); 131 61 132 62 133 class QTableViewPrivate : public QAbstractItemViewPrivate … … 69 140 columnResizeTimerID(0), rowResizeTimerID(0), 70 141 horizontalHeader(0), verticalHeader(0), 71 sortingEnabled(false), geometryRecursionBlock(false) 142 sortingEnabled(false), geometryRecursionBlock(false), 143 visualCursor(QPoint()) 72 144 { 73 145 wrapItemText = true; … … 99 171 int sectionSpanSize(const QHeaderView *header, int logical, int span) const; 100 172 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, 106 174 const QStyleOptionViewItemV4 &option, QBitArray *drawn, 107 175 int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn); … … 121 189 bool sortingEnabled; 122 190 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; 142 194 143 195 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; 145 197 inline int rowSpan(int row, int column) const { 146 198 return span(row, column).height(); … … 150 202 } 151 203 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(); 163 205 } 164 206 inline int rowSpanHeight(int row, int span) const { … … 195 237 } 196 238 197 QRect visualSpanRect(const Span &span) const;239 QRect visualSpanRect(const QSpanCollection::Span &span) const; 198 240 199 241 void _q_selectRow(int row); … … 202 244 void selectRow(int row, bool anchor); 203 245 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); 204 251 }; 205 252
Note:
See TracChangeset
for help on using the changeset viewer.