| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QCOLUMNVIEW_H |
| 5 | #define QCOLUMNVIEW_H |
| 6 | |
| 7 | #include <QtWidgets/qtwidgetsglobal.h> |
| 8 | #include <QtWidgets/qabstractitemview.h> |
| 9 | |
| 10 | QT_REQUIRE_CONFIG(columnview); |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | class QColumnViewPrivate; |
| 15 | |
| 16 | class Q_WIDGETS_EXPORT QColumnView : public QAbstractItemView { |
| 17 | |
| 18 | Q_OBJECT |
| 19 | Q_PROPERTY(bool resizeGripsVisible READ resizeGripsVisible WRITE setResizeGripsVisible) |
| 20 | |
| 21 | Q_SIGNALS: |
| 22 | void updatePreviewWidget(const QModelIndex &index); |
| 23 | |
| 24 | public: |
| 25 | explicit QColumnView(QWidget *parent = nullptr); |
| 26 | ~QColumnView(); |
| 27 | |
| 28 | // QAbstractItemView overloads |
| 29 | QModelIndex indexAt(const QPoint &point) const override; |
| 30 | void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override; |
| 31 | QSize sizeHint() const override; |
| 32 | QRect visualRect(const QModelIndex &index) const override; |
| 33 | void setModel(QAbstractItemModel *model) override; |
| 34 | void setSelectionModel(QItemSelectionModel * selectionModel) override; |
| 35 | void setRootIndex(const QModelIndex &index) override; |
| 36 | void selectAll() override; |
| 37 | |
| 38 | // QColumnView functions |
| 39 | void setResizeGripsVisible(bool visible); |
| 40 | bool resizeGripsVisible() const; |
| 41 | |
| 42 | QWidget *previewWidget() const; |
| 43 | void setPreviewWidget(QWidget *widget); |
| 44 | |
| 45 | void setColumnWidths(const QList<int> &list); |
| 46 | QList<int> columnWidths() const; |
| 47 | |
| 48 | protected: |
| 49 | QColumnView(QColumnViewPrivate &dd, QWidget *parent = nullptr); |
| 50 | |
| 51 | // QAbstractItemView overloads |
| 52 | bool isIndexHidden(const QModelIndex &index) const override; |
| 53 | QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; |
| 54 | void resizeEvent(QResizeEvent *event) override; |
| 55 | void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags command) override; |
| 56 | QRegion visualRegionForSelection(const QItemSelection &selection) const override; |
| 57 | int horizontalOffset() const override; |
| 58 | int verticalOffset() const override; |
| 59 | void rowsInserted(const QModelIndex &parent, int start, int end) override; |
| 60 | void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; |
| 61 | |
| 62 | // QColumnView functions |
| 63 | void scrollContentsBy(int dx, int dy) override; |
| 64 | virtual QAbstractItemView* createColumn(const QModelIndex &rootIndex); |
| 65 | void initializeColumn(QAbstractItemView *column) const; |
| 66 | |
| 67 | private: |
| 68 | Q_DECLARE_PRIVATE(QColumnView) |
| 69 | Q_DISABLE_COPY(QColumnView) |
| 70 | }; |
| 71 | |
| 72 | QT_END_NAMESPACE |
| 73 | |
| 74 | #endif // QCOLUMNVIEW_H |
| 75 | |
| 76 |
