qitemselectionmodel.sip 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. // qitemselectionmodel.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 QItemSelectionRange
  22. {
  23. %TypeHeaderCode
  24. #include <qitemselectionmodel.h>
  25. %End
  26. public:
  27. QItemSelectionRange();
  28. QItemSelectionRange(const QModelIndex &atopLeft, const QModelIndex &abottomRight);
  29. explicit QItemSelectionRange(const QModelIndex &index);
  30. int top() const;
  31. int left() const;
  32. int bottom() const;
  33. int right() const;
  34. int width() const;
  35. int height() const;
  36. const QPersistentModelIndex &topLeft() const;
  37. const QPersistentModelIndex &bottomRight() const;
  38. QModelIndex parent() const;
  39. const QAbstractItemModel *model() const;
  40. bool contains(const QModelIndex &index) const;
  41. bool contains(int row, int column, const QModelIndex &parentIndex) const;
  42. bool intersects(const QItemSelectionRange &other) const;
  43. %If (- Qt_6_8_0)
  44. bool operator==(const QItemSelectionRange &other) const;
  45. %End
  46. %If (- Qt_6_8_0)
  47. bool operator!=(const QItemSelectionRange &other) const;
  48. %End
  49. bool isValid() const;
  50. QModelIndexList indexes() const;
  51. QItemSelectionRange intersected(const QItemSelectionRange &other) const;
  52. bool isEmpty() const;
  53. void swap(QItemSelectionRange &other /Constrained/);
  54. };
  55. class QItemSelectionModel : public QObject
  56. {
  57. %TypeHeaderCode
  58. #include <qitemselectionmodel.h>
  59. %End
  60. public:
  61. enum SelectionFlag /BaseType=Flag/
  62. {
  63. NoUpdate,
  64. Clear,
  65. Select,
  66. Deselect,
  67. Toggle,
  68. Current,
  69. Rows,
  70. Columns,
  71. SelectCurrent,
  72. ToggleCurrent,
  73. ClearAndSelect,
  74. };
  75. typedef QFlags<QItemSelectionModel::SelectionFlag> SelectionFlags;
  76. explicit QItemSelectionModel(QAbstractItemModel *model /TransferThis/ = 0);
  77. QItemSelectionModel(QAbstractItemModel *model, QObject *parent /TransferThis/);
  78. virtual ~QItemSelectionModel();
  79. QModelIndex currentIndex() const;
  80. bool isSelected(const QModelIndex &index) const;
  81. bool isRowSelected(int row, const QModelIndex &parent = QModelIndex()) const;
  82. bool isColumnSelected(int column, const QModelIndex &parent = QModelIndex()) const;
  83. bool rowIntersectsSelection(int row, const QModelIndex &parent = QModelIndex()) const;
  84. bool columnIntersectsSelection(int column, const QModelIndex &parent = QModelIndex()) const;
  85. QModelIndexList selectedIndexes() const;
  86. const QItemSelection selection() const;
  87. QAbstractItemModel *model();
  88. public slots:
  89. virtual void clear();
  90. void clearSelection();
  91. virtual void reset();
  92. virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
  93. virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command);
  94. virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
  95. virtual void clearCurrentIndex();
  96. signals:
  97. void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
  98. void currentChanged(const QModelIndex &current, const QModelIndex &previous);
  99. void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);
  100. void currentColumnChanged(const QModelIndex &current, const QModelIndex &previous);
  101. protected:
  102. void emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection);
  103. public:
  104. bool hasSelection() const;
  105. QModelIndexList selectedRows(int column = 0) const;
  106. QModelIndexList selectedColumns(int row = 0) const;
  107. void setModel(QAbstractItemModel *model);
  108. signals:
  109. void modelChanged(QAbstractItemModel *model);
  110. };
  111. class QItemSelection
  112. {
  113. %TypeHeaderCode
  114. #include <qitemselectionmodel.h>
  115. %End
  116. public:
  117. QItemSelection();
  118. QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight);
  119. void select(const QModelIndex &topLeft, const QModelIndex &bottomRight);
  120. bool contains(const QModelIndex &index) const;
  121. int __contains__(const QModelIndex &index);
  122. %MethodCode
  123. // It looks like you can't assign QBool to int.
  124. sipRes = bool(sipCpp->contains(*a0));
  125. %End
  126. QModelIndexList indexes() const;
  127. void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command);
  128. static void split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result);
  129. void __setitem__(int i, const QItemSelectionRange &range);
  130. %MethodCode
  131. int len;
  132. len = sipCpp->count();
  133. if ((a0 = (int)sipConvertFromSequenceIndex(a0, len)) < 0)
  134. sipIsErr = 1;
  135. else
  136. (*sipCpp)[a0] = *a1;
  137. %End
  138. void __setitem__(SIP_PYSLICE slice, const QItemSelection &list);
  139. %MethodCode
  140. Py_ssize_t start, stop, step, slicelength;
  141. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  142. {
  143. sipIsErr = 1;
  144. }
  145. else
  146. {
  147. int vlen = a1->count();
  148. if (vlen != slicelength)
  149. {
  150. sipBadLengthForSlice(vlen, slicelength);
  151. sipIsErr = 1;
  152. }
  153. else
  154. {
  155. QItemSelection::const_iterator it = a1->begin();
  156. for (Py_ssize_t i = 0; i < slicelength; ++i)
  157. {
  158. (*sipCpp)[start] = *it;
  159. start += step;
  160. ++it;
  161. }
  162. }
  163. }
  164. %End
  165. void __delitem__(int i);
  166. %MethodCode
  167. if ((a0 = (int)sipConvertFromSequenceIndex(a0, sipCpp->count())) < 0)
  168. sipIsErr = 1;
  169. else
  170. sipCpp->removeAt(a0);
  171. %End
  172. void __delitem__(SIP_PYSLICE slice);
  173. %MethodCode
  174. Py_ssize_t start, stop, step, slicelength;
  175. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  176. {
  177. sipIsErr = 1;
  178. }
  179. else
  180. {
  181. for (Py_ssize_t i = 0; i < slicelength; ++i)
  182. {
  183. sipCpp->removeAt(start);
  184. start += step - 1;
  185. }
  186. }
  187. %End
  188. QItemSelectionRange operator[](int i);
  189. %MethodCode
  190. Py_ssize_t idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
  191. if (idx < 0)
  192. sipIsErr = 1;
  193. else
  194. sipRes = new QItemSelectionRange(sipCpp->operator[]((int)idx));
  195. %End
  196. QItemSelection operator[](SIP_PYSLICE slice);
  197. %MethodCode
  198. Py_ssize_t start, stop, step, slicelength;
  199. if (sipConvertFromSliceObject(a0, sipCpp->count(), &start, &stop, &step, &slicelength) < 0)
  200. {
  201. sipIsErr = 1;
  202. }
  203. else
  204. {
  205. sipRes = new QItemSelection();
  206. for (Py_ssize_t i = 0; i < slicelength; ++i)
  207. {
  208. (*sipRes) += (*sipCpp)[start];
  209. start += step;
  210. }
  211. }
  212. %End
  213. // Methods inherited from QList<QItemSelectionRange>.
  214. bool operator!=(const QItemSelection &other) const;
  215. bool operator==(const QItemSelection &other) const;
  216. // Keep the following in sync with QStringList (except for mid()).
  217. void clear();
  218. bool isEmpty() const;
  219. void append(const QItemSelectionRange &range);
  220. void prepend(const QItemSelectionRange &range);
  221. void insert(int i, const QItemSelectionRange &range);
  222. void replace(int i, const QItemSelectionRange &range);
  223. void removeAt(int i);
  224. int removeAll(const QItemSelectionRange &range);
  225. QItemSelectionRange takeAt(int i);
  226. QItemSelectionRange takeFirst();
  227. QItemSelectionRange takeLast();
  228. void move(int from, int to);
  229. int count(const QItemSelectionRange &range) const;
  230. int count() const /__len__/;
  231. QItemSelectionRange &first();
  232. QItemSelectionRange &last();
  233. int indexOf(const QItemSelectionRange &value, int from = 0) const;
  234. int lastIndexOf(const QItemSelectionRange &value, int from = -1) const;
  235. QItemSelection &operator+=(const QItemSelection &other);
  236. QItemSelection &operator+=(const QItemSelectionRange &value);
  237. };
  238. %If (Qt_6_8_0 -)
  239. bool operator!=(const QItemSelectionRange &lhs, const QItemSelectionRange &rhs);
  240. %End
  241. %If (Qt_6_8_0 -)
  242. bool operator==(const QItemSelectionRange &lhs, const QItemSelectionRange &rhs);
  243. %End