1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.widgets.treeview; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.abstractitemmodel; 19 import qt.core.coreevent; 20 import qt.core.itemselectionmodel; 21 import qt.core.namespace; 22 import qt.core.point; 23 import qt.core.rect; 24 import qt.core.size; 25 import qt.core.string; 26 import qt.core.vector; 27 import qt.gui.event; 28 import qt.gui.painter; 29 import qt.gui.region; 30 import qt.helpers; 31 import qt.widgets.abstractitemview; 32 import qt.widgets.headerview; 33 import qt.widgets.styleoption; 34 import qt.widgets.widget; 35 36 /+ class tst_QTreeView; 37 38 QT_REQUIRE_CONFIG(treeview); +/ 39 40 41 extern(C++, class) struct QTreeViewPrivate; 42 /+ class QHeaderView; +/ 43 44 class /+ Q_WIDGETS_EXPORT +/ QTreeView : QAbstractItemView 45 { 46 mixin(Q_OBJECT); 47 /+ Q_PROPERTY(int autoExpandDelay READ autoExpandDelay WRITE setAutoExpandDelay) 48 Q_PROPERTY(int indentation READ indentation WRITE setIndentation RESET resetIndentation) 49 Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated) 50 Q_PROPERTY(bool uniformRowHeights READ uniformRowHeights WRITE setUniformRowHeights) 51 Q_PROPERTY(bool itemsExpandable READ itemsExpandable WRITE setItemsExpandable) 52 Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) 53 Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated) 54 Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus) 55 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) 56 Q_PROPERTY(bool headerHidden READ isHeaderHidden WRITE setHeaderHidden) 57 Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick) +/ 58 59 public: 60 /+ explicit +/this(QWidget parent = null); 61 ~this(); 62 63 override void setModel(QAbstractItemModel model); 64 override void setRootIndex(ref const(QModelIndex) index); 65 override void setSelectionModel(QItemSelectionModel selectionModel); 66 67 final QHeaderView header() const; 68 final void setHeader(QHeaderView header); 69 70 final int autoExpandDelay() const; 71 final void setAutoExpandDelay(int delay); 72 73 final int indentation() const; 74 final void setIndentation(int i); 75 final void resetIndentation(); 76 77 final bool rootIsDecorated() const; 78 final void setRootIsDecorated(bool show); 79 80 final bool uniformRowHeights() const; 81 final void setUniformRowHeights(bool uniform); 82 83 final bool itemsExpandable() const; 84 final void setItemsExpandable(bool enable); 85 86 final bool expandsOnDoubleClick() const; 87 final void setExpandsOnDoubleClick(bool enable); 88 89 final int columnViewportPosition(int column) const; 90 final int columnWidth(int column) const; 91 final void setColumnWidth(int column, int width); 92 final int columnAt(int x) const; 93 94 final bool isColumnHidden(int column) const; 95 final void setColumnHidden(int column, bool hide); 96 97 final bool isHeaderHidden() const; 98 final void setHeaderHidden(bool hide); 99 100 final bool isRowHidden(int row, ref const(QModelIndex) parent) const; 101 final void setRowHidden(int row, ref const(QModelIndex) parent, bool hide); 102 103 final bool isFirstColumnSpanned(int row, ref const(QModelIndex) parent) const; 104 final void setFirstColumnSpanned(int row, ref const(QModelIndex) parent, bool span); 105 106 final bool isExpanded(ref const(QModelIndex) index) const; 107 final void setExpanded(ref const(QModelIndex) index, bool expand); 108 109 final void setSortingEnabled(bool enable); 110 final bool isSortingEnabled() const; 111 112 final void setAnimated(bool enable); 113 final bool isAnimated() const; 114 115 final void setAllColumnsShowFocus(bool enable); 116 final bool allColumnsShowFocus() const; 117 118 final void setWordWrap(bool on); 119 final bool wordWrap() const; 120 121 final void setTreePosition(int logicalIndex); 122 final int treePosition() const; 123 124 override void keyboardSearch(ref const(QString) search); 125 126 override QRect visualRect(ref const(QModelIndex) index) const; 127 override void scrollTo(ref const(QModelIndex) index, ScrollHint hint = ScrollHint.EnsureVisible); 128 override QModelIndex indexAt(ref const(QPoint) p) const; 129 final QModelIndex indexAbove(ref const(QModelIndex) index) const; 130 final QModelIndex indexBelow(ref const(QModelIndex) index) const; 131 132 override void doItemsLayout(); 133 override void reset(); 134 135 136 override void dataChanged(ref const(QModelIndex) topLeft, ref const(QModelIndex) bottomRight, ref const(QVector!(int)) roles = globalInitVar!(QVector!(int))); 137 override void selectAll(); 138 139 /+ Q_SIGNALS +/public: 140 @QSignal final void expanded(ref const(QModelIndex) index); 141 @QSignal final void collapsed(ref const(QModelIndex) index); 142 143 public /+ Q_SLOTS +/: 144 @QSlot final void hideColumn(int column); 145 @QSlot final void showColumn(int column); 146 @QSlot final void expand(ref const(QModelIndex) index); 147 @QSlot final void collapse(ref const(QModelIndex) index); 148 @QSlot final void resizeColumnToContents(int column); 149 /+ #if QT_DEPRECATED_SINCE(5, 13) +/ 150 /+ QT_DEPRECATED_X ("Use QTreeView::sortByColumn(int column, Qt::SortOrder order) instead") +/ 151 @QSlot final void sortByColumn(int column); 152 /+ #endif +/ 153 @QSlot final void sortByColumn(int column, /+ Qt:: +/qt.core.namespace.SortOrder order); 154 @QSlot final void expandAll(); 155 @QSlot final void expandRecursively(ref const(QModelIndex) index, int depth = -1); 156 @QSlot final void collapseAll(); 157 @QSlot final void expandToDepth(int depth); 158 159 protected /+ Q_SLOTS +/: 160 @QSlot final void columnResized(int column, int oldSize, int newSize); 161 @QSlot final void columnCountChanged(int oldCount, int newCount); 162 @QSlot final void columnMoved(); 163 @QSlot final void reexpand(); 164 @QSlot final void rowsRemoved(ref const(QModelIndex) parent, int first, int last); 165 @QSlot override void verticalScrollbarValueChanged(int value); 166 167 protected: 168 this(ref QTreeViewPrivate dd, QWidget parent = null); 169 override void scrollContentsBy(int dx, int dy); 170 override void rowsInserted(ref const(QModelIndex) parent, int start, int end); 171 override void rowsAboutToBeRemoved(ref const(QModelIndex) parent, int start, int end); 172 173 override QModelIndex moveCursor(CursorAction cursorAction, /+ Qt:: +/qt.core.namespace.KeyboardModifiers modifiers); 174 override int horizontalOffset() const; 175 override int verticalOffset() const; 176 177 override void setSelection(ref const(QRect) rect, QItemSelectionModel.SelectionFlags command); 178 override QRegion visualRegionForSelection(ref const(QItemSelection) selection) const; 179 override QModelIndexList selectedIndexes() const; 180 181 override void timerEvent(QTimerEvent event); 182 override void paintEvent(QPaintEvent event); 183 184 final void drawTree(QPainter* painter, ref const(QRegion) region) const; 185 /+ virtual +/ void drawRow(QPainter* painter, 186 ref const(QStyleOptionViewItem) options, 187 ref const(QModelIndex) index) const; 188 /+ virtual +/ void drawBranches(QPainter* painter, 189 ref const(QRect) rect, 190 ref const(QModelIndex) index) const; 191 192 override void mousePressEvent(QMouseEvent event); 193 override void mouseReleaseEvent(QMouseEvent event); 194 override void mouseDoubleClickEvent(QMouseEvent event); 195 override void mouseMoveEvent(QMouseEvent event); 196 override void keyPressEvent(QKeyEvent event); 197 /+ #if QT_CONFIG(draganddrop) +/ 198 override void dragMoveEvent(QDragMoveEvent event); 199 /+ #endif +/ 200 override bool viewportEvent(QEvent event); 201 202 override void updateGeometries(); 203 204 override QSize viewportSizeHint() const; 205 206 override int sizeHintForColumn(int column) const; 207 final int indexRowSizeHint(ref const(QModelIndex) index) const; 208 final int rowHeight(ref const(QModelIndex) index) const; 209 210 override void horizontalScrollbarAction(int action); 211 212 override bool isIndexHidden(ref const(QModelIndex) index) const; 213 override void selectionChanged(ref const(QItemSelection) selected, 214 ref const(QItemSelection) deselected); 215 override void currentChanged(ref const(QModelIndex) current, ref const(QModelIndex) previous); 216 217 private: 218 /+ friend class ::tst_QTreeView; +/ 219 /+ friend class QAccessibleTable; +/ 220 /+ friend class QAccessibleTree; +/ 221 /+ friend class QAccessibleTableCell; +/ 222 final int visualIndex(ref const(QModelIndex) index) const; 223 224 /+ Q_DECLARE_PRIVATE(QTreeView) +/ 225 /+ Q_DISABLE_COPY(QTreeView) +/ 226 /+ #if QT_CONFIG(animation) 227 Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation()) 228 #endif // animation 229 Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset()) 230 Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order)) +/ 231 } 232