source: trunk/src/gui/itemviews/qtableview.h@ 95

Last change on this file since 95 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 6.4 KB
Line 
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_H
43#define QTABLEVIEW_H
44
45#include <QtGui/qabstractitemview.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Gui)
52
53#ifndef QT_NO_TABLEVIEW
54
55class QHeaderView;
56class QTableViewPrivate;
57
58class Q_GUI_EXPORT QTableView : public QAbstractItemView
59{
60 Q_OBJECT
61 Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
62 Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
63 Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
64 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
65 Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
66
67public:
68 explicit QTableView(QWidget *parent = 0);
69 ~QTableView();
70
71 void setModel(QAbstractItemModel *model);
72 void setRootIndex(const QModelIndex &index);
73 void setSelectionModel(QItemSelectionModel *selectionModel);
74
75 QHeaderView *horizontalHeader() const;
76 QHeaderView *verticalHeader() const;
77 void setHorizontalHeader(QHeaderView *header);
78 void setVerticalHeader(QHeaderView *header);
79
80 int rowViewportPosition(int row) const;
81 int rowAt(int y) const;
82
83 void setRowHeight(int row, int height);
84 int rowHeight(int row) const;
85
86 int columnViewportPosition(int column) const;
87 int columnAt(int x) const;
88
89 void setColumnWidth(int column, int width);
90 int columnWidth(int column) const;
91
92 bool isRowHidden(int row) const;
93 void setRowHidden(int row, bool hide);
94
95 bool isColumnHidden(int column) const;
96 void setColumnHidden(int column, bool hide);
97
98 void setSortingEnabled(bool enable);
99 bool isSortingEnabled() const;
100
101 bool showGrid() const;
102
103 Qt::PenStyle gridStyle() const;
104 void setGridStyle(Qt::PenStyle style);
105
106 void setWordWrap(bool on);
107 bool wordWrap() const;
108
109 void setCornerButtonEnabled(bool enable);
110 bool isCornerButtonEnabled() const;
111
112 QRect visualRect(const QModelIndex &index) const;
113 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
114 QModelIndex indexAt(const QPoint &p) const;
115
116 void setSpan(int row, int column, int rowSpan, int columnSpan);
117 int rowSpan(int row, int column) const;
118 int columnSpan(int row, int column) const;
119 void clearSpans();
120
121 void sortByColumn(int column, Qt::SortOrder order);
122
123public Q_SLOTS:
124 void selectRow(int row);
125 void selectColumn(int column);
126 void hideRow(int row);
127 void hideColumn(int column);
128 void showRow(int row);
129 void showColumn(int column);
130 void resizeRowToContents(int row);
131 void resizeRowsToContents();
132 void resizeColumnToContents(int column);
133 void resizeColumnsToContents();
134 void sortByColumn(int column);
135 void setShowGrid(bool show);
136
137protected Q_SLOTS:
138 void rowMoved(int row, int oldIndex, int newIndex);
139 void columnMoved(int column, int oldIndex, int newIndex);
140 void rowResized(int row, int oldHeight, int newHeight);
141 void columnResized(int column, int oldWidth, int newWidth);
142 void rowCountChanged(int oldCount, int newCount);
143 void columnCountChanged(int oldCount, int newCount);
144
145protected:
146 QTableView(QTableViewPrivate &, QWidget *parent);
147 void scrollContentsBy(int dx, int dy);
148
149 QStyleOptionViewItem viewOptions() const;
150 void paintEvent(QPaintEvent *e);
151
152 void timerEvent(QTimerEvent *event);
153
154 int horizontalOffset() const;
155 int verticalOffset() const;
156 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
157
158 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
159 QRegion visualRegionForSelection(const QItemSelection &selection) const;
160 QModelIndexList selectedIndexes() const;
161
162 void updateGeometries();
163
164 int sizeHintForRow(int row) const;
165 int sizeHintForColumn(int column) const;
166
167 void verticalScrollbarAction(int action);
168 void horizontalScrollbarAction(int action);
169
170 bool isIndexHidden(const QModelIndex &index) const;
171
172 void selectionChanged(const QItemSelection &selected,
173 const QItemSelection &deselected);
174 void currentChanged(const QModelIndex &current,
175 const QModelIndex &previous);
176
177private:
178 friend class QAccessibleItemView;
179 int visualIndex(const QModelIndex &index) const;
180
181 Q_DECLARE_PRIVATE(QTableView)
182 Q_DISABLE_COPY(QTableView)
183 Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int))
184 Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int))
185};
186
187#endif // QT_NO_TABLEVIEW
188
189QT_END_NAMESPACE
190
191QT_END_HEADER
192
193#endif // QTABLEVIEW_H
Note: See TracBrowser for help on using the repository browser.