source: trunk/src/gui/itemviews/qtreeview.h@ 332

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

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

File size: 8.7 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 QTREEVIEW_H
43#define QTREEVIEW_H
44
45#include <QtGui/qabstractitemview.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Gui)
52
53#ifndef QT_NO_TREEVIEW
54
55class QTreeViewPrivate;
56class QHeaderView;
57
58class Q_GUI_EXPORT QTreeView : public QAbstractItemView
59{
60 Q_OBJECT
61 Q_PROPERTY(int autoExpandDelay READ autoExpandDelay WRITE setAutoExpandDelay)
62 Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
63 Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
64 Q_PROPERTY(bool uniformRowHeights READ uniformRowHeights WRITE setUniformRowHeights)
65 Q_PROPERTY(bool itemsExpandable READ itemsExpandable WRITE setItemsExpandable)
66 Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
67 Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
68 Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus)
69 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
70 Q_PROPERTY(bool headerHidden READ isHeaderHidden WRITE setHeaderHidden)
71 Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
72
73public:
74 explicit QTreeView(QWidget *parent = 0);
75 ~QTreeView();
76
77 void setModel(QAbstractItemModel *model);
78 void setRootIndex(const QModelIndex &index);
79 void setSelectionModel(QItemSelectionModel *selectionModel);
80
81 QHeaderView *header() const;
82 void setHeader(QHeaderView *header);
83
84 int autoExpandDelay() const;
85 void setAutoExpandDelay(int delay);
86
87 int indentation() const;
88 void setIndentation(int i);
89
90 bool rootIsDecorated() const;
91 void setRootIsDecorated(bool show);
92
93 bool uniformRowHeights() const;
94 void setUniformRowHeights(bool uniform);
95
96 bool itemsExpandable() const;
97 void setItemsExpandable(bool enable);
98
99 bool expandsOnDoubleClick() const;
100 void setExpandsOnDoubleClick(bool enable);
101
102 int columnViewportPosition(int column) const;
103 int columnWidth(int column) const;
104 void setColumnWidth(int column, int width);
105 int columnAt(int x) const;
106
107 bool isColumnHidden(int column) const;
108 void setColumnHidden(int column, bool hide);
109
110 bool isHeaderHidden() const;
111 void setHeaderHidden(bool hide);
112
113 bool isRowHidden(int row, const QModelIndex &parent) const;
114 void setRowHidden(int row, const QModelIndex &parent, bool hide);
115
116 bool isFirstColumnSpanned(int row, const QModelIndex &parent) const;
117 void setFirstColumnSpanned(int row, const QModelIndex &parent, bool span);
118
119 bool isExpanded(const QModelIndex &index) const;
120 void setExpanded(const QModelIndex &index, bool expand);
121
122 void setSortingEnabled(bool enable);
123 bool isSortingEnabled() const;
124
125 void setAnimated(bool enable);
126 bool isAnimated() const;
127
128 void setAllColumnsShowFocus(bool enable);
129 bool allColumnsShowFocus() const;
130
131 void setWordWrap(bool on);
132 bool wordWrap() const;
133
134 void keyboardSearch(const QString &search);
135
136 QRect visualRect(const QModelIndex &index) const;
137 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
138 QModelIndex indexAt(const QPoint &p) const;
139 QModelIndex indexAbove(const QModelIndex &index) const;
140 QModelIndex indexBelow(const QModelIndex &index) const;
141
142 void doItemsLayout();
143 void reset();
144
145 void sortByColumn(int column, Qt::SortOrder order);
146
147Q_SIGNALS:
148 void expanded(const QModelIndex &index);
149 void collapsed(const QModelIndex &index);
150
151public Q_SLOTS:
152 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
153 void hideColumn(int column);
154 void showColumn(int column);
155 void expand(const QModelIndex &index);
156 void collapse(const QModelIndex &index);
157 void resizeColumnToContents(int column);
158 void sortByColumn(int column);
159 void selectAll();
160 void expandAll();
161 void collapseAll();
162 void expandToDepth(int depth);
163
164protected Q_SLOTS:
165 void columnResized(int column, int oldSize, int newSize);
166 void columnCountChanged(int oldCount, int newCount);
167 void columnMoved();
168 void reexpand();
169 void rowsRemoved(const QModelIndex &parent, int first, int last);
170
171protected:
172 QTreeView(QTreeViewPrivate &dd, QWidget *parent = 0);
173 void scrollContentsBy(int dx, int dy);
174 void rowsInserted(const QModelIndex &parent, int start, int end);
175 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
176
177 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
178 int horizontalOffset() const;
179 int verticalOffset() const;
180
181 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
182 QRegion visualRegionForSelection(const QItemSelection &selection) const;
183 QModelIndexList selectedIndexes() const;
184
185 void timerEvent(QTimerEvent *event);
186 void paintEvent(QPaintEvent *event);
187
188 void drawTree(QPainter *painter, const QRegion &region) const;
189 virtual void drawRow(QPainter *painter,
190 const QStyleOptionViewItem &options,
191 const QModelIndex &index) const;
192 virtual void drawBranches(QPainter *painter,
193 const QRect &rect,
194 const QModelIndex &index) const;
195
196 void mousePressEvent(QMouseEvent *event);
197 void mouseReleaseEvent(QMouseEvent *event);
198 void mouseDoubleClickEvent(QMouseEvent *event);
199 void mouseMoveEvent(QMouseEvent *event);
200 void keyPressEvent(QKeyEvent *event);
201#ifndef QT_NO_DRAGANDDROP
202 void dragMoveEvent(QDragMoveEvent *event);
203#endif
204 bool viewportEvent(QEvent *event);
205
206 void updateGeometries();
207
208 int sizeHintForColumn(int column) const;
209 int indexRowSizeHint(const QModelIndex &index) const;
210 int rowHeight(const QModelIndex &index) const;
211
212 void horizontalScrollbarAction(int action);
213
214 bool isIndexHidden(const QModelIndex &index) const;
215 void selectionChanged(const QItemSelection &selected,
216 const QItemSelection &deselected);
217 void currentChanged(const QModelIndex &current, const QModelIndex &previous);
218
219private:
220 friend class QAccessibleItemView;
221 int visualIndex(const QModelIndex &index) const;
222
223 Q_DECLARE_PRIVATE(QTreeView)
224 Q_DISABLE_COPY(QTreeView)
225 Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation())
226 Q_PRIVATE_SLOT(d_func(), void _q_animate())
227 Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(const QModelIndex&, const QModelIndex &))
228 Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex &, int, int))
229 Q_PRIVATE_SLOT(d_func(), void _q_columnsRemoved(const QModelIndex &, int, int))
230 Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
231 Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
232 Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
233};
234
235#endif // QT_NO_TREEVIEW
236
237QT_END_NAMESPACE
238
239QT_END_HEADER
240
241#endif // QTREEVIEW_H
Note: See TracBrowser for help on using the repository browser.