1// qabstractitemmodel.sip generated by MetaSIP
2//
3// This file is part of the QtCore 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 QModelIndex
24{
25%TypeHeaderCode
26#include <qabstractitemmodel.h>
27%End
28
29public:
30    QModelIndex();
31    QModelIndex child(int arow, int acolumn) const;
32    int row() const;
33    int column() const;
34    QVariant data(int role = Qt::ItemDataRole::DisplayRole) const;
35    Qt::ItemFlags flags() const;
36    SIP_PYOBJECT internalPointer() const;
37%MethodCode
38        sipRes = reinterpret_cast<PyObject *>(sipCpp->internalPointer());
39
40        if (!sipRes)
41            sipRes = Py_None;
42
43        Py_INCREF(sipRes);
44%End
45
46    SIP_PYOBJECT internalId() const /TypeHint="int"/;
47%MethodCode
48        // Python needs to treat the result as an unsigned value (which may not happen
49        // on 64 bit systems).  Instead we get the real value as it is stored (as a
50        // void *) and let Python convert that.
51        sipRes = PyLong_FromVoidPtr(sipCpp->internalPointer());
52%End
53
54    const QAbstractItemModel *model() const;
55    bool isValid() const;
56    QModelIndex parent() const;
57    QModelIndex sibling(int arow, int acolumn) const;
58%If (Qt_5_11_0 -)
59    QModelIndex siblingAtColumn(int column) const;
60%End
61%If (Qt_5_11_0 -)
62    QModelIndex siblingAtRow(int row) const;
63%End
64    bool operator==(const QModelIndex &other) const;
65    bool operator<(const QModelIndex &other) const;
66    bool operator!=(const QModelIndex &other) const;
67    long __hash__() const;
68%MethodCode
69        sipRes = qHash(*sipCpp);
70%End
71};
72
73class QPersistentModelIndex
74{
75%TypeHeaderCode
76#include <qabstractitemmodel.h>
77%End
78
79public:
80    QPersistentModelIndex();
81    QPersistentModelIndex(const QModelIndex &index);
82    QPersistentModelIndex(const QPersistentModelIndex &other);
83    ~QPersistentModelIndex();
84    int row() const;
85    int column() const;
86    QVariant data(int role = Qt::ItemDataRole::DisplayRole) const;
87    Qt::ItemFlags flags() const;
88    QModelIndex parent() const;
89    QModelIndex sibling(int row, int column) const;
90    QModelIndex child(int row, int column) const;
91    const QAbstractItemModel *model() const;
92    bool isValid() const;
93    void swap(QPersistentModelIndex &other /Constrained/);
94    operator const QModelIndex &() const;
95    bool operator<(const QPersistentModelIndex &other) const;
96    bool operator==(const QPersistentModelIndex &other) const;
97    bool operator==(const QModelIndex &other) const;
98    bool operator!=(const QPersistentModelIndex &other) const;
99    bool operator!=(const QModelIndex &other) const;
100    long __hash__() const;
101%MethodCode
102        sipRes = qHash(*sipCpp);
103%End
104};
105
106typedef QList<QModelIndex> QModelIndexList;
107
108class QAbstractItemModel : QObject
109{
110%TypeHeaderCode
111#include <qabstractitemmodel.h>
112%End
113
114public:
115    enum LayoutChangeHint
116    {
117        NoLayoutChangeHint,
118        VerticalSortHint,
119        HorizontalSortHint,
120    };
121
122    explicit QAbstractItemModel(QObject *parent /TransferThis/ = 0);
123    virtual ~QAbstractItemModel();
124    bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
125    virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const = 0;
126    virtual QModelIndex parent(const QModelIndex &child) const = 0;
127    QObject *parent() const;
128    virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
129    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
130    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
131    virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
132    virtual QVariant data(const QModelIndex &index, int role = Qt::ItemDataRole::DisplayRole) const = 0;
133    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::ItemDataRole::EditRole);
134    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::ItemDataRole::DisplayRole) const;
135    virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::ItemDataRole::EditRole);
136    virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
137    virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
138    virtual QStringList mimeTypes() const;
139    virtual QMimeData *mimeData(const QModelIndexList &indexes) const /TransferBack/;
140    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
141    virtual Qt::DropActions supportedDropActions() const;
142    virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
143    virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
144    virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
145    virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
146    virtual void fetchMore(const QModelIndex &parent);
147    virtual bool canFetchMore(const QModelIndex &parent) const;
148    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
149    virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
150    virtual QModelIndex buddy(const QModelIndex &index) const;
151    virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchStartsWith|Qt::MatchWrap) const;
152    virtual QSize span(const QModelIndex &index) const;
153
154signals:
155    void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
156    void headerDataChanged(Qt::Orientation orientation, int first, int last);
157    void layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
158    void layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
159    void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
160    void rowsInserted(const QModelIndex &parent, int first, int last);
161    void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
162    void rowsRemoved(const QModelIndex &parent, int first, int last);
163    void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last);
164    void columnsInserted(const QModelIndex &parent, int first, int last);
165    void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
166    void columnsRemoved(const QModelIndex &parent, int first, int last);
167    void modelAboutToBeReset();
168    void modelReset();
169
170public slots:
171    virtual bool submit();
172    virtual void revert();
173
174protected:
175    void encodeData(const QModelIndexList &indexes, QDataStream &stream) const;
176    bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream);
177    void beginInsertRows(const QModelIndex &parent, int first, int last);
178    void endInsertRows();
179    void beginRemoveRows(const QModelIndex &parent, int first, int last);
180    void endRemoveRows();
181    void beginInsertColumns(const QModelIndex &parent, int first, int last);
182    void endInsertColumns();
183    void beginRemoveColumns(const QModelIndex &parent, int first, int last);
184    void endRemoveColumns();
185    QModelIndexList persistentIndexList() const;
186    void changePersistentIndex(const QModelIndex &from, const QModelIndex &to);
187    void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
188
189public:
190    bool insertRow(int row, const QModelIndex &parent = QModelIndex());
191    bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
192    bool removeRow(int row, const QModelIndex &parent = QModelIndex());
193    bool removeColumn(int column, const QModelIndex &parent = QModelIndex());
194    virtual Qt::DropActions supportedDragActions() const;
195    virtual QHash<int, QByteArray> roleNames() const;
196
197protected:
198    QModelIndex createIndex(int row, int column, SIP_PYOBJECT object = 0) const [QModelIndex (int row, int column, void *object = 0)];
199%MethodCode
200        // The Qt API is broken (and won't be fixed as it would break binary
201        // compatibility) regarding the internal id of a model index on different
202        // architectures (32 vs 64 bits).  We choose to work around the breakage as it
203        // is fairly subtle and continues to catch people out.  Instead of letting Qt
204        // convert betweed an integer id and a pointer id (the internal format used by
205        // Qt) we let Python do it.
206
207        void *ptr;
208
209        if (a2)
210        {
211            // Try and convert it to a Python long and fallback to the object's
212            // address if it fails.
213            ptr = PyLong_AsVoidPtr(a2);
214
215            if (PyErr_Occurred())
216            {
217                PyErr_Clear();
218                ptr = a2;
219            }
220        }
221        else
222        {
223            ptr = 0;
224        }
225
226        #if defined(SIP_PROTECTED_IS_PUBLIC)
227        sipRes = new QModelIndex(sipCpp->createIndex(a0, a1, ptr));
228        #else
229        sipRes = new QModelIndex(sipCpp->sipProtect_createIndex(a0, a1, ptr));
230        #endif
231%End
232
233signals:
234    void rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow);
235    void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
236    void columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn);
237    void columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column);
238
239protected:
240    bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow);
241    void endMoveRows();
242    bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn);
243    void endMoveColumns();
244    void beginResetModel() /ReleaseGIL/;
245    void endResetModel() /ReleaseGIL/;
246
247protected slots:
248%If (Qt_5_1_0 -)
249    void resetInternalData();
250%End
251
252public:
253    virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const;
254    virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild);
255    virtual bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild);
256    bool moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild);
257    bool moveColumn(const QModelIndex &sourceParent, int sourceColumn, const QModelIndex &destinationParent, int destinationChild);
258%If (Qt_5_11_0 -)
259
260    enum class CheckIndexOption
261    {
262        NoOption,
263        IndexIsValid,
264        DoNotUseParent,
265        ParentIsInvalid,
266    };
267
268%End
269%If (Qt_5_11_0 -)
270    typedef QFlags<QAbstractItemModel::CheckIndexOption> CheckIndexOptions;
271%End
272%If (Qt_5_11_0 -)
273    bool checkIndex(const QModelIndex &index, QAbstractItemModel::CheckIndexOptions options = QAbstractItemModel::CheckIndexOption::NoOption) const;
274%End
275};
276
277class QAbstractTableModel : QAbstractItemModel
278{
279%TypeHeaderCode
280#include <qabstractitemmodel.h>
281%End
282
283public:
284    explicit QAbstractTableModel(QObject *parent /TransferThis/ = 0);
285    virtual ~QAbstractTableModel();
286    virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
287    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
288%If (Qt_5_1_0 -)
289    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
290%End
291%If (Qt_5_2_0 -)
292    QObject *parent() const;
293%End
294%If (Qt_5_5_0 -)
295    virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
296%End
297
298private:
299    virtual QModelIndex parent(const QModelIndex &child) const;
300    virtual bool hasChildren(const QModelIndex &parent) const;
301};
302
303class QAbstractListModel : QAbstractItemModel
304{
305%TypeHeaderCode
306#include <qabstractitemmodel.h>
307%End
308
309public:
310    explicit QAbstractListModel(QObject *parent /TransferThis/ = 0);
311    virtual ~QAbstractListModel();
312    virtual QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
313    virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
314%If (Qt_5_1_0 -)
315    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
316%End
317%If (Qt_5_2_0 -)
318    QObject *parent() const;
319%End
320%If (Qt_5_5_0 -)
321    virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
322%End
323
324private:
325    virtual QModelIndex parent(const QModelIndex &child) const;
326    virtual int columnCount(const QModelIndex &parent) const;
327    virtual bool hasChildren(const QModelIndex &parent) const;
328};
329
330%If (Qt_5_11_0 -)
331QFlags<QAbstractItemModel::CheckIndexOption> operator|(QAbstractItemModel::CheckIndexOption f1, QFlags<QAbstractItemModel::CheckIndexOption> f2);
332%End
333