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.tableview; 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.gui.event; 26 import qt.gui.region; 27 import qt.helpers; 28 import qt.widgets.abstractitemview; 29 import qt.widgets.headerview; 30 import qt.widgets.styleoption; 31 import qt.widgets.widget; 32 33 /+ QT_REQUIRE_CONFIG(tableview); 34 35 36 class QHeaderView; +/ 37 extern(C++, class) struct QTableViewPrivate; 38 39 class /+ Q_WIDGETS_EXPORT +/ QTableView : QAbstractItemView 40 { 41 mixin(Q_OBJECT); 42 /+ Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid) 43 Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle) 44 Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) 45 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) 46 #if QT_CONFIG(abstractbutton) 47 Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled) 48 #endif +/ 49 50 public: 51 /+ explicit +/this(QWidget parent = null); 52 ~this(); 53 54 override void setModel(QAbstractItemModel model); 55 override void setRootIndex(ref const(QModelIndex) index); 56 override void setSelectionModel(QItemSelectionModel selectionModel); 57 override void doItemsLayout(); 58 59 final QHeaderView horizontalHeader() const; 60 final QHeaderView verticalHeader() const; 61 final void setHorizontalHeader(QHeaderView header); 62 final void setVerticalHeader(QHeaderView header); 63 64 final int rowViewportPosition(int row) const; 65 final int rowAt(int y) const; 66 67 final void setRowHeight(int row, int height); 68 final int rowHeight(int row) const; 69 70 final int columnViewportPosition(int column) const; 71 final int columnAt(int x) const; 72 73 final void setColumnWidth(int column, int width); 74 final int columnWidth(int column) const; 75 76 final bool isRowHidden(int row) const; 77 final void setRowHidden(int row, bool hide); 78 79 final bool isColumnHidden(int column) const; 80 final void setColumnHidden(int column, bool hide); 81 82 final void setSortingEnabled(bool enable); 83 final bool isSortingEnabled() const; 84 85 final bool showGrid() const; 86 87 final /+ Qt:: +/qt.core.namespace.PenStyle gridStyle() const; 88 final void setGridStyle(/+ Qt:: +/qt.core.namespace.PenStyle style); 89 90 final void setWordWrap(bool on); 91 final bool wordWrap() const; 92 93 /+ #if QT_CONFIG(abstractbutton) +/ 94 final void setCornerButtonEnabled(bool enable); 95 final bool isCornerButtonEnabled() const; 96 /+ #endif +/ 97 98 override QRect visualRect(ref const(QModelIndex) index) const; 99 override void scrollTo(ref const(QModelIndex) index, ScrollHint hint = ScrollHint.EnsureVisible); 100 override QModelIndex indexAt(ref const(QPoint) p) const; 101 102 final void setSpan(int row, int column, int rowSpan, int columnSpan); 103 final int rowSpan(int row, int column) const; 104 final int columnSpan(int row, int column) const; 105 final void clearSpans(); 106 107 108 public /+ Q_SLOTS +/: 109 @QSlot final void selectRow(int row); 110 @QSlot final void selectColumn(int column); 111 @QSlot final void hideRow(int row); 112 @QSlot final void hideColumn(int column); 113 @QSlot final void showRow(int row); 114 @QSlot final void showColumn(int column); 115 @QSlot final void resizeRowToContents(int row); 116 @QSlot final void resizeRowsToContents(); 117 @QSlot final void resizeColumnToContents(int column); 118 @QSlot final void resizeColumnsToContents(); 119 /+ #if QT_DEPRECATED_SINCE(5, 13) +/ 120 /+ QT_DEPRECATED_X ("Use QTableView::sortByColumn(int column, Qt::SortOrder order) instead") +/ 121 @QSlot final void sortByColumn(int column); 122 /+ #endif +/ 123 @QSlot final void sortByColumn(int column, /+ Qt:: +/qt.core.namespace.SortOrder order); 124 @QSlot final void setShowGrid(bool show); 125 126 protected /+ Q_SLOTS +/: 127 @QSlot final void rowMoved(int row, int oldIndex, int newIndex); 128 @QSlot final void columnMoved(int column, int oldIndex, int newIndex); 129 @QSlot final void rowResized(int row, int oldHeight, int newHeight); 130 @QSlot final void columnResized(int column, int oldWidth, int newWidth); 131 @QSlot final void rowCountChanged(int oldCount, int newCount); 132 @QSlot final void columnCountChanged(int oldCount, int newCount); 133 134 protected: 135 this(ref QTableViewPrivate , QWidget parent); 136 override void scrollContentsBy(int dx, int dy); 137 138 override QStyleOptionViewItem viewOptions() const; 139 override void paintEvent(QPaintEvent e); 140 141 override void timerEvent(QTimerEvent event); 142 143 override int horizontalOffset() const; 144 override int verticalOffset() const; 145 override QModelIndex moveCursor(CursorAction cursorAction, /+ Qt:: +/qt.core.namespace.KeyboardModifiers modifiers); 146 147 override void setSelection(ref const(QRect) rect, QItemSelectionModel.SelectionFlags command); 148 override QRegion visualRegionForSelection(ref const(QItemSelection) selection) const; 149 override QModelIndexList selectedIndexes() const; 150 151 override void updateGeometries(); 152 153 override QSize viewportSizeHint() const; 154 155 override int sizeHintForRow(int row) const; 156 override int sizeHintForColumn(int column) const; 157 158 override void verticalScrollbarAction(int action); 159 override void horizontalScrollbarAction(int action); 160 161 override bool isIndexHidden(ref const(QModelIndex) index) const; 162 163 override void selectionChanged(ref const(QItemSelection) selected, 164 ref const(QItemSelection) deselected); 165 override void currentChanged(ref const(QModelIndex) current, 166 ref const(QModelIndex) previous); 167 168 private: 169 /+ friend class QAccessibleItemView; +/ 170 final int visualIndex(ref const(QModelIndex) index) const; 171 172 /+ Q_DECLARE_PRIVATE(QTableView) +/ 173 /+ Q_DISABLE_COPY(QTableView) +/ 174 /+ Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int)) 175 Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int)) 176 Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedRows(QModelIndex,int,int)) 177 Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int)) 178 Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int)) 179 Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int)) 180 Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order)) +/ 181 } 182