qlistview.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QLISTVIEW_H
  40. #define QLISTVIEW_H
  41. #include <QtWidgets/qabstractitemview.h>
  42. QT_BEGIN_NAMESPACE
  43. #ifndef QT_NO_LISTVIEW
  44. class QListViewPrivate;
  45. class Q_WIDGETS_EXPORT QListView : public QAbstractItemView
  46. {
  47. Q_OBJECT
  48. Q_PROPERTY(Movement movement READ movement WRITE setMovement)
  49. Q_PROPERTY(Flow flow READ flow WRITE setFlow)
  50. Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
  51. Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
  52. Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
  53. Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
  54. Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
  55. Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
  56. Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
  57. Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
  58. Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
  59. Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
  60. Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
  61. public:
  62. enum Movement { Static, Free, Snap };
  63. Q_ENUM(Movement)
  64. enum Flow { LeftToRight, TopToBottom };
  65. Q_ENUM(Flow)
  66. enum ResizeMode { Fixed, Adjust };
  67. Q_ENUM(ResizeMode)
  68. enum LayoutMode { SinglePass, Batched };
  69. Q_ENUM(LayoutMode)
  70. enum ViewMode { ListMode, IconMode };
  71. Q_ENUM(ViewMode)
  72. explicit QListView(QWidget *parent = Q_NULLPTR);
  73. ~QListView();
  74. void setMovement(Movement movement);
  75. Movement movement() const;
  76. void setFlow(Flow flow);
  77. Flow flow() const;
  78. void setWrapping(bool enable);
  79. bool isWrapping() const;
  80. void setResizeMode(ResizeMode mode);
  81. ResizeMode resizeMode() const;
  82. void setLayoutMode(LayoutMode mode);
  83. LayoutMode layoutMode() const;
  84. void setSpacing(int space);
  85. int spacing() const;
  86. void setBatchSize(int batchSize);
  87. int batchSize() const;
  88. void setGridSize(const QSize &size);
  89. QSize gridSize() const;
  90. void setViewMode(ViewMode mode);
  91. ViewMode viewMode() const;
  92. void clearPropertyFlags();
  93. bool isRowHidden(int row) const;
  94. void setRowHidden(int row, bool hide);
  95. void setModelColumn(int column);
  96. int modelColumn() const;
  97. void setUniformItemSizes(bool enable);
  98. bool uniformItemSizes() const;
  99. void setWordWrap(bool on);
  100. bool wordWrap() const;
  101. void setSelectionRectVisible(bool show);
  102. bool isSelectionRectVisible() const;
  103. QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
  104. void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;
  105. QModelIndex indexAt(const QPoint &p) const Q_DECL_OVERRIDE;
  106. void doItemsLayout() Q_DECL_OVERRIDE;
  107. void reset() Q_DECL_OVERRIDE;
  108. void setRootIndex(const QModelIndex &index) Q_DECL_OVERRIDE;
  109. Q_SIGNALS:
  110. void indexesMoved(const QModelIndexList &indexes);
  111. protected:
  112. QListView(QListViewPrivate &, QWidget *parent = Q_NULLPTR);
  113. bool event(QEvent *e) Q_DECL_OVERRIDE;
  114. void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
  115. void resizeContents(int width, int height);
  116. QSize contentsSize() const;
  117. void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) Q_DECL_OVERRIDE;
  118. void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
  119. void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
  120. void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
  121. void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
  122. #ifndef QT_NO_WHEELEVENT
  123. void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
  124. #endif
  125. void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
  126. void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
  127. #ifndef QT_NO_DRAGANDDROP
  128. void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
  129. void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
  130. void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
  131. void startDrag(Qt::DropActions supportedActions) Q_DECL_OVERRIDE;
  132. #endif // QT_NO_DRAGANDDROP
  133. QStyleOptionViewItem viewOptions() const Q_DECL_OVERRIDE;
  134. void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
  135. int horizontalOffset() const Q_DECL_OVERRIDE;
  136. int verticalOffset() const Q_DECL_OVERRIDE;
  137. QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
  138. QRect rectForIndex(const QModelIndex &index) const;
  139. void setPositionForIndex(const QPoint &position, const QModelIndex &index);
  140. void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) Q_DECL_OVERRIDE;
  141. QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
  142. QModelIndexList selectedIndexes() const Q_DECL_OVERRIDE;
  143. void updateGeometries() Q_DECL_OVERRIDE;
  144. bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
  145. void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) Q_DECL_OVERRIDE;
  146. void currentChanged(const QModelIndex &current, const QModelIndex &previous) Q_DECL_OVERRIDE;
  147. QSize viewportSizeHint() const Q_DECL_OVERRIDE;
  148. private:
  149. int visualIndex(const QModelIndex &index) const;
  150. Q_DECLARE_PRIVATE(QListView)
  151. Q_DISABLE_COPY(QListView)
  152. };
  153. #endif // QT_NO_LISTVIEW
  154. QT_END_NAMESPACE
  155. #endif // QLISTVIEW_H