QtGui/qtreeview.h Source File

qtreeview.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QTREEVIEW_H
43 #define QTREEVIEW_H
44 
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 #ifndef QT_NO_TREEVIEW
54 
55 class QTreeViewPrivate;
56 class QHeaderView;
57 
58 class 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 
73 public:
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 
147  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
148  void selectAll();
149 
150 Q_SIGNALS:
151  void expanded(const QModelIndex &index);
152  void collapsed(const QModelIndex &index);
153 
154 public Q_SLOTS:
155  void hideColumn(int column);
156  void showColumn(int column);
157  void expand(const QModelIndex &index);
158  void collapse(const QModelIndex &index);
159  void resizeColumnToContents(int column);
160  void sortByColumn(int column);
161  void expandAll();
162  void collapseAll();
163  void expandToDepth(int depth);
164 
165 protected Q_SLOTS:
166  void columnResized(int column, int oldSize, int newSize);
167  void columnCountChanged(int oldCount, int newCount);
168  void columnMoved();
169  void reexpand();
170  void rowsRemoved(const QModelIndex &parent, int first, int last);
171 
172 protected:
173  QTreeView(QTreeViewPrivate &dd, QWidget *parent = 0);
174  void scrollContentsBy(int dx, int dy);
175  void rowsInserted(const QModelIndex &parent, int start, int end);
176  void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
177 
178  QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
179  int horizontalOffset() const;
180  int verticalOffset() const;
181 
182  void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
183  QRegion visualRegionForSelection(const QItemSelection &selection) const;
184  QModelIndexList selectedIndexes() const;
185 
186  void timerEvent(QTimerEvent *event);
187  void paintEvent(QPaintEvent *event);
188 
189  void drawTree(QPainter *painter, const QRegion &region) const;
190  virtual void drawRow(QPainter *painter,
191  const QStyleOptionViewItem &options,
192  const QModelIndex &index) const;
193  virtual void drawBranches(QPainter *painter,
194  const QRect &rect,
195  const QModelIndex &index) const;
196 
197  void mousePressEvent(QMouseEvent *event);
198  void mouseReleaseEvent(QMouseEvent *event);
199  void mouseDoubleClickEvent(QMouseEvent *event);
200  void mouseMoveEvent(QMouseEvent *event);
201  void keyPressEvent(QKeyEvent *event);
202 #ifndef QT_NO_DRAGANDDROP
203  void dragMoveEvent(QDragMoveEvent *event);
204 #endif
205  bool viewportEvent(QEvent *event);
206 
207  void updateGeometries();
208 
209  int sizeHintForColumn(int column) const;
210  int indexRowSizeHint(const QModelIndex &index) const;
211  int rowHeight(const QModelIndex &index) const;
212 
213  void horizontalScrollbarAction(int action);
214 
215  bool isIndexHidden(const QModelIndex &index) const;
216  void selectionChanged(const QItemSelection &selected,
217  const QItemSelection &deselected);
218  void currentChanged(const QModelIndex &current, const QModelIndex &previous);
219 
220 private:
221  friend class QAccessibleItemView;
222  friend class QAccessibleTable2;
223  friend class QAccessibleTree;
224  friend class QAccessibleTable2Cell;
225  int visualIndex(const QModelIndex &index) const;
226 
227  Q_DECLARE_PRIVATE(QTreeView)
228  Q_DISABLE_COPY(QTreeView)
229 #ifndef QT_NO_ANIMATION
230  Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation())
231 #endif //QT_NO_ANIMATION
232  Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
233  Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
234 };
235 
236 #endif // QT_NO_TREEVIEW
237 
239 
241 
242 #endif // QTREEVIEW_H
int int int int * dy
Definition: GLee.h:10535
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
GLuint start
Definition: GLee.h:872
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
bool viewportEvent(QEvent *event)
virtual void updateGeometries()
GLenum GLsizei width
Definition: GLee.h:873
virtual void horizontalScrollbarAction(int action)
Definition: qnamespace.h:54
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
virtual bool isIndexHidden(const QModelIndex &index) const =0
Definition: qpoint.h:53
void dragMoveEvent(QDragMoveEvent *event)
GLenum GLenum GLvoid * row
Definition: GLee.h:893
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLint * first
Definition: GLee.h:1362
GLenum GLint x
Definition: GLee.h:876
#define Q_OBJECT
Definition: qobjectdefs.h:157
GLuint GLuint end
Definition: GLee.h:872
GLint GLint GLsizei GLsizei GLsizei depth
Definition: GLee.h:905
Definition: qrect.h:58
GLfloat GLfloat p
Definition: GLee.h:5416
GLenum GLenum GLvoid GLvoid * column
Definition: GLee.h:893
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous)
int int int * dx
Definition: GLee.h:10535
GLboolean reset
Definition: GLee.h:895
GLenum GLenum GLvoid GLvoid GLvoid * span
Definition: GLee.h:893
#define QT_END_HEADER
Definition: qglobal.h:142
virtual int sizeHintForColumn(int column) const
GLuint index
Definition: GLee.h:1704
SortOrder
Definition: qnamespace.h:189