qabstractitemmodel.sip 17 KB

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