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.headerview; 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.vector; 26 import qt.gui.event; 27 import qt.gui.painter; 28 import qt.gui.region; 29 import qt.helpers; 30 import qt.widgets.abstractitemview; 31 import qt.widgets.styleoption; 32 import qt.widgets.widget; 33 version(QT_NO_DATASTREAM){}else 34 import qt.core.bytearray; 35 36 /+ QT_REQUIRE_CONFIG(itemviews); +/ 37 38 39 extern(C++, class) struct QHeaderViewPrivate; 40 /+ class QStyleOptionHeader; +/ 41 42 class /+ Q_WIDGETS_EXPORT +/ QHeaderView : QAbstractItemView 43 { 44 mixin(Q_OBJECT); 45 /+ Q_PROPERTY(bool firstSectionMovable READ isFirstSectionMovable WRITE setFirstSectionMovable) 46 Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown) 47 Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections) 48 Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection) 49 Q_PROPERTY(bool cascadingSectionResizes READ cascadingSectionResizes WRITE setCascadingSectionResizes) 50 Q_PROPERTY(int defaultSectionSize READ defaultSectionSize WRITE setDefaultSectionSize RESET resetDefaultSectionSize) 51 Q_PROPERTY(int minimumSectionSize READ minimumSectionSize WRITE setMinimumSectionSize) 52 Q_PROPERTY(int maximumSectionSize READ maximumSectionSize WRITE setMaximumSectionSize) 53 Q_PROPERTY(Qt::Alignment defaultAlignment READ defaultAlignment WRITE setDefaultAlignment) +/ 54 55 public: 56 57 enum ResizeMode 58 { 59 Interactive, 60 Stretch, 61 Fixed, 62 ResizeToContents, 63 Custom = ResizeMode.Fixed 64 } 65 /+ Q_ENUM(ResizeMode) +/ 66 67 /+ explicit +/this(/+ Qt:: +/qt.core.namespace.Orientation orientation, QWidget parent = null); 68 /+ virtual +/~this(); 69 70 override void setModel(QAbstractItemModel model); 71 72 final /+ Qt:: +/qt.core.namespace.Orientation orientation() const; 73 final int offset() const; 74 final int length() const; 75 override QSize sizeHint() const; 76 override void setVisible(bool v); 77 final int sectionSizeHint(int logicalIndex) const; 78 79 final int visualIndexAt(int position) const; 80 final int logicalIndexAt(int position) const; 81 82 pragma(inline, true) final int logicalIndexAt(int ax, int ay) const 83 { return orientation() == /+ Qt:: +/qt.core.namespace.Orientation.Horizontal ? logicalIndexAt(ax) : logicalIndexAt(ay); } 84 pragma(inline, true) final int logicalIndexAt(ref const(QPoint) apos) const 85 { return logicalIndexAt(apos.x(), apos.y()); } 86 87 final int sectionSize(int logicalIndex) const; 88 final int sectionPosition(int logicalIndex) const; 89 final int sectionViewportPosition(int logicalIndex) const; 90 91 final void moveSection(int from, int to); 92 final void swapSections(int first, int second); 93 final void resizeSection(int logicalIndex, int size); 94 final void resizeSections(QHeaderView.ResizeMode mode); 95 96 final bool isSectionHidden(int logicalIndex) const; 97 final void setSectionHidden(int logicalIndex, bool hide); 98 final int hiddenSectionCount() const; 99 100 pragma(inline, true) final void hideSection(int alogicalIndex) 101 { setSectionHidden(alogicalIndex, true); } 102 pragma(inline, true) final void showSection(int alogicalIndex) 103 { setSectionHidden(alogicalIndex, false); } 104 105 final int count() const; 106 final int visualIndex(int logicalIndex) const; 107 final int logicalIndex(int visualIndex) const; 108 109 final void setSectionsMovable(bool movable); 110 final bool sectionsMovable() const; 111 /+ #if QT_DEPRECATED_SINCE(5, 0) 112 inline QT_DEPRECATED void setMovable(bool movable) { setSectionsMovable(movable); } 113 inline QT_DEPRECATED bool isMovable() const { return sectionsMovable(); } 114 #endif +/ 115 final void setFirstSectionMovable(bool movable); 116 final bool isFirstSectionMovable() const; 117 118 final void setSectionsClickable(bool clickable); 119 final bool sectionsClickable() const; 120 /+ #if QT_DEPRECATED_SINCE(5, 0) 121 inline QT_DEPRECATED void setClickable(bool clickable) { setSectionsClickable(clickable); } 122 inline QT_DEPRECATED bool isClickable() const { return sectionsClickable(); } 123 #endif +/ 124 125 final void setHighlightSections(bool highlight); 126 final bool highlightSections() const; 127 128 final ResizeMode sectionResizeMode(int logicalIndex) const; 129 final void setSectionResizeMode(ResizeMode mode); 130 final void setSectionResizeMode(int logicalIndex, ResizeMode mode); 131 132 final void setResizeContentsPrecision(int precision); 133 final int resizeContentsPrecision() const; 134 135 /+ #if QT_DEPRECATED_SINCE(5, 0) 136 inline QT_DEPRECATED void setResizeMode(ResizeMode mode) 137 { setSectionResizeMode(mode); } 138 inline QT_DEPRECATED void setResizeMode(int logicalindex, ResizeMode mode) 139 { setSectionResizeMode(logicalindex, mode); } 140 inline QT_DEPRECATED ResizeMode resizeMode(int logicalindex) const 141 { return sectionResizeMode(logicalindex); } 142 #endif +/ 143 144 final int stretchSectionCount() const; 145 146 final void setSortIndicatorShown(bool show); 147 final bool isSortIndicatorShown() const; 148 149 final void setSortIndicator(int logicalIndex, /+ Qt:: +/qt.core.namespace.SortOrder order); 150 final int sortIndicatorSection() const; 151 final /+ Qt:: +/qt.core.namespace.SortOrder sortIndicatorOrder() const; 152 153 final bool stretchLastSection() const; 154 final void setStretchLastSection(bool stretch); 155 156 final bool cascadingSectionResizes() const; 157 final void setCascadingSectionResizes(bool enable); 158 159 final int defaultSectionSize() const; 160 final void setDefaultSectionSize(int size); 161 final void resetDefaultSectionSize(); 162 163 final int minimumSectionSize() const; 164 final void setMinimumSectionSize(int size); 165 final int maximumSectionSize() const; 166 final void setMaximumSectionSize(int size); 167 168 final /+ Qt:: +/qt.core.namespace.Alignment defaultAlignment() const; 169 final void setDefaultAlignment(/+ Qt:: +/qt.core.namespace.Alignment alignment); 170 171 override void doItemsLayout(); 172 final bool sectionsMoved() const; 173 final bool sectionsHidden() const; 174 175 version(QT_NO_DATASTREAM){}else 176 { 177 final QByteArray saveState() const; 178 final bool restoreState(ref const(QByteArray) state); 179 } 180 181 override void reset(); 182 183 public /+ Q_SLOTS +/: 184 @QSlot final void setOffset(int offset); 185 @QSlot final void setOffsetToSectionPosition(int visualIndex); 186 @QSlot final void setOffsetToLastSection(); 187 @QSlot final void headerDataChanged(/+ Qt:: +/qt.core.namespace.Orientation orientation, int logicalFirst, int logicalLast); 188 189 /+ Q_SIGNALS +/public: 190 @QSignal final void sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex); 191 @QSignal final void sectionResized(int logicalIndex, int oldSize, int newSize); 192 @QSignal final void sectionPressed(int logicalIndex); 193 @QSignal final void sectionClicked(int logicalIndex); 194 @QSignal final void sectionEntered(int logicalIndex); 195 @QSignal final void sectionDoubleClicked(int logicalIndex); 196 @QSignal final void sectionCountChanged(int oldCount, int newCount); 197 @QSignal final void sectionHandleDoubleClicked(int logicalIndex); 198 @QSignal final void geometriesChanged(); 199 @QSignal final void sortIndicatorChanged(int logicalIndex, /+ Qt:: +/qt.core.namespace.SortOrder order); 200 201 protected /+ Q_SLOTS +/: 202 @QSlot final void updateSection(int logicalIndex); 203 @QSlot final void resizeSections(); 204 @QSlot final void sectionsInserted(ref const(QModelIndex) parent, int logicalFirst, int logicalLast); 205 @QSlot final void sectionsAboutToBeRemoved(ref const(QModelIndex) parent, int logicalFirst, int logicalLast); 206 207 protected: 208 this(ref QHeaderViewPrivate dd, /+ Qt:: +/qt.core.namespace.Orientation orientation, QWidget parent = null); 209 final void initialize(); 210 211 final void initializeSections(); 212 final void initializeSections(int start, int end); 213 override void currentChanged(ref const(QModelIndex) current, ref const(QModelIndex) old); 214 215 override bool event(QEvent e); 216 override void paintEvent(QPaintEvent e); 217 override void mousePressEvent(QMouseEvent e); 218 override void mouseMoveEvent(QMouseEvent e); 219 override void mouseReleaseEvent(QMouseEvent e); 220 override void mouseDoubleClickEvent(QMouseEvent e); 221 override bool viewportEvent(QEvent e); 222 223 /+ virtual +/ void paintSection(QPainter* painter, ref const(QRect) rect, int logicalIndex) const; 224 /+ virtual +/ QSize sectionSizeFromContents(int logicalIndex) const; 225 226 override int horizontalOffset() const; 227 override int verticalOffset() const; 228 override void updateGeometries(); 229 override void scrollContentsBy(int dx, int dy); 230 231 override void dataChanged(ref const(QModelIndex) topLeft, ref const(QModelIndex) bottomRight, ref const(QVector!(int)) roles = globalInitVar!(QVector!(int))); 232 override void rowsInserted(ref const(QModelIndex) parent, int start, int end); 233 234 override QRect visualRect(ref const(QModelIndex) index) const; 235 override void scrollTo(ref const(QModelIndex) index, ScrollHint hint); 236 237 override QModelIndex indexAt(ref const(QPoint) p) const; 238 override bool isIndexHidden(ref const(QModelIndex) index) const; 239 240 override QModelIndex moveCursor(CursorAction, /+ Qt:: +/qt.core.namespace.KeyboardModifiers); 241 override void setSelection(ref const(QRect) rect, QItemSelectionModel.SelectionFlags flags); 242 override QRegion visualRegionForSelection(ref const(QItemSelection) selection) const; 243 final void initStyleOption(QStyleOptionHeader* option) const; 244 245 /+ friend class QTableView; +/ 246 /+ friend class QTreeView; +/ 247 248 private: 249 // ### Qt6: make them protected slots in QHeaderViewPrivate 250 /+ Q_PRIVATE_SLOT(d_func(), void _q_sectionsRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast)) 251 Q_PRIVATE_SLOT(d_func(), void _q_sectionsAboutToBeMoved(const QModelIndex &sourceParent, int logicalStart, int logicalEnd, const QModelIndex &destinationParent, int logicalDestination)) 252 Q_PRIVATE_SLOT(d_func(), void _q_sectionsMoved(const QModelIndex &sourceParent, int logicalStart, int logicalEnd, const QModelIndex &destinationParent, int logicalDestination)) 253 Q_PRIVATE_SLOT(d_func(), void _q_sectionsAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), 254 QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint)) 255 Q_PRIVATE_SLOT(d_func(), void _q_sectionsChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), 256 QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint)) 257 Q_DECLARE_PRIVATE(QHeaderView) +/ 258 /+ Q_DISABLE_COPY(QHeaderView) +/ 259 } 260