PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/qt/qtbase/src/widgets/itemviews/qabstractitemview.h

https://gitlab.com/x33n/phantomjs
C Header | 379 lines | 266 code | 73 blank | 40 comment | 0 complexity | 2fafb4bd0c8b6dabd39509395cc5cedf MD5 | raw file
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
  4. ** Contact: http://www.qt-project.org/legal
  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 Digia. For licensing terms and
  14. ** conditions see http://qt.digia.com/licensing. For further information
  15. ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 2.1 requirements
  23. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  24. **
  25. ** In addition, as a special exception, Digia gives you certain additional
  26. ** rights. These rights are described in the Digia Qt LGPL Exception
  27. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  28. **
  29. ** GNU General Public License Usage
  30. ** Alternatively, this file may be used under the terms of the GNU
  31. ** General Public License version 3.0 as published by the Free Software
  32. ** Foundation and appearing in the file LICENSE.GPL included in the
  33. ** packaging of this file. Please review the following information to
  34. ** ensure the GNU General Public License version 3.0 requirements will be
  35. ** met: http://www.gnu.org/copyleft/gpl.html.
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #ifndef QABSTRACTITEMVIEW_H
  42. #define QABSTRACTITEMVIEW_H
  43. #include <QtWidgets/qabstractscrollarea.h>
  44. #include <QtCore/qabstractitemmodel.h>
  45. #include <QtCore/qitemselectionmodel.h>
  46. #include <QtWidgets/qabstractitemdelegate.h>
  47. QT_BEGIN_NAMESPACE
  48. #ifndef QT_NO_ITEMVIEWS
  49. class QMenu;
  50. class QDrag;
  51. class QEvent;
  52. class QAbstractItemViewPrivate;
  53. class Q_WIDGETS_EXPORT QAbstractItemView : public QAbstractScrollArea
  54. {
  55. Q_OBJECT
  56. Q_ENUMS(SelectionMode SelectionBehavior ScrollHint ScrollMode DragDropMode)
  57. Q_FLAGS(EditTriggers)
  58. Q_PROPERTY(bool autoScroll READ hasAutoScroll WRITE setAutoScroll)
  59. Q_PROPERTY(int autoScrollMargin READ autoScrollMargin WRITE setAutoScrollMargin)
  60. Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)
  61. Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation)
  62. #ifndef QT_NO_DRAGANDDROP
  63. Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown)
  64. Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
  65. Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode)
  66. Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode)
  67. Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction)
  68. #endif
  69. Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
  70. Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
  71. Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
  72. Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
  73. Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
  74. Q_PROPERTY(ScrollMode verticalScrollMode READ verticalScrollMode WRITE setVerticalScrollMode)
  75. Q_PROPERTY(ScrollMode horizontalScrollMode READ horizontalScrollMode WRITE setHorizontalScrollMode)
  76. public:
  77. enum SelectionMode {
  78. NoSelection,
  79. SingleSelection,
  80. MultiSelection,
  81. ExtendedSelection,
  82. ContiguousSelection
  83. };
  84. enum SelectionBehavior {
  85. SelectItems,
  86. SelectRows,
  87. SelectColumns
  88. };
  89. enum ScrollHint {
  90. EnsureVisible,
  91. PositionAtTop,
  92. PositionAtBottom,
  93. PositionAtCenter
  94. };
  95. enum EditTrigger {
  96. NoEditTriggers = 0,
  97. CurrentChanged = 1,
  98. DoubleClicked = 2,
  99. SelectedClicked = 4,
  100. EditKeyPressed = 8,
  101. AnyKeyPressed = 16,
  102. AllEditTriggers = 31
  103. };
  104. Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
  105. enum ScrollMode {
  106. ScrollPerItem,
  107. ScrollPerPixel
  108. };
  109. explicit QAbstractItemView(QWidget *parent = 0);
  110. ~QAbstractItemView();
  111. virtual void setModel(QAbstractItemModel *model);
  112. QAbstractItemModel *model() const;
  113. virtual void setSelectionModel(QItemSelectionModel *selectionModel);
  114. QItemSelectionModel *selectionModel() const;
  115. void setItemDelegate(QAbstractItemDelegate *delegate);
  116. QAbstractItemDelegate *itemDelegate() const;
  117. void setSelectionMode(QAbstractItemView::SelectionMode mode);
  118. QAbstractItemView::SelectionMode selectionMode() const;
  119. void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
  120. QAbstractItemView::SelectionBehavior selectionBehavior() const;
  121. QModelIndex currentIndex() const;
  122. QModelIndex rootIndex() const;
  123. void setEditTriggers(EditTriggers triggers);
  124. EditTriggers editTriggers() const;
  125. void setVerticalScrollMode(ScrollMode mode);
  126. ScrollMode verticalScrollMode() const;
  127. void setHorizontalScrollMode(ScrollMode mode);
  128. ScrollMode horizontalScrollMode() const;
  129. void setAutoScroll(bool enable);
  130. bool hasAutoScroll() const;
  131. void setAutoScrollMargin(int margin);
  132. int autoScrollMargin() const;
  133. void setTabKeyNavigation(bool enable);
  134. bool tabKeyNavigation() const;
  135. #ifndef QT_NO_DRAGANDDROP
  136. void setDropIndicatorShown(bool enable);
  137. bool showDropIndicator() const;
  138. void setDragEnabled(bool enable);
  139. bool dragEnabled() const;
  140. void setDragDropOverwriteMode(bool overwrite);
  141. bool dragDropOverwriteMode() const;
  142. enum DragDropMode {
  143. NoDragDrop,
  144. DragOnly,
  145. DropOnly,
  146. DragDrop,
  147. InternalMove
  148. };
  149. void setDragDropMode(DragDropMode behavior);
  150. DragDropMode dragDropMode() const;
  151. void setDefaultDropAction(Qt::DropAction dropAction);
  152. Qt::DropAction defaultDropAction() const;
  153. #endif
  154. void setAlternatingRowColors(bool enable);
  155. bool alternatingRowColors() const;
  156. void setIconSize(const QSize &size);
  157. QSize iconSize() const;
  158. void setTextElideMode(Qt::TextElideMode mode);
  159. Qt::TextElideMode textElideMode() const;
  160. virtual void keyboardSearch(const QString &search);
  161. virtual QRect visualRect(const QModelIndex &index) const = 0;
  162. virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) = 0;
  163. virtual QModelIndex indexAt(const QPoint &point) const = 0;
  164. QSize sizeHintForIndex(const QModelIndex &index) const;
  165. virtual int sizeHintForRow(int row) const;
  166. virtual int sizeHintForColumn(int column) const;
  167. void openPersistentEditor(const QModelIndex &index);
  168. void closePersistentEditor(const QModelIndex &index);
  169. void setIndexWidget(const QModelIndex &index, QWidget *widget);
  170. QWidget *indexWidget(const QModelIndex &index) const;
  171. void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate);
  172. QAbstractItemDelegate *itemDelegateForRow(int row) const;
  173. void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate);
  174. QAbstractItemDelegate *itemDelegateForColumn(int column) const;
  175. QAbstractItemDelegate *itemDelegate(const QModelIndex &index) const;
  176. virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
  177. #ifdef Q_NO_USING_KEYWORD
  178. inline void update() { QAbstractScrollArea::update(); }
  179. #else
  180. using QAbstractScrollArea::update;
  181. #endif
  182. public Q_SLOTS:
  183. virtual void reset();
  184. virtual void setRootIndex(const QModelIndex &index);
  185. virtual void doItemsLayout();
  186. virtual void selectAll();
  187. void edit(const QModelIndex &index);
  188. void clearSelection();
  189. void setCurrentIndex(const QModelIndex &index);
  190. void scrollToTop();
  191. void scrollToBottom();
  192. void update(const QModelIndex &index);
  193. protected Q_SLOTS:
  194. virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
  195. virtual void rowsInserted(const QModelIndex &parent, int start, int end);
  196. virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
  197. virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
  198. virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
  199. virtual void updateEditorData();
  200. virtual void updateEditorGeometries();
  201. virtual void updateGeometries();
  202. virtual void verticalScrollbarAction(int action);
  203. virtual void horizontalScrollbarAction(int action);
  204. virtual void verticalScrollbarValueChanged(int value);
  205. virtual void horizontalScrollbarValueChanged(int value);
  206. virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
  207. virtual void commitData(QWidget *editor);
  208. virtual void editorDestroyed(QObject *editor);
  209. Q_SIGNALS:
  210. void pressed(const QModelIndex &index);
  211. void clicked(const QModelIndex &index);
  212. void doubleClicked(const QModelIndex &index);
  213. void activated(const QModelIndex &index);
  214. void entered(const QModelIndex &index);
  215. void viewportEntered();
  216. protected:
  217. QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
  218. void setHorizontalStepsPerItem(int steps);
  219. int horizontalStepsPerItem() const;
  220. void setVerticalStepsPerItem(int steps);
  221. int verticalStepsPerItem() const;
  222. enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight,
  223. MoveHome, MoveEnd, MovePageUp, MovePageDown,
  224. MoveNext, MovePrevious };
  225. virtual QModelIndex moveCursor(CursorAction cursorAction,
  226. Qt::KeyboardModifiers modifiers) = 0;
  227. virtual int horizontalOffset() const = 0;
  228. virtual int verticalOffset() const = 0;
  229. virtual bool isIndexHidden(const QModelIndex &index) const = 0;
  230. virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) = 0;
  231. virtual QRegion visualRegionForSelection(const QItemSelection &selection) const = 0;
  232. virtual QModelIndexList selectedIndexes() const;
  233. virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
  234. virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
  235. const QEvent *event = 0) const;
  236. #ifndef QT_NO_DRAGANDDROP
  237. virtual void startDrag(Qt::DropActions supportedActions);
  238. #endif
  239. virtual QStyleOptionViewItem viewOptions() const;
  240. enum State {
  241. NoState,
  242. DraggingState,
  243. DragSelectingState,
  244. EditingState,
  245. ExpandingState,
  246. CollapsingState,
  247. AnimatingState
  248. };
  249. State state() const;
  250. void setState(State state);
  251. void scheduleDelayedItemsLayout();
  252. void executeDelayedItemsLayout();
  253. void setDirtyRegion(const QRegion &region);
  254. void scrollDirtyRegion(int dx, int dy);
  255. QPoint dirtyRegionOffset() const;
  256. void startAutoScroll();
  257. void stopAutoScroll();
  258. void doAutoScroll();
  259. bool focusNextPrevChild(bool next);
  260. bool event(QEvent *event);
  261. bool viewportEvent(QEvent *event);
  262. void mousePressEvent(QMouseEvent *event);
  263. void mouseMoveEvent(QMouseEvent *event);
  264. void mouseReleaseEvent(QMouseEvent *event);
  265. void mouseDoubleClickEvent(QMouseEvent *event);
  266. #ifndef QT_NO_DRAGANDDROP
  267. void dragEnterEvent(QDragEnterEvent *event);
  268. void dragMoveEvent(QDragMoveEvent *event);
  269. void dragLeaveEvent(QDragLeaveEvent *event);
  270. void dropEvent(QDropEvent *event);
  271. #endif
  272. void focusInEvent(QFocusEvent *event);
  273. void focusOutEvent(QFocusEvent *event);
  274. void keyPressEvent(QKeyEvent *event);
  275. void resizeEvent(QResizeEvent *event);
  276. void timerEvent(QTimerEvent *event);
  277. void inputMethodEvent(QInputMethodEvent *event);
  278. #ifndef QT_NO_DRAGANDDROP
  279. enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport };
  280. DropIndicatorPosition dropIndicatorPosition() const;
  281. #endif
  282. QSize viewportSizeHint() const Q_DECL_OVERRIDE;
  283. private:
  284. Q_DECLARE_PRIVATE(QAbstractItemView)
  285. Q_DISABLE_COPY(QAbstractItemView)
  286. Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex&, int, int))
  287. Q_PRIVATE_SLOT(d_func(), void _q_columnsRemoved(const QModelIndex&, int, int))
  288. Q_PRIVATE_SLOT(d_func(), void _q_columnsInserted(const QModelIndex&, int, int))
  289. Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex&, int, int))
  290. Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int))
  291. Q_PRIVATE_SLOT(d_func(), void _q_columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int))
  292. Q_PRIVATE_SLOT(d_func(), void _q_rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int))
  293. Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
  294. Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
  295. Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
  296. #ifndef QT_NO_GESTURES
  297. Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged())
  298. #endif
  299. friend class QTreeViewPrivate; // needed to compile with MSVC
  300. friend class QListModeViewBase;
  301. friend class QListViewPrivate;
  302. };
  303. Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
  304. #endif // QT_NO_ITEMVIEWS
  305. QT_END_NAMESPACE
  306. #endif // QABSTRACTITEMVIEW_H