Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:24:21

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QTABLEVIEW_H
0006 #define QTABLEVIEW_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtWidgets/qabstractitemview.h>
0010 
0011 QT_REQUIRE_CONFIG(tableview);
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 class QHeaderView;
0016 class QTableViewPrivate;
0017 
0018 class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
0022     Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
0023     Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
0024     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
0025 #if QT_CONFIG(abstractbutton)
0026     Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
0027 #endif
0028 
0029 public:
0030     explicit QTableView(QWidget *parent = nullptr);
0031     ~QTableView();
0032 
0033     void setModel(QAbstractItemModel *model) override;
0034     void setRootIndex(const QModelIndex &index) override;
0035     void setSelectionModel(QItemSelectionModel *selectionModel) override;
0036     void doItemsLayout() override;
0037 
0038     QHeaderView *horizontalHeader() const;
0039     QHeaderView *verticalHeader() const;
0040     void setHorizontalHeader(QHeaderView *header);
0041     void setVerticalHeader(QHeaderView *header);
0042 
0043     int rowViewportPosition(int row) const;
0044     int rowAt(int y) const;
0045 
0046     void setRowHeight(int row, int height);
0047     int rowHeight(int row) const;
0048 
0049     int columnViewportPosition(int column) const;
0050     int columnAt(int x) const;
0051 
0052     void setColumnWidth(int column, int width);
0053     int columnWidth(int column) const;
0054 
0055     bool isRowHidden(int row) const;
0056     void setRowHidden(int row, bool hide);
0057 
0058     bool isColumnHidden(int column) const;
0059     void setColumnHidden(int column, bool hide);
0060 
0061     void setSortingEnabled(bool enable);
0062     bool isSortingEnabled() const;
0063 
0064     bool showGrid() const;
0065 
0066     Qt::PenStyle gridStyle() const;
0067     void setGridStyle(Qt::PenStyle style);
0068 
0069     void setWordWrap(bool on);
0070     bool wordWrap() const;
0071 
0072 #if QT_CONFIG(abstractbutton)
0073     void setCornerButtonEnabled(bool enable);
0074     bool isCornerButtonEnabled() const;
0075 #endif
0076 
0077     QRect visualRect(const QModelIndex &index) const override;
0078     void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
0079     QModelIndex indexAt(const QPoint &p) const override;
0080 
0081     void setSpan(int row, int column, int rowSpan, int columnSpan);
0082     int rowSpan(int row, int column) const;
0083     int columnSpan(int row, int column) const;
0084     void clearSpans();
0085 
0086 
0087 public Q_SLOTS:
0088     void selectRow(int row);
0089     void selectColumn(int column);
0090     void hideRow(int row);
0091     void hideColumn(int column);
0092     void showRow(int row);
0093     void showColumn(int column);
0094     void resizeRowToContents(int row);
0095     void resizeRowsToContents();
0096     void resizeColumnToContents(int column);
0097     void resizeColumnsToContents();
0098     void sortByColumn(int column, Qt::SortOrder order);
0099     void setShowGrid(bool show);
0100 
0101 protected Q_SLOTS:
0102     void rowMoved(int row, int oldIndex, int newIndex);
0103     void columnMoved(int column, int oldIndex, int newIndex);
0104     void rowResized(int row, int oldHeight, int newHeight);
0105     void columnResized(int column, int oldWidth, int newWidth);
0106     void rowCountChanged(int oldCount, int newCount);
0107     void columnCountChanged(int oldCount, int newCount);
0108 
0109 protected:
0110     QTableView(QTableViewPrivate &, QWidget *parent);
0111     void scrollContentsBy(int dx, int dy) override;
0112 
0113     void initViewItemOption(QStyleOptionViewItem *option) const override;
0114     void paintEvent(QPaintEvent *e) override;
0115 
0116     void timerEvent(QTimerEvent *event) override;
0117 
0118 #if QT_CONFIG(draganddrop)
0119     void dropEvent(QDropEvent *event) override;
0120 #endif
0121 
0122     int horizontalOffset() const override;
0123     int verticalOffset() const override;
0124     QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
0125 
0126     void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
0127     QRegion visualRegionForSelection(const QItemSelection &selection) const override;
0128     QModelIndexList selectedIndexes() const override;
0129 
0130     void updateGeometries() override;
0131 
0132     QSize viewportSizeHint() const override;
0133 
0134     int sizeHintForRow(int row) const override;
0135     int sizeHintForColumn(int column) const override;
0136 
0137     void verticalScrollbarAction(int action) override;
0138     void horizontalScrollbarAction(int action) override;
0139 
0140     bool isIndexHidden(const QModelIndex &index) const override;
0141 
0142     void selectionChanged(const QItemSelection &selected,
0143                           const QItemSelection &deselected) override;
0144     void currentChanged(const QModelIndex &current,
0145                           const QModelIndex &previous) override;
0146 
0147 private:
0148     friend class QAccessibleItemView;
0149     int visualIndex(const QModelIndex &index) const;
0150 
0151     Q_DECLARE_PRIVATE(QTableView)
0152     Q_DISABLE_COPY(QTableView)
0153 };
0154 
0155 QT_END_NAMESPACE
0156 
0157 #endif // QTABLEVIEW_H