| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 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.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QTABLEVIEW_P_H
|
|---|
| 43 | #define QTABLEVIEW_P_H
|
|---|
| 44 |
|
|---|
| 45 | //
|
|---|
| 46 | // W A R N I N G
|
|---|
| 47 | // -------------
|
|---|
| 48 | //
|
|---|
| 49 | // This file is not part of the Qt API. It exists purely as an
|
|---|
| 50 | // implementation detail. This header file may change from version to
|
|---|
| 51 | // version without notice, or even be removed.
|
|---|
| 52 | //
|
|---|
| 53 | // We mean it.
|
|---|
| 54 | //
|
|---|
| 55 |
|
|---|
| 56 | #include "private/qabstractitemview_p.h"
|
|---|
| 57 |
|
|---|
| 58 | #ifndef QT_NO_TABLEVIEW
|
|---|
| 59 |
|
|---|
| 60 | QT_BEGIN_NAMESPACE
|
|---|
| 61 |
|
|---|
| 62 | class QTableViewPrivate : public QAbstractItemViewPrivate
|
|---|
| 63 | {
|
|---|
| 64 | Q_DECLARE_PUBLIC(QTableView)
|
|---|
| 65 | public:
|
|---|
| 66 | QTableViewPrivate()
|
|---|
| 67 | : showGrid(true), gridStyle(Qt::SolidLine),
|
|---|
| 68 | rowSectionAnchor(-1), columnSectionAnchor(-1),
|
|---|
| 69 | columnResizeTimerID(0), rowResizeTimerID(0),
|
|---|
| 70 | horizontalHeader(0), verticalHeader(0),
|
|---|
| 71 | sortingEnabled(false), geometryRecursionBlock(false)
|
|---|
| 72 | {
|
|---|
| 73 | wrapItemText = true;
|
|---|
| 74 | #ifndef QT_NO_DRAGANDDROP
|
|---|
| 75 | overwrite = true;
|
|---|
| 76 | #endif
|
|---|
| 77 | }
|
|---|
| 78 | void init();
|
|---|
| 79 | void trimHiddenSelections(QItemSelectionRange *range) const;
|
|---|
| 80 |
|
|---|
| 81 | inline bool isHidden(int row, int col) const {
|
|---|
| 82 | return verticalHeader->isSectionHidden(row)
|
|---|
| 83 | || horizontalHeader->isSectionHidden(col);
|
|---|
| 84 | }
|
|---|
| 85 | inline int visualRow(int logicalRow) const {
|
|---|
| 86 | return verticalHeader->visualIndex(logicalRow);
|
|---|
| 87 | }
|
|---|
| 88 | inline int visualColumn(int logicalCol) const {
|
|---|
| 89 | return horizontalHeader->visualIndex(logicalCol);
|
|---|
| 90 | }
|
|---|
| 91 | inline int logicalRow(int visualRow) const {
|
|---|
| 92 | return verticalHeader->logicalIndex(visualRow);
|
|---|
| 93 | }
|
|---|
| 94 | inline int logicalColumn(int visualCol) const {
|
|---|
| 95 | return horizontalHeader->logicalIndex(visualCol);
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | int sectionSpanEndLogical(const QHeaderView *header, int logical, int span) const;
|
|---|
| 99 | int sectionSpanSize(const QHeaderView *header, int logical, int span) const;
|
|---|
| 100 | 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,
|
|---|
| 106 | const QStyleOptionViewItemV4 &option, QBitArray *drawn,
|
|---|
| 107 | int firstVisualRow, int lastVisualRow, int firstVisualColumn, int lastVisualColumn);
|
|---|
| 108 | void drawCell(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index);
|
|---|
| 109 |
|
|---|
| 110 | bool showGrid;
|
|---|
| 111 | Qt::PenStyle gridStyle;
|
|---|
| 112 | int rowSectionAnchor;
|
|---|
| 113 | int columnSectionAnchor;
|
|---|
| 114 | int columnResizeTimerID;
|
|---|
| 115 | int rowResizeTimerID;
|
|---|
| 116 | QList<int> columnsToUpdate;
|
|---|
| 117 | QList<int> rowsToUpdate;
|
|---|
| 118 | QHeaderView *horizontalHeader;
|
|---|
| 119 | QHeaderView *verticalHeader;
|
|---|
| 120 | QWidget *cornerWidget;
|
|---|
| 121 | bool sortingEnabled;
|
|---|
| 122 | 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;
|
|---|
| 142 |
|
|---|
| 143 | void setSpan(int row, int column, int rowSpan, int columnSpan);
|
|---|
| 144 | Span span(int row, int column) const;
|
|---|
| 145 | inline int rowSpan(int row, int column) const {
|
|---|
| 146 | return span(row, column).height();
|
|---|
| 147 | }
|
|---|
| 148 | inline int columnSpan(int row, int column) const {
|
|---|
| 149 | return span(row, column).width();
|
|---|
| 150 | }
|
|---|
| 151 | 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());
|
|---|
| 163 | }
|
|---|
| 164 | inline int rowSpanHeight(int row, int span) const {
|
|---|
| 165 | return sectionSpanSize(verticalHeader, row, span);
|
|---|
| 166 | }
|
|---|
| 167 | inline int columnSpanWidth(int column, int span) const {
|
|---|
| 168 | return sectionSpanSize(horizontalHeader, column, span);
|
|---|
| 169 | }
|
|---|
| 170 | inline int rowSpanEndLogical(int row, int span) const {
|
|---|
| 171 | return sectionSpanEndLogical(verticalHeader, row, span);
|
|---|
| 172 | }
|
|---|
| 173 | inline int columnSpanEndLogical(int column, int span) const {
|
|---|
| 174 | return sectionSpanEndLogical(horizontalHeader, column, span);
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | inline bool isRowHidden(int row) const {
|
|---|
| 178 | return verticalHeader->isSectionHidden(row);
|
|---|
| 179 | }
|
|---|
| 180 | inline bool isColumnHidden(int column) const {
|
|---|
| 181 | return horizontalHeader->isSectionHidden(column);
|
|---|
| 182 | }
|
|---|
| 183 | inline bool isCellEnabled(int row, int column) const {
|
|---|
| 184 | return isIndexEnabled(model->index(row, column, root));
|
|---|
| 185 | }
|
|---|
| 186 | inline bool isVisualRowHiddenOrDisabled(int row, int column) const {
|
|---|
| 187 | int r = logicalRow(row);
|
|---|
| 188 | int c = logicalColumn(column);
|
|---|
| 189 | return isRowHidden(r) || !isCellEnabled(r, c);
|
|---|
| 190 | }
|
|---|
| 191 | inline bool isVisualColumnHiddenOrDisabled(int row, int column) const {
|
|---|
| 192 | int r = logicalRow(row);
|
|---|
| 193 | int c = logicalColumn(column);
|
|---|
| 194 | return isColumnHidden(c) || !isCellEnabled(r, c);
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | QRect visualSpanRect(const Span &span) const;
|
|---|
| 198 |
|
|---|
| 199 | void _q_selectRow(int row);
|
|---|
| 200 | void _q_selectColumn(int column);
|
|---|
| 201 |
|
|---|
| 202 | void selectRow(int row, bool anchor);
|
|---|
| 203 | void selectColumn(int column, bool anchor);
|
|---|
| 204 | };
|
|---|
| 205 |
|
|---|
| 206 | QT_END_NAMESPACE
|
|---|
| 207 |
|
|---|
| 208 | #endif // QT_NO_TABLEVIEW
|
|---|
| 209 |
|
|---|
| 210 | #endif // QTABLEVIEW_P_H
|
|---|