Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QTREEVIEW_H
00043 #define QTREEVIEW_H
00044
00045 #include <QtGui/qabstractitemview.h>
00046
00047 QT_BEGIN_HEADER
00048
00049 QT_BEGIN_NAMESPACE
00050
00051 QT_MODULE(Gui)
00052
00053 #ifndef QT_NO_TREEVIEW
00054
00055 class QTreeViewPrivate;
00056 class QHeaderView;
00057
00058 class Q_GUI_EXPORT QTreeView : public QAbstractItemView
00059 {
00060 Q_OBJECT
00061 Q_PROPERTY(int autoExpandDelay READ autoExpandDelay WRITE setAutoExpandDelay)
00062 Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
00063 Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
00064 Q_PROPERTY(bool uniformRowHeights READ uniformRowHeights WRITE setUniformRowHeights)
00065 Q_PROPERTY(bool itemsExpandable READ itemsExpandable WRITE setItemsExpandable)
00066 Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
00067 Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
00068 Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus)
00069 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
00070 Q_PROPERTY(bool headerHidden READ isHeaderHidden WRITE setHeaderHidden)
00071 Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
00072
00073 public:
00074 explicit QTreeView(QWidget *parent = 0);
00075 ~QTreeView();
00076
00077 void setModel(QAbstractItemModel *model);
00078 void setRootIndex(const QModelIndex &index);
00079 void setSelectionModel(QItemSelectionModel *selectionModel);
00080
00081 QHeaderView *header() const;
00082 void setHeader(QHeaderView *header);
00083
00084 int autoExpandDelay() const;
00085 void setAutoExpandDelay(int delay);
00086
00087 int indentation() const;
00088 void setIndentation(int i);
00089
00090 bool rootIsDecorated() const;
00091 void setRootIsDecorated(bool show);
00092
00093 bool uniformRowHeights() const;
00094 void setUniformRowHeights(bool uniform);
00095
00096 bool itemsExpandable() const;
00097 void setItemsExpandable(bool enable);
00098
00099 bool expandsOnDoubleClick() const;
00100 void setExpandsOnDoubleClick(bool enable);
00101
00102 int columnViewportPosition(int column) const;
00103 int columnWidth(int column) const;
00104 void setColumnWidth(int column, int width);
00105 int columnAt(int x) const;
00106
00107 bool isColumnHidden(int column) const;
00108 void setColumnHidden(int column, bool hide);
00109
00110 bool isHeaderHidden() const;
00111 void setHeaderHidden(bool hide);
00112
00113 bool isRowHidden(int row, const QModelIndex &parent) const;
00114 void setRowHidden(int row, const QModelIndex &parent, bool hide);
00115
00116 bool isFirstColumnSpanned(int row, const QModelIndex &parent) const;
00117 void setFirstColumnSpanned(int row, const QModelIndex &parent, bool span);
00118
00119 bool isExpanded(const QModelIndex &index) const;
00120 void setExpanded(const QModelIndex &index, bool expand);
00121
00122 void setSortingEnabled(bool enable);
00123 bool isSortingEnabled() const;
00124
00125 void setAnimated(bool enable);
00126 bool isAnimated() const;
00127
00128 void setAllColumnsShowFocus(bool enable);
00129 bool allColumnsShowFocus() const;
00130
00131 void setWordWrap(bool on);
00132 bool wordWrap() const;
00133
00134 void keyboardSearch(const QString &search);
00135
00136 QRect visualRect(const QModelIndex &index) const;
00137 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
00138 QModelIndex indexAt(const QPoint &p) const;
00139 QModelIndex indexAbove(const QModelIndex &index) const;
00140 QModelIndex indexBelow(const QModelIndex &index) const;
00141
00142 void doItemsLayout();
00143 void reset();
00144
00145 void sortByColumn(int column, Qt::SortOrder order);
00146
00147 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
00148 void selectAll();
00149
00150 Q_SIGNALS:
00151 void expanded(const QModelIndex &index);
00152 void collapsed(const QModelIndex &index);
00153
00154 public Q_SLOTS:
00155 void hideColumn(int column);
00156 void showColumn(int column);
00157 void expand(const QModelIndex &index);
00158 void collapse(const QModelIndex &index);
00159 void resizeColumnToContents(int column);
00160 void sortByColumn(int column);
00161 void expandAll();
00162 void collapseAll();
00163 void expandToDepth(int depth);
00164
00165 protected Q_SLOTS:
00166 void columnResized(int column, int oldSize, int newSize);
00167 void columnCountChanged(int oldCount, int newCount);
00168 void columnMoved();
00169 void reexpand();
00170 void rowsRemoved(const QModelIndex &parent, int first, int last);
00171
00172 protected:
00173 QTreeView(QTreeViewPrivate &dd, QWidget *parent = 0);
00174 void scrollContentsBy(int dx, int dy);
00175 void rowsInserted(const QModelIndex &parent, int start, int end);
00176 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
00177
00178 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
00179 int horizontalOffset() const;
00180 int verticalOffset() const;
00181
00182 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
00183 QRegion visualRegionForSelection(const QItemSelection &selection) const;
00184 QModelIndexList selectedIndexes() const;
00185
00186 void timerEvent(QTimerEvent *event);
00187 void paintEvent(QPaintEvent *event);
00188
00189 void drawTree(QPainter *painter, const QRegion ®ion) const;
00190 virtual void drawRow(QPainter *painter,
00191 const QStyleOptionViewItem &options,
00192 const QModelIndex &index) const;
00193 virtual void drawBranches(QPainter *painter,
00194 const QRect &rect,
00195 const QModelIndex &index) const;
00196
00197 void mousePressEvent(QMouseEvent *event);
00198 void mouseReleaseEvent(QMouseEvent *event);
00199 void mouseDoubleClickEvent(QMouseEvent *event);
00200 void mouseMoveEvent(QMouseEvent *event);
00201 void keyPressEvent(QKeyEvent *event);
00202 #ifndef QT_NO_DRAGANDDROP
00203 void dragMoveEvent(QDragMoveEvent *event);
00204 #endif
00205 bool viewportEvent(QEvent *event);
00206
00207 void updateGeometries();
00208
00209 int sizeHintForColumn(int column) const;
00210 int indexRowSizeHint(const QModelIndex &index) const;
00211 int rowHeight(const QModelIndex &index) const;
00212
00213 void horizontalScrollbarAction(int action);
00214
00215 bool isIndexHidden(const QModelIndex &index) const;
00216 void selectionChanged(const QItemSelection &selected,
00217 const QItemSelection &deselected);
00218 void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
00219
00220 private:
00221 friend class QAccessibleItemView;
00222 int visualIndex(const QModelIndex &index) const;
00223
00224 Q_DECLARE_PRIVATE(QTreeView)
00225 Q_DISABLE_COPY(QTreeView)
00226 #ifndef QT_NO_ANIMATION
00227 Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation())
00228 #endif //QT_NO_ANIMATION
00229 Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
00230 Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
00231 };
00232
00233 #endif // QT_NO_TREEVIEW
00234
00235 QT_END_NAMESPACE
00236
00237 QT_END_HEADER
00238
00239 #endif // QTREEVIEW_H