Warning, file /include/QtWidgets/qtreeview.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QTREEVIEW_H
0005 #define QTREEVIEW_H
0006
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qabstractitemview.h>
0009
0010 class tst_QTreeView;
0011
0012 QT_REQUIRE_CONFIG(treeview);
0013
0014 QT_BEGIN_NAMESPACE
0015
0016 class QTreeViewPrivate;
0017 class QHeaderView;
0018
0019 class Q_WIDGETS_EXPORT QTreeView : public QAbstractItemView
0020 {
0021 Q_OBJECT
0022 Q_PROPERTY(int autoExpandDelay READ autoExpandDelay WRITE setAutoExpandDelay)
0023 Q_PROPERTY(int indentation READ indentation WRITE setIndentation RESET resetIndentation)
0024 Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
0025 Q_PROPERTY(bool uniformRowHeights READ uniformRowHeights WRITE setUniformRowHeights)
0026 Q_PROPERTY(bool itemsExpandable READ itemsExpandable WRITE setItemsExpandable)
0027 Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
0028 Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
0029 Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus)
0030 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
0031 Q_PROPERTY(bool headerHidden READ isHeaderHidden WRITE setHeaderHidden)
0032 Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
0033
0034 public:
0035 explicit QTreeView(QWidget *parent = nullptr);
0036 ~QTreeView();
0037
0038 void setModel(QAbstractItemModel *model) override;
0039 void setRootIndex(const QModelIndex &index) override;
0040 void setSelectionModel(QItemSelectionModel *selectionModel) override;
0041
0042 QHeaderView *header() const;
0043 void setHeader(QHeaderView *header);
0044
0045 int autoExpandDelay() const;
0046 void setAutoExpandDelay(int delay);
0047
0048 int indentation() const;
0049 void setIndentation(int i);
0050 void resetIndentation();
0051
0052 bool rootIsDecorated() const;
0053 void setRootIsDecorated(bool show);
0054
0055 bool uniformRowHeights() const;
0056 void setUniformRowHeights(bool uniform);
0057
0058 bool itemsExpandable() const;
0059 void setItemsExpandable(bool enable);
0060
0061 bool expandsOnDoubleClick() const;
0062 void setExpandsOnDoubleClick(bool enable);
0063
0064 int columnViewportPosition(int column) const;
0065 int columnWidth(int column) const;
0066 void setColumnWidth(int column, int width);
0067 int columnAt(int x) const;
0068
0069 bool isColumnHidden(int column) const;
0070 void setColumnHidden(int column, bool hide);
0071
0072 bool isHeaderHidden() const;
0073 void setHeaderHidden(bool hide);
0074
0075 bool isRowHidden(int row, const QModelIndex &parent) const;
0076 void setRowHidden(int row, const QModelIndex &parent, bool hide);
0077
0078 bool isFirstColumnSpanned(int row, const QModelIndex &parent) const;
0079 void setFirstColumnSpanned(int row, const QModelIndex &parent, bool span);
0080
0081 bool isExpanded(const QModelIndex &index) const;
0082 void setExpanded(const QModelIndex &index, bool expand);
0083
0084 void setSortingEnabled(bool enable);
0085 bool isSortingEnabled() const;
0086
0087 void setAnimated(bool enable);
0088 bool isAnimated() const;
0089
0090 void setAllColumnsShowFocus(bool enable);
0091 bool allColumnsShowFocus() const;
0092
0093 void setWordWrap(bool on);
0094 bool wordWrap() const;
0095
0096 void setTreePosition(int logicalIndex);
0097 int treePosition() const;
0098
0099 void keyboardSearch(const QString &search) override;
0100
0101 QRect visualRect(const QModelIndex &index) const override;
0102 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
0103 QModelIndex indexAt(const QPoint &p) const override;
0104 QModelIndex indexAbove(const QModelIndex &index) const;
0105 QModelIndex indexBelow(const QModelIndex &index) const;
0106
0107 void doItemsLayout() override;
0108 void reset() override;
0109
0110 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
0111 const QList<int> &roles = QList<int>()) override;
0112 void selectAll() override;
0113
0114 Q_SIGNALS:
0115 void expanded(const QModelIndex &index);
0116 void collapsed(const QModelIndex &index);
0117
0118 public Q_SLOTS:
0119 void hideColumn(int column);
0120 void showColumn(int column);
0121 void expand(const QModelIndex &index);
0122 void collapse(const QModelIndex &index);
0123 void resizeColumnToContents(int column);
0124 void sortByColumn(int column, Qt::SortOrder order);
0125 void expandAll();
0126 void expandRecursively(const QModelIndex &index, int depth = -1);
0127 void collapseAll();
0128 void expandToDepth(int depth);
0129
0130 protected Q_SLOTS:
0131 void columnResized(int column, int oldSize, int newSize);
0132 void columnCountChanged(int oldCount, int newCount);
0133 void columnMoved();
0134 void reexpand();
0135 void rowsRemoved(const QModelIndex &parent, int first, int last);
0136 void verticalScrollbarValueChanged(int value) override;
0137
0138 protected:
0139 QTreeView(QTreeViewPrivate &dd, QWidget *parent = nullptr);
0140 void scrollContentsBy(int dx, int dy) override;
0141 void rowsInserted(const QModelIndex &parent, int start, int end) override;
0142 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
0143
0144 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
0145 int horizontalOffset() const override;
0146 int verticalOffset() const override;
0147
0148 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
0149 QRegion visualRegionForSelection(const QItemSelection &selection) const override;
0150 QModelIndexList selectedIndexes() const override;
0151
0152 void changeEvent(QEvent *event) override;
0153 void timerEvent(QTimerEvent *event) override;
0154 void paintEvent(QPaintEvent *event) override;
0155
0156 void drawTree(QPainter *painter, const QRegion ®ion) const;
0157 virtual void drawRow(QPainter *painter,
0158 const QStyleOptionViewItem &options,
0159 const QModelIndex &index) const;
0160 virtual void drawBranches(QPainter *painter,
0161 const QRect &rect,
0162 const QModelIndex &index) const;
0163
0164 void mousePressEvent(QMouseEvent *event) override;
0165 void mouseReleaseEvent(QMouseEvent *event) override;
0166 void mouseDoubleClickEvent(QMouseEvent *event) override;
0167 void mouseMoveEvent(QMouseEvent *event) override;
0168 void keyPressEvent(QKeyEvent *event) override;
0169 #if QT_CONFIG(draganddrop)
0170 void dragMoveEvent(QDragMoveEvent *event) override;
0171 #endif
0172 bool viewportEvent(QEvent *event) override;
0173
0174 void updateGeometries() override;
0175
0176 QSize viewportSizeHint() const override;
0177
0178 int sizeHintForColumn(int column) const override;
0179 int indexRowSizeHint(const QModelIndex &index) const;
0180 int rowHeight(const QModelIndex &index) const;
0181
0182 void horizontalScrollbarAction(int action) override;
0183
0184 bool isIndexHidden(const QModelIndex &index) const override;
0185 void selectionChanged(const QItemSelection &selected,
0186 const QItemSelection &deselected) override;
0187 void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override;
0188
0189 private:
0190 friend class ::tst_QTreeView;
0191 friend class QAccessibleTable;
0192 friend class QAccessibleTree;
0193 friend class QAccessibleTableCell;
0194 int visualIndex(const QModelIndex &index) const;
0195
0196 Q_DECLARE_PRIVATE(QTreeView)
0197 Q_DISABLE_COPY(QTreeView)
0198 };
0199
0200 QT_END_NAMESPACE
0201
0202 #endif