Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | QTreeWidgetItemIterator::QTreeWidgetItemIterator(const QTreeWidgetItemIterator &it) | - |
6 | : d_ptr(new QTreeWidgetItemIteratorPrivate(*(it.d_ptr))), | - |
7 | current(it.current), flags(it.flags) | - |
8 | { | - |
9 | QTreeWidgetItemIteratorPrivate * const d = d_func(); | - |
10 | ((!(d->m_model)) ? qt_assert("d->m_model",__FILE__,81) : qt_noop()); | - |
11 | d->m_model->iterators.append(this); | - |
12 | } never executed: end of block | 0 |
13 | QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags) | - |
14 | : current(0), flags(flags) | - |
15 | { | - |
16 | ((!(widget)) ? qt_assert("widget",__FILE__,97) : qt_noop()); | - |
17 | QTreeModel *model = qobject_cast<QTreeModel*>(widget->model()); | - |
18 | ((!(model)) ? qt_assert("model",__FILE__,99) : qt_noop()); | - |
19 | d_ptr.reset(new QTreeWidgetItemIteratorPrivate(this, model)); | - |
20 | model->iterators.append(this); | - |
21 | if (!model->rootItem->children.isEmpty()TRUE | never evaluated | FALSE | never evaluated |
) current = model->rootItem->child(0);never executed: current = model->rootItem->child(0); | 0 |
22 | if (currentTRUE | never evaluated | FALSE | never evaluated |
&& !matchesFlags(current)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
23 | ++(* never executed: ++(*this); this);never executed: ++(*this); | 0 |
24 | } never executed: end of block | 0 |
25 | QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidgetItem *item, IteratorFlags flags) | - |
26 | : d_ptr(new QTreeWidgetItemIteratorPrivate( | - |
27 | this, qobject_cast<QTreeModel*>(item->view->model()))), | - |
28 | current(item), flags(flags) | - |
29 | { | - |
30 | QTreeWidgetItemIteratorPrivate * const d = d_func(); | - |
31 | ((!(item)) ? qt_assert("item",__FILE__,122) : qt_noop()); | - |
32 | QTreeModel *model = qobject_cast<QTreeModel*>(item->view->model()); | - |
33 | ((!(model)) ? qt_assert("model",__FILE__,124) : qt_noop()); | - |
34 | model->iterators.append(this); | - |
35 | | - |
36 | | - |
37 | | - |
38 | QTreeWidgetItem *parent = item; | - |
39 | parent = parent->parent(); | - |
40 | QTreeWidgetItem *root = d->m_model->rootItem; | - |
41 | d->m_currentIndex = (parentTRUE | never evaluated | FALSE | never evaluated |
? parent : root)->indexOfChild(item); | 0 |
42 | | - |
43 | while (parentTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
44 | QTreeWidgetItem *itm = parent; | - |
45 | parent = parent->parent(); | - |
46 | const int index = (parentTRUE | never evaluated | FALSE | never evaluated |
? parent : root)->indexOfChild(itm); | 0 |
47 | d->m_parentIndex.prepend(index); | - |
48 | } never executed: end of block | 0 |
49 | | - |
50 | if (currentTRUE | never evaluated | FALSE | never evaluated |
&& !matchesFlags(current)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
51 | ++(* never executed: ++(*this); this);never executed: ++(*this); | 0 |
52 | } never executed: end of block | 0 |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | QTreeWidgetItemIterator::~QTreeWidgetItemIterator() | - |
59 | { | - |
60 | d_func()->m_model->iterators.removeAll(this); | - |
61 | } never executed: end of block | 0 |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator=(const QTreeWidgetItemIterator &it) | - |
69 | { | - |
70 | QTreeWidgetItemIteratorPrivate * const d = d_func(); | - |
71 | if (d_func()->m_model != it.d_func()->m_modelTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
72 | d_func()->m_model->iterators.removeAll(this); | - |
73 | it.d_func()->m_model->iterators.append(this); | - |
74 | } never executed: end of block | 0 |
75 | current = it.current; | - |
76 | flags = it.flags; | - |
77 | d->operator=(*it.d_func()); | - |
78 | return never executed: return *this; *this;never executed: return *this; | 0 |
79 | } | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | | - |
86 | | - |
87 | QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++() | - |
88 | { | - |
89 | if (currentTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
90 | do { | - |
91 | current = d_func()->next(current); | - |
92 | } never executed: end of block while (currentTRUE | never evaluated | FALSE | never evaluated |
&& !matchesFlags(current)TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
93 | return never executed: return *this; *this;never executed: return *this; | 0 |
94 | } | - |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator--() | - |
103 | { | - |
104 | if (currentTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
105 | do { | - |
106 | current = d_func()->previous(current); | - |
107 | } never executed: end of block while (currentTRUE | never evaluated | FALSE | never evaluated |
&& !matchesFlags(current)TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
108 | return never executed: return *this; *this;never executed: return *this; | 0 |
109 | } | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | bool QTreeWidgetItemIterator::matchesFlags(const QTreeWidgetItem *item) const | - |
115 | { | - |
116 | if (!itemTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
117 | return never executed: return false; false;never executed: return false; | 0 |
118 | | - |
119 | if (flags == AllTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
120 | return never executed: return true; true;never executed: return true; | 0 |
121 | | - |
122 | { | - |
123 | Qt::ItemFlags itemFlags = item->flags(); | - |
124 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Selectable)TRUE | never evaluated | FALSE | never evaluated |
&& !(itemFlags & Qt::ItemIsSelectable)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
125 | return never executed: return false; false;never executed: return false; | 0 |
126 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & NotSelectable)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
itemFlags & Qt::ItemIsSelectable)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
127 | return never executed: return false; false;never executed: return false; | 0 |
128 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & DragEnabled)TRUE | never evaluated | FALSE | never evaluated |
&& !(itemFlags & Qt::ItemIsDragEnabled)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
129 | return never executed: return false; false;never executed: return false; | 0 |
130 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & DragDisabled)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
itemFlags & Qt::ItemIsDragEnabled)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
131 | return never executed: return false; false;never executed: return false; | 0 |
132 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & DropEnabled)TRUE | never evaluated | FALSE | never evaluated |
&& !(itemFlags & Qt::ItemIsDropEnabled)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
133 | return never executed: return false; false;never executed: return false; | 0 |
134 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & DropDisabled)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
itemFlags & Qt::ItemIsDropEnabled)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
135 | return never executed: return false; false;never executed: return false; | 0 |
136 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Enabled)TRUE | never evaluated | FALSE | never evaluated |
&& !(itemFlags & Qt::ItemIsEnabled)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
137 | return never executed: return false; false;never executed: return false; | 0 |
138 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Disabled)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
itemFlags & Qt::ItemIsEnabled)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
139 | return never executed: return false; false;never executed: return false; | 0 |
140 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Editable)TRUE | never evaluated | FALSE | never evaluated |
&& !(itemFlags & Qt::ItemIsEditable)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
141 | return never executed: return false; false;never executed: return false; | 0 |
142 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & NotEditable)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
itemFlags & Qt::ItemIsEditable)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
143 | return never executed: return false; false;never executed: return false; | 0 |
144 | } | - |
145 | | - |
146 | if (flags & (Checked|NotChecked)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
147 | | - |
148 | Qt::CheckState check = item->checkState(0); | - |
149 | | - |
150 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Checked)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
check == Qt::Unchecked)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
151 | return never executed: return false; false;never executed: return false; | 0 |
152 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & NotChecked)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
check != Qt::Unchecked)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
153 | return never executed: return false; false;never executed: return false; | 0 |
154 | } never executed: end of block | 0 |
155 | | - |
156 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & HasChildren)TRUE | never evaluated | FALSE | never evaluated |
&& !item->childCount()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
157 | return never executed: return false; false;never executed: return false; | 0 |
158 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & NoChildren)TRUE | never evaluated | FALSE | never evaluated |
&& item->childCount()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
159 | return never executed: return false; false;never executed: return false; | 0 |
160 | | - |
161 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Hidden)TRUE | never evaluated | FALSE | never evaluated |
&& !item->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
162 | return never executed: return false; false;never executed: return false; | 0 |
163 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & NotHidden)TRUE | never evaluated | FALSE | never evaluated |
&& item->isHidden()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
164 | return never executed: return false; false;never executed: return false; | 0 |
165 | | - |
166 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Selected)TRUE | never evaluated | FALSE | never evaluated |
&& !item->isSelected()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
167 | return never executed: return false; false;never executed: return false; | 0 |
168 | if ((TRUE | never evaluated | FALSE | never evaluated |
flags & Unselected)TRUE | never evaluated | FALSE | never evaluated |
&& item->isSelected()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
169 | return never executed: return false; false;never executed: return false; | 0 |
170 | | - |
171 | return never executed: return true; true;never executed: return true; | 0 |
172 | } | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | QTreeWidgetItem* QTreeWidgetItemIteratorPrivate::nextSibling(const QTreeWidgetItem* item) const | - |
178 | { | - |
179 | ((!(item)) ? qt_assert("item",__FILE__,270) : qt_noop()); | - |
180 | QTreeWidgetItem *next = 0; | - |
181 | if (QTreeWidgetItem *par = item->parent()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
182 | int i = par->indexOfChild(const_cast<QTreeWidgetItem*>(item)); | - |
183 | next = par->child(i + 1); | - |
184 | } never executed: end of block else { | 0 |
185 | QTreeWidget *tw = item->treeWidget(); | - |
186 | int i = tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem*>(item)); | - |
187 | next = tw->topLevelItem(i + 1); | - |
188 | } never executed: end of block | 0 |
189 | return never executed: return next; next;never executed: return next; | 0 |
190 | } | - |
191 | | - |
192 | QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *current) | - |
193 | { | - |
194 | if (!currentTRUE | never evaluated | FALSE | never evaluated |
) returnnever executed: return 0; 0;never executed: return 0; | 0 |
195 | | - |
196 | QTreeWidgetItem *next = 0; | - |
197 | if (current->childCount()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
198 | | - |
199 | m_parentIndex.push(m_currentIndex); | - |
200 | m_currentIndex = 0; | - |
201 | next = current->child(0); | - |
202 | } never executed: end of block else { | 0 |
203 | | - |
204 | QTreeWidgetItem *parent = current->parent(); | - |
205 | next = parentTRUE | never evaluated | FALSE | never evaluated |
? parent->child(m_currentIndex + 1) | 0 |
206 | : m_model->rootItem->child(m_currentIndex + 1); | - |
207 | while (!nextTRUE | never evaluated | FALSE | never evaluated |
&& parentTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
208 | | - |
209 | parent = parent->parent(); | - |
210 | m_currentIndex = m_parentIndex.pop(); | - |
211 | next = parentTRUE | never evaluated | FALSE | never evaluated |
? parent->child(m_currentIndex + 1) | 0 |
212 | : m_model->rootItem->child(m_currentIndex + 1); | - |
213 | } never executed: end of block | 0 |
214 | if (nextTRUE | never evaluated | FALSE | never evaluated |
) ++(never executed: ++(m_currentIndex); m_currentIndex);never executed: ++(m_currentIndex); | 0 |
215 | } never executed: end of block | 0 |
216 | return never executed: return next; next;never executed: return next; | 0 |
217 | } | - |
218 | | - |
219 | QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::previous(const QTreeWidgetItem *current) | - |
220 | { | - |
221 | if (!currentTRUE | never evaluated | FALSE | never evaluated |
) returnnever executed: return 0; 0;never executed: return 0; | 0 |
222 | | - |
223 | QTreeWidgetItem *prev = 0; | - |
224 | | - |
225 | QTreeWidgetItem *parent = current->parent(); | - |
226 | prev = parentTRUE | never evaluated | FALSE | never evaluated |
? parent->child(m_currentIndex - 1) | 0 |
227 | : m_model->rootItem->child(m_currentIndex - 1); | - |
228 | if (prevTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
229 | | - |
230 | --m_currentIndex; | - |
231 | while (prevTRUE | never evaluated | FALSE | never evaluated |
&& prev->childCount()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
232 | m_parentIndex.push(m_currentIndex); | - |
233 | m_currentIndex = prev->childCount() - 1; | - |
234 | prev = prev->child(m_currentIndex); | - |
235 | } never executed: end of block | 0 |
236 | } never executed: end of block else if (parentTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
237 | m_currentIndex = m_parentIndex.pop(); | - |
238 | prev = parent; | - |
239 | } never executed: end of block | 0 |
240 | return never executed: return prev; prev;never executed: return prev; | 0 |
241 | } | - |
242 | | - |
243 | void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *itemToBeRemoved) | - |
244 | { | - |
245 | QTreeWidgetItemIterator * const q = q_func(); | - |
246 | ((!(itemToBeRemoved)) ? qt_assert("itemToBeRemoved",__FILE__,337) : qt_noop()); | - |
247 | | - |
248 | if (!q->currentTRUE | never evaluated | FALSE | never evaluated |
) return;never executed: return; | 0 |
249 | QTreeWidgetItem *nextItem = q->current; | - |
250 | | - |
251 | | - |
252 | if (nextItem->parent() != itemToBeRemoved->parent()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
253 | while (nextItem->parent()TRUE | never evaluated | FALSE | never evaluated |
&& nextItem != itemToBeRemovedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
254 | nextItem = nextItem->parent(); | - |
255 | } never executed: end of block | 0 |
256 | } never executed: end of block | 0 |
257 | | - |
258 | | - |
259 | if (nextItem == itemToBeRemovedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
260 | QTreeWidgetItem *parent = nextItem; | - |
261 | nextItem = 0; | - |
262 | while (parentTRUE | never evaluated | FALSE | never evaluated |
&& !nextItemTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
263 | nextItem = nextSibling(parent); | - |
264 | parent = parent->parent(); | - |
265 | } never executed: end of block | 0 |
266 | if (nextItemTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
267 | | - |
268 | *q = QTreeWidgetItemIterator(nextItem, q->flags); | - |
269 | if (!(q->matchesFlags(nextItem))TRUE | never evaluated | FALSE | never evaluated |
) ++(*never executed: ++(*q); q);never executed: ++(*q); | 0 |
270 | } never executed: end of block else { | 0 |
271 | | - |
272 | q->current = 0; | - |
273 | m_parentIndex.clear(); | - |
274 | return; never executed: return; | 0 |
275 | } | - |
276 | } | - |
277 | if (nextItem->parent() == itemToBeRemoved->parent()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
278 | | - |
279 | | - |
280 | | - |
281 | QTreeWidgetItem *par = itemToBeRemoved->parent(); | - |
282 | QTreeWidget *tw = itemToBeRemoved->treeWidget(); | - |
283 | int indexOfItemToBeRemoved = parTRUE | never evaluated | FALSE | never evaluated |
? par->indexOfChild(const_cast<QTreeWidgetItem *>(itemToBeRemoved)) | 0 |
284 | : tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem *>(itemToBeRemoved)); | - |
285 | int indexOfNextItem = parTRUE | never evaluated | FALSE | never evaluated |
? par->indexOfChild(nextItem) : tw->indexOfTopLevelItem(nextItem); | 0 |
286 | | - |
287 | if (indexOfItemToBeRemoved <= indexOfNextItemTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
288 | | - |
289 | | - |
290 | m_currentIndex--; | - |
291 | } never executed: end of block | 0 |
292 | } never executed: end of block | 0 |
293 | } never executed: end of block | 0 |
294 | | - |
| | |