Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qtreewidget.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | typedef bool(*LessThan)(const QPair<QTreeWidgetItem*,int>&,const QPair<QTreeWidgetItem*,int>&); | - | ||||||||||||||||||
10 | - | |||||||||||||||||||
11 | class QTreeModelLessThan | - | ||||||||||||||||||
12 | { | - | ||||||||||||||||||
13 | public: | - | ||||||||||||||||||
14 | inline bool operator()(QTreeWidgetItem *i1, QTreeWidgetItem *i2) const | - | ||||||||||||||||||
15 | { return *i1 < *i2; } | - | ||||||||||||||||||
16 | }; | - | ||||||||||||||||||
17 | - | |||||||||||||||||||
18 | class QTreeModelGreaterThan | - | ||||||||||||||||||
19 | { | - | ||||||||||||||||||
20 | public: | - | ||||||||||||||||||
21 | inline bool operator()(QTreeWidgetItem *i1, QTreeWidgetItem *i2) const | - | ||||||||||||||||||
22 | { return *i2 < *i1; } | - | ||||||||||||||||||
23 | }; | - | ||||||||||||||||||
24 | QTreeModel::QTreeModel(int columns, QTreeWidget *parent) | - | ||||||||||||||||||
25 | : QAbstractItemModel(parent), rootItem(new QTreeWidgetItem), | - | ||||||||||||||||||
26 | headerItem(new QTreeWidgetItem), skipPendingSort(false) | - | ||||||||||||||||||
27 | { | - | ||||||||||||||||||
28 | rootItem->view = parent; | - | ||||||||||||||||||
29 | rootItem->itemFlags = Qt::ItemIsDropEnabled; | - | ||||||||||||||||||
30 | headerItem->view = parent; | - | ||||||||||||||||||
31 | setColumnCount(columns); | - | ||||||||||||||||||
32 | } | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | - | |||||||||||||||||||
35 | - | |||||||||||||||||||
36 | - | |||||||||||||||||||
37 | - | |||||||||||||||||||
38 | - | |||||||||||||||||||
39 | QTreeModel::QTreeModel(QTreeModelPrivate &dd, QTreeWidget *parent) | - | ||||||||||||||||||
40 | : QAbstractItemModel(dd, parent), rootItem(new QTreeWidgetItem), | - | ||||||||||||||||||
41 | headerItem(new QTreeWidgetItem), skipPendingSort(false) | - | ||||||||||||||||||
42 | { | - | ||||||||||||||||||
43 | rootItem->view = parent; | - | ||||||||||||||||||
44 | rootItem->itemFlags = Qt::ItemIsDropEnabled; | - | ||||||||||||||||||
45 | headerItem->view = parent; | - | ||||||||||||||||||
46 | } | - | ||||||||||||||||||
47 | - | |||||||||||||||||||
48 | - | |||||||||||||||||||
49 | - | |||||||||||||||||||
50 | - | |||||||||||||||||||
51 | - | |||||||||||||||||||
52 | - | |||||||||||||||||||
53 | - | |||||||||||||||||||
54 | QTreeModel::~QTreeModel() | - | ||||||||||||||||||
55 | { | - | ||||||||||||||||||
56 | clear(); | - | ||||||||||||||||||
57 | headerItem->view = nullptr; | - | ||||||||||||||||||
58 | delete headerItem; | - | ||||||||||||||||||
59 | rootItem->view = 0; | - | ||||||||||||||||||
60 | delete rootItem; | - | ||||||||||||||||||
61 | } | - | ||||||||||||||||||
62 | - | |||||||||||||||||||
63 | - | |||||||||||||||||||
64 | - | |||||||||||||||||||
65 | - | |||||||||||||||||||
66 | - | |||||||||||||||||||
67 | - | |||||||||||||||||||
68 | - | |||||||||||||||||||
69 | void QTreeModel::clear() | - | ||||||||||||||||||
70 | { | - | ||||||||||||||||||
71 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
72 | beginResetModel(); | - | ||||||||||||||||||
73 | for (int i = 0; i < rootItem->childCount(); ++i) { | - | ||||||||||||||||||
74 | QTreeWidgetItem *item = rootItem->children.at(i); | - | ||||||||||||||||||
75 | item->par = 0; | - | ||||||||||||||||||
76 | item->view = 0; | - | ||||||||||||||||||
77 | delete item; | - | ||||||||||||||||||
78 | } | - | ||||||||||||||||||
79 | rootItem->children.clear(); | - | ||||||||||||||||||
80 | sortPendingTimer.stop(); | - | ||||||||||||||||||
81 | endResetModel(); | - | ||||||||||||||||||
82 | } | - | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | - | |||||||||||||||||||
85 | - | |||||||||||||||||||
86 | - | |||||||||||||||||||
87 | - | |||||||||||||||||||
88 | - | |||||||||||||||||||
89 | - | |||||||||||||||||||
90 | void QTreeModel::setColumnCount(int columns) | - | ||||||||||||||||||
91 | { | - | ||||||||||||||||||
92 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
93 | if (columns < 0) | - | ||||||||||||||||||
94 | return; | - | ||||||||||||||||||
95 | if (!headerItem) { | - | ||||||||||||||||||
96 | headerItem = new QTreeWidgetItem(); | - | ||||||||||||||||||
97 | headerItem->view = view(); | - | ||||||||||||||||||
98 | } | - | ||||||||||||||||||
99 | int count = columnCount(); | - | ||||||||||||||||||
100 | if (count == columns) | - | ||||||||||||||||||
101 | return; | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | if (columns < count) { | - | ||||||||||||||||||
104 | beginRemoveColumns(QModelIndex(), columns, count - 1); | - | ||||||||||||||||||
105 | headerItem->values.resize(columns); | - | ||||||||||||||||||
106 | endRemoveColumns(); | - | ||||||||||||||||||
107 | } else { | - | ||||||||||||||||||
108 | beginInsertColumns(QModelIndex(), count, columns - 1); | - | ||||||||||||||||||
109 | headerItem->values.resize(columns); | - | ||||||||||||||||||
110 | for (int i = count; i < columns; ++i) { | - | ||||||||||||||||||
111 | headerItem->values[i].append(QWidgetItemData(Qt::DisplayRole, QString::number(i + 1))); | - | ||||||||||||||||||
112 | headerItem->d->display.append(QString::number(i + 1)); | - | ||||||||||||||||||
113 | } | - | ||||||||||||||||||
114 | endInsertColumns(); | - | ||||||||||||||||||
115 | } | - | ||||||||||||||||||
116 | } | - | ||||||||||||||||||
117 | QTreeWidgetItem *QTreeModel::item(const QModelIndex &index) const | - | ||||||||||||||||||
118 | { | - | ||||||||||||||||||
119 | if (!index.isValid()) | - | ||||||||||||||||||
120 | return 0; | - | ||||||||||||||||||
121 | return static_cast<QTreeWidgetItem*>(index.internalPointer()); | - | ||||||||||||||||||
122 | } | - | ||||||||||||||||||
123 | QModelIndex QTreeModel::index(const QTreeWidgetItem *item, int column) const | - | ||||||||||||||||||
124 | { | - | ||||||||||||||||||
125 | executePendingSort(); | - | ||||||||||||||||||
126 | - | |||||||||||||||||||
127 | if (!item || (item == rootItem)) | - | ||||||||||||||||||
128 | return QModelIndex(); | - | ||||||||||||||||||
129 | const QTreeWidgetItem *par = item->parent(); | - | ||||||||||||||||||
130 | QTreeWidgetItem *itm = const_cast<QTreeWidgetItem*>(item); | - | ||||||||||||||||||
131 | if (!par) | - | ||||||||||||||||||
132 | par = rootItem; | - | ||||||||||||||||||
133 | int row; | - | ||||||||||||||||||
134 | int guess = item->d->rowGuess; | - | ||||||||||||||||||
135 | if (guess >= 0 | - | ||||||||||||||||||
136 | && par->children.count() > guess | - | ||||||||||||||||||
137 | && par->children.at(guess) == itm) { | - | ||||||||||||||||||
138 | row = guess; | - | ||||||||||||||||||
139 | } else { | - | ||||||||||||||||||
140 | row = par->children.lastIndexOf(itm); | - | ||||||||||||||||||
141 | itm->d->rowGuess = row; | - | ||||||||||||||||||
142 | } | - | ||||||||||||||||||
143 | return createIndex(row, column, itm); | - | ||||||||||||||||||
144 | } | - | ||||||||||||||||||
145 | QModelIndex QTreeModel::index(int row, int column, const QModelIndex &parent) const | - | ||||||||||||||||||
146 | { | - | ||||||||||||||||||
147 | executePendingSort(); | - | ||||||||||||||||||
148 | - | |||||||||||||||||||
149 | int c = columnCount(parent); | - | ||||||||||||||||||
150 | if (row < 0 || column < 0 || column >= c) | - | ||||||||||||||||||
151 | return QModelIndex(); | - | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | QTreeWidgetItem *parentItem = parent.isValid() ? item(parent) : rootItem; | - | ||||||||||||||||||
154 | if (parentItem && row < parentItem->childCount()) { | - | ||||||||||||||||||
155 | QTreeWidgetItem *itm = parentItem->child(row); | - | ||||||||||||||||||
156 | if (itm) | - | ||||||||||||||||||
157 | return createIndex(row, column, itm); | - | ||||||||||||||||||
158 | return QModelIndex(); | - | ||||||||||||||||||
159 | } | - | ||||||||||||||||||
160 | - | |||||||||||||||||||
161 | return QModelIndex(); | - | ||||||||||||||||||
162 | } | - | ||||||||||||||||||
163 | QModelIndex QTreeModel::parent(const QModelIndex &child) const | - | ||||||||||||||||||
164 | { | - | ||||||||||||||||||
165 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | - | |||||||||||||||||||
168 | if (!child.isValid()) | - | ||||||||||||||||||
169 | return QModelIndex(); | - | ||||||||||||||||||
170 | QTreeWidgetItem *itm = static_cast<QTreeWidgetItem *>(child.internalPointer()); | - | ||||||||||||||||||
171 | if (!itm || itm == rootItem) | - | ||||||||||||||||||
172 | return QModelIndex(); | - | ||||||||||||||||||
173 | QTreeWidgetItem *parent = itm->parent(); | - | ||||||||||||||||||
174 | return index(parent, 0); | - | ||||||||||||||||||
175 | } | - | ||||||||||||||||||
176 | int QTreeModel::rowCount(const QModelIndex &parent) const | - | ||||||||||||||||||
177 | { | - | ||||||||||||||||||
178 | if (!parent.isValid()) | - | ||||||||||||||||||
179 | return rootItem->childCount(); | - | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | QTreeWidgetItem *parentItem = item(parent); | - | ||||||||||||||||||
182 | if (parentItem) | - | ||||||||||||||||||
183 | return parentItem->childCount(); | - | ||||||||||||||||||
184 | return 0; | - | ||||||||||||||||||
185 | } | - | ||||||||||||||||||
186 | int QTreeModel::columnCount(const QModelIndex &index) const | - | ||||||||||||||||||
187 | { | - | ||||||||||||||||||
188 | (void)index;; | - | ||||||||||||||||||
189 | if (!headerItem) | - | ||||||||||||||||||
190 | return 0; | - | ||||||||||||||||||
191 | return headerItem->columnCount(); | - | ||||||||||||||||||
192 | } | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | bool QTreeModel::hasChildren(const QModelIndex &parent) const | - | ||||||||||||||||||
195 | { | - | ||||||||||||||||||
196 | if (!parent.isValid()) | - | ||||||||||||||||||
197 | return (rootItem->childCount() > 0); | - | ||||||||||||||||||
198 | - | |||||||||||||||||||
199 | QTreeWidgetItem *itm = item(parent); | - | ||||||||||||||||||
200 | if (!itm) | - | ||||||||||||||||||
201 | return false; | - | ||||||||||||||||||
202 | switch (itm->d->policy) { | - | ||||||||||||||||||
203 | case QTreeWidgetItem::ShowIndicator: | - | ||||||||||||||||||
204 | return true; | - | ||||||||||||||||||
205 | case QTreeWidgetItem::DontShowIndicator: | - | ||||||||||||||||||
206 | return false; | - | ||||||||||||||||||
207 | case QTreeWidgetItem::DontShowIndicatorWhenChildless: | - | ||||||||||||||||||
208 | return (itm->childCount() > 0); | - | ||||||||||||||||||
209 | } | - | ||||||||||||||||||
210 | return false; | - | ||||||||||||||||||
211 | } | - | ||||||||||||||||||
212 | QVariant QTreeModel::data(const QModelIndex &index, int role) const | - | ||||||||||||||||||
213 | { | - | ||||||||||||||||||
214 | if (!index.isValid()) | - | ||||||||||||||||||
215 | return QVariant(); | - | ||||||||||||||||||
216 | QTreeWidgetItem *itm = item(index); | - | ||||||||||||||||||
217 | if (itm) | - | ||||||||||||||||||
218 | return itm->data(index.column(), role); | - | ||||||||||||||||||
219 | return QVariant(); | - | ||||||||||||||||||
220 | } | - | ||||||||||||||||||
221 | bool QTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) | - | ||||||||||||||||||
222 | { | - | ||||||||||||||||||
223 | if (!index.isValid()) | - | ||||||||||||||||||
224 | return false; | - | ||||||||||||||||||
225 | QTreeWidgetItem *itm = item(index); | - | ||||||||||||||||||
226 | if (itm) { | - | ||||||||||||||||||
227 | itm->setData(index.column(), role, value); | - | ||||||||||||||||||
228 | return true; | - | ||||||||||||||||||
229 | } | - | ||||||||||||||||||
230 | return false; | - | ||||||||||||||||||
231 | } | - | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | QMap<int, QVariant> QTreeModel::itemData(const QModelIndex &index) const | - | ||||||||||||||||||
234 | { | - | ||||||||||||||||||
235 | QMap<int, QVariant> roles; | - | ||||||||||||||||||
236 | QTreeWidgetItem *itm = item(index); | - | ||||||||||||||||||
237 | if (itm) { | - | ||||||||||||||||||
238 | int column = index.column(); | - | ||||||||||||||||||
239 | if (column < itm->values.count()) { | - | ||||||||||||||||||
240 | for (int i = 0; i < itm->values.at(column).count(); ++i) { | - | ||||||||||||||||||
241 | roles.insert(itm->values.at(column).at(i).role, | - | ||||||||||||||||||
242 | itm->values.at(column).at(i).value); | - | ||||||||||||||||||
243 | } | - | ||||||||||||||||||
244 | } | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | - | |||||||||||||||||||
247 | QVariant displayValue = itm->data(column, Qt::DisplayRole); | - | ||||||||||||||||||
248 | if (displayValue.isValid()) | - | ||||||||||||||||||
249 | roles.insert(Qt::DisplayRole, displayValue); | - | ||||||||||||||||||
250 | - | |||||||||||||||||||
251 | QVariant checkValue = itm->data(column, Qt::CheckStateRole); | - | ||||||||||||||||||
252 | if (checkValue.isValid()) | - | ||||||||||||||||||
253 | roles.insert(Qt::CheckStateRole, checkValue); | - | ||||||||||||||||||
254 | } | - | ||||||||||||||||||
255 | return roles; | - | ||||||||||||||||||
256 | } | - | ||||||||||||||||||
257 | - | |||||||||||||||||||
258 | - | |||||||||||||||||||
259 | - | |||||||||||||||||||
260 | - | |||||||||||||||||||
261 | - | |||||||||||||||||||
262 | bool QTreeModel::insertRows(int row, int count, const QModelIndex &parent) | - | ||||||||||||||||||
263 | { | - | ||||||||||||||||||
264 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
265 | if (count < 1 || row < 0 || row > rowCount(parent) || parent.column() > 0) | - | ||||||||||||||||||
266 | return false; | - | ||||||||||||||||||
267 | - | |||||||||||||||||||
268 | beginInsertRows(parent, row, row + count - 1); | - | ||||||||||||||||||
269 | QTreeWidgetItem *par = item(parent); | - | ||||||||||||||||||
270 | while (count > 0) { | - | ||||||||||||||||||
271 | QTreeWidgetItem *item = new QTreeWidgetItem(); | - | ||||||||||||||||||
272 | item->view = view(); | - | ||||||||||||||||||
273 | item->par = par; | - | ||||||||||||||||||
274 | if (par) | - | ||||||||||||||||||
275 | par->children.insert(row++, item); | - | ||||||||||||||||||
276 | else | - | ||||||||||||||||||
277 | rootItem->children.insert(row++, item); | - | ||||||||||||||||||
278 | --count; | - | ||||||||||||||||||
279 | } | - | ||||||||||||||||||
280 | endInsertRows(); | - | ||||||||||||||||||
281 | return true; | - | ||||||||||||||||||
282 | } | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | - | |||||||||||||||||||
285 | - | |||||||||||||||||||
286 | - | |||||||||||||||||||
287 | - | |||||||||||||||||||
288 | bool QTreeModel::insertColumns(int column, int count, const QModelIndex &parent) | - | ||||||||||||||||||
289 | { | - | ||||||||||||||||||
290 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
291 | if (count < 1 || column < 0 || column > columnCount(parent) || parent.column() > 0 || !headerItem) | - | ||||||||||||||||||
292 | return false; | - | ||||||||||||||||||
293 | - | |||||||||||||||||||
294 | beginInsertColumns(parent, column, column + count - 1); | - | ||||||||||||||||||
295 | - | |||||||||||||||||||
296 | int oldCount = columnCount(parent); | - | ||||||||||||||||||
297 | column = qBound(0, column, oldCount); | - | ||||||||||||||||||
298 | headerItem->values.resize(oldCount + count); | - | ||||||||||||||||||
299 | for (int i = oldCount; i < oldCount + count; ++i) { | - | ||||||||||||||||||
300 | headerItem->values[i].append(QWidgetItemData(Qt::DisplayRole, QString::number(i + 1))); | - | ||||||||||||||||||
301 | headerItem->d->display.append(QString::number(i + 1)); | - | ||||||||||||||||||
302 | } | - | ||||||||||||||||||
303 | - | |||||||||||||||||||
304 | QStack<QTreeWidgetItem*> itemstack; | - | ||||||||||||||||||
305 | itemstack.push(0); | - | ||||||||||||||||||
306 | while (!itemstack.isEmpty()) { | - | ||||||||||||||||||
307 | QTreeWidgetItem *par = itemstack.pop(); | - | ||||||||||||||||||
308 | QList<QTreeWidgetItem*> children = par ? par->children : rootItem->children; | - | ||||||||||||||||||
309 | for (int row = 0; row < children.count(); ++row) { | - | ||||||||||||||||||
310 | QTreeWidgetItem *child = children.at(row); | - | ||||||||||||||||||
311 | if (child->children.count()) | - | ||||||||||||||||||
312 | itemstack.push(child); | - | ||||||||||||||||||
313 | child->values.insert(column, count, QVector<QWidgetItemData>()); | - | ||||||||||||||||||
314 | } | - | ||||||||||||||||||
315 | } | - | ||||||||||||||||||
316 | - | |||||||||||||||||||
317 | endInsertColumns(); | - | ||||||||||||||||||
318 | return true; | - | ||||||||||||||||||
319 | } | - | ||||||||||||||||||
320 | - | |||||||||||||||||||
321 | - | |||||||||||||||||||
322 | - | |||||||||||||||||||
323 | - | |||||||||||||||||||
324 | - | |||||||||||||||||||
325 | bool QTreeModel::removeRows(int row, int count, const QModelIndex &parent) { | - | ||||||||||||||||||
326 | if (count < 1 || row < 0 || (row + count) > rowCount(parent)) | - | ||||||||||||||||||
327 | return false; | - | ||||||||||||||||||
328 | - | |||||||||||||||||||
329 | beginRemoveRows(parent, row, row + count - 1); | - | ||||||||||||||||||
330 | - | |||||||||||||||||||
331 | QSignalBlocker blocker(this); | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | QTreeWidgetItem *itm = item(parent); | - | ||||||||||||||||||
334 | for (int i = row + count - 1; i >= row; --i) { | - | ||||||||||||||||||
335 | QTreeWidgetItem *child = itm ? itm->takeChild(i) : rootItem->children.takeAt(i); | - | ||||||||||||||||||
336 | ((!(child)) ? qt_assert("child",__FILE__,494500) : qt_noop()); | - | ||||||||||||||||||
337 | child->view = 0; | - | ||||||||||||||||||
338 | delete child; | - | ||||||||||||||||||
339 | child = 0; | - | ||||||||||||||||||
340 | } | - | ||||||||||||||||||
341 | blocker.unblock(); | - | ||||||||||||||||||
342 | - | |||||||||||||||||||
343 | endRemoveRows(); | - | ||||||||||||||||||
344 | return true; | - | ||||||||||||||||||
345 | } | - | ||||||||||||||||||
346 | QVariant QTreeModel::headerData(int section, Qt::Orientation orientation, int role) const | - | ||||||||||||||||||
347 | { | - | ||||||||||||||||||
348 | if (orientation != Qt::Horizontal) | - | ||||||||||||||||||
349 | return QVariant(); | - | ||||||||||||||||||
350 | - | |||||||||||||||||||
351 | if (headerItem) | - | ||||||||||||||||||
352 | return headerItem->data(section, role); | - | ||||||||||||||||||
353 | if (role == Qt::DisplayRole) | - | ||||||||||||||||||
354 | return QString::number(section + 1); | - | ||||||||||||||||||
355 | return QVariant(); | - | ||||||||||||||||||
356 | } | - | ||||||||||||||||||
357 | bool QTreeModel::setHeaderData(int section, Qt::Orientation orientation, | - | ||||||||||||||||||
358 | const QVariant &value, int role) | - | ||||||||||||||||||
359 | { | - | ||||||||||||||||||
360 | if (section < 0 || orientation != Qt::Horizontal || !headerItem || section >= columnCount()) | - | ||||||||||||||||||
361 | return false; | - | ||||||||||||||||||
362 | - | |||||||||||||||||||
363 | headerItem->setData(section, role, value); | - | ||||||||||||||||||
364 | return true; | - | ||||||||||||||||||
365 | } | - | ||||||||||||||||||
366 | Qt::ItemFlags QTreeModel::flags(const QModelIndex &index) const | - | ||||||||||||||||||
367 | { | - | ||||||||||||||||||
368 | if (!index.isValid()) | - | ||||||||||||||||||
369 | return rootItem->flags(); | - | ||||||||||||||||||
370 | QTreeWidgetItem *itm = item(index); | - | ||||||||||||||||||
371 | ((!(itm)) ? qt_assert("itm",__FILE__,557563) : qt_noop()); | - | ||||||||||||||||||
372 | return itm->flags(); | - | ||||||||||||||||||
373 | } | - | ||||||||||||||||||
374 | void QTreeModel::sort(int column, Qt::SortOrder order) | - | ||||||||||||||||||
375 | { | - | ||||||||||||||||||
376 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
377 | sortPendingTimer.stop(); | - | ||||||||||||||||||
378 | - | |||||||||||||||||||
379 | if (column < 0 || column >= columnCount()) | - | ||||||||||||||||||
380 | return; | - | ||||||||||||||||||
381 | - | |||||||||||||||||||
382 | - | |||||||||||||||||||
383 | rootItem->sortChildren(column, order, true); | - | ||||||||||||||||||
384 | } | - | ||||||||||||||||||
385 | - | |||||||||||||||||||
386 | - | |||||||||||||||||||
387 | - | |||||||||||||||||||
388 | - | |||||||||||||||||||
389 | void QTreeModel::ensureSorted(int column, Qt::SortOrder order, | - | ||||||||||||||||||
390 | int start, int end, const QModelIndex &parent) | - | ||||||||||||||||||
391 | { | - | ||||||||||||||||||
392 | if (isChanging()) | - | ||||||||||||||||||
393 | return; | - | ||||||||||||||||||
394 | - | |||||||||||||||||||
395 | sortPendingTimer.stop(); | - | ||||||||||||||||||
396 | - | |||||||||||||||||||
397 | if (column < 0 || column >= columnCount()) | - | ||||||||||||||||||
398 | return; | - | ||||||||||||||||||
399 | - | |||||||||||||||||||
400 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
401 | - | |||||||||||||||||||
402 | QTreeWidgetItem *itm = item(parent); | - | ||||||||||||||||||
403 | if (!itm) | - | ||||||||||||||||||
404 | itm = rootItem; | - | ||||||||||||||||||
405 | QList<QTreeWidgetItem*> lst = itm->children; | - | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | int count = end - start + 1; | - | ||||||||||||||||||
408 | QVector < QPair<QTreeWidgetItem*,int> > sorting(count); | - | ||||||||||||||||||
409 | for (int i = 0; i < count; ++i) { | - | ||||||||||||||||||
410 | sorting[i].first = lst.at(start + i); | - | ||||||||||||||||||
411 | sorting[i].second = start + i; | - | ||||||||||||||||||
412 | } | - | ||||||||||||||||||
413 | - | |||||||||||||||||||
414 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); | - | ||||||||||||||||||
415 | std::stable_sort(sorting.begin(), sorting.end(), compare); | - | ||||||||||||||||||
416 | - | |||||||||||||||||||
417 | QModelIndexList oldPersistentIndexes; | - | ||||||||||||||||||
418 | QModelIndexList newPersistentIndexes; | - | ||||||||||||||||||
419 | QList<QTreeWidgetItem*>::iterator lit = lst.begin(); | - | ||||||||||||||||||
420 | bool changed = false; | - | ||||||||||||||||||
421 | - | |||||||||||||||||||
422 | for (int i = 0; i < count; ++i) { | - | ||||||||||||||||||
423 | int oldRow = sorting.at(i).second; | - | ||||||||||||||||||
424 | - | |||||||||||||||||||
425 | int tmpitepos = lit - lst.begin(); | - | ||||||||||||||||||
426 | QTreeWidgetItem *item = lst.takeAt(oldRow); | - | ||||||||||||||||||
427 | if (tmpitepos > lst.size()) | - | ||||||||||||||||||
428 | --tmpitepos; | - | ||||||||||||||||||
429 | lit = lst.begin() + tmpitepos; | - | ||||||||||||||||||
430 | - | |||||||||||||||||||
431 | lit = sortedInsertionIterator(lit, lst.end(), order, item); | - | ||||||||||||||||||
432 | int newRow = qMax(lit - lst.begin(), 0); | - | ||||||||||||||||||
433 | - | |||||||||||||||||||
434 | if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1)) && !(*lst.at(oldRow - 1) < *item )) | - | ||||||||||||||||||
435 | newRow = oldRow; | - | ||||||||||||||||||
436 | - | |||||||||||||||||||
437 | lit = lst.insert(lit, item); | - | ||||||||||||||||||
438 | if (newRow != oldRow) { | - | ||||||||||||||||||
439 | - | |||||||||||||||||||
440 | if (!changed) { | - | ||||||||||||||||||
441 | changed = true; | - | ||||||||||||||||||
442 | layoutAboutToBeChanged(); | - | ||||||||||||||||||
443 | oldPersistentIndexes = persistentIndexList(); | - | ||||||||||||||||||
444 | newPersistentIndexes = oldPersistentIndexes; | - | ||||||||||||||||||
445 | } | - | ||||||||||||||||||
446 | for (int j = i + 1; j < count; ++j) { | - | ||||||||||||||||||
447 | int otherRow = sorting.at(j).second; | - | ||||||||||||||||||
448 | if (oldRow < otherRow && newRow >= otherRow) | - | ||||||||||||||||||
449 | --sorting[j].second; | - | ||||||||||||||||||
450 | else if (oldRow > otherRow && newRow <= otherRow) | - | ||||||||||||||||||
451 | ++sorting[j].second; | - | ||||||||||||||||||
452 | } | - | ||||||||||||||||||
453 | for (int k = 0; k < newPersistentIndexes.count(); ++k) { | - | ||||||||||||||||||
454 | QModelIndex pi = newPersistentIndexes.at(k); | - | ||||||||||||||||||
455 | if (pi.parent() != parent) | - | ||||||||||||||||||
456 | continue; | - | ||||||||||||||||||
457 | int oldPersistentRow = pi.row(); | - | ||||||||||||||||||
458 | int newPersistentRow = oldPersistentRow; | - | ||||||||||||||||||
459 | if (oldPersistentRow == oldRow) | - | ||||||||||||||||||
460 | newPersistentRow = newRow; | - | ||||||||||||||||||
461 | else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow) | - | ||||||||||||||||||
462 | newPersistentRow = oldPersistentRow - 1; | - | ||||||||||||||||||
463 | else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow) | - | ||||||||||||||||||
464 | newPersistentRow = oldPersistentRow + 1; | - | ||||||||||||||||||
465 | if (newPersistentRow != oldPersistentRow) | - | ||||||||||||||||||
466 | newPersistentIndexes[k] = createIndex(newPersistentRow, | - | ||||||||||||||||||
467 | pi.column(), pi.internalPointer()); | - | ||||||||||||||||||
468 | } | - | ||||||||||||||||||
469 | } | - | ||||||||||||||||||
470 | } | - | ||||||||||||||||||
471 | - | |||||||||||||||||||
472 | if (changed) { | - | ||||||||||||||||||
473 | itm->children = lst; | - | ||||||||||||||||||
474 | changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes); | - | ||||||||||||||||||
475 | layoutChanged(); | - | ||||||||||||||||||
476 | } | - | ||||||||||||||||||
477 | } | - | ||||||||||||||||||
478 | bool QTreeModel::itemLessThan(const QPair<QTreeWidgetItem*,int> &left, | - | ||||||||||||||||||
479 | const QPair<QTreeWidgetItem*,int> &right) | - | ||||||||||||||||||
480 | { | - | ||||||||||||||||||
481 | return *(left.first) < *(right.first); | - | ||||||||||||||||||
482 | } | - | ||||||||||||||||||
483 | bool QTreeModel::itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left, | - | ||||||||||||||||||
484 | const QPair<QTreeWidgetItem*,int> &right) | - | ||||||||||||||||||
485 | { | - | ||||||||||||||||||
486 | return *(right.first) < *(left.first); | - | ||||||||||||||||||
487 | } | - | ||||||||||||||||||
488 | - | |||||||||||||||||||
489 | - | |||||||||||||||||||
490 | - | |||||||||||||||||||
491 | - | |||||||||||||||||||
492 | QList<QTreeWidgetItem*>::iterator QTreeModel::sortedInsertionIterator( | - | ||||||||||||||||||
493 | const QList<QTreeWidgetItem*>::iterator &begin, | - | ||||||||||||||||||
494 | const QList<QTreeWidgetItem*>::iterator &end, | - | ||||||||||||||||||
495 | Qt::SortOrder order, QTreeWidgetItem *item) | - | ||||||||||||||||||
496 | { | - | ||||||||||||||||||
497 | if (order == Qt::AscendingOrder) | - | ||||||||||||||||||
498 | return std::lower_bound(begin, end, item, QTreeModelLessThan()); | - | ||||||||||||||||||
499 | return std::lower_bound(begin, end, item, QTreeModelGreaterThan()); | - | ||||||||||||||||||
500 | } | - | ||||||||||||||||||
501 | - | |||||||||||||||||||
502 | QStringList QTreeModel::mimeTypes() const | - | ||||||||||||||||||
503 | { | - | ||||||||||||||||||
504 | return view()->mimeTypes(); | - | ||||||||||||||||||
505 | } | - | ||||||||||||||||||
506 | - | |||||||||||||||||||
507 | QMimeData *QTreeModel::internalMimeData() const | - | ||||||||||||||||||
508 | { | - | ||||||||||||||||||
509 | return QAbstractItemModel::mimeData(cachedIndexes); | - | ||||||||||||||||||
510 | } | - | ||||||||||||||||||
511 | - | |||||||||||||||||||
512 | QMimeData *QTreeModel::mimeData(const QModelIndexList &indexes) const | - | ||||||||||||||||||
513 | { | - | ||||||||||||||||||
514 | QList<QTreeWidgetItem*> items; | - | ||||||||||||||||||
515 | for (int i = 0; i <const auto &index : indexes.count(); ++i) { | - | ||||||||||||||||||
516 | if (indexesindex
| 0 | ||||||||||||||||||
517 | items << item(indexes.at(i));index); never executed: items << item(index); | 0 | ||||||||||||||||||
518 | } never executed: end of block | 0 | ||||||||||||||||||
519 | - | |||||||||||||||||||
520 | - | |||||||||||||||||||
521 | - | |||||||||||||||||||
522 | cachedIndexes = indexes; | - | ||||||||||||||||||
523 | QMimeData *mimeData = view()->mimeData(items); | - | ||||||||||||||||||
524 | cachedIndexes.clear(); | - | ||||||||||||||||||
525 | return never executed: mimeData;return mimeData; never executed: return mimeData; | 0 | ||||||||||||||||||
526 | } | - | ||||||||||||||||||
527 | - | |||||||||||||||||||
528 | bool QTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - | ||||||||||||||||||
529 | int row, int column, const QModelIndex &parent) | - | ||||||||||||||||||
530 | { | - | ||||||||||||||||||
531 | if (row == -1 && column == -1) | - | ||||||||||||||||||
532 | row = rowCount(parent); | - | ||||||||||||||||||
533 | return view()->dropMimeData(item(parent), row, data, action); | - | ||||||||||||||||||
534 | } | - | ||||||||||||||||||
535 | - | |||||||||||||||||||
536 | Qt::DropActions QTreeModel::supportedDropActions() const | - | ||||||||||||||||||
537 | { | - | ||||||||||||||||||
538 | return view()->supportedDropActions(); | - | ||||||||||||||||||
539 | } | - | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | void QTreeModel::itemChanged(QTreeWidgetItem *item) | - | ||||||||||||||||||
542 | { | - | ||||||||||||||||||
543 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
544 | QModelIndex left = index(item, 0); | - | ||||||||||||||||||
545 | QModelIndex right = index(item, item->columnCount() - 1); | - | ||||||||||||||||||
546 | dataChanged(left, right); | - | ||||||||||||||||||
547 | } | - | ||||||||||||||||||
548 | - | |||||||||||||||||||
549 | bool QTreeModel::isChanging() const | - | ||||||||||||||||||
550 | { | - | ||||||||||||||||||
551 | const QTreeModelPrivate * const d = d_func(); | - | ||||||||||||||||||
552 | return !d->changes.isEmpty(); | - | ||||||||||||||||||
553 | } | - | ||||||||||||||||||
554 | - | |||||||||||||||||||
555 | - | |||||||||||||||||||
556 | - | |||||||||||||||||||
557 | - | |||||||||||||||||||
558 | - | |||||||||||||||||||
559 | - | |||||||||||||||||||
560 | - | |||||||||||||||||||
561 | void QTreeModel::emitDataChanged(QTreeWidgetItem *item, int column) | - | ||||||||||||||||||
562 | { | - | ||||||||||||||||||
563 | if (signalsBlocked()) | - | ||||||||||||||||||
564 | return; | - | ||||||||||||||||||
565 | - | |||||||||||||||||||
566 | if (headerItem == item && column < item->columnCount()) { | - | ||||||||||||||||||
567 | if (column == -1) | - | ||||||||||||||||||
568 | headerDataChanged(Qt::Horizontal, 0, columnCount() - 1); | - | ||||||||||||||||||
569 | else | - | ||||||||||||||||||
570 | headerDataChanged(Qt::Horizontal, column, column); | - | ||||||||||||||||||
571 | return; | - | ||||||||||||||||||
572 | } | - | ||||||||||||||||||
573 | - | |||||||||||||||||||
574 | SkipSorting skipSorting(this); | - | ||||||||||||||||||
575 | - | |||||||||||||||||||
576 | QModelIndex bottomRight, topLeft; | - | ||||||||||||||||||
577 | if (column == -1) { | - | ||||||||||||||||||
578 | topLeft = index(item, 0); | - | ||||||||||||||||||
579 | bottomRight = createIndex(topLeft.row(), columnCount() - 1, item); | - | ||||||||||||||||||
580 | } else { | - | ||||||||||||||||||
581 | topLeft = index(item, column); | - | ||||||||||||||||||
582 | bottomRight = topLeft; | - | ||||||||||||||||||
583 | } | - | ||||||||||||||||||
584 | dataChanged(topLeft, bottomRight); | - | ||||||||||||||||||
585 | } | - | ||||||||||||||||||
586 | - | |||||||||||||||||||
587 | void QTreeModel::beginInsertItems(QTreeWidgetItem *parent, int row, int count) | - | ||||||||||||||||||
588 | { | - | ||||||||||||||||||
589 | QModelIndex par = index(parent, 0); | - | ||||||||||||||||||
590 | beginInsertRows(par, row, row + count - 1); | - | ||||||||||||||||||
591 | } | - | ||||||||||||||||||
592 | - | |||||||||||||||||||
593 | void QTreeModel::endInsertItems() | - | ||||||||||||||||||
594 | { | - | ||||||||||||||||||
595 | endInsertRows(); | - | ||||||||||||||||||
596 | } | - | ||||||||||||||||||
597 | - | |||||||||||||||||||
598 | void QTreeModel::beginRemoveItems(QTreeWidgetItem *parent, int row, int count) | - | ||||||||||||||||||
599 | { | - | ||||||||||||||||||
600 | ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,814820) : qt_noop()); | - | ||||||||||||||||||
601 | ((!(count > 0)) ? qt_assert("count > 0",__FILE__,815821) : qt_noop()); | - | ||||||||||||||||||
602 | beginRemoveRows(index(parent, 0), row, row + count - 1); | - | ||||||||||||||||||
603 | if (!parent) | - | ||||||||||||||||||
604 | parent = rootItem; | - | ||||||||||||||||||
605 | - | |||||||||||||||||||
606 | for (int i = 0; i < iterators.count(); ++i) { | - | ||||||||||||||||||
607 | for (int j = 0; j < count; j++) { | - | ||||||||||||||||||
608 | QTreeWidgetItem *c = parent->child(row + j); | - | ||||||||||||||||||
609 | iterators[i]->d_func()->ensureValidIterator(c); | - | ||||||||||||||||||
610 | } | - | ||||||||||||||||||
611 | } | - | ||||||||||||||||||
612 | } | - | ||||||||||||||||||
613 | - | |||||||||||||||||||
614 | void QTreeModel::endRemoveItems() | - | ||||||||||||||||||
615 | { | - | ||||||||||||||||||
616 | endRemoveRows(); | - | ||||||||||||||||||
617 | } | - | ||||||||||||||||||
618 | - | |||||||||||||||||||
619 | void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortOrder order) | - | ||||||||||||||||||
620 | { | - | ||||||||||||||||||
621 | - | |||||||||||||||||||
622 | (void)column;; | - | ||||||||||||||||||
623 | if (isChanging()) | - | ||||||||||||||||||
624 | return; | - | ||||||||||||||||||
625 | - | |||||||||||||||||||
626 | - | |||||||||||||||||||
627 | QVector< QPair<QTreeWidgetItem*,int> > sorting(items->count()); | - | ||||||||||||||||||
628 | for (int i = 0; i < sorting.count(); ++i) { | - | ||||||||||||||||||
629 | sorting[i].first = items->at(i); | - | ||||||||||||||||||
630 | sorting[i].second = i; | - | ||||||||||||||||||
631 | } | - | ||||||||||||||||||
632 | - | |||||||||||||||||||
633 | - | |||||||||||||||||||
634 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); | - | ||||||||||||||||||
635 | std::stable_sort(sorting.begin(), sorting.end(), compare); | - | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | QModelIndexList fromList; | - | ||||||||||||||||||
638 | QModelIndexList toList; | - | ||||||||||||||||||
639 | int colCount = columnCount(); | - | ||||||||||||||||||
640 | for (int r = 0; r < sorting.count(); ++r) { | - | ||||||||||||||||||
641 | int oldRow = sorting.at(r).second; | - | ||||||||||||||||||
642 | if (oldRow == r) | - | ||||||||||||||||||
643 | continue; | - | ||||||||||||||||||
644 | QTreeWidgetItem *item = sorting.at(r).first; | - | ||||||||||||||||||
645 | items->replace(r, item); | - | ||||||||||||||||||
646 | for (int c = 0; c < colCount; ++c) { | - | ||||||||||||||||||
647 | QModelIndex from = createIndex(oldRow, c, item); | - | ||||||||||||||||||
648 | if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) { | - | ||||||||||||||||||
649 | QModelIndex to = createIndex(r, c, item); | - | ||||||||||||||||||
650 | fromList << from; | - | ||||||||||||||||||
651 | toList << to; | - | ||||||||||||||||||
652 | } | - | ||||||||||||||||||
653 | } | - | ||||||||||||||||||
654 | } | - | ||||||||||||||||||
655 | changePersistentIndexList(fromList, toList); | - | ||||||||||||||||||
656 | } | - | ||||||||||||||||||
657 | - | |||||||||||||||||||
658 | void QTreeModel::timerEvent(QTimerEvent *ev) | - | ||||||||||||||||||
659 | { | - | ||||||||||||||||||
660 | if (ev->timerId() == sortPendingTimer.timerId()) { | - | ||||||||||||||||||
661 | executePendingSort(); | - | ||||||||||||||||||
662 | } else { | - | ||||||||||||||||||
663 | QAbstractItemModel::timerEvent(ev); | - | ||||||||||||||||||
664 | } | - | ||||||||||||||||||
665 | } | - | ||||||||||||||||||
666 | QTreeWidgetItem::QTreeWidgetItem(int type) | - | ||||||||||||||||||
667 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
668 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
669 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
670 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
671 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
672 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
673 | { | - | ||||||||||||||||||
674 | } | - | ||||||||||||||||||
675 | QTreeWidgetItem::QTreeWidgetItem(const QStringList &strings, int type) | - | ||||||||||||||||||
676 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
677 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
678 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
679 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
680 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
681 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
682 | { | - | ||||||||||||||||||
683 | for (int i = 0; i < strings.count(); ++i) | - | ||||||||||||||||||
684 | setText(i, strings.at(i)); | - | ||||||||||||||||||
685 | } | - | ||||||||||||||||||
686 | QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, int type) | - | ||||||||||||||||||
687 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
688 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
689 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
690 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
691 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
692 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
693 | { | - | ||||||||||||||||||
694 | if (view && view->model()) { | - | ||||||||||||||||||
695 | QTreeModel *model = qobject_cast<QTreeModel*>(view->model()); | - | ||||||||||||||||||
696 | model->rootItem->addChild(this); | - | ||||||||||||||||||
697 | values.reserve(model->headerItem->columnCount()); | - | ||||||||||||||||||
698 | } | - | ||||||||||||||||||
699 | } | - | ||||||||||||||||||
700 | QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type) | - | ||||||||||||||||||
701 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
702 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
703 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
704 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
705 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
706 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
707 | { | - | ||||||||||||||||||
708 | for (int i = 0; i < strings.count(); ++i) | - | ||||||||||||||||||
709 | setText(i, strings.at(i)); | - | ||||||||||||||||||
710 | if (view && view->model()) { | - | ||||||||||||||||||
711 | QTreeModel *model = qobject_cast<QTreeModel*>(view->model()); | - | ||||||||||||||||||
712 | model->rootItem->addChild(this); | - | ||||||||||||||||||
713 | values.reserve(model->headerItem->columnCount()); | - | ||||||||||||||||||
714 | } | - | ||||||||||||||||||
715 | } | - | ||||||||||||||||||
716 | QTreeWidgetItem::QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type) | - | ||||||||||||||||||
717 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
718 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
719 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
720 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
721 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
722 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
723 | { | - | ||||||||||||||||||
724 | if (view) { | - | ||||||||||||||||||
725 | QTreeModel *model = qobject_cast<QTreeModel*>(view->model()); | - | ||||||||||||||||||
726 | if (model) { | - | ||||||||||||||||||
727 | int i = model->rootItem->children.indexOf(after) + 1; | - | ||||||||||||||||||
728 | model->rootItem->insertChild(i, this); | - | ||||||||||||||||||
729 | values.reserve(model->headerItem->columnCount()); | - | ||||||||||||||||||
730 | } | - | ||||||||||||||||||
731 | } | - | ||||||||||||||||||
732 | } | - | ||||||||||||||||||
733 | - | |||||||||||||||||||
734 | - | |||||||||||||||||||
735 | - | |||||||||||||||||||
736 | - | |||||||||||||||||||
737 | - | |||||||||||||||||||
738 | - | |||||||||||||||||||
739 | QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, int type) | - | ||||||||||||||||||
740 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
741 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
742 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
743 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
744 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
745 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
746 | { | - | ||||||||||||||||||
747 | if (parent) | - | ||||||||||||||||||
748 | parent->addChild(this); | - | ||||||||||||||||||
749 | } | - | ||||||||||||||||||
750 | - | |||||||||||||||||||
751 | - | |||||||||||||||||||
752 | - | |||||||||||||||||||
753 | - | |||||||||||||||||||
754 | - | |||||||||||||||||||
755 | - | |||||||||||||||||||
756 | - | |||||||||||||||||||
757 | QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type) | - | ||||||||||||||||||
758 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
759 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
760 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
761 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
762 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
763 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
764 | { | - | ||||||||||||||||||
765 | for (int i = 0; i < strings.count(); ++i) | - | ||||||||||||||||||
766 | setText(i, strings.at(i)); | - | ||||||||||||||||||
767 | if (parent) | - | ||||||||||||||||||
768 | parent->addChild(this); | - | ||||||||||||||||||
769 | } | - | ||||||||||||||||||
770 | QTreeWidgetItem::QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type) | - | ||||||||||||||||||
771 | : rtti(type), view(0), d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
772 | itemFlags(Qt::ItemIsSelectable | - | ||||||||||||||||||
773 | |Qt::ItemIsUserCheckable | - | ||||||||||||||||||
774 | |Qt::ItemIsEnabled | - | ||||||||||||||||||
775 | |Qt::ItemIsDragEnabled | - | ||||||||||||||||||
776 | |Qt::ItemIsDropEnabled) | - | ||||||||||||||||||
777 | { | - | ||||||||||||||||||
778 | if (parent) { | - | ||||||||||||||||||
779 | int i = parent->children.indexOf(after) + 1; | - | ||||||||||||||||||
780 | parent->insertChild(i, this); | - | ||||||||||||||||||
781 | } | - | ||||||||||||||||||
782 | } | - | ||||||||||||||||||
783 | QTreeWidgetItem::~QTreeWidgetItem() | - | ||||||||||||||||||
784 | { | - | ||||||||||||||||||
785 | QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0); | - | ||||||||||||||||||
786 | bool wasSkipSort = false; | - | ||||||||||||||||||
787 | if (model) { | - | ||||||||||||||||||
788 | wasSkipSort = model->skipPendingSort; | - | ||||||||||||||||||
789 | model->skipPendingSort = true; | - | ||||||||||||||||||
790 | } | - | ||||||||||||||||||
791 | if (par) { | - | ||||||||||||||||||
792 | int i = par->children.indexOf(this); | - | ||||||||||||||||||
793 | if (i >= 0) { | - | ||||||||||||||||||
794 | if (model) model->beginRemoveItems(par, i, 1); | - | ||||||||||||||||||
795 | - | |||||||||||||||||||
796 | - | |||||||||||||||||||
797 | if (!par->children.isEmpty() && par->children.at(i) == this) | - | ||||||||||||||||||
798 | par->children.takeAt(i); | - | ||||||||||||||||||
799 | if (model) model->endRemoveItems(); | - | ||||||||||||||||||
800 | } | - | ||||||||||||||||||
801 | } else if (model) { | - | ||||||||||||||||||
802 | if (this == model->headerItem) { | - | ||||||||||||||||||
803 | model->headerItem = 0; | - | ||||||||||||||||||
804 | } else { | - | ||||||||||||||||||
805 | int i = model->rootItem->children.indexOf(this); | - | ||||||||||||||||||
806 | if (i >= 0) { | - | ||||||||||||||||||
807 | model->beginRemoveItems(0, i, 1); | - | ||||||||||||||||||
808 | - | |||||||||||||||||||
809 | - | |||||||||||||||||||
810 | if (!model->rootItem->children.isEmpty() && model->rootItem->children.at(i) == this) | - | ||||||||||||||||||
811 | model->rootItem->children.takeAt(i); | - | ||||||||||||||||||
812 | model->endRemoveItems(); | - | ||||||||||||||||||
813 | } | - | ||||||||||||||||||
814 | } | - | ||||||||||||||||||
815 | } | - | ||||||||||||||||||
816 | - | |||||||||||||||||||
817 | - | |||||||||||||||||||
818 | for (int i = 0; i < children.count(); ++i) { | - | ||||||||||||||||||
819 | QTreeWidgetItem *child = children.at(i); | - | ||||||||||||||||||
820 | - | |||||||||||||||||||
821 | child->par = 0; | - | ||||||||||||||||||
822 | - | |||||||||||||||||||
823 | child->view = 0; | - | ||||||||||||||||||
824 | delete child; | - | ||||||||||||||||||
825 | } | - | ||||||||||||||||||
826 | - | |||||||||||||||||||
827 | children.clear(); | - | ||||||||||||||||||
828 | delete d; | - | ||||||||||||||||||
829 | if (model) { | - | ||||||||||||||||||
830 | model->skipPendingSort = wasSkipSort; | - | ||||||||||||||||||
831 | } | - | ||||||||||||||||||
832 | } | - | ||||||||||||||||||
833 | - | |||||||||||||||||||
834 | - | |||||||||||||||||||
835 | - | |||||||||||||||||||
836 | - | |||||||||||||||||||
837 | QTreeWidgetItem *QTreeWidgetItem::clone() const | - | ||||||||||||||||||
838 | { | - | ||||||||||||||||||
839 | QTreeWidgetItem *copy = 0; | - | ||||||||||||||||||
840 | - | |||||||||||||||||||
841 | QStack<const QTreeWidgetItem*> stack; | - | ||||||||||||||||||
842 | QStack<QTreeWidgetItem*> parentStack; | - | ||||||||||||||||||
843 | stack.push(this); | - | ||||||||||||||||||
844 | parentStack.push(0); | - | ||||||||||||||||||
845 | - | |||||||||||||||||||
846 | QTreeWidgetItem *root = 0; | - | ||||||||||||||||||
847 | const QTreeWidgetItem *item = 0; | - | ||||||||||||||||||
848 | QTreeWidgetItem *parent = 0; | - | ||||||||||||||||||
849 | while (!stack.isEmpty()) { | - | ||||||||||||||||||
850 | - | |||||||||||||||||||
851 | item = stack.pop(); | - | ||||||||||||||||||
852 | parent = parentStack.pop(); | - | ||||||||||||||||||
853 | - | |||||||||||||||||||
854 | - | |||||||||||||||||||
855 | copy = new QTreeWidgetItem(*item); | - | ||||||||||||||||||
856 | if (!root) | - | ||||||||||||||||||
857 | root = copy; | - | ||||||||||||||||||
858 | - | |||||||||||||||||||
859 | - | |||||||||||||||||||
860 | if (parent) { | - | ||||||||||||||||||
861 | copy->par = parent; | - | ||||||||||||||||||
862 | parent->children.insert(0, copy); | - | ||||||||||||||||||
863 | } | - | ||||||||||||||||||
864 | - | |||||||||||||||||||
865 | for (int i = 0; i < item->childCount(); ++i) { | - | ||||||||||||||||||
866 | stack.push(item->child(i)); | - | ||||||||||||||||||
867 | parentStack.push(copy); | - | ||||||||||||||||||
868 | } | - | ||||||||||||||||||
869 | } | - | ||||||||||||||||||
870 | return root; | - | ||||||||||||||||||
871 | } | - | ||||||||||||||||||
872 | void QTreeWidgetItem::setChildIndicatorPolicy(QTreeWidgetItem::ChildIndicatorPolicy policy) | - | ||||||||||||||||||
873 | { | - | ||||||||||||||||||
874 | if (d->policy == policy) | - | ||||||||||||||||||
875 | return; | - | ||||||||||||||||||
876 | d->policy = policy; | - | ||||||||||||||||||
877 | - | |||||||||||||||||||
878 | if (!view) | - | ||||||||||||||||||
879 | return; | - | ||||||||||||||||||
880 | - | |||||||||||||||||||
881 | view->scheduleDelayedItemsLayout(); | - | ||||||||||||||||||
882 | } | - | ||||||||||||||||||
883 | - | |||||||||||||||||||
884 | - | |||||||||||||||||||
885 | - | |||||||||||||||||||
886 | - | |||||||||||||||||||
887 | - | |||||||||||||||||||
888 | - | |||||||||||||||||||
889 | - | |||||||||||||||||||
890 | QTreeWidgetItem::ChildIndicatorPolicy QTreeWidgetItem::childIndicatorPolicy() const | - | ||||||||||||||||||
891 | { | - | ||||||||||||||||||
892 | return d->policy; | - | ||||||||||||||||||
893 | } | - | ||||||||||||||||||
894 | void QTreeWidgetItem::setFlags(Qt::ItemFlags flags) | - | ||||||||||||||||||
895 | { | - | ||||||||||||||||||
896 | const bool enable = (flags & Qt::ItemIsEnabled); | - | ||||||||||||||||||
897 | const bool changedState = bool(itemFlags & Qt::ItemIsEnabled) != enable; | - | ||||||||||||||||||
898 | const bool changedExplicit = d->disabled != !enable; | - | ||||||||||||||||||
899 | - | |||||||||||||||||||
900 | d->disabled = !enable; | - | ||||||||||||||||||
901 | - | |||||||||||||||||||
902 | if (enable && par && !(par->itemFlags & Qt::ItemIsEnabled)) | - | ||||||||||||||||||
903 | itemFlags = flags & ~Qt::ItemIsEnabled; | - | ||||||||||||||||||
904 | else | - | ||||||||||||||||||
905 | itemFlags = flags; | - | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | if (changedState && changedExplicit) { | - | ||||||||||||||||||
908 | QStack<QTreeWidgetItem*> parents; | - | ||||||||||||||||||
909 | parents.push(this); | - | ||||||||||||||||||
910 | while (!parents.isEmpty()) { | - | ||||||||||||||||||
911 | QTreeWidgetItem *parent = parents.pop(); | - | ||||||||||||||||||
912 | for (int i = 0; i < parent->children.count(); ++i) { | - | ||||||||||||||||||
913 | QTreeWidgetItem *child = parent->children.at(i); | - | ||||||||||||||||||
914 | if (!child->d->disabled) { | - | ||||||||||||||||||
915 | parents.push(child); | - | ||||||||||||||||||
916 | if (enable) | - | ||||||||||||||||||
917 | child->itemFlags = child->itemFlags | Qt::ItemIsEnabled; | - | ||||||||||||||||||
918 | else | - | ||||||||||||||||||
919 | child->itemFlags = child->itemFlags & ~Qt::ItemIsEnabled; | - | ||||||||||||||||||
920 | child->itemChanged(); | - | ||||||||||||||||||
921 | } | - | ||||||||||||||||||
922 | } | - | ||||||||||||||||||
923 | } | - | ||||||||||||||||||
924 | } | - | ||||||||||||||||||
925 | itemChanged(); | - | ||||||||||||||||||
926 | } | - | ||||||||||||||||||
927 | - | |||||||||||||||||||
928 | void QTreeWidgetItemPrivate::propagateDisabled(QTreeWidgetItem *item) | - | ||||||||||||||||||
929 | { | - | ||||||||||||||||||
930 | ((!(item)) ? qt_assert("item",__FILE__,16511657) : qt_noop()); | - | ||||||||||||||||||
931 | const bool enable = item->par ? (item->par->itemFlags.testFlag(Qt::ItemIsEnabled)) : true; | - | ||||||||||||||||||
932 | - | |||||||||||||||||||
933 | QStack<QTreeWidgetItem*> parents; | - | ||||||||||||||||||
934 | parents.push(item); | - | ||||||||||||||||||
935 | while (!parents.isEmpty()) { | - | ||||||||||||||||||
936 | QTreeWidgetItem *parent = parents.pop(); | - | ||||||||||||||||||
937 | if (!parent->d->disabled) { | - | ||||||||||||||||||
938 | Qt::ItemFlags oldFlags = parent->itemFlags; | - | ||||||||||||||||||
939 | if (enable) | - | ||||||||||||||||||
940 | parent->itemFlags = parent->itemFlags | Qt::ItemIsEnabled; | - | ||||||||||||||||||
941 | else | - | ||||||||||||||||||
942 | parent->itemFlags = parent->itemFlags & ~Qt::ItemIsEnabled; | - | ||||||||||||||||||
943 | if (parent->itemFlags != oldFlags) | - | ||||||||||||||||||
944 | parent->itemChanged(); | - | ||||||||||||||||||
945 | } | - | ||||||||||||||||||
946 | - | |||||||||||||||||||
947 | for (int i = 0; i < parent->children.count(); ++i) { | - | ||||||||||||||||||
948 | QTreeWidgetItem *child = parent->children.at(i); | - | ||||||||||||||||||
949 | parents.push(child); | - | ||||||||||||||||||
950 | } | - | ||||||||||||||||||
951 | } | - | ||||||||||||||||||
952 | } | - | ||||||||||||||||||
953 | Qt::ItemFlags QTreeWidgetItem::flags() const | - | ||||||||||||||||||
954 | { | - | ||||||||||||||||||
955 | return itemFlags; | - | ||||||||||||||||||
956 | } | - | ||||||||||||||||||
957 | void QTreeWidgetItem::setData(int column, int role, const QVariant &value) | - | ||||||||||||||||||
958 | { | - | ||||||||||||||||||
959 | if (column < 0
| 0 | ||||||||||||||||||
960 | return; never executed: return; | 0 | ||||||||||||||||||
961 | - | |||||||||||||||||||
962 | QTreeModel *model = (view
| 0 | ||||||||||||||||||
963 | switch (role) { | - | ||||||||||||||||||
964 | case never executed: Qt::EditRole:case Qt::EditRole: never executed: case Qt::EditRole: | 0 | ||||||||||||||||||
965 | case never executed: Qt::DisplayRole:case Qt::DisplayRole: never executed: {case Qt::DisplayRole: | 0 | ||||||||||||||||||
966 | if (values.count() <= column
| 0 | ||||||||||||||||||
967 | if (model
| 0 | ||||||||||||||||||
968 | model->setColumnCount(column + 1); never executed: model->setColumnCount(column + 1); | 0 | ||||||||||||||||||
969 | else | - | ||||||||||||||||||
970 | values.resize(column + 1); never executed: values.resize(column + 1); | 0 | ||||||||||||||||||
971 | } | - | ||||||||||||||||||
972 | if (d->display.count() <= column
| 0 | ||||||||||||||||||
973 | for (int i = d->display.count() - 1; i < column - 1
| 0 | ||||||||||||||||||
974 | d->display.append(QVariant()); never executed: d->display.append(QVariant()); | 0 | ||||||||||||||||||
975 | d->display.append(value); | - | ||||||||||||||||||
976 | } never executed: else if (d->display[column] != valueend of block
| 0 | ||||||||||||||||||
977 | d->display[column] = value; | - | ||||||||||||||||||
978 | } never executed: else {end of block | 0 | ||||||||||||||||||
979 | return; never executed: return; | 0 | ||||||||||||||||||
980 | } | - | ||||||||||||||||||
981 | } break; never executed: break; | 0 | ||||||||||||||||||
982 | case never executed: Qt::CheckStateRole:case Qt::CheckStateRole: never executed: case Qt::CheckStateRole: | 0 | ||||||||||||||||||
983 | if ((
| 0 | ||||||||||||||||||
984 | for (int i = 0; i < children.count()
| 0 | ||||||||||||||||||
985 | QTreeWidgetItem *child = children.at(i); | - | ||||||||||||||||||
986 | if (child->data(column, role).isValid()
| 0 | ||||||||||||||||||
987 | Qt::ItemFlags f = itemFlags; | - | ||||||||||||||||||
988 | itemFlags &= ~Qt::ItemIsAutoTristate; | - | ||||||||||||||||||
989 | child->setData(column, role, value); | - | ||||||||||||||||||
990 | itemFlags = f; | - | ||||||||||||||||||
991 | } never executed: end of block | 0 | ||||||||||||||||||
992 | } never executed: end of block | 0 | ||||||||||||||||||
993 | } never executed: end of block | 0 | ||||||||||||||||||
994 | - | |||||||||||||||||||
995 | default never executed: :default: never executed: default: code before this statement never executed: default: | 0 | ||||||||||||||||||
996 | if (column < values.count()
| 0 | ||||||||||||||||||
997 | bool found = false; | - | ||||||||||||||||||
998 | const QVector<QWidgetItemData> column_values = values.at(column); | - | ||||||||||||||||||
999 | for (int i = 0; i < column_values.count()
| 0 | ||||||||||||||||||
1000 | if (column_values.at(i).role == role
| 0 | ||||||||||||||||||
1001 | if (column_values.at(i).value == value
| 0 | ||||||||||||||||||
1002 | return; never executed: return; | 0 | ||||||||||||||||||
1003 | values[column][i].value = value; | - | ||||||||||||||||||
1004 | found = true; | - | ||||||||||||||||||
1005 | break; never executed: break; | 0 | ||||||||||||||||||
1006 | } | - | ||||||||||||||||||
1007 | } never executed: end of block | 0 | ||||||||||||||||||
1008 | if (!found
| 0 | ||||||||||||||||||
1009 | values[column].append(QWidgetItemData(role, value)); never executed: values[column].append(QWidgetItemData(role, value)); | 0 | ||||||||||||||||||
1010 | } never executed: else {end of block | 0 | ||||||||||||||||||
1011 | if (model
| 0 | ||||||||||||||||||
1012 | model->setColumnCount(column + 1); never executed: model->setColumnCount(column + 1); | 0 | ||||||||||||||||||
1013 | else | - | ||||||||||||||||||
1014 | values.resize(column + 1); never executed: values.resize(column + 1); | 0 | ||||||||||||||||||
1015 | values[column].append(QWidgetItemData(role, value)); | - | ||||||||||||||||||
1016 | } never executed: end of block | 0 | ||||||||||||||||||
1017 | } | - | ||||||||||||||||||
1018 | - | |||||||||||||||||||
1019 | if (model
| 0 | ||||||||||||||||||
1020 | model->emitDataChanged(this, column); | - | ||||||||||||||||||
1021 | if (role == Qt::CheckStateRole
| 0 | ||||||||||||||||||
1022 | QTreeWidgetItem *p; | - | ||||||||||||||||||
1023 | for (p = par; p
| 0 | ||||||||||||||||||
1024 | model->emitDataChanged(p, column); never executed: model->emitDataChanged(p, column); | 0 | ||||||||||||||||||
1025 | } never executed: end of block | 0 | ||||||||||||||||||
1026 | } never executed: end of block | 0 | ||||||||||||||||||
1027 | } never executed: end of block | 0 | ||||||||||||||||||
1028 | - | |||||||||||||||||||
1029 | - | |||||||||||||||||||
1030 | - | |||||||||||||||||||
1031 | - | |||||||||||||||||||
1032 | QVariant QTreeWidgetItem::data(int column, int role) const | - | ||||||||||||||||||
1033 | { | - | ||||||||||||||||||
1034 | switch (role) { | - | ||||||||||||||||||
1035 | case never executed: Qt::EditRole:case Qt::EditRole: never executed: case Qt::EditRole: | 0 | ||||||||||||||||||
1036 | case never executed: Qt::DisplayRole:case Qt::DisplayRole: never executed: case Qt::DisplayRole: | 0 | ||||||||||||||||||
1037 | if (column >= 0
| 0 | ||||||||||||||||||
1038 | return never executed: d->display.at(column);return d->display.at(column); never executed: return d->display.at(column); | 0 | ||||||||||||||||||
1039 | break; never executed: break; | 0 | ||||||||||||||||||
1040 | case never executed: Qt::CheckStateRole:case Qt::CheckStateRole: never executed: case Qt::CheckStateRole: | 0 | ||||||||||||||||||
1041 | - | |||||||||||||||||||
1042 | if (children.count()
| 0 | ||||||||||||||||||
1043 | return never executed: childrenCheckState(column);return childrenCheckState(column); never executed: return childrenCheckState(column); | 0 | ||||||||||||||||||
1044 | - | |||||||||||||||||||
1045 | default never executed: :default: never executed: default: code before this statement never executed: default: | 0 | ||||||||||||||||||
1046 | if (column >= 0
| 0 | ||||||||||||||||||
1047 | const QVector<QWidgetItemData> &column_values = values.at(column); | - | ||||||||||||||||||
1048 | for (int i = 0; i <const auto &column_value : column_values.count(); ++i) { | - | ||||||||||||||||||
1049 | if (column_valuescolumn_value
| 0 | ||||||||||||||||||
1050 | return never executed: column_valuescolumn_value.at(i).value;return column_value.value; never executed: return column_value.value; | 0 | ||||||||||||||||||
1051 | } never executed: end of block | 0 | ||||||||||||||||||
1052 | } never executed: end of block | 0 | ||||||||||||||||||
1053 | } never executed: end of block | 0 | ||||||||||||||||||
1054 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
1055 | } | - | ||||||||||||||||||
1056 | - | |||||||||||||||||||
1057 | - | |||||||||||||||||||
1058 | - | |||||||||||||||||||
1059 | - | |||||||||||||||||||
1060 | - | |||||||||||||||||||
1061 | - | |||||||||||||||||||
1062 | bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const | - | ||||||||||||||||||
1063 | { | - | ||||||||||||||||||
1064 | int column = view ? view->sortColumn() : 0; | - | ||||||||||||||||||
1065 | const QVariant v1 = data(column, Qt::DisplayRole); | - | ||||||||||||||||||
1066 | const QVariant v2 = other.data(column, Qt::DisplayRole); | - | ||||||||||||||||||
1067 | return QAbstractItemModelPrivate::variantLessThan(v1, v2); | - | ||||||||||||||||||
1068 | } | - | ||||||||||||||||||
1069 | void QTreeWidgetItem::read(QDataStream &in) | - | ||||||||||||||||||
1070 | { | - | ||||||||||||||||||
1071 | - | |||||||||||||||||||
1072 | if (in.version() < QDataStream::Qt_4_2) { | - | ||||||||||||||||||
1073 | d->display.clear(); | - | ||||||||||||||||||
1074 | in >> values; | - | ||||||||||||||||||
1075 | - | |||||||||||||||||||
1076 | for (int column = 0; column < values.count(); ++column) { | - | ||||||||||||||||||
1077 | d->display << QVariant(); | - | ||||||||||||||||||
1078 | for (int i = 0; i < values.at(column).count(); ++i) { | - | ||||||||||||||||||
1079 | if (values.at(column).at(i).role == Qt::DisplayRole) { | - | ||||||||||||||||||
1080 | d->display[column] = values.at(column).at(i).value; | - | ||||||||||||||||||
1081 | values[column].remove(i--); | - | ||||||||||||||||||
1082 | } | - | ||||||||||||||||||
1083 | } | - | ||||||||||||||||||
1084 | } | - | ||||||||||||||||||
1085 | } else { | - | ||||||||||||||||||
1086 | in >> values >> d->display; | - | ||||||||||||||||||
1087 | } | - | ||||||||||||||||||
1088 | } | - | ||||||||||||||||||
1089 | - | |||||||||||||||||||
1090 | - | |||||||||||||||||||
1091 | - | |||||||||||||||||||
1092 | - | |||||||||||||||||||
1093 | - | |||||||||||||||||||
1094 | - | |||||||||||||||||||
1095 | void QTreeWidgetItem::write(QDataStream &out) const | - | ||||||||||||||||||
1096 | { | - | ||||||||||||||||||
1097 | out << values << d->display; | - | ||||||||||||||||||
1098 | } | - | ||||||||||||||||||
1099 | QTreeWidgetItem::QTreeWidgetItem(const QTreeWidgetItem &other) | - | ||||||||||||||||||
1100 | : rtti(Type), values(other.values), view(0), | - | ||||||||||||||||||
1101 | d(new QTreeWidgetItemPrivate(this)), par(0), | - | ||||||||||||||||||
1102 | itemFlags(other.itemFlags) | - | ||||||||||||||||||
1103 | { | - | ||||||||||||||||||
1104 | d->display = other.d->display; | - | ||||||||||||||||||
1105 | } | - | ||||||||||||||||||
1106 | QTreeWidgetItem &QTreeWidgetItem::operator=(const QTreeWidgetItem &other) | - | ||||||||||||||||||
1107 | { | - | ||||||||||||||||||
1108 | values = other.values; | - | ||||||||||||||||||
1109 | d->display = other.d->display; | - | ||||||||||||||||||
1110 | d->policy = other.d->policy; | - | ||||||||||||||||||
1111 | itemFlags = other.itemFlags; | - | ||||||||||||||||||
1112 | return *this; | - | ||||||||||||||||||
1113 | } | - | ||||||||||||||||||
1114 | - | |||||||||||||||||||
1115 | - | |||||||||||||||||||
1116 | - | |||||||||||||||||||
1117 | - | |||||||||||||||||||
1118 | - | |||||||||||||||||||
1119 | - | |||||||||||||||||||
1120 | void QTreeWidgetItem::addChild(QTreeWidgetItem *child) | - | ||||||||||||||||||
1121 | { | - | ||||||||||||||||||
1122 | if (child) { | - | ||||||||||||||||||
1123 | insertChild(children.count(), child); | - | ||||||||||||||||||
1124 | child->d->rowGuess = children.count() - 1; | - | ||||||||||||||||||
1125 | } | - | ||||||||||||||||||
1126 | } | - | ||||||||||||||||||
1127 | - | |||||||||||||||||||
1128 | - | |||||||||||||||||||
1129 | - | |||||||||||||||||||
1130 | - | |||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | - | |||||||||||||||||||
1133 | void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child) | - | ||||||||||||||||||
1134 | { | - | ||||||||||||||||||
1135 | if (index < 0 || index > children.count() || child == 0 || child->view != 0 || child->par != 0) | - | ||||||||||||||||||
1136 | return; | - | ||||||||||||||||||
1137 | - | |||||||||||||||||||
1138 | if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0)) { | - | ||||||||||||||||||
1139 | const bool wasSkipSort = model->skipPendingSort; | - | ||||||||||||||||||
1140 | model->skipPendingSort = true; | - | ||||||||||||||||||
1141 | if (model->rootItem == this) | - | ||||||||||||||||||
1142 | child->par = 0; | - | ||||||||||||||||||
1143 | else | - | ||||||||||||||||||
1144 | child->par = this; | - | ||||||||||||||||||
1145 | if (view->isSortingEnabled()) { | - | ||||||||||||||||||
1146 | - | |||||||||||||||||||
1147 | if (!model->sortPendingTimer.isActive()) | - | ||||||||||||||||||
1148 | model->sortPendingTimer.start(0, model); | - | ||||||||||||||||||
1149 | } | - | ||||||||||||||||||
1150 | model->beginInsertItems(this, index, 1); | - | ||||||||||||||||||
1151 | int cols = model->columnCount(); | - | ||||||||||||||||||
1152 | QStack<QTreeWidgetItem*> stack; | - | ||||||||||||||||||
1153 | stack.push(child); | - | ||||||||||||||||||
1154 | while (!stack.isEmpty()) { | - | ||||||||||||||||||
1155 | QTreeWidgetItem *i = stack.pop(); | - | ||||||||||||||||||
1156 | i->view = view; | - | ||||||||||||||||||
1157 | i->values.reserve(cols); | - | ||||||||||||||||||
1158 | for (int c = 0; c < i->children.count(); ++c) | - | ||||||||||||||||||
1159 | stack.push(i->children.at(c)); | - | ||||||||||||||||||
1160 | } | - | ||||||||||||||||||
1161 | children.insert(index, child); | - | ||||||||||||||||||
1162 | model->endInsertItems(); | - | ||||||||||||||||||
1163 | model->skipPendingSort = wasSkipSort; | - | ||||||||||||||||||
1164 | } else { | - | ||||||||||||||||||
1165 | child->par = this; | - | ||||||||||||||||||
1166 | children.insert(index, child); | - | ||||||||||||||||||
1167 | } | - | ||||||||||||||||||
1168 | if (child->par) | - | ||||||||||||||||||
1169 | d->propagateDisabled(child); | - | ||||||||||||||||||
1170 | } | - | ||||||||||||||||||
1171 | - | |||||||||||||||||||
1172 | - | |||||||||||||||||||
1173 | - | |||||||||||||||||||
1174 | - | |||||||||||||||||||
1175 | - | |||||||||||||||||||
1176 | void QTreeWidgetItem::removeChild(QTreeWidgetItem *child) | - | ||||||||||||||||||
1177 | { | - | ||||||||||||||||||
1178 | (void)takeChild(children.indexOf(child)); | - | ||||||||||||||||||
1179 | } | - | ||||||||||||||||||
1180 | - | |||||||||||||||||||
1181 | - | |||||||||||||||||||
1182 | - | |||||||||||||||||||
1183 | - | |||||||||||||||||||
1184 | QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) | - | ||||||||||||||||||
1185 | { | - | ||||||||||||||||||
1186 | - | |||||||||||||||||||
1187 | - | |||||||||||||||||||
1188 | QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0); | - | ||||||||||||||||||
1189 | if (model) { | - | ||||||||||||||||||
1190 | - | |||||||||||||||||||
1191 | - | |||||||||||||||||||
1192 | - | |||||||||||||||||||
1193 | - | |||||||||||||||||||
1194 | model->skipPendingSort = false; | - | ||||||||||||||||||
1195 | model->executePendingSort(); | - | ||||||||||||||||||
1196 | } | - | ||||||||||||||||||
1197 | if (index >= 0 && index < children.count()) { | - | ||||||||||||||||||
1198 | if (model) model->beginRemoveItems(this, index, 1); | - | ||||||||||||||||||
1199 | QTreeWidgetItem *item = children.takeAt(index); | - | ||||||||||||||||||
1200 | item->par = 0; | - | ||||||||||||||||||
1201 | QStack<QTreeWidgetItem*> stack; | - | ||||||||||||||||||
1202 | stack.push(item); | - | ||||||||||||||||||
1203 | while (!stack.isEmpty()) { | - | ||||||||||||||||||
1204 | QTreeWidgetItem *i = stack.pop(); | - | ||||||||||||||||||
1205 | i->view = 0; | - | ||||||||||||||||||
1206 | for (int c = 0; c < i->children.count(); ++c) | - | ||||||||||||||||||
1207 | stack.push(i->children.at(c)); | - | ||||||||||||||||||
1208 | } | - | ||||||||||||||||||
1209 | d->propagateDisabled(item); | - | ||||||||||||||||||
1210 | if (model) model->endRemoveRows(); | - | ||||||||||||||||||
1211 | return item; | - | ||||||||||||||||||
1212 | } | - | ||||||||||||||||||
1213 | return 0; | - | ||||||||||||||||||
1214 | } | - | ||||||||||||||||||
1215 | void QTreeWidgetItem::addChildren(const QList<QTreeWidgetItem*> &children) | - | ||||||||||||||||||
1216 | { | - | ||||||||||||||||||
1217 | insertChildren(this->children.count(), children); | - | ||||||||||||||||||
1218 | } | - | ||||||||||||||||||
1219 | void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &children) | - | ||||||||||||||||||
1220 | { | - | ||||||||||||||||||
1221 | if (view && view->isSortingEnabled()) { | - | ||||||||||||||||||
1222 | for (int n = 0; n < children.count(); ++n) | - | ||||||||||||||||||
1223 | insertChild(index, children.at(n)); | - | ||||||||||||||||||
1224 | return; | - | ||||||||||||||||||
1225 | } | - | ||||||||||||||||||
1226 | QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0); | - | ||||||||||||||||||
1227 | QStack<QTreeWidgetItem*> stack; | - | ||||||||||||||||||
1228 | QList<QTreeWidgetItem*> itemsToInsert; | - | ||||||||||||||||||
1229 | for (int n = 0; n < children.count(); ++n) { | - | ||||||||||||||||||
1230 | QTreeWidgetItem *child = children.at(n); | - | ||||||||||||||||||
1231 | if (child->view || child->par) | - | ||||||||||||||||||
1232 | continue; | - | ||||||||||||||||||
1233 | itemsToInsert.append(child); | - | ||||||||||||||||||
1234 | if (view && model) { | - | ||||||||||||||||||
1235 | if (child->childCount() == 0) | - | ||||||||||||||||||
1236 | child->view = view; | - | ||||||||||||||||||
1237 | else | - | ||||||||||||||||||
1238 | stack.push(child); | - | ||||||||||||||||||
1239 | } | - | ||||||||||||||||||
1240 | if (model && (model->rootItem == this)) | - | ||||||||||||||||||
1241 | child->par = 0; | - | ||||||||||||||||||
1242 | else | - | ||||||||||||||||||
1243 | child->par = this; | - | ||||||||||||||||||
1244 | } | - | ||||||||||||||||||
1245 | if (!itemsToInsert.isEmpty()) { | - | ||||||||||||||||||
1246 | while (!stack.isEmpty()) { | - | ||||||||||||||||||
1247 | QTreeWidgetItem *i = stack.pop(); | - | ||||||||||||||||||
1248 | i->view = view; | - | ||||||||||||||||||
1249 | for (int c = 0; c < i->children.count(); ++c) | - | ||||||||||||||||||
1250 | stack.push(i->children.at(c)); | - | ||||||||||||||||||
1251 | } | - | ||||||||||||||||||
1252 | if (model) model->beginInsertItems(this, index, itemsToInsert.count()); | - | ||||||||||||||||||
1253 | for (int n = 0; n < itemsToInsert.count(); ++n) { | - | ||||||||||||||||||
1254 | QTreeWidgetItem *child = itemsToInsert.at(n); | - | ||||||||||||||||||
1255 | this->children.insert(index + n, child); | - | ||||||||||||||||||
1256 | if (child->par) | - | ||||||||||||||||||
1257 | d->propagateDisabled(child); | - | ||||||||||||||||||
1258 | } | - | ||||||||||||||||||
1259 | if (model) model->endInsertItems(); | - | ||||||||||||||||||
1260 | } | - | ||||||||||||||||||
1261 | } | - | ||||||||||||||||||
1262 | - | |||||||||||||||||||
1263 | - | |||||||||||||||||||
1264 | - | |||||||||||||||||||
1265 | - | |||||||||||||||||||
1266 | - | |||||||||||||||||||
1267 | - | |||||||||||||||||||
1268 | QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren() | - | ||||||||||||||||||
1269 | { | - | ||||||||||||||||||
1270 | QList<QTreeWidgetItem*> removed; | - | ||||||||||||||||||
1271 | if (children.count() > 0) { | - | ||||||||||||||||||
1272 | QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0); | - | ||||||||||||||||||
1273 | if (model) { | - | ||||||||||||||||||
1274 | - | |||||||||||||||||||
1275 | - | |||||||||||||||||||
1276 | - | |||||||||||||||||||
1277 | - | |||||||||||||||||||
1278 | model->executePendingSort(); | - | ||||||||||||||||||
1279 | } | - | ||||||||||||||||||
1280 | if (model) model->beginRemoveItems(this, 0, children.count()); | - | ||||||||||||||||||
1281 | for (int n = 0; n < children.count(); ++n) { | - | ||||||||||||||||||
1282 | QTreeWidgetItem *item = children.at(n); | - | ||||||||||||||||||
1283 | item->par = 0; | - | ||||||||||||||||||
1284 | QStack<QTreeWidgetItem*> stack; | - | ||||||||||||||||||
1285 | stack.push(item); | - | ||||||||||||||||||
1286 | while (!stack.isEmpty()) { | - | ||||||||||||||||||
1287 | QTreeWidgetItem *i = stack.pop(); | - | ||||||||||||||||||
1288 | i->view = 0; | - | ||||||||||||||||||
1289 | for (int c = 0; c < i->children.count(); ++c) | - | ||||||||||||||||||
1290 | stack.push(i->children.at(c)); | - | ||||||||||||||||||
1291 | } | - | ||||||||||||||||||
1292 | d->propagateDisabled(item); | - | ||||||||||||||||||
1293 | } | - | ||||||||||||||||||
1294 | removed = children; | - | ||||||||||||||||||
1295 | children.clear(); | - | ||||||||||||||||||
1296 | if (model) model->endRemoveItems(); | - | ||||||||||||||||||
1297 | } | - | ||||||||||||||||||
1298 | return removed; | - | ||||||||||||||||||
1299 | } | - | ||||||||||||||||||
1300 | - | |||||||||||||||||||
1301 | - | |||||||||||||||||||
1302 | void QTreeWidgetItemPrivate::sortChildren(int column, Qt::SortOrder order, bool climb) | - | ||||||||||||||||||
1303 | { | - | ||||||||||||||||||
1304 | QTreeModel *model = (q->view ? qobject_cast<QTreeModel*>(q->view->model()) : 0); | - | ||||||||||||||||||
1305 | if (!model) | - | ||||||||||||||||||
1306 | return; | - | ||||||||||||||||||
1307 | model->sortItems(&q->children, column, order); | - | ||||||||||||||||||
1308 | if (climb) { | - | ||||||||||||||||||
1309 | QList<QTreeWidgetItem*>::iterator it = q->children.begin(); | - | ||||||||||||||||||
1310 | for (; it != q->children.end(); ++it) { | - | ||||||||||||||||||
1311 | - | |||||||||||||||||||
1312 | - | |||||||||||||||||||
1313 | (*it)->d->sortChildren(column, order, climb); | - | ||||||||||||||||||
1314 | } | - | ||||||||||||||||||
1315 | } | - | ||||||||||||||||||
1316 | } | - | ||||||||||||||||||
1317 | void QTreeWidgetItem::sortChildren(int column, Qt::SortOrder order, bool climb) | - | ||||||||||||||||||
1318 | { | - | ||||||||||||||||||
1319 | QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0); | - | ||||||||||||||||||
1320 | if (!model) | - | ||||||||||||||||||
1321 | return; | - | ||||||||||||||||||
1322 | if (model->isChanging()) | - | ||||||||||||||||||
1323 | return; | - | ||||||||||||||||||
1324 | QTreeModel::SkipSorting skipSorting(model); | - | ||||||||||||||||||
1325 | int oldSortColumn = view->d_func()->explicitSortColumn; | - | ||||||||||||||||||
1326 | view->d_func()->explicitSortColumn = column; | - | ||||||||||||||||||
1327 | model->layoutAboutToBeChanged(); | - | ||||||||||||||||||
1328 | d->sortChildren(column, order, climb); | - | ||||||||||||||||||
1329 | model->layoutChanged(); | - | ||||||||||||||||||
1330 | view->d_func()->explicitSortColumn = oldSortColumn; | - | ||||||||||||||||||
1331 | } | - | ||||||||||||||||||
1332 | QVariant QTreeWidgetItem::childrenCheckState(int column) const | - | ||||||||||||||||||
1333 | { | - | ||||||||||||||||||
1334 | if (column < 0
| 0 | ||||||||||||||||||
1335 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
1336 | bool checkedChildren = false; | - | ||||||||||||||||||
1337 | bool uncheckedChildren = false; | - | ||||||||||||||||||
1338 | for (int i = 0; i <const auto *child : children.count(); ++i) { | - | ||||||||||||||||||
1339 | QVariant value = children.at(i)->child->data(column, Qt::CheckStateRole); | - | ||||||||||||||||||
1340 | if (!value.isValid()
| 0 | ||||||||||||||||||
1341 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
1342 | - | |||||||||||||||||||
1343 | switch (static_cast<Qt::CheckState>(value.toInt())) | - | ||||||||||||||||||
1344 | { | - | ||||||||||||||||||
1345 | case never executed: Qt::Unchecked:case Qt::Unchecked: never executed: case Qt::Unchecked: | 0 | ||||||||||||||||||
1346 | uncheckedChildren = true; | - | ||||||||||||||||||
1347 | break; never executed: break; | 0 | ||||||||||||||||||
1348 | case never executed: Qt::Checked:case Qt::Checked: never executed: case Qt::Checked: | 0 | ||||||||||||||||||
1349 | checkedChildren = true; | - | ||||||||||||||||||
1350 | break; never executed: break; | 0 | ||||||||||||||||||
1351 | case never executed: Qt::PartiallyChecked:case Qt::PartiallyChecked: never executed: case Qt::PartiallyChecked: | 0 | ||||||||||||||||||
1352 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1353 | return never executed: Qt::PartiallyChecked;return Qt::PartiallyChecked; never executed: return Qt::PartiallyChecked; | 0 | ||||||||||||||||||
1354 | } | - | ||||||||||||||||||
1355 | - | |||||||||||||||||||
1356 | if (uncheckedChildren
| 0 | ||||||||||||||||||
1357 | return never executed: Qt::PartiallyChecked;return Qt::PartiallyChecked; never executed: return Qt::PartiallyChecked; | 0 | ||||||||||||||||||
1358 | } never executed: end of block | 0 | ||||||||||||||||||
1359 | - | |||||||||||||||||||
1360 | if (uncheckedChildren
| 0 | ||||||||||||||||||
1361 | return never executed: Qt::Unchecked;return Qt::Unchecked; never executed: return Qt::Unchecked; | 0 | ||||||||||||||||||
1362 | else if (checkedChildren
| 0 | ||||||||||||||||||
1363 | return never executed: Qt::Checked;return Qt::Checked; never executed: return Qt::Checked; | 0 | ||||||||||||||||||
1364 | else | - | ||||||||||||||||||
1365 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
1366 | } | - | ||||||||||||||||||
1367 | void QTreeWidgetItem::emitDataChanged() | - | ||||||||||||||||||
1368 | { | - | ||||||||||||||||||
1369 | itemChanged(); | - | ||||||||||||||||||
1370 | } | - | ||||||||||||||||||
1371 | - | |||||||||||||||||||
1372 | - | |||||||||||||||||||
1373 | - | |||||||||||||||||||
1374 | - | |||||||||||||||||||
1375 | void QTreeWidgetItem::itemChanged() | - | ||||||||||||||||||
1376 | { | - | ||||||||||||||||||
1377 | if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0)) | - | ||||||||||||||||||
1378 | model->itemChanged(this); | - | ||||||||||||||||||
1379 | } | - | ||||||||||||||||||
1380 | - | |||||||||||||||||||
1381 | - | |||||||||||||||||||
1382 | - | |||||||||||||||||||
1383 | - | |||||||||||||||||||
1384 | void QTreeWidgetItem::executePendingSort() const | - | ||||||||||||||||||
1385 | { | - | ||||||||||||||||||
1386 | if (QTreeModel *model = (view ? qobject_cast<QTreeModel*>(view->model()) : 0)) | - | ||||||||||||||||||
1387 | model->executePendingSort(); | - | ||||||||||||||||||
1388 | } | - | ||||||||||||||||||
1389 | QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item) | - | ||||||||||||||||||
1390 | { | - | ||||||||||||||||||
1391 | item.write(out); | - | ||||||||||||||||||
1392 | return out; | - | ||||||||||||||||||
1393 | } | - | ||||||||||||||||||
1394 | QDataStream &operator>>(QDataStream &in, QTreeWidgetItem &item) | - | ||||||||||||||||||
1395 | { | - | ||||||||||||||||||
1396 | item.read(in); | - | ||||||||||||||||||
1397 | return in; | - | ||||||||||||||||||
1398 | } | - | ||||||||||||||||||
1399 | - | |||||||||||||||||||
1400 | - | |||||||||||||||||||
1401 | - | |||||||||||||||||||
1402 | void QTreeWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) | - | ||||||||||||||||||
1403 | { | - | ||||||||||||||||||
1404 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1405 | q->itemPressed(item(index), index.column()); | - | ||||||||||||||||||
1406 | } | - | ||||||||||||||||||
1407 | - | |||||||||||||||||||
1408 | void QTreeWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) | - | ||||||||||||||||||
1409 | { | - | ||||||||||||||||||
1410 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1411 | q->itemClicked(item(index), index.column()); | - | ||||||||||||||||||
1412 | } | - | ||||||||||||||||||
1413 | - | |||||||||||||||||||
1414 | void QTreeWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) | - | ||||||||||||||||||
1415 | { | - | ||||||||||||||||||
1416 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1417 | q->itemDoubleClicked(item(index), index.column()); | - | ||||||||||||||||||
1418 | } | - | ||||||||||||||||||
1419 | - | |||||||||||||||||||
1420 | void QTreeWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) | - | ||||||||||||||||||
1421 | { | - | ||||||||||||||||||
1422 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1423 | q->itemActivated(item(index), index.column()); | - | ||||||||||||||||||
1424 | } | - | ||||||||||||||||||
1425 | - | |||||||||||||||||||
1426 | void QTreeWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) | - | ||||||||||||||||||
1427 | { | - | ||||||||||||||||||
1428 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1429 | q->itemEntered(item(index), index.column()); | - | ||||||||||||||||||
1430 | } | - | ||||||||||||||||||
1431 | - | |||||||||||||||||||
1432 | void QTreeWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) | - | ||||||||||||||||||
1433 | { | - | ||||||||||||||||||
1434 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1435 | QTreeWidgetItem *indexItem = item(index); | - | ||||||||||||||||||
1436 | if (indexItem) | - | ||||||||||||||||||
1437 | q->itemChanged(indexItem, index.column()); | - | ||||||||||||||||||
1438 | } | - | ||||||||||||||||||
1439 | - | |||||||||||||||||||
1440 | void QTreeWidgetPrivate::_q_emitItemExpanded(const QModelIndex &index) | - | ||||||||||||||||||
1441 | { | - | ||||||||||||||||||
1442 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1443 | q->itemExpanded(item(index)); | - | ||||||||||||||||||
1444 | } | - | ||||||||||||||||||
1445 | - | |||||||||||||||||||
1446 | void QTreeWidgetPrivate::_q_emitItemCollapsed(const QModelIndex &index) | - | ||||||||||||||||||
1447 | { | - | ||||||||||||||||||
1448 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1449 | q->itemCollapsed(item(index)); | - | ||||||||||||||||||
1450 | } | - | ||||||||||||||||||
1451 | - | |||||||||||||||||||
1452 | void QTreeWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, | - | ||||||||||||||||||
1453 | const QModelIndex &previous) | - | ||||||||||||||||||
1454 | { | - | ||||||||||||||||||
1455 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1456 | QTreeWidgetItem *currentItem = item(current); | - | ||||||||||||||||||
1457 | QTreeWidgetItem *previousItem = item(previous); | - | ||||||||||||||||||
1458 | q->currentItemChanged(currentItem, previousItem); | - | ||||||||||||||||||
1459 | } | - | ||||||||||||||||||
1460 | - | |||||||||||||||||||
1461 | void QTreeWidgetPrivate::_q_sort() | - | ||||||||||||||||||
1462 | { | - | ||||||||||||||||||
1463 | if (sortingEnabled) { | - | ||||||||||||||||||
1464 | int column = header->sortIndicatorSection(); | - | ||||||||||||||||||
1465 | Qt::SortOrder order = header->sortIndicatorOrder(); | - | ||||||||||||||||||
1466 | treeModel()->sort(column, order); | - | ||||||||||||||||||
1467 | } | - | ||||||||||||||||||
1468 | } | - | ||||||||||||||||||
1469 | - | |||||||||||||||||||
1470 | void QTreeWidgetPrivate::_q_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) | - | ||||||||||||||||||
1471 | { | - | ||||||||||||||||||
1472 | QTreeWidget * const q = q_func(); | - | ||||||||||||||||||
1473 | QModelIndexList indices = selected.indexes(); | - | ||||||||||||||||||
1474 | int i; | - | ||||||||||||||||||
1475 | QTreeModel *m = treeModel(); | - | ||||||||||||||||||
1476 | for (i = 0; i < indices.count(); ++i) { | - | ||||||||||||||||||
1477 | QTreeWidgetItem *item = m->item(indices.at(i)); | - | ||||||||||||||||||
1478 | item->d->selected = true; | - | ||||||||||||||||||
1479 | } | - | ||||||||||||||||||
1480 | - | |||||||||||||||||||
1481 | indices = deselected.indexes(); | - | ||||||||||||||||||
1482 | for (i = 0; i < indices.count(); ++i) { | - | ||||||||||||||||||
1483 | QTreeWidgetItem *item = m->item(indices.at(i)); | - | ||||||||||||||||||
1484 | item->d->selected = false; | - | ||||||||||||||||||
1485 | } | - | ||||||||||||||||||
1486 | - | |||||||||||||||||||
1487 | q->itemSelectionChanged(); | - | ||||||||||||||||||
1488 | } | - | ||||||||||||||||||
1489 | - | |||||||||||||||||||
1490 | void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, | - | ||||||||||||||||||
1491 | const QModelIndex &bottomRight) | - | ||||||||||||||||||
1492 | { | - | ||||||||||||||||||
1493 | if (sortingEnabled && topLeft.isValid() && bottomRight.isValid() | - | ||||||||||||||||||
1494 | && !treeModel()->sortPendingTimer.isActive()) { | - | ||||||||||||||||||
1495 | int column = header->sortIndicatorSection(); | - | ||||||||||||||||||
1496 | if (column >= topLeft.column() && column <= bottomRight.column()) { | - | ||||||||||||||||||
1497 | Qt::SortOrder order = header->sortIndicatorOrder(); | - | ||||||||||||||||||
1498 | treeModel()->ensureSorted(column, order, topLeft.row(), | - | ||||||||||||||||||
1499 | bottomRight.row(), topLeft.parent()); | - | ||||||||||||||||||
1500 | } | - | ||||||||||||||||||
1501 | } | - | ||||||||||||||||||
1502 | } | - | ||||||||||||||||||
1503 | QTreeWidget::QTreeWidget(QWidget *parent) | - | ||||||||||||||||||
1504 | : QTreeView(*new QTreeWidgetPrivate(), parent) | - | ||||||||||||||||||
1505 | { | - | ||||||||||||||||||
1506 | QTreeView::setModel(new QTreeModel(1, this)); | - | ||||||||||||||||||
1507 | connect(this, qFlagLocation("2""pressed(QModelIndex)" "\0" __FILE__ ":" "2519""2526"), | - | ||||||||||||||||||
1508 | qFlagLocation("1""_q_emitItemPressed(QModelIndex)" "\0" __FILE__ ":" "2520""2527")); | - | ||||||||||||||||||
1509 | connect(this, qFlagLocation("2""clicked(QModelIndex)" "\0" __FILE__ ":" "2521""2528"), | - | ||||||||||||||||||
1510 | qFlagLocation("1""_q_emitItemClicked(QModelIndex)" "\0" __FILE__ ":" "2522""2529")); | - | ||||||||||||||||||
1511 | connect(this, qFlagLocation("2""doubleClicked(QModelIndex)" "\0" __FILE__ ":" "2523""2530"), | - | ||||||||||||||||||
1512 | qFlagLocation("1""_q_emitItemDoubleClicked(QModelIndex)" "\0" __FILE__ ":" "2524""2531")); | - | ||||||||||||||||||
1513 | connect(this, qFlagLocation("2""activated(QModelIndex)" "\0" __FILE__ ":" "2525""2532"), | - | ||||||||||||||||||
1514 | qFlagLocation("1""_q_emitItemActivated(QModelIndex)" "\0" __FILE__ ":" "2526""2533")); | - | ||||||||||||||||||
1515 | connect(this, qFlagLocation("2""entered(QModelIndex)" "\0" __FILE__ ":" "2527""2534"), | - | ||||||||||||||||||
1516 | qFlagLocation("1""_q_emitItemEntered(QModelIndex)" "\0" __FILE__ ":" "2528""2535")); | - | ||||||||||||||||||
1517 | connect(this, qFlagLocation("2""expanded(QModelIndex)" "\0" __FILE__ ":" "2529""2536"), | - | ||||||||||||||||||
1518 | qFlagLocation("1""_q_emitItemExpanded(QModelIndex)" "\0" __FILE__ ":" "2530""2537")); | - | ||||||||||||||||||
1519 | connect(this, qFlagLocation("2""collapsed(QModelIndex)" "\0" __FILE__ ":" "2531""2538"), | - | ||||||||||||||||||
1520 | qFlagLocation("1""_q_emitItemCollapsed(QModelIndex)" "\0" __FILE__ ":" "2532""2539")); | - | ||||||||||||||||||
1521 | connect(selectionModel(), qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2533""2540"), | - | ||||||||||||||||||
1522 | this, qFlagLocation("1""_q_emitCurrentItemChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2534""2541")); | - | ||||||||||||||||||
1523 | connect(model(), qFlagLocation("2""dataChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2535""2542"), | - | ||||||||||||||||||
1524 | this, qFlagLocation("1""_q_emitItemChanged(QModelIndex)" "\0" __FILE__ ":" "2536""2543")); | - | ||||||||||||||||||
1525 | connect(model(), qFlagLocation("2""dataChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2537""2544"), | - | ||||||||||||||||||
1526 | this, qFlagLocation("1""_q_dataChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "2538""2545")); | - | ||||||||||||||||||
1527 | connect(model(), qFlagLocation("2""columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "2539""2546"), | - | ||||||||||||||||||
1528 | this, qFlagLocation("1""_q_sort()" "\0" __FILE__ ":" "2540""2547")); | - | ||||||||||||||||||
1529 | connect(selectionModel(), qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "2541""2548"), | - | ||||||||||||||||||
1530 | this, qFlagLocation("1""_q_selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "2542""2549")); | - | ||||||||||||||||||
1531 | header()->setSectionsClickable(false); | - | ||||||||||||||||||
1532 | } | - | ||||||||||||||||||
1533 | - | |||||||||||||||||||
1534 | - | |||||||||||||||||||
1535 | - | |||||||||||||||||||
1536 | - | |||||||||||||||||||
1537 | - | |||||||||||||||||||
1538 | QTreeWidget::~QTreeWidget() | - | ||||||||||||||||||
1539 | { | - | ||||||||||||||||||
1540 | } | - | ||||||||||||||||||
1541 | - | |||||||||||||||||||
1542 | - | |||||||||||||||||||
1543 | - | |||||||||||||||||||
1544 | - | |||||||||||||||||||
1545 | - | |||||||||||||||||||
1546 | - | |||||||||||||||||||
1547 | - | |||||||||||||||||||
1548 | int QTreeWidget::columnCount() const | - | ||||||||||||||||||
1549 | { | - | ||||||||||||||||||
1550 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1551 | return d->model->columnCount(); | - | ||||||||||||||||||
1552 | } | - | ||||||||||||||||||
1553 | - | |||||||||||||||||||
1554 | - | |||||||||||||||||||
1555 | - | |||||||||||||||||||
1556 | - | |||||||||||||||||||
1557 | - | |||||||||||||||||||
1558 | void QTreeWidget::setColumnCount(int columns) | - | ||||||||||||||||||
1559 | { | - | ||||||||||||||||||
1560 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1561 | if (columns < 0) | - | ||||||||||||||||||
1562 | return; | - | ||||||||||||||||||
1563 | d->treeModel()->setColumnCount(columns); | - | ||||||||||||||||||
1564 | } | - | ||||||||||||||||||
1565 | QTreeWidgetItem *QTreeWidget::invisibleRootItem() const | - | ||||||||||||||||||
1566 | { | - | ||||||||||||||||||
1567 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1568 | return d->treeModel()->rootItem; | - | ||||||||||||||||||
1569 | } | - | ||||||||||||||||||
1570 | QTreeWidgetItem *QTreeWidget::topLevelItem(int index) const | - | ||||||||||||||||||
1571 | { | - | ||||||||||||||||||
1572 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1573 | return d->treeModel()->rootItem->child(index); | - | ||||||||||||||||||
1574 | } | - | ||||||||||||||||||
1575 | int QTreeWidget::topLevelItemCount() const | - | ||||||||||||||||||
1576 | { | - | ||||||||||||||||||
1577 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1578 | return d->treeModel()->rootItem->childCount(); | - | ||||||||||||||||||
1579 | } | - | ||||||||||||||||||
1580 | void QTreeWidget::insertTopLevelItem(int index, QTreeWidgetItem *item) | - | ||||||||||||||||||
1581 | { | - | ||||||||||||||||||
1582 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1583 | d->treeModel()->rootItem->insertChild(index, item); | - | ||||||||||||||||||
1584 | } | - | ||||||||||||||||||
1585 | void QTreeWidget::addTopLevelItem(QTreeWidgetItem *item) | - | ||||||||||||||||||
1586 | { | - | ||||||||||||||||||
1587 | insertTopLevelItem(topLevelItemCount(), item); | - | ||||||||||||||||||
1588 | } | - | ||||||||||||||||||
1589 | QTreeWidgetItem *QTreeWidget::takeTopLevelItem(int index) | - | ||||||||||||||||||
1590 | { | - | ||||||||||||||||||
1591 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1592 | return d->treeModel()->rootItem->takeChild(index); | - | ||||||||||||||||||
1593 | } | - | ||||||||||||||||||
1594 | - | |||||||||||||||||||
1595 | - | |||||||||||||||||||
1596 | - | |||||||||||||||||||
1597 | - | |||||||||||||||||||
1598 | - | |||||||||||||||||||
1599 | - | |||||||||||||||||||
1600 | - | |||||||||||||||||||
1601 | int QTreeWidget::indexOfTopLevelItem(QTreeWidgetItem *item) const | - | ||||||||||||||||||
1602 | { | - | ||||||||||||||||||
1603 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1604 | d->treeModel()->executePendingSort(); | - | ||||||||||||||||||
1605 | return d->treeModel()->rootItem->children.indexOf(item); | - | ||||||||||||||||||
1606 | } | - | ||||||||||||||||||
1607 | void QTreeWidget::insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items) | - | ||||||||||||||||||
1608 | { | - | ||||||||||||||||||
1609 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1610 | d->treeModel()->rootItem->insertChildren(index, items); | - | ||||||||||||||||||
1611 | } | - | ||||||||||||||||||
1612 | - | |||||||||||||||||||
1613 | - | |||||||||||||||||||
1614 | - | |||||||||||||||||||
1615 | - | |||||||||||||||||||
1616 | - | |||||||||||||||||||
1617 | - | |||||||||||||||||||
1618 | void QTreeWidget::addTopLevelItems(const QList<QTreeWidgetItem*> &items) | - | ||||||||||||||||||
1619 | { | - | ||||||||||||||||||
1620 | insertTopLevelItems(topLevelItemCount(), items); | - | ||||||||||||||||||
1621 | } | - | ||||||||||||||||||
1622 | - | |||||||||||||||||||
1623 | - | |||||||||||||||||||
1624 | - | |||||||||||||||||||
1625 | - | |||||||||||||||||||
1626 | - | |||||||||||||||||||
1627 | - | |||||||||||||||||||
1628 | - | |||||||||||||||||||
1629 | QTreeWidgetItem *QTreeWidget::headerItem() const | - | ||||||||||||||||||
1630 | { | - | ||||||||||||||||||
1631 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1632 | return d->treeModel()->headerItem; | - | ||||||||||||||||||
1633 | } | - | ||||||||||||||||||
1634 | void QTreeWidget::setHeaderItem(QTreeWidgetItem *item) | - | ||||||||||||||||||
1635 | { | - | ||||||||||||||||||
1636 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1637 | if (!item) | - | ||||||||||||||||||
1638 | return; | - | ||||||||||||||||||
1639 | item->view = this; | - | ||||||||||||||||||
1640 | - | |||||||||||||||||||
1641 | int oldCount = columnCount(); | - | ||||||||||||||||||
1642 | if (oldCount < item->columnCount()) | - | ||||||||||||||||||
1643 | d->treeModel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount()); | - | ||||||||||||||||||
1644 | else | - | ||||||||||||||||||
1645 | d->treeModel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount); | - | ||||||||||||||||||
1646 | delete d->treeModel()->headerItem; | - | ||||||||||||||||||
1647 | d->treeModel()->headerItem = item; | - | ||||||||||||||||||
1648 | if (oldCount < item->columnCount()) | - | ||||||||||||||||||
1649 | d->treeModel()->endInsertColumns(); | - | ||||||||||||||||||
1650 | else | - | ||||||||||||||||||
1651 | d->treeModel()->endRemoveColumns(); | - | ||||||||||||||||||
1652 | d->treeModel()->headerDataChanged(Qt::Horizontal, 0, oldCount); | - | ||||||||||||||||||
1653 | } | - | ||||||||||||||||||
1654 | void QTreeWidget::setHeaderLabels(const QStringList &labels) | - | ||||||||||||||||||
1655 | { | - | ||||||||||||||||||
1656 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1657 | if (columnCount() < labels.count()) | - | ||||||||||||||||||
1658 | setColumnCount(labels.count()); | - | ||||||||||||||||||
1659 | QTreeWidgetItem *item = d->treeModel()->headerItem; | - | ||||||||||||||||||
1660 | for (int i = 0; i < labels.count(); ++i) | - | ||||||||||||||||||
1661 | item->setText(i, labels.at(i)); | - | ||||||||||||||||||
1662 | } | - | ||||||||||||||||||
1663 | QTreeWidgetItem *QTreeWidget::currentItem() const | - | ||||||||||||||||||
1664 | { | - | ||||||||||||||||||
1665 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1666 | return d->item(currentIndex()); | - | ||||||||||||||||||
1667 | } | - | ||||||||||||||||||
1668 | - | |||||||||||||||||||
1669 | - | |||||||||||||||||||
1670 | - | |||||||||||||||||||
1671 | - | |||||||||||||||||||
1672 | - | |||||||||||||||||||
1673 | - | |||||||||||||||||||
1674 | - | |||||||||||||||||||
1675 | int QTreeWidget::currentColumn() const | - | ||||||||||||||||||
1676 | { | - | ||||||||||||||||||
1677 | return currentIndex().column(); | - | ||||||||||||||||||
1678 | } | - | ||||||||||||||||||
1679 | void QTreeWidget::setCurrentItem(QTreeWidgetItem *item) | - | ||||||||||||||||||
1680 | { | - | ||||||||||||||||||
1681 | setCurrentItem(item, 0); | - | ||||||||||||||||||
1682 | } | - | ||||||||||||||||||
1683 | - | |||||||||||||||||||
1684 | - | |||||||||||||||||||
1685 | - | |||||||||||||||||||
1686 | - | |||||||||||||||||||
1687 | - | |||||||||||||||||||
1688 | - | |||||||||||||||||||
1689 | - | |||||||||||||||||||
1690 | void QTreeWidget::setCurrentItem(QTreeWidgetItem *item, int column) | - | ||||||||||||||||||
1691 | { | - | ||||||||||||||||||
1692 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1693 | setCurrentIndex(d->index(item, column)); | - | ||||||||||||||||||
1694 | } | - | ||||||||||||||||||
1695 | void QTreeWidget::setCurrentItem(QTreeWidgetItem *item, int column, | - | ||||||||||||||||||
1696 | QItemSelectionModel::SelectionFlags command) | - | ||||||||||||||||||
1697 | { | - | ||||||||||||||||||
1698 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1699 | d->selectionModel->setCurrentIndex(d->index(item, column), command); | - | ||||||||||||||||||
1700 | } | - | ||||||||||||||||||
1701 | QTreeWidgetItem *QTreeWidget::itemAt(const QPoint &p) const | - | ||||||||||||||||||
1702 | { | - | ||||||||||||||||||
1703 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1704 | return d->item(indexAt(p)); | - | ||||||||||||||||||
1705 | } | - | ||||||||||||||||||
1706 | QRect QTreeWidget::visualItemRect(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1707 | { | - | ||||||||||||||||||
1708 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1709 | - | |||||||||||||||||||
1710 | - | |||||||||||||||||||
1711 | QModelIndex base = d->index(item); | - | ||||||||||||||||||
1712 | const int firstVisiblesection = header()->logicalIndexAt(- header()->offset()); | - | ||||||||||||||||||
1713 | const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1); | - | ||||||||||||||||||
1714 | QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection)); | - | ||||||||||||||||||
1715 | QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection)); | - | ||||||||||||||||||
1716 | return visualRect(first) | visualRect(last); | - | ||||||||||||||||||
1717 | } | - | ||||||||||||||||||
1718 | int QTreeWidget::sortColumn() const | - | ||||||||||||||||||
1719 | { | - | ||||||||||||||||||
1720 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1721 | return (d->explicitSortColumn != -1 | - | ||||||||||||||||||
1722 | ? d->explicitSortColumn | - | ||||||||||||||||||
1723 | : header()->sortIndicatorSection()); | - | ||||||||||||||||||
1724 | } | - | ||||||||||||||||||
1725 | void QTreeWidget::sortItems(int column, Qt::SortOrder order) | - | ||||||||||||||||||
1726 | { | - | ||||||||||||||||||
1727 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1728 | header()->setSortIndicator(column, order); | - | ||||||||||||||||||
1729 | d->model->sort(column, order); | - | ||||||||||||||||||
1730 | } | - | ||||||||||||||||||
1731 | - | |||||||||||||||||||
1732 | - | |||||||||||||||||||
1733 | - | |||||||||||||||||||
1734 | - | |||||||||||||||||||
1735 | - | |||||||||||||||||||
1736 | void QTreeWidget::editItem(QTreeWidgetItem *item, int column) | - | ||||||||||||||||||
1737 | { | - | ||||||||||||||||||
1738 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1739 | edit(d->index(item, column)); | - | ||||||||||||||||||
1740 | } | - | ||||||||||||||||||
1741 | - | |||||||||||||||||||
1742 | - | |||||||||||||||||||
1743 | - | |||||||||||||||||||
1744 | - | |||||||||||||||||||
1745 | - | |||||||||||||||||||
1746 | - | |||||||||||||||||||
1747 | - | |||||||||||||||||||
1748 | void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column) | - | ||||||||||||||||||
1749 | { | - | ||||||||||||||||||
1750 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1751 | QAbstractItemView::openPersistentEditor(d->index(item, column)); | - | ||||||||||||||||||
1752 | } | - | ||||||||||||||||||
1753 | void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column) | - | ||||||||||||||||||
1754 | { | - | ||||||||||||||||||
1755 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1756 | QAbstractItemView::closePersistentEditor(d->index(item, column)); | - | ||||||||||||||||||
1757 | } | - | ||||||||||||||||||
1758 | - | |||||||||||||||||||
1759 | - | |||||||||||||||||||
1760 | - | |||||||||||||||||||
1761 | - | |||||||||||||||||||
1762 | - | |||||||||||||||||||
1763 | - | |||||||||||||||||||
1764 | - | |||||||||||||||||||
1765 | QWidget *QTreeWidget::itemWidget(QTreeWidgetItem *item, int column) const | - | ||||||||||||||||||
1766 | { | - | ||||||||||||||||||
1767 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1768 | return QAbstractItemView::indexWidget(d->index(item, column)); | - | ||||||||||||||||||
1769 | } | - | ||||||||||||||||||
1770 | void QTreeWidget::setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget) | - | ||||||||||||||||||
1771 | { | - | ||||||||||||||||||
1772 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1773 | QAbstractItemView::setIndexWidget(d->index(item, column), widget); | - | ||||||||||||||||||
1774 | } | - | ||||||||||||||||||
1775 | bool QTreeWidget::isItemSelected(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1776 | { | - | ||||||||||||||||||
1777 | if (!item) | - | ||||||||||||||||||
1778 | return false; | - | ||||||||||||||||||
1779 | return item->d->selected; | - | ||||||||||||||||||
1780 | } | - | ||||||||||||||||||
1781 | void QTreeWidget::setItemSelected(const QTreeWidgetItem *item, bool select) | - | ||||||||||||||||||
1782 | { | - | ||||||||||||||||||
1783 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1784 | - | |||||||||||||||||||
1785 | if (!item) | - | ||||||||||||||||||
1786 | return; | - | ||||||||||||||||||
1787 | - | |||||||||||||||||||
1788 | selectionModel()->select(d->index(item), (select ? QItemSelectionModel::Select | - | ||||||||||||||||||
1789 | : QItemSelectionModel::Deselect) | - | ||||||||||||||||||
1790 | |QItemSelectionModel::Rows); | - | ||||||||||||||||||
1791 | item->d->selected = select; | - | ||||||||||||||||||
1792 | } | - | ||||||||||||||||||
1793 | - | |||||||||||||||||||
1794 | - | |||||||||||||||||||
1795 | - | |||||||||||||||||||
1796 | - | |||||||||||||||||||
1797 | - | |||||||||||||||||||
1798 | - | |||||||||||||||||||
1799 | QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const | - | ||||||||||||||||||
1800 | { | - | ||||||||||||||||||
1801 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1802 | const QModelIndexList indexes = selectionModel()->selectedIndexes(); | - | ||||||||||||||||||
1803 | QList<QTreeWidgetItem*> items; | - | ||||||||||||||||||
1804 | items.reserve(indexes.count()); | - | ||||||||||||||||||
1805 | QSet<QTreeWidgetItem *> seen; | - | ||||||||||||||||||
1806 | seen.reserve(indexes.count()); | - | ||||||||||||||||||
1807 | for (int i = 0; i <const auto &index : indexes.count(); ++i) { | - | ||||||||||||||||||
1808 | QTreeWidgetItem *item = d->item(indexes.at(i));index); | - | ||||||||||||||||||
1809 | if (isItemHidden(item)
| 0 | ||||||||||||||||||
1810 | continue; never executed: continue; | 0 | ||||||||||||||||||
1811 | seen.insert(item); | - | ||||||||||||||||||
1812 | items.append(item); | - | ||||||||||||||||||
1813 | } never executed: end of block | 0 | ||||||||||||||||||
1814 | return never executed: items;return items; never executed: return items; | 0 | ||||||||||||||||||
1815 | } | - | ||||||||||||||||||
1816 | - | |||||||||||||||||||
1817 | - | |||||||||||||||||||
1818 | - | |||||||||||||||||||
1819 | - | |||||||||||||||||||
1820 | QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFlags flags, int column) const | - | ||||||||||||||||||
1821 | { | - | ||||||||||||||||||
1822 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1823 | QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()), | - | ||||||||||||||||||
1824 | Qt::DisplayRole, text, -1, flags); | - | ||||||||||||||||||
1825 | QList<QTreeWidgetItem*> items; | - | ||||||||||||||||||
1826 | const int indexesSize = indexes.size(); | - | ||||||||||||||||||
1827 | items.reserve(indexesSize); | - | ||||||||||||||||||
1828 | for (int i = 0; i < indexesSize; ++i) | - | ||||||||||||||||||
1829 | items.append(d->item(indexes.at(i))); | - | ||||||||||||||||||
1830 | return items; | - | ||||||||||||||||||
1831 | } | - | ||||||||||||||||||
1832 | bool QTreeWidget::isItemHidden(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1833 | { | - | ||||||||||||||||||
1834 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1835 | if (item == d->treeModel()->headerItem) | - | ||||||||||||||||||
1836 | return header()->isHidden(); | - | ||||||||||||||||||
1837 | if (d->hiddenIndexes.isEmpty()) | - | ||||||||||||||||||
1838 | return false; | - | ||||||||||||||||||
1839 | QTreeModel::SkipSorting skipSorting(d->treeModel()); | - | ||||||||||||||||||
1840 | return d->isRowHidden(d->index(item)); | - | ||||||||||||||||||
1841 | } | - | ||||||||||||||||||
1842 | void QTreeWidget::setItemHidden(const QTreeWidgetItem *item, bool hide) | - | ||||||||||||||||||
1843 | { | - | ||||||||||||||||||
1844 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1845 | if (item == d->treeModel()->headerItem) { | - | ||||||||||||||||||
1846 | header()->setHidden(hide); | - | ||||||||||||||||||
1847 | } else { | - | ||||||||||||||||||
1848 | const QModelIndex index = d->index(item); | - | ||||||||||||||||||
1849 | setRowHidden(index.row(), index.parent(), hide); | - | ||||||||||||||||||
1850 | } | - | ||||||||||||||||||
1851 | } | - | ||||||||||||||||||
1852 | bool QTreeWidget::isItemExpanded(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1853 | { | - | ||||||||||||||||||
1854 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1855 | QTreeModel::SkipSorting skipSorting(d->treeModel()); | - | ||||||||||||||||||
1856 | return isExpanded(d->index(item)); | - | ||||||||||||||||||
1857 | } | - | ||||||||||||||||||
1858 | void QTreeWidget::setItemExpanded(const QTreeWidgetItem *item, bool expand) | - | ||||||||||||||||||
1859 | { | - | ||||||||||||||||||
1860 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1861 | QTreeModel::SkipSorting skipSorting(d->treeModel()); | - | ||||||||||||||||||
1862 | setExpanded(d->index(item), expand); | - | ||||||||||||||||||
1863 | } | - | ||||||||||||||||||
1864 | bool QTreeWidget::isFirstItemColumnSpanned(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1865 | { | - | ||||||||||||||||||
1866 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1867 | if (item == d->treeModel()->headerItem) | - | ||||||||||||||||||
1868 | return false; | - | ||||||||||||||||||
1869 | const QModelIndex index = d->index(item); | - | ||||||||||||||||||
1870 | return isFirstColumnSpanned(index.row(), index.parent()); | - | ||||||||||||||||||
1871 | } | - | ||||||||||||||||||
1872 | void QTreeWidget::setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span) | - | ||||||||||||||||||
1873 | { | - | ||||||||||||||||||
1874 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1875 | if (item == d->treeModel()->headerItem) | - | ||||||||||||||||||
1876 | return; | - | ||||||||||||||||||
1877 | const QModelIndex index = d->index(item); | - | ||||||||||||||||||
1878 | setFirstColumnSpanned(index.row(), index.parent(), span); | - | ||||||||||||||||||
1879 | } | - | ||||||||||||||||||
1880 | - | |||||||||||||||||||
1881 | - | |||||||||||||||||||
1882 | - | |||||||||||||||||||
1883 | - | |||||||||||||||||||
1884 | - | |||||||||||||||||||
1885 | - | |||||||||||||||||||
1886 | QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1887 | { | - | ||||||||||||||||||
1888 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1889 | if (item == d->treeModel()->headerItem) | - | ||||||||||||||||||
1890 | return 0; | - | ||||||||||||||||||
1891 | const QModelIndex index = d->index(item); | - | ||||||||||||||||||
1892 | const QModelIndex above = indexAbove(index); | - | ||||||||||||||||||
1893 | return d->item(above); | - | ||||||||||||||||||
1894 | } | - | ||||||||||||||||||
1895 | - | |||||||||||||||||||
1896 | - | |||||||||||||||||||
1897 | - | |||||||||||||||||||
1898 | - | |||||||||||||||||||
1899 | - | |||||||||||||||||||
1900 | - | |||||||||||||||||||
1901 | QTreeWidgetItem *QTreeWidget::itemBelow(const QTreeWidgetItem *item) const | - | ||||||||||||||||||
1902 | { | - | ||||||||||||||||||
1903 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1904 | if (item == d->treeModel()->headerItem) | - | ||||||||||||||||||
1905 | return 0; | - | ||||||||||||||||||
1906 | const QModelIndex index = d->index(item); | - | ||||||||||||||||||
1907 | const QModelIndex below = indexBelow(index); | - | ||||||||||||||||||
1908 | return d->item(below); | - | ||||||||||||||||||
1909 | } | - | ||||||||||||||||||
1910 | - | |||||||||||||||||||
1911 | - | |||||||||||||||||||
1912 | - | |||||||||||||||||||
1913 | - | |||||||||||||||||||
1914 | void QTreeWidget::setSelectionModel(QItemSelectionModel *selectionModel) | - | ||||||||||||||||||
1915 | { | - | ||||||||||||||||||
1916 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1917 | QTreeView::setSelectionModel(selectionModel); | - | ||||||||||||||||||
1918 | QItemSelection newSelection = selectionModel->selection(); | - | ||||||||||||||||||
1919 | if (!newSelection.isEmpty()) | - | ||||||||||||||||||
1920 | d->_q_selectionChanged(newSelection, QItemSelection()); | - | ||||||||||||||||||
1921 | } | - | ||||||||||||||||||
1922 | - | |||||||||||||||||||
1923 | - | |||||||||||||||||||
1924 | - | |||||||||||||||||||
1925 | - | |||||||||||||||||||
1926 | - | |||||||||||||||||||
1927 | - | |||||||||||||||||||
1928 | - | |||||||||||||||||||
1929 | void QTreeWidget::scrollToItem(const QTreeWidgetItem *item, QAbstractItemView::ScrollHint hint) | - | ||||||||||||||||||
1930 | { | - | ||||||||||||||||||
1931 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1932 | QTreeView::scrollTo(d->index(item), hint); | - | ||||||||||||||||||
1933 | } | - | ||||||||||||||||||
1934 | - | |||||||||||||||||||
1935 | - | |||||||||||||||||||
1936 | - | |||||||||||||||||||
1937 | - | |||||||||||||||||||
1938 | - | |||||||||||||||||||
1939 | - | |||||||||||||||||||
1940 | - | |||||||||||||||||||
1941 | void QTreeWidget::expandItem(const QTreeWidgetItem *item) | - | ||||||||||||||||||
1942 | { | - | ||||||||||||||||||
1943 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1944 | QTreeModel::SkipSorting skipSorting(d->treeModel()); | - | ||||||||||||||||||
1945 | expand(d->index(item)); | - | ||||||||||||||||||
1946 | } | - | ||||||||||||||||||
1947 | - | |||||||||||||||||||
1948 | - | |||||||||||||||||||
1949 | - | |||||||||||||||||||
1950 | - | |||||||||||||||||||
1951 | - | |||||||||||||||||||
1952 | - | |||||||||||||||||||
1953 | - | |||||||||||||||||||
1954 | void QTreeWidget::collapseItem(const QTreeWidgetItem *item) | - | ||||||||||||||||||
1955 | { | - | ||||||||||||||||||
1956 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1957 | QTreeModel::SkipSorting skipSorting(d->treeModel()); | - | ||||||||||||||||||
1958 | collapse(d->index(item)); | - | ||||||||||||||||||
1959 | } | - | ||||||||||||||||||
1960 | void QTreeWidget::clear() | - | ||||||||||||||||||
1961 | { | - | ||||||||||||||||||
1962 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1963 | selectionModel()->clear(); | - | ||||||||||||||||||
1964 | d->treeModel()->clear(); | - | ||||||||||||||||||
1965 | } | - | ||||||||||||||||||
1966 | - | |||||||||||||||||||
1967 | - | |||||||||||||||||||
1968 | - | |||||||||||||||||||
1969 | - | |||||||||||||||||||
1970 | - | |||||||||||||||||||
1971 | - | |||||||||||||||||||
1972 | - | |||||||||||||||||||
1973 | QStringList QTreeWidget::mimeTypes() const | - | ||||||||||||||||||
1974 | { | - | ||||||||||||||||||
1975 | return model()->QAbstractItemModel::mimeTypes(); | - | ||||||||||||||||||
1976 | } | - | ||||||||||||||||||
1977 | QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const | - | ||||||||||||||||||
1978 | - | |||||||||||||||||||
1979 | { | - | ||||||||||||||||||
1980 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1981 | if (d->treeModel()->cachedIndexes.isEmpty()
| 0 | ||||||||||||||||||
1982 | QList<QModelIndex> indexes; | - | ||||||||||||||||||
1983 | for (int i = 0; i < items.count(); ++i) { | - | ||||||||||||||||||
QTreeWidgetItemconst auto *item =: items.at(i);) { | ||||||||||||||||||||
1984 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||||||||
1985 | QMessageLogger(__FILE__, 32853291, __PRETTY_FUNCTION__).warning("QTreeWidget::mimeData: Null-item passed"); | - | ||||||||||||||||||
1986 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1987 | } | - | ||||||||||||||||||
1988 | - | |||||||||||||||||||
1989 | for (int c = 0; c < item->values.count()
| 0 | ||||||||||||||||||
1990 | const QModelIndex index = indexFromItem(item, c); | - | ||||||||||||||||||
1991 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||||||||
1992 | QMessageLogger(__FILE__, 32923298, __PRETTY_FUNCTION__).warning() << "QTreeWidget::mimeData: No index associated with item :" << item; | - | ||||||||||||||||||
1993 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
1994 | } | - | ||||||||||||||||||
1995 | indexes << index; | - | ||||||||||||||||||
1996 | } never executed: end of block | 0 | ||||||||||||||||||
1997 | } never executed: end of block | 0 | ||||||||||||||||||
1998 | return never executed: d->model->QAbstractItemModel::mimeData(indexes);return d->model->QAbstractItemModel::mimeData(indexes); never executed: return d->model->QAbstractItemModel::mimeData(indexes); | 0 | ||||||||||||||||||
1999 | } | - | ||||||||||||||||||
2000 | return never executed: d->treeModel()->internalMimeData();return d->treeModel()->internalMimeData(); never executed: return d->treeModel()->internalMimeData(); | 0 | ||||||||||||||||||
2001 | } | - | ||||||||||||||||||
2002 | bool QTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, | - | ||||||||||||||||||
2003 | const QMimeData *data, Qt::DropAction action) | - | ||||||||||||||||||
2004 | { | - | ||||||||||||||||||
2005 | QModelIndex idx; | - | ||||||||||||||||||
2006 | if (parent) idx = indexFromItem(parent); | - | ||||||||||||||||||
2007 | return model()->QAbstractItemModel::dropMimeData(data, action , index, 0, idx); | - | ||||||||||||||||||
2008 | } | - | ||||||||||||||||||
2009 | - | |||||||||||||||||||
2010 | - | |||||||||||||||||||
2011 | - | |||||||||||||||||||
2012 | - | |||||||||||||||||||
2013 | - | |||||||||||||||||||
2014 | - | |||||||||||||||||||
2015 | Qt::DropActions QTreeWidget::supportedDropActions() const | - | ||||||||||||||||||
2016 | { | - | ||||||||||||||||||
2017 | return model()->QAbstractItemModel::supportedDropActions() | Qt::MoveAction; | - | ||||||||||||||||||
2018 | } | - | ||||||||||||||||||
2019 | - | |||||||||||||||||||
2020 | - | |||||||||||||||||||
2021 | - | |||||||||||||||||||
2022 | - | |||||||||||||||||||
2023 | - | |||||||||||||||||||
2024 | - | |||||||||||||||||||
2025 | - | |||||||||||||||||||
2026 | QList<QTreeWidgetItem*> QTreeWidget::items(const QMimeData *data) const | - | ||||||||||||||||||
2027 | { | - | ||||||||||||||||||
2028 | (void)data;; | - | ||||||||||||||||||
2029 | return QList<QTreeWidgetItem*>(); | - | ||||||||||||||||||
2030 | } | - | ||||||||||||||||||
2031 | QModelIndex QTreeWidget::indexFromItem(const QTreeWidgetItem *item, int column) const | - | ||||||||||||||||||
2032 | { | - | ||||||||||||||||||
2033 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
2034 | return never executed: d->index(item, column);return d->index(item, column); never executed: return d->index(item, column); | 0 | ||||||||||||||||||
2035 | } | - | ||||||||||||||||||
2036 | - | |||||||||||||||||||
2037 | - | |||||||||||||||||||
2038 | - | |||||||||||||||||||
2039 | - | |||||||||||||||||||
2040 | - | |||||||||||||||||||
2041 | QModelIndex QTreeWidget::indexFromItem(QTreeWidgetItem *item, int column) const | - | ||||||||||||||||||
2042 | { | - | ||||||||||||||||||
2043 | return never executed: indexFromItem(const_cast<const QTreeWidgetItem *>(item),return indexFromItem(const_cast<const QTreeWidgetItem *>(item), column); never executed: return indexFromItem(const_cast<const QTreeWidgetItem *>(item), column); never executed: column);return indexFromItem(const_cast<const QTreeWidgetItem *>(item), column); never executed: return indexFromItem(const_cast<const QTreeWidgetItem *>(item), column); | 0 | ||||||||||||||||||
2044 | } | - | ||||||||||||||||||
2045 | - | |||||||||||||||||||
2046 | - | |||||||||||||||||||
2047 | - | |||||||||||||||||||
2048 | - | |||||||||||||||||||
2049 | - | |||||||||||||||||||
2050 | - | |||||||||||||||||||
2051 | QTreeWidgetItem *QTreeWidget::itemFromIndex(const QModelIndex &index) const | - | ||||||||||||||||||
2052 | { | - | ||||||||||||||||||
2053 | const QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
2054 | return d->item(index); | - | ||||||||||||||||||
2055 | } | - | ||||||||||||||||||
2056 | - | |||||||||||||||||||
2057 | - | |||||||||||||||||||
2058 | - | |||||||||||||||||||
2059 | void QTreeWidget::dropEvent(QDropEvent *event) { | - | ||||||||||||||||||
2060 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
2061 | if (event->source() == this
| 0 | ||||||||||||||||||
2062 | dragDropMode() == QAbstractItemView::InternalMove
| 0 | ||||||||||||||||||
2063 | QModelIndex topIndex; | - | ||||||||||||||||||
2064 | int col = -1; | - | ||||||||||||||||||
2065 | int row = -1; | - | ||||||||||||||||||
2066 | if (d->dropOn(event, &row, &col, &topIndex)
| 0 | ||||||||||||||||||
2067 | const QList<QModelIndex> idxs = selectedIndexes(); | - | ||||||||||||||||||
2068 | QList<QPersistentModelIndex> indexes; | - | ||||||||||||||||||
2069 | const int indexesCount = idxs.count(); | - | ||||||||||||||||||
2070 | indexes.reserve(indexesCount); | - | ||||||||||||||||||
2071 | for (int i = 0; i < indexesCount; i++)const auto &idx : idxs) | - | ||||||||||||||||||
2072 | indexes.append(idxs.at(i));idx); never executed: indexes.append(idx); | 0 | ||||||||||||||||||
2073 | - | |||||||||||||||||||
2074 | if (indexes.contains(topIndex)
| 0 | ||||||||||||||||||
2075 | return; never executed: return; | 0 | ||||||||||||||||||
2076 | - | |||||||||||||||||||
2077 | - | |||||||||||||||||||
2078 | QPersistentModelIndex dropRow = model()->index(row, col, topIndex); | - | ||||||||||||||||||
2079 | - | |||||||||||||||||||
2080 | - | |||||||||||||||||||
2081 | QList<QTreeWidgetItem *> taken; | - | ||||||||||||||||||
2082 | for (int i = 0; i <const auto &index : indexes.count(); ++i) { | - | ||||||||||||||||||
2083 | QTreeWidgetItem *parent = itemFromIndex(indexes.at(i));index); | - | ||||||||||||||||||
2084 | if (!parent
| 0 | ||||||||||||||||||
2085 | taken.append(takeTopLevelItem(indexesindex.at(i).row())); | - | ||||||||||||||||||
2086 | } never executed: else {end of block | 0 | ||||||||||||||||||
2087 | taken.append(parent->parent()->takeChild(indexesindex.at(i).row())); | - | ||||||||||||||||||
2088 | } never executed: end of block | 0 | ||||||||||||||||||
2089 | } | - | ||||||||||||||||||
2090 | - | |||||||||||||||||||
2091 | - | |||||||||||||||||||
2092 | for (int i = 0; i < indexes.count()
| 0 | ||||||||||||||||||
2093 | - | |||||||||||||||||||
2094 | if (row == -1
| 0 | ||||||||||||||||||
2095 | if (topIndex.isValid()
| 0 | ||||||||||||||||||
2096 | QTreeWidgetItem *parent = itemFromIndex(topIndex); | - | ||||||||||||||||||
2097 | parent->insertChild(parent->childCount(), taken.takeFirst()); | - | ||||||||||||||||||
2098 | } never executed: else {end of block | 0 | ||||||||||||||||||
2099 | insertTopLevelItem(topLevelItemCount(), taken.takeFirst()); | - | ||||||||||||||||||
2100 | } never executed: end of block | 0 | ||||||||||||||||||
2101 | } else { | - | ||||||||||||||||||
2102 | int r = dropRow.row() >= 0
| 0 | ||||||||||||||||||
2103 | if (topIndex.isValid()
| 0 | ||||||||||||||||||
2104 | QTreeWidgetItem *parent = itemFromIndex(topIndex); | - | ||||||||||||||||||
2105 | parent->insertChild(qMin(r, parent->childCount()), taken.takeFirst()); | - | ||||||||||||||||||
2106 | } never executed: else {end of block | 0 | ||||||||||||||||||
2107 | insertTopLevelItem(qMin(r, topLevelItemCount()), taken.takeFirst()); | - | ||||||||||||||||||
2108 | } never executed: end of block | 0 | ||||||||||||||||||
2109 | } | - | ||||||||||||||||||
2110 | } | - | ||||||||||||||||||
2111 | - | |||||||||||||||||||
2112 | event->accept(); | - | ||||||||||||||||||
2113 | - | |||||||||||||||||||
2114 | event->setDropAction(Qt::CopyAction); | - | ||||||||||||||||||
2115 | } never executed: end of block | 0 | ||||||||||||||||||
2116 | } never executed: end of block | 0 | ||||||||||||||||||
2117 | - | |||||||||||||||||||
2118 | QTreeView::dropEvent(event); | - | ||||||||||||||||||
2119 | } never executed: end of block | 0 | ||||||||||||||||||
2120 | - | |||||||||||||||||||
2121 | - | |||||||||||||||||||
2122 | - | |||||||||||||||||||
2123 | - | |||||||||||||||||||
2124 | - | |||||||||||||||||||
2125 | - | |||||||||||||||||||
2126 | void QTreeWidget::setModel(QAbstractItemModel * ) | - | ||||||||||||||||||
2127 | { | - | ||||||||||||||||||
2128 | ((!(!"QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.")) ? qt_assert("!\"QTreeWidget::setModel() - Changing the model of the QTreeWidget is not allowed.\"",__FILE__,34363453) : qt_noop()); | - | ||||||||||||||||||
2129 | } | - | ||||||||||||||||||
2130 | - | |||||||||||||||||||
2131 | - | |||||||||||||||||||
2132 | - | |||||||||||||||||||
2133 | - | |||||||||||||||||||
2134 | bool QTreeWidget::event(QEvent *e) | - | ||||||||||||||||||
2135 | { | - | ||||||||||||||||||
2136 | QTreeWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
2137 | if (e->type() == QEvent::Polish) | - | ||||||||||||||||||
2138 | d->treeModel()->executePendingSort(); | - | ||||||||||||||||||
2139 | return QTreeView::event(e); | - | ||||||||||||||||||
2140 | } | - | ||||||||||||||||||
2141 | - | |||||||||||||||||||
2142 | - | |||||||||||||||||||
2143 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |