1// qabstractitemview.sip generated by MetaSIP
2//
3// This file is part of the QtWidgets Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23class QAbstractItemView : QAbstractScrollArea
24{
25%TypeHeaderCode
26#include <qabstractitemview.h>
27%End
28
29public:
30    enum DragDropMode
31    {
32        NoDragDrop,
33        DragOnly,
34        DropOnly,
35        DragDrop,
36        InternalMove,
37    };
38
39    enum EditTrigger
40    {
41        NoEditTriggers,
42        CurrentChanged,
43        DoubleClicked,
44        SelectedClicked,
45        EditKeyPressed,
46        AnyKeyPressed,
47        AllEditTriggers,
48    };
49
50    typedef QFlags<QAbstractItemView::EditTrigger> EditTriggers;
51
52    enum ScrollHint
53    {
54        EnsureVisible,
55        PositionAtTop,
56        PositionAtBottom,
57        PositionAtCenter,
58    };
59
60    enum ScrollMode
61    {
62        ScrollPerItem,
63        ScrollPerPixel,
64    };
65
66    enum SelectionBehavior
67    {
68        SelectItems,
69        SelectRows,
70        SelectColumns,
71    };
72
73    enum SelectionMode
74    {
75        NoSelection,
76        SingleSelection,
77        MultiSelection,
78        ExtendedSelection,
79        ContiguousSelection,
80    };
81
82    explicit QAbstractItemView(QWidget *parent /TransferThis/ = 0);
83    virtual ~QAbstractItemView();
84    virtual void setModel(QAbstractItemModel *model /KeepReference/);
85    QAbstractItemModel *model() const;
86    virtual void setSelectionModel(QItemSelectionModel *selectionModel /KeepReference/);
87    QItemSelectionModel *selectionModel() const;
88    void setItemDelegate(QAbstractItemDelegate *delegate /KeepReference/);
89    QAbstractItemDelegate *itemDelegate() const;
90    void setSelectionMode(QAbstractItemView::SelectionMode mode);
91    QAbstractItemView::SelectionMode selectionMode() const;
92    void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
93    QAbstractItemView::SelectionBehavior selectionBehavior() const;
94    QModelIndex currentIndex() const;
95    QModelIndex rootIndex() const;
96    void setEditTriggers(QAbstractItemView::EditTriggers triggers);
97    QAbstractItemView::EditTriggers editTriggers() const;
98    void setAutoScroll(bool enable);
99    bool hasAutoScroll() const;
100    void setTabKeyNavigation(bool enable);
101    bool tabKeyNavigation() const;
102    void setDropIndicatorShown(bool enable);
103    bool showDropIndicator() const;
104    void setDragEnabled(bool enable);
105    bool dragEnabled() const;
106    void setAlternatingRowColors(bool enable);
107    bool alternatingRowColors() const;
108    void setIconSize(const QSize &size);
109    QSize iconSize() const;
110    void setTextElideMode(Qt::TextElideMode mode);
111    Qt::TextElideMode textElideMode() const;
112    virtual void keyboardSearch(const QString &search);
113    virtual QRect visualRect(const QModelIndex &index) const = 0;
114    virtual void scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint = QAbstractItemView::EnsureVisible) = 0;
115    virtual QModelIndex indexAt(const QPoint &p) const = 0;
116    QSize sizeHintForIndex(const QModelIndex &index) const;
117    virtual int sizeHintForRow(int row) const;
118    virtual int sizeHintForColumn(int column) const;
119    void openPersistentEditor(const QModelIndex &index);
120    void closePersistentEditor(const QModelIndex &index);
121    void setIndexWidget(const QModelIndex &index, QWidget *widget /Transfer/);
122%MethodCode
123        // We have to break the association with any existing widget.
124        QWidget *w = sipCpp->indexWidget(*a0);
125
126        if (w)
127        {
128            PyObject *wo = sipGetPyObject(w, sipType_QWidget);
129
130            if (wo)
131                sipTransferTo(wo, 0);
132        }
133
134        Py_BEGIN_ALLOW_THREADS
135        sipCpp->setIndexWidget(*a0, a1);
136        Py_END_ALLOW_THREADS
137%End
138
139    QWidget *indexWidget(const QModelIndex &index) const;
140
141public slots:
142    virtual void reset();
143    virtual void setRootIndex(const QModelIndex &index);
144    virtual void selectAll();
145    void edit(const QModelIndex &index);
146    void clearSelection();
147    void setCurrentIndex(const QModelIndex &index);
148    void scrollToTop();
149    void scrollToBottom();
150    void update();
151    void update(const QModelIndex &index);
152
153protected slots:
154    virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
155    virtual void rowsInserted(const QModelIndex &parent, int start, int end);
156    virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
157    virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
158    virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
159    virtual void updateEditorData();
160    virtual void updateEditorGeometries();
161    virtual void updateGeometries();
162    virtual void verticalScrollbarAction(int action);
163    virtual void horizontalScrollbarAction(int action);
164    virtual void verticalScrollbarValueChanged(int value);
165    virtual void horizontalScrollbarValueChanged(int value);
166    virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
167    virtual void commitData(QWidget *editor);
168    virtual void editorDestroyed(QObject *editor);
169
170signals:
171    void pressed(const QModelIndex &index);
172    void clicked(const QModelIndex &index);
173    void doubleClicked(const QModelIndex &index);
174    void activated(const QModelIndex &index);
175    void entered(const QModelIndex &index);
176    void viewportEntered();
177%If (Qt_5_5_0 -)
178    void iconSizeChanged(const QSize &size);
179%End
180
181protected:
182    enum CursorAction
183    {
184        MoveUp,
185        MoveDown,
186        MoveLeft,
187        MoveRight,
188        MoveHome,
189        MoveEnd,
190        MovePageUp,
191        MovePageDown,
192        MoveNext,
193        MovePrevious,
194    };
195
196    virtual QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) = 0;
197    virtual int horizontalOffset() const = 0;
198    virtual int verticalOffset() const = 0;
199    virtual bool isIndexHidden(const QModelIndex &index) const = 0;
200    virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) = 0;
201    virtual QRegion visualRegionForSelection(const QItemSelection &selection) const = 0;
202    virtual QModelIndexList selectedIndexes() const;
203    virtual bool edit(const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event);
204    virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event = 0) const;
205    virtual void startDrag(Qt::DropActions supportedActions);
206    virtual QStyleOptionViewItem viewOptions() const;
207
208    enum State
209    {
210        NoState,
211        DraggingState,
212        DragSelectingState,
213        EditingState,
214        ExpandingState,
215        CollapsingState,
216        AnimatingState,
217    };
218
219    QAbstractItemView::State state() const;
220    void setState(QAbstractItemView::State state);
221    void scheduleDelayedItemsLayout();
222    void executeDelayedItemsLayout();
223    void scrollDirtyRegion(int dx, int dy);
224    void setDirtyRegion(const QRegion &region);
225    QPoint dirtyRegionOffset() const;
226    virtual bool event(QEvent *event);
227    virtual bool viewportEvent(QEvent *e);
228    virtual void mousePressEvent(QMouseEvent *e);
229    virtual void mouseMoveEvent(QMouseEvent *e);
230    virtual void mouseReleaseEvent(QMouseEvent *e);
231    virtual void mouseDoubleClickEvent(QMouseEvent *e);
232    virtual void dragEnterEvent(QDragEnterEvent *e);
233    virtual void dragMoveEvent(QDragMoveEvent *e);
234    virtual void dragLeaveEvent(QDragLeaveEvent *e);
235    virtual void dropEvent(QDropEvent *e);
236    virtual void focusInEvent(QFocusEvent *e);
237    virtual void focusOutEvent(QFocusEvent *e);
238    virtual void keyPressEvent(QKeyEvent *e);
239    virtual void resizeEvent(QResizeEvent *e);
240    virtual void timerEvent(QTimerEvent *e);
241
242    enum DropIndicatorPosition
243    {
244        OnItem,
245        AboveItem,
246        BelowItem,
247        OnViewport,
248    };
249
250    QAbstractItemView::DropIndicatorPosition dropIndicatorPosition() const;
251
252public:
253    void setVerticalScrollMode(QAbstractItemView::ScrollMode mode);
254    QAbstractItemView::ScrollMode verticalScrollMode() const;
255    void setHorizontalScrollMode(QAbstractItemView::ScrollMode mode);
256    QAbstractItemView::ScrollMode horizontalScrollMode() const;
257    void setDragDropOverwriteMode(bool overwrite);
258    bool dragDropOverwriteMode() const;
259    void setDragDropMode(QAbstractItemView::DragDropMode behavior);
260    QAbstractItemView::DragDropMode dragDropMode() const;
261    void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate /KeepReference/);
262    QAbstractItemDelegate *itemDelegateForRow(int row) const;
263    void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate /KeepReference/);
264    QAbstractItemDelegate *itemDelegateForColumn(int column) const;
265    QAbstractItemDelegate *itemDelegate(const QModelIndex &index) const;
266    virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
267    void setAutoScrollMargin(int margin);
268    int autoScrollMargin() const;
269
270protected:
271    virtual bool focusNextPrevChild(bool next);
272    virtual void inputMethodEvent(QInputMethodEvent *event);
273%If (Qt_5_2_0 -)
274    virtual QSize viewportSizeHint() const;
275%End
276%If (Qt_5_11_0 -)
277    virtual bool eventFilter(QObject *object, QEvent *event);
278%End
279
280public:
281    void setDefaultDropAction(Qt::DropAction dropAction);
282    Qt::DropAction defaultDropAction() const;
283%If (Qt_5_7_0 -)
284    void resetVerticalScrollMode();
285%End
286%If (Qt_5_7_0 -)
287    void resetHorizontalScrollMode();
288%End
289%If (Qt_5_10_0 -)
290    bool isPersistentEditorOpen(const QModelIndex &index) const;
291%End
292};
293
294QFlags<QAbstractItemView::EditTrigger> operator|(QAbstractItemView::EditTrigger f1, QFlags<QAbstractItemView::EditTrigger> f2);
295