Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:36

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 
0004 #ifndef QLISTVIEW_H
0005 #define QLISTVIEW_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qabstractitemview.h>
0009 
0010 QT_REQUIRE_CONFIG(listview);
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 class QListViewPrivate;
0015 
0016 class Q_WIDGETS_EXPORT QListView : public QAbstractItemView
0017 {
0018     Q_OBJECT
0019     Q_PROPERTY(Movement movement READ movement WRITE setMovement)
0020     Q_PROPERTY(Flow flow READ flow WRITE setFlow)
0021     Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
0022     Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
0023     Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
0024     Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
0025     Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
0026     Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
0027     Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
0028     Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
0029     Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
0030     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
0031     Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
0032     Q_PROPERTY(Qt::Alignment itemAlignment READ itemAlignment WRITE setItemAlignment)
0033 
0034 public:
0035     enum Movement { Static, Free, Snap };
0036     Q_ENUM(Movement)
0037     enum Flow { LeftToRight, TopToBottom };
0038     Q_ENUM(Flow)
0039     enum ResizeMode { Fixed, Adjust };
0040     Q_ENUM(ResizeMode)
0041     enum LayoutMode { SinglePass, Batched };
0042     Q_ENUM(LayoutMode)
0043     enum ViewMode { ListMode, IconMode };
0044     Q_ENUM(ViewMode)
0045 
0046     explicit QListView(QWidget *parent = nullptr);
0047     ~QListView();
0048 
0049     void setMovement(Movement movement);
0050     Movement movement() const;
0051 
0052     void setFlow(Flow flow);
0053     Flow flow() const;
0054 
0055     void setWrapping(bool enable);
0056     bool isWrapping() const;
0057 
0058     void setResizeMode(ResizeMode mode);
0059     ResizeMode resizeMode() const;
0060 
0061     void setLayoutMode(LayoutMode mode);
0062     LayoutMode layoutMode() const;
0063 
0064     void setSpacing(int space);
0065     int spacing() const;
0066 
0067     void setBatchSize(int batchSize);
0068     int batchSize() const;
0069 
0070     void setGridSize(const QSize &size);
0071     QSize gridSize() const;
0072 
0073     void setViewMode(ViewMode mode);
0074     ViewMode viewMode() const;
0075 
0076     void clearPropertyFlags();
0077 
0078     bool isRowHidden(int row) const;
0079     void setRowHidden(int row, bool hide);
0080 
0081     void setModelColumn(int column);
0082     int modelColumn() const;
0083 
0084     void setUniformItemSizes(bool enable);
0085     bool uniformItemSizes() const;
0086 
0087     void setWordWrap(bool on);
0088     bool wordWrap() const;
0089 
0090     void setSelectionRectVisible(bool show);
0091     bool isSelectionRectVisible() const;
0092 
0093     void setItemAlignment(Qt::Alignment alignment);
0094     Qt::Alignment itemAlignment() const;
0095 
0096     QRect visualRect(const QModelIndex &index) const override;
0097     void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
0098     QModelIndex indexAt(const QPoint &p) const override;
0099 
0100     void doItemsLayout() override;
0101     void reset() override;
0102     void setRootIndex(const QModelIndex &index) override;
0103 
0104 Q_SIGNALS:
0105     void indexesMoved(const QModelIndexList &indexes);
0106 
0107 protected:
0108     QListView(QListViewPrivate &, QWidget *parent = nullptr);
0109 
0110     bool event(QEvent *e) override;
0111 
0112     void scrollContentsBy(int dx, int dy) override;
0113 
0114     void resizeContents(int width, int height);
0115     QSize contentsSize() const;
0116 
0117     void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
0118                      const QList<int> &roles = QList<int>()) override;
0119     void rowsInserted(const QModelIndex &parent, int start, int end) override;
0120     void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
0121 
0122     void mouseMoveEvent(QMouseEvent *e) override;
0123     void mouseReleaseEvent(QMouseEvent *e) override;
0124 #if QT_CONFIG(wheelevent)
0125     void wheelEvent(QWheelEvent *e) override;
0126 #endif
0127 
0128     void timerEvent(QTimerEvent *e) override;
0129     void resizeEvent(QResizeEvent *e) override;
0130 #if QT_CONFIG(draganddrop)
0131     void dragMoveEvent(QDragMoveEvent *e) override;
0132     void dragLeaveEvent(QDragLeaveEvent *e) override;
0133     void dropEvent(QDropEvent *e) override;
0134     void startDrag(Qt::DropActions supportedActions) override;
0135 #endif // QT_CONFIG(draganddrop)
0136 
0137     void initViewItemOption(QStyleOptionViewItem *option) const override;
0138     void paintEvent(QPaintEvent *e) override;
0139 
0140     int horizontalOffset() const override;
0141     int verticalOffset() const override;
0142     QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
0143     QRect rectForIndex(const QModelIndex &index) const;
0144     void setPositionForIndex(const QPoint &position, const QModelIndex &index);
0145 
0146     void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
0147     QRegion visualRegionForSelection(const QItemSelection &selection) const override;
0148     QModelIndexList selectedIndexes() const override;
0149 
0150     void updateGeometries() override;
0151 
0152     bool isIndexHidden(const QModelIndex &index) const override;
0153 
0154     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
0155     void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
0156 
0157     QSize viewportSizeHint() const override;
0158 
0159 private:
0160     int visualIndex(const QModelIndex &index) const;
0161     friend class QCommonListViewBase;
0162 
0163     Q_DECLARE_PRIVATE(QListView)
0164     Q_DISABLE_COPY(QListView)
0165 };
0166 
0167 QT_END_NAMESPACE
0168 
0169 #endif // QLISTVIEW_H