Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | typedef bool(*LessThan)(const QPair<QListWidgetItem*,int>&,const QPair<QListWidgetItem*,int>&); | - |
10 | | - |
11 | class QListWidgetMimeData : public QMimeData | - |
12 | { | - |
13 | public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; | - |
14 | public: | - |
15 | QList<QListWidgetItem*> items; | - |
16 | }; | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | QListModel::QListModel(QListWidget *parent) | - |
22 | : QAbstractListModel(parent) | - |
23 | { | - |
24 | } executed: } Execution Count:108 | 108 |
25 | | - |
26 | QListModel::~QListModel() | - |
27 | { | - |
28 | clear(); | - |
29 | } executed: } Execution Count:108 | 108 |
30 | | - |
31 | void QListModel::clear() | - |
32 | { | - |
33 | beginResetModel(); | - |
34 | for (int i = 0; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:13858 | yes Evaluation Count:108 |
| 108-13858 |
35 | if (items.at(i)) { partially evaluated: items.at(i) yes Evaluation Count:13858 | no Evaluation Count:0 |
| 0-13858 |
36 | items.at(i)->d->theid = -1; | - |
37 | items.at(i)->view = 0; | - |
38 | delete items.at(i); | - |
39 | } executed: } Execution Count:13858 | 13858 |
40 | } executed: } Execution Count:13858 | 13858 |
41 | items.clear(); | - |
42 | endResetModel(); | - |
43 | } executed: } Execution Count:108 | 108 |
44 | | - |
45 | QListWidgetItem *QListModel::at(int row) const | - |
46 | { | - |
47 | return items.value(row); executed: return items.value(row); Execution Count:150 | 150 |
48 | } | - |
49 | | - |
50 | void QListModel::remove(QListWidgetItem *item) | - |
51 | { | - |
52 | if (!item) | 0 |
53 | return; | 0 |
54 | int row = items.indexOf(item); | - |
55 | qt_noop(); | - |
56 | beginRemoveRows(QModelIndex(), row, row); | - |
57 | items.at(row)->d->theid = -1; | - |
58 | items.at(row)->view = 0; | - |
59 | items.removeAt(row); | - |
60 | endRemoveRows(); | - |
61 | } | 0 |
62 | | - |
63 | void QListModel::insert(int row, QListWidgetItem *item) | - |
64 | { | - |
65 | if (!item) partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:13858 |
| 0-13858 |
66 | return; | 0 |
67 | | - |
68 | item->view = qobject_cast<QListWidget*>(QObject::parent()); | - |
69 | if (item->view && item->view->isSortingEnabled()) { partially evaluated: item->view yes Evaluation Count:13858 | no Evaluation Count:0 |
partially evaluated: item->view->isSortingEnabled() no Evaluation Count:0 | yes Evaluation Count:13858 |
| 0-13858 |
70 | | - |
71 | QList<QListWidgetItem*>::iterator it; | - |
72 | it = sortedInsertionIterator(items.begin(), items.end(), | - |
73 | item->view->sortOrder(), item); | - |
74 | row = qMax(it - items.begin(), 0); | - |
75 | } else { | 0 |
76 | if (row < 0) partially evaluated: row < 0 no Evaluation Count:0 | yes Evaluation Count:13858 |
| 0-13858 |
77 | row = 0; | 0 |
78 | else if (row > items.count()) partially evaluated: row > items.count() no Evaluation Count:0 | yes Evaluation Count:13858 |
| 0-13858 |
79 | row = items.count(); never executed: row = items.count(); | 0 |
80 | } | - |
81 | beginInsertRows(QModelIndex(), row, row); | - |
82 | items.insert(row, item); | - |
83 | item->d->theid = row; | - |
84 | endInsertRows(); | - |
85 | } executed: } Execution Count:13858 | 13858 |
86 | | - |
87 | void QListModel::insert(int row, const QStringList &labels) | - |
88 | { | - |
89 | const int count = labels.count(); | - |
90 | if (count <= 0) never evaluated: count <= 0 | 0 |
91 | return; | 0 |
92 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
93 | if (view && view->isSortingEnabled()) { never evaluated: view->isSortingEnabled() | 0 |
94 | | - |
95 | for (int i = 0; i < count; ++i) { never evaluated: i < count | 0 |
96 | QListWidgetItem *item = new QListWidgetItem(labels.at(i)); | - |
97 | insert(row, item); | - |
98 | } | 0 |
99 | } else { | 0 |
100 | if (row < 0) | 0 |
101 | row = 0; | 0 |
102 | else if (row > items.count()) never evaluated: row > items.count() | 0 |
103 | row = items.count(); never executed: row = items.count(); | 0 |
104 | beginInsertRows(QModelIndex(), row, row + count - 1); | - |
105 | for (int i = 0; i < count; ++i) { never evaluated: i < count | 0 |
106 | QListWidgetItem *item = new QListWidgetItem(labels.at(i)); | - |
107 | item->d->theid = row; | - |
108 | item->view = qobject_cast<QListWidget*>(QObject::parent()); | - |
109 | items.insert(row++, item); | - |
110 | } | 0 |
111 | endInsertRows(); | - |
112 | } | 0 |
113 | } | - |
114 | | - |
115 | QListWidgetItem *QListModel::take(int row) | - |
116 | { | - |
117 | if (row < 0 || row >= items.count()) never evaluated: row >= items.count() | 0 |
118 | return 0; never executed: return 0; | 0 |
119 | | - |
120 | beginRemoveRows(QModelIndex(), row, row); | - |
121 | items.at(row)->d->theid = -1; | - |
122 | items.at(row)->view = 0; | - |
123 | QListWidgetItem *item = items.takeAt(row); | - |
124 | endRemoveRows(); | - |
125 | return item; never executed: return item; | 0 |
126 | } | - |
127 | | - |
128 | void QListModel::move(int srcRow, int dstRow) | - |
129 | { | - |
130 | if (srcRow == dstRow never evaluated: srcRow == dstRow | 0 |
131 | || srcRow < 0 || srcRow >= items.count() never evaluated: srcRow < 0 never evaluated: srcRow >= items.count() | 0 |
132 | || dstRow < 0 || dstRow > items.count()) never evaluated: dstRow < 0 never evaluated: dstRow > items.count() | 0 |
133 | return; | 0 |
134 | | - |
135 | if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow)) never evaluated: !beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow) | 0 |
136 | return; | 0 |
137 | if (srcRow < dstRow) never evaluated: srcRow < dstRow | 0 |
138 | --dstRow; never executed: --dstRow; | 0 |
139 | items.move(srcRow, dstRow); | - |
140 | endMoveRows(); | - |
141 | } | 0 |
142 | | - |
143 | int QListModel::rowCount(const QModelIndex &parent) const | - |
144 | { | - |
145 | return parent.isValid() ? 0 : items.count(); executed: return parent.isValid() ? 0 : items.count(); Execution Count:31049 | 31049 |
146 | } | - |
147 | | - |
148 | QModelIndex QListModel::index(QListWidgetItem *item) const | - |
149 | { | - |
150 | if (!item || !item->view || static_cast<const QListModel *>(item->view->model()) != this partially evaluated: !item no Evaluation Count:0 | yes Evaluation Count:285 |
partially evaluated: !item->view no Evaluation Count:0 | yes Evaluation Count:285 |
partially evaluated: static_cast<const QListModel *>(item->view->model()) != this no Evaluation Count:0 | yes Evaluation Count:285 |
| 0-285 |
151 | || items.isEmpty()) partially evaluated: items.isEmpty() no Evaluation Count:0 | yes Evaluation Count:285 |
| 0-285 |
152 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
153 | int row; | - |
154 | const int theid = item->d->theid; | - |
155 | if (theid >= 0 && theid < items.count() && items.at(theid) == item) { partially evaluated: theid >= 0 yes Evaluation Count:285 | no Evaluation Count:0 |
partially evaluated: theid < items.count() yes Evaluation Count:285 | no Evaluation Count:0 |
partially evaluated: items.at(theid) == item yes Evaluation Count:285 | no Evaluation Count:0 |
| 0-285 |
156 | row = theid; | - |
157 | } else { executed: } Execution Count:285 | 285 |
158 | row = items.lastIndexOf(item); | - |
159 | if (row == -1) never evaluated: row == -1 | 0 |
160 | return QModelIndex(); never executed: return QModelIndex(); | 0 |
161 | item->d->theid = row; | - |
162 | } | 0 |
163 | return createIndex(row, 0, item); executed: return createIndex(row, 0, item); Execution Count:285 | 285 |
164 | } | - |
165 | | - |
166 | QModelIndex QListModel::index(int row, int column, const QModelIndex &parent) const | - |
167 | { | - |
168 | if (hasIndex(row, column, parent)) evaluated: hasIndex(row, column, parent) yes Evaluation Count:2429 | yes Evaluation Count:155 |
| 155-2429 |
169 | return createIndex(row, column, items.at(row)); executed: return createIndex(row, column, items.at(row)); Execution Count:2429 | 2429 |
170 | return QModelIndex(); executed: return QModelIndex(); Execution Count:155 | 155 |
171 | } | - |
172 | | - |
173 | QVariant QListModel::data(const QModelIndex &index, int role) const | - |
174 | { | - |
175 | if (!index.isValid() || index.row() >= items.count()) evaluated: !index.isValid() yes Evaluation Count:4 | yes Evaluation Count:3956 |
partially evaluated: index.row() >= items.count() no Evaluation Count:0 | yes Evaluation Count:3956 |
| 0-3956 |
176 | return QVariant(); executed: return QVariant(); Execution Count:4 | 4 |
177 | return items.at(index.row())->data(role); executed: return items.at(index.row())->data(role); Execution Count:3956 | 3956 |
178 | } | - |
179 | | - |
180 | bool QListModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
181 | { | - |
182 | if (!index.isValid() || index.row() >= items.count()) evaluated: !index.isValid() yes Evaluation Count:5 | yes Evaluation Count:101 |
partially evaluated: index.row() >= items.count() no Evaluation Count:0 | yes Evaluation Count:101 |
| 0-101 |
183 | return false; executed: return false; Execution Count:5 | 5 |
184 | items.at(index.row())->setData(role, value); | - |
185 | return true; executed: return true; Execution Count:101 | 101 |
186 | } | - |
187 | | - |
188 | QMap<int, QVariant> QListModel::itemData(const QModelIndex &index) const | - |
189 | { | - |
190 | QMap<int, QVariant> roles; | - |
191 | if (!index.isValid() || index.row() >= items.count()) partially evaluated: !index.isValid() yes Evaluation Count:2 | no Evaluation Count:0 |
never evaluated: index.row() >= items.count() | 0-2 |
192 | return roles; executed: return roles; Execution Count:2 | 2 |
193 | QListWidgetItem *itm = items.at(index.row()); | - |
194 | for (int i = 0; i < itm->d->values.count(); ++i) { never evaluated: i < itm->d->values.count() | 0 |
195 | roles.insert(itm->d->values.at(i).role, | - |
196 | itm->d->values.at(i).value); | - |
197 | } | 0 |
198 | return roles; never executed: return roles; | 0 |
199 | } | - |
200 | | - |
201 | bool QListModel::insertRows(int row, int count, const QModelIndex &parent) | - |
202 | { | - |
203 | if (count < 1 || row < 0 || row > rowCount() || parent.isValid()) evaluated: count < 1 yes Evaluation Count:16 | yes Evaluation Count:22 |
evaluated: row < 0 yes Evaluation Count:4 | yes Evaluation Count:18 |
evaluated: row > rowCount() yes Evaluation Count:4 | yes Evaluation Count:14 |
partially evaluated: parent.isValid() no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-22 |
204 | return false; executed: return false; Execution Count:24 | 24 |
205 | | - |
206 | beginInsertRows(QModelIndex(), row, row + count - 1); | - |
207 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
208 | QListWidgetItem *itm = 0; | - |
209 | | - |
210 | for (int r = row; r < row + count; ++r) { evaluated: r < row + count yes Evaluation Count:360 | yes Evaluation Count:14 |
| 14-360 |
211 | itm = new QListWidgetItem; | - |
212 | itm->view = view; | - |
213 | itm->d->theid = r; | - |
214 | items.insert(r, itm); | - |
215 | } executed: } Execution Count:360 | 360 |
216 | | - |
217 | endInsertRows(); | - |
218 | return true; executed: return true; Execution Count:14 | 14 |
219 | } | - |
220 | | - |
221 | bool QListModel::removeRows(int row, int count, const QModelIndex &parent) | - |
222 | { | - |
223 | if (count < 1 || row < 0 || (row + count) > rowCount() || parent.isValid()) evaluated: count < 1 yes Evaluation Count:16 | yes Evaluation Count:28 |
evaluated: row < 0 yes Evaluation Count:6 | yes Evaluation Count:22 |
evaluated: (row + count) > rowCount() yes Evaluation Count:8 | yes Evaluation Count:14 |
partially evaluated: parent.isValid() no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-28 |
224 | return false; executed: return false; Execution Count:30 | 30 |
225 | | - |
226 | beginRemoveRows(QModelIndex(), row, row + count - 1); | - |
227 | QListWidgetItem *itm = 0; | - |
228 | for (int r = row; r < row + count; ++r) { evaluated: r < row + count yes Evaluation Count:360 | yes Evaluation Count:14 |
| 14-360 |
229 | itm = items.takeAt(row); | - |
230 | itm->view = 0; | - |
231 | itm->d->theid = -1; | - |
232 | delete itm; | - |
233 | } executed: } Execution Count:360 | 360 |
234 | endRemoveRows(); | - |
235 | return true; executed: return true; Execution Count:14 | 14 |
236 | } | - |
237 | | - |
238 | Qt::ItemFlags QListModel::flags(const QModelIndex &index) const | - |
239 | { | - |
240 | if (!index.isValid() || index.row() >= items.count() || index.model() != this) evaluated: !index.isValid() yes Evaluation Count:2 | yes Evaluation Count:167 |
partially evaluated: index.row() >= items.count() no Evaluation Count:0 | yes Evaluation Count:167 |
partially evaluated: index.model() != this no Evaluation Count:0 | yes Evaluation Count:167 |
| 0-167 |
241 | return Qt::ItemIsDropEnabled; executed: return Qt::ItemIsDropEnabled; Execution Count:2 | 2 |
242 | return items.at(index.row())->flags(); executed: return items.at(index.row())->flags(); Execution Count:167 | 167 |
243 | } | - |
244 | | - |
245 | void QListModel::sort(int column, Qt::SortOrder order) | - |
246 | { | - |
247 | if (column != 0) evaluated: column != 0 yes Evaluation Count:11 | yes Evaluation Count:1 |
| 1-11 |
248 | return; executed: return; Execution Count:11 | 11 |
249 | | - |
250 | layoutAboutToBeChanged(); | - |
251 | | - |
252 | QVector < QPair<QListWidgetItem*,int> > sorting(items.count()); | - |
253 | for (int i = 0; i < items.count(); ++i) { evaluated: i < items.count() yes Evaluation Count:200 | yes Evaluation Count:1 |
| 1-200 |
254 | QListWidgetItem *item = items.at(i); | - |
255 | sorting[i].first = item; | - |
256 | sorting[i].second = i; | - |
257 | } executed: } Execution Count:200 | 200 |
258 | | - |
259 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); partially evaluated: order == Qt::AscendingOrder yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
260 | qSort(sorting.begin(), sorting.end(), compare); | - |
261 | QModelIndexList fromIndexes; | - |
262 | QModelIndexList toIndexes; | - |
263 | for (int r = 0; r < sorting.count(); ++r) { evaluated: r < sorting.count() yes Evaluation Count:200 | yes Evaluation Count:1 |
| 1-200 |
264 | QListWidgetItem *item = sorting.at(r).first; | - |
265 | toIndexes.append(createIndex(r, 0, item)); | - |
266 | fromIndexes.append(createIndex(sorting.at(r).second, 0, sorting.at(r).first)); | - |
267 | items[r] = sorting.at(r).first; | - |
268 | } executed: } Execution Count:200 | 200 |
269 | changePersistentIndexList(fromIndexes, toIndexes); | - |
270 | | - |
271 | layoutChanged(); | - |
272 | } executed: } Execution Count:1 | 1 |
273 | void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int end) | - |
274 | { | - |
275 | if (column != 0) never evaluated: column != 0 | 0 |
276 | return; | 0 |
277 | | - |
278 | int count = end - start + 1; | - |
279 | QVector < QPair<QListWidgetItem*,int> > sorting(count); | - |
280 | for (int i = 0; i < count; ++i) { never evaluated: i < count | 0 |
281 | sorting[i].first = items.at(start + i); | - |
282 | sorting[i].second = start + i; | - |
283 | } | 0 |
284 | | - |
285 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); never evaluated: order == Qt::AscendingOrder | 0 |
286 | qSort(sorting.begin(), sorting.end(), compare); | - |
287 | | - |
288 | QModelIndexList oldPersistentIndexes = persistentIndexList(); | - |
289 | QModelIndexList newPersistentIndexes = oldPersistentIndexes; | - |
290 | QList<QListWidgetItem*> tmp = items; | - |
291 | QList<QListWidgetItem*>::iterator lit = tmp.begin(); | - |
292 | bool changed = false; | - |
293 | for (int i = 0; i < count; ++i) { never evaluated: i < count | 0 |
294 | int oldRow = sorting.at(i).second; | - |
295 | QListWidgetItem *item = tmp.takeAt(oldRow); | - |
296 | lit = sortedInsertionIterator(lit, tmp.end(), order, item); | - |
297 | int newRow = qMax(lit - tmp.begin(), 0); | - |
298 | lit = tmp.insert(lit, item); | - |
299 | if (newRow != oldRow) { never evaluated: newRow != oldRow | 0 |
300 | changed = true; | - |
301 | for (int j = i + 1; j < count; ++j) { never evaluated: j < count | 0 |
302 | int otherRow = sorting.at(j).second; | - |
303 | if (oldRow < otherRow && newRow >= otherRow) never evaluated: oldRow < otherRow never evaluated: newRow >= otherRow | 0 |
304 | --sorting[j].second; never executed: --sorting[j].second; | 0 |
305 | else if (oldRow > otherRow && newRow <= otherRow) never evaluated: oldRow > otherRow never evaluated: newRow <= otherRow | 0 |
306 | ++sorting[j].second; never executed: ++sorting[j].second; | 0 |
307 | } | - |
308 | for (int k = 0; k < newPersistentIndexes.count(); ++k) { never evaluated: k < newPersistentIndexes.count() | 0 |
309 | QModelIndex pi = newPersistentIndexes.at(k); | - |
310 | int oldPersistentRow = pi.row(); | - |
311 | int newPersistentRow = oldPersistentRow; | - |
312 | if (oldPersistentRow == oldRow) never evaluated: oldPersistentRow == oldRow | 0 |
313 | newPersistentRow = newRow; never executed: newPersistentRow = newRow; | 0 |
314 | else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow) never evaluated: oldRow < oldPersistentRow never evaluated: newRow >= oldPersistentRow | 0 |
315 | newPersistentRow = oldPersistentRow - 1; never executed: newPersistentRow = oldPersistentRow - 1; | 0 |
316 | else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow) never evaluated: oldRow > oldPersistentRow never evaluated: newRow <= oldPersistentRow | 0 |
317 | newPersistentRow = oldPersistentRow + 1; never executed: newPersistentRow = oldPersistentRow + 1; | 0 |
318 | if (newPersistentRow != oldPersistentRow) never evaluated: newPersistentRow != oldPersistentRow | 0 |
319 | newPersistentIndexes[k] = createIndex(newPersistentRow, | 0 |
320 | pi.column(), pi.internalPointer()); never executed: newPersistentIndexes[k] = createIndex(newPersistentRow, pi.column(), pi.internalPointer()); | 0 |
321 | } | 0 |
322 | } | 0 |
323 | } | 0 |
324 | | - |
325 | if (changed) { | 0 |
326 | layoutAboutToBeChanged(); | - |
327 | items = tmp; | - |
328 | changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes); | - |
329 | layoutChanged(); | - |
330 | } | 0 |
331 | } | 0 |
332 | | - |
333 | bool QListModel::itemLessThan(const QPair<QListWidgetItem*,int> &left, | - |
334 | const QPair<QListWidgetItem*,int> &right) | - |
335 | { | - |
336 | return (*left.first) < (*right.first); executed: return (*left.first) < (*right.first); Execution Count:2079 | 2079 |
337 | } | - |
338 | | - |
339 | bool QListModel::itemGreaterThan(const QPair<QListWidgetItem*,int> &left, | - |
340 | const QPair<QListWidgetItem*,int> &right) | - |
341 | { | - |
342 | return (*right.first) < (*left.first); never executed: return (*right.first) < (*left.first); | 0 |
343 | } | - |
344 | | - |
345 | QList<QListWidgetItem*>::iterator QListModel::sortedInsertionIterator( | - |
346 | const QList<QListWidgetItem*>::iterator &begin, | - |
347 | const QList<QListWidgetItem*>::iterator &end, | - |
348 | Qt::SortOrder order, QListWidgetItem *item) | - |
349 | { | - |
350 | if (order == Qt::AscendingOrder) never evaluated: order == Qt::AscendingOrder | 0 |
351 | return std::lower_bound(begin, end, item, QListModelLessThan()); never executed: return std::lower_bound(begin, end, item, QListModelLessThan()); | 0 |
352 | return std::lower_bound(begin, end, item, QListModelGreaterThan()); never executed: return std::lower_bound(begin, end, item, QListModelGreaterThan()); | 0 |
353 | } | - |
354 | | - |
355 | void QListModel::itemChanged(QListWidgetItem *item) | - |
356 | { | - |
357 | QModelIndex idx = index(item); | - |
358 | dataChanged(idx, idx); | - |
359 | } executed: } Execution Count:101 | 101 |
360 | | - |
361 | QStringList QListModel::mimeTypes() const | - |
362 | { | - |
363 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
364 | return view->mimeTypes(); executed: return view->mimeTypes(); Execution Count:2 | 2 |
365 | } | - |
366 | | - |
367 | QMimeData *QListModel::internalMimeData() const | - |
368 | { | - |
369 | return QAbstractItemModel::mimeData(cachedIndexes); never executed: return QAbstractItemModel::mimeData(cachedIndexes); | 0 |
370 | } | - |
371 | | - |
372 | QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const | - |
373 | { | - |
374 | QList<QListWidgetItem*> itemlist; | - |
375 | for (int i = 0; i < indexes.count(); ++i) never evaluated: i < indexes.count() | 0 |
376 | itemlist << at(indexes.at(i).row()); never executed: itemlist << at(indexes.at(i).row()); | 0 |
377 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
378 | | - |
379 | cachedIndexes = indexes; | - |
380 | QMimeData *mimeData = view->mimeData(itemlist); | - |
381 | cachedIndexes.clear(); | - |
382 | return mimeData; never executed: return mimeData; | 0 |
383 | } | - |
384 | | - |
385 | | - |
386 | bool QListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
387 | int row, int column, const QModelIndex &index) | - |
388 | { | - |
389 | (void)column;; | - |
390 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
391 | if (index.isValid()) never evaluated: index.isValid() | 0 |
392 | row = index.row(); never executed: row = index.row(); | 0 |
393 | else if (row == -1) never evaluated: row == -1 | 0 |
394 | row = items.count(); never executed: row = items.count(); | 0 |
395 | | - |
396 | return view->dropMimeData(row, data, action); never executed: return view->dropMimeData(row, data, action); | 0 |
397 | } | - |
398 | | - |
399 | Qt::DropActions QListModel::supportedDropActions() const | - |
400 | { | - |
401 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
402 | return view->supportedDropActions(); executed: return view->supportedDropActions(); Execution Count:2 | 2 |
403 | } | - |
404 | QListWidgetItem::QListWidgetItem(QListWidget *view, int type) | - |
405 | : rtti(type), view(view), d(new QListWidgetItemPrivate(this)), | - |
406 | itemFlags(Qt::ItemIsSelectable | - |
407 | |Qt::ItemIsUserCheckable | - |
408 | |Qt::ItemIsEnabled | - |
409 | |Qt::ItemIsDragEnabled) | - |
410 | { | - |
411 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) partially evaluated: view no Evaluation Count:0 | yes Evaluation Count:562 |
| 0-562 |
412 | model->insert(model->rowCount(), this); never executed: model->insert(model->rowCount(), this); | 0 |
413 | } executed: } Execution Count:562 | 562 |
414 | QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int type) | - |
415 | : rtti(type), view(0), d(new QListWidgetItemPrivate(this)), | - |
416 | itemFlags(Qt::ItemIsSelectable | - |
417 | |Qt::ItemIsUserCheckable | - |
418 | |Qt::ItemIsEnabled | - |
419 | |Qt::ItemIsDragEnabled) | - |
420 | { | - |
421 | setData(Qt::DisplayRole, text); | - |
422 | this->view = view; | - |
423 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) partially evaluated: view no Evaluation Count:0 | yes Evaluation Count:13656 |
| 0-13656 |
424 | model->insert(model->rowCount(), this); never executed: model->insert(model->rowCount(), this); | 0 |
425 | } executed: } Execution Count:13656 | 13656 |
426 | QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text, | - |
427 | QListWidget *view, int type) | - |
428 | : rtti(type), view(0), d(new QListWidgetItemPrivate(this)), | - |
429 | itemFlags(Qt::ItemIsSelectable | - |
430 | |Qt::ItemIsUserCheckable | - |
431 | |Qt::ItemIsEnabled | - |
432 | |Qt::ItemIsDragEnabled) | - |
433 | { | - |
434 | setData(Qt::DisplayRole, text); | - |
435 | setData(Qt::DecorationRole, icon); | - |
436 | this->view = view; | - |
437 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | 0 |
438 | model->insert(model->rowCount(), this); never executed: model->insert(model->rowCount(), this); | 0 |
439 | } | 0 |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | QListWidgetItem::~QListWidgetItem() | - |
445 | { | - |
446 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) partially evaluated: view no Evaluation Count:0 | yes Evaluation Count:14218 |
| 0-14218 |
447 | model->remove(this); never executed: model->remove(this); | 0 |
448 | delete d; | - |
449 | } executed: } Execution Count:14218 | 14218 |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | QListWidgetItem *QListWidgetItem::clone() const | - |
455 | { | - |
456 | return new QListWidgetItem(*this); never executed: return new QListWidgetItem(*this); | 0 |
457 | } | - |
458 | | - |
459 | | - |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | | - |
465 | void QListWidgetItem::setData(int role, const QVariant &value) | - |
466 | { | - |
467 | bool found = false; | - |
468 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); evaluated: role == Qt::EditRole yes Evaluation Count:101 | yes Evaluation Count:13858 |
| 101-13858 |
469 | for (int i = 0; i < d->values.count(); ++i) { evaluated: i < d->values.count() yes Evaluation Count:101 | yes Evaluation Count:13858 |
| 101-13858 |
470 | if (d->values.at(i).role == role) { partially evaluated: d->values.at(i).role == role yes Evaluation Count:101 | no Evaluation Count:0 |
| 0-101 |
471 | if (d->values.at(i).value == value) partially evaluated: d->values.at(i).value == value no Evaluation Count:0 | yes Evaluation Count:101 |
| 0-101 |
472 | return; | 0 |
473 | d->values[i].value = value; | - |
474 | found = true; | - |
475 | break; executed: break; Execution Count:101 | 101 |
476 | } | - |
477 | } | 0 |
478 | if (!found) evaluated: !found yes Evaluation Count:13858 | yes Evaluation Count:101 |
| 101-13858 |
479 | d->values.append(QWidgetItemData(role, value)); executed: d->values.append(QWidgetItemData(role, value)); Execution Count:13858 | 13858 |
480 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) evaluated: view yes Evaluation Count:101 | yes Evaluation Count:13858 |
| 101-13858 |
481 | model->itemChanged(this); executed: model->itemChanged(this); Execution Count:101 | 101 |
482 | } executed: } Execution Count:13959 | 13959 |
483 | | - |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | QVariant QListWidgetItem::data(int role) const | - |
491 | { | - |
492 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); evaluated: role == Qt::EditRole yes Evaluation Count:1 | yes Evaluation Count:8227 |
| 1-8227 |
493 | for (int i = 0; i < d->values.count(); ++i) evaluated: i < d->values.count() yes Evaluation Count:8228 | yes Evaluation Count:3362 |
| 3362-8228 |
494 | if (d->values.at(i).role == role) evaluated: d->values.at(i).role == role yes Evaluation Count:4866 | yes Evaluation Count:3362 |
| 3362-4866 |
495 | return d->values.at(i).value; executed: return d->values.at(i).value; Execution Count:4866 | 4866 |
496 | return QVariant(); executed: return QVariant(); Execution Count:3362 | 3362 |
497 | } | - |
498 | | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | bool QListWidgetItem::operator<(const QListWidgetItem &other) const | - |
504 | { | - |
505 | const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); | - |
506 | return QAbstractItemModelPrivate::variantLessThan(v1, v2); executed: return QAbstractItemModelPrivate::variantLessThan(v1, v2); Execution Count:2079 | 2079 |
507 | } | - |
508 | void QListWidgetItem::read(QDataStream &in) | - |
509 | { | - |
510 | in >> d->values; | - |
511 | } | 0 |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | | - |
517 | | - |
518 | void QListWidgetItem::write(QDataStream &out) const | - |
519 | { | - |
520 | out << d->values; | - |
521 | } | 0 |
522 | QListWidgetItem::QListWidgetItem(const QListWidgetItem &other) | - |
523 | : rtti(Type), view(0), | - |
524 | d(new QListWidgetItemPrivate(this)), | - |
525 | itemFlags(other.itemFlags) | - |
526 | { | - |
527 | d->values = other.d->values; | - |
528 | } | 0 |
529 | QListWidgetItem &QListWidgetItem::operator=(const QListWidgetItem &other) | - |
530 | { | - |
531 | d->values = other.d->values; | - |
532 | itemFlags = other.itemFlags; | - |
533 | return *this; never executed: return *this; | 0 |
534 | } | - |
535 | QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item) | - |
536 | { | - |
537 | item.write(out); | - |
538 | return out; never executed: return out; | 0 |
539 | } | - |
540 | QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) | - |
541 | { | - |
542 | item.read(in); | - |
543 | return in; never executed: return in; | 0 |
544 | } | - |
545 | void QListWidgetItem::setFlags(Qt::ItemFlags aflags) { | - |
546 | itemFlags = aflags; | - |
547 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | 0 |
548 | model->itemChanged(this); never executed: model->itemChanged(this); | 0 |
549 | } | 0 |
550 | void QListWidgetPrivate::setup() | - |
551 | { | - |
552 | QListWidget * const q = q_func(); | - |
553 | q->QListView::setModel(new QListModel(q)); | - |
554 | | - |
555 | QObject::connect(q, "2""pressed(QModelIndex)", q, "1""_q_emitItemPressed(QModelIndex)"); | - |
556 | QObject::connect(q, "2""clicked(QModelIndex)", q, "1""_q_emitItemClicked(QModelIndex)"); | - |
557 | QObject::connect(q, "2""doubleClicked(QModelIndex)", | - |
558 | q, "1""_q_emitItemDoubleClicked(QModelIndex)"); | - |
559 | QObject::connect(q, "2""activated(QModelIndex)", | - |
560 | q, "1""_q_emitItemActivated(QModelIndex)"); | - |
561 | QObject::connect(q, "2""entered(QModelIndex)", q, "1""_q_emitItemEntered(QModelIndex)"); | - |
562 | QObject::connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
563 | q, "1""_q_emitItemChanged(QModelIndex)"); | - |
564 | QObject::connect(q->selectionModel(), "2""currentChanged(QModelIndex,QModelIndex)", | - |
565 | q, "1""_q_emitCurrentItemChanged(QModelIndex,QModelIndex)"); | - |
566 | QObject::connect(q->selectionModel(), "2""selectionChanged(QItemSelection,QItemSelection)", | - |
567 | q, "2""itemSelectionChanged()"); | - |
568 | QObject::connect(model, "2""dataChanged(QModelIndex,QModelIndex)", | - |
569 | q, "1""_q_dataChanged(QModelIndex,QModelIndex)"); | - |
570 | QObject::connect(model, "2""columnsRemoved(QModelIndex,int,int)", q, "1""_q_sort()"); | - |
571 | } executed: } Execution Count:108 | 108 |
572 | | - |
573 | void QListWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) | - |
574 | { | - |
575 | QListWidget * const q = q_func(); | - |
576 | q->itemPressed(listModel()->at(index.row())); | - |
577 | } executed: } Execution Count:5 | 5 |
578 | | - |
579 | void QListWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) | - |
580 | { | - |
581 | QListWidget * const q = q_func(); | - |
582 | q->itemClicked(listModel()->at(index.row())); | - |
583 | } executed: } Execution Count:5 | 5 |
584 | | - |
585 | void QListWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) | - |
586 | { | - |
587 | QListWidget * const q = q_func(); | - |
588 | q->itemDoubleClicked(listModel()->at(index.row())); | - |
589 | } | 0 |
590 | | - |
591 | void QListWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) | - |
592 | { | - |
593 | QListWidget * const q = q_func(); | - |
594 | q->itemActivated(listModel()->at(index.row())); | - |
595 | } | 0 |
596 | | - |
597 | void QListWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) | - |
598 | { | - |
599 | QListWidget * const q = q_func(); | - |
600 | q->itemEntered(listModel()->at(index.row())); | - |
601 | } executed: } Execution Count:1 | 1 |
602 | | - |
603 | void QListWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) | - |
604 | { | - |
605 | QListWidget * const q = q_func(); | - |
606 | q->itemChanged(listModel()->at(index.row())); | - |
607 | } executed: } Execution Count:101 | 101 |
608 | | - |
609 | void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, | - |
610 | const QModelIndex &previous) | - |
611 | { | - |
612 | QListWidget * const q = q_func(); | - |
613 | QPersistentModelIndex persistentCurrent = current; | - |
614 | QListWidgetItem *currentItem = listModel()->at(persistentCurrent.row()); | - |
615 | q->currentItemChanged(currentItem, listModel()->at(previous.row())); | - |
616 | | - |
617 | | - |
618 | | - |
619 | if (!persistentCurrent.isValid()) { partially evaluated: !persistentCurrent.isValid() no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
620 | currentItem = 0; | - |
621 | } | 0 |
622 | | - |
623 | q->currentTextChanged(currentItem ? currentItem->text() : QString()); | - |
624 | q->currentRowChanged(persistentCurrent.row()); | - |
625 | } executed: } Execution Count:10 | 10 |
626 | | - |
627 | void QListWidgetPrivate::_q_sort() | - |
628 | { | - |
629 | if (sortingEnabled) never evaluated: sortingEnabled | 0 |
630 | model->sort(0, sortOrder); never executed: model->sort(0, sortOrder); | 0 |
631 | } | 0 |
632 | | - |
633 | void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, | - |
634 | const QModelIndex &bottomRight) | - |
635 | { | - |
636 | if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()) partially evaluated: sortingEnabled no Evaluation Count:0 | yes Evaluation Count:101 |
never evaluated: topLeft.isValid() never evaluated: bottomRight.isValid() | 0-101 |
637 | listModel()->ensureSorted(topLeft.column(), sortOrder, | 0 |
638 | topLeft.row(), bottomRight.row()); never executed: listModel()->ensureSorted(topLeft.column(), sortOrder, topLeft.row(), bottomRight.row()); | 0 |
639 | } executed: } Execution Count:101 | 101 |
640 | QListWidget::QListWidget(QWidget *parent) | - |
641 | : QListView(*new QListWidgetPrivate(), parent) | - |
642 | { | - |
643 | QListWidgetPrivate * const d = d_func(); | - |
644 | d->setup(); | - |
645 | } executed: } Execution Count:108 | 108 |
646 | | - |
647 | | - |
648 | | - |
649 | | - |
650 | | - |
651 | QListWidget::~QListWidget() | - |
652 | { | - |
653 | } | - |
654 | QListWidgetItem *QListWidget::item(int row) const | - |
655 | { | - |
656 | const QListWidgetPrivate * const d = d_func(); | - |
657 | if (row < 0 || row >= d->model->rowCount()) partially evaluated: row < 0 no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: row >= d->model->rowCount() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
658 | return 0; never executed: return 0; | 0 |
659 | return d->listModel()->at(row); executed: return d->listModel()->at(row); Execution Count:2 | 2 |
660 | } | - |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | int QListWidget::row(const QListWidgetItem *item) const | - |
669 | { | - |
670 | const QListWidgetPrivate * const d = d_func(); | - |
671 | return d->listModel()->index(const_cast<QListWidgetItem*>(item)).row(); executed: return d->listModel()->index(const_cast<QListWidgetItem*>(item)).row(); Execution Count:182 | 182 |
672 | } | - |
673 | void QListWidget::insertItem(int row, QListWidgetItem *item) | - |
674 | { | - |
675 | QListWidgetPrivate * const d = d_func(); | - |
676 | if (item && !item->view) partially evaluated: item yes Evaluation Count:202 | no Evaluation Count:0 |
partially evaluated: !item->view yes Evaluation Count:202 | no Evaluation Count:0 |
| 0-202 |
677 | d->listModel()->insert(row, item); executed: d->listModel()->insert(row, item); Execution Count:202 | 202 |
678 | } executed: } Execution Count:202 | 202 |
679 | void QListWidget::insertItem(int row, const QString &label) | - |
680 | { | - |
681 | QListWidgetPrivate * const d = d_func(); | - |
682 | d->listModel()->insert(row, new QListWidgetItem(label)); | - |
683 | } executed: } Execution Count:13656 | 13656 |
684 | void QListWidget::insertItems(int row, const QStringList &labels) | - |
685 | { | - |
686 | QListWidgetPrivate * const d = d_func(); | - |
687 | d->listModel()->insert(row, labels); | - |
688 | } | 0 |
689 | QListWidgetItem *QListWidget::takeItem(int row) | - |
690 | { | - |
691 | QListWidgetPrivate * const d = d_func(); | - |
692 | if (row < 0 || row >= d->model->rowCount()) never evaluated: row >= d->model->rowCount() | 0 |
693 | return 0; never executed: return 0; | 0 |
694 | return d->listModel()->take(row); never executed: return d->listModel()->take(row); | 0 |
695 | } | - |
696 | | - |
697 | | - |
698 | | - |
699 | | - |
700 | | - |
701 | | - |
702 | int QListWidget::count() const | - |
703 | { | - |
704 | const QListWidgetPrivate * const d = d_func(); | - |
705 | return d->model->rowCount(); executed: return d->model->rowCount(); Execution Count:13858 | 13858 |
706 | } | - |
707 | | - |
708 | | - |
709 | | - |
710 | | - |
711 | QListWidgetItem *QListWidget::currentItem() const | - |
712 | { | - |
713 | const QListWidgetPrivate * const d = d_func(); | - |
714 | return d->listModel()->at(currentIndex().row()); executed: return d->listModel()->at(currentIndex().row()); Execution Count:4 | 4 |
715 | } | - |
716 | void QListWidget::setCurrentItem(QListWidgetItem *item) | - |
717 | { | - |
718 | setCurrentRow(row(item)); | - |
719 | } | 0 |
720 | | - |
721 | | - |
722 | | - |
723 | | - |
724 | | - |
725 | void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command) | - |
726 | { | - |
727 | setCurrentRow(row(item), command); | - |
728 | } | 0 |
729 | int QListWidget::currentRow() const | - |
730 | { | - |
731 | return currentIndex().row(); never executed: return currentIndex().row(); | 0 |
732 | } | - |
733 | | - |
734 | void QListWidget::setCurrentRow(int row) | - |
735 | { | - |
736 | QListWidgetPrivate * const d = d_func(); | - |
737 | QModelIndex index = d->listModel()->index(row); | - |
738 | if (d->selectionMode == SingleSelection) never evaluated: d->selectionMode == SingleSelection | 0 |
739 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); never executed: selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | 0 |
740 | else if (d->selectionMode == NoSelection) never evaluated: d->selectionMode == NoSelection | 0 |
741 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); never executed: selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | 0 |
742 | else | - |
743 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); never executed: selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); | 0 |
744 | } | - |
745 | | - |
746 | | - |
747 | | - |
748 | | - |
749 | | - |
750 | | - |
751 | void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command) | - |
752 | { | - |
753 | QListWidgetPrivate * const d = d_func(); | - |
754 | d->selectionModel->setCurrentIndex(d->listModel()->index(row), command); | - |
755 | } | 0 |
756 | | - |
757 | | - |
758 | | - |
759 | | - |
760 | | - |
761 | | - |
762 | QListWidgetItem *QListWidget::itemAt(const QPoint &p) const | - |
763 | { | - |
764 | const QListWidgetPrivate * const d = d_func(); | - |
765 | return d->listModel()->at(indexAt(p).row()); never executed: return d->listModel()->at(indexAt(p).row()); | 0 |
766 | | - |
767 | } | - |
768 | QRect QListWidget::visualItemRect(const QListWidgetItem *item) const | - |
769 | { | - |
770 | const QListWidgetPrivate * const d = d_func(); | - |
771 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
772 | return visualRect(index); executed: return visualRect(index); Execution Count:2 | 2 |
773 | } | - |
774 | | - |
775 | | - |
776 | | - |
777 | | - |
778 | void QListWidget::sortItems(Qt::SortOrder order) | - |
779 | { | - |
780 | QListWidgetPrivate * const d = d_func(); | - |
781 | d->sortOrder = order; | - |
782 | d->listModel()->sort(0, order); | - |
783 | } | 0 |
784 | void QListWidget::setSortingEnabled(bool enable) | - |
785 | { | - |
786 | QListWidgetPrivate * const d = d_func(); | - |
787 | d->sortingEnabled = enable; | - |
788 | } | 0 |
789 | | - |
790 | bool QListWidget::isSortingEnabled() const | - |
791 | { | - |
792 | const QListWidgetPrivate * const d = d_func(); | - |
793 | return d->sortingEnabled; executed: return d->sortingEnabled; Execution Count:13858 | 13858 |
794 | } | - |
795 | | - |
796 | | - |
797 | | - |
798 | | - |
799 | Qt::SortOrder QListWidget::sortOrder() const | - |
800 | { | - |
801 | const QListWidgetPrivate * const d = d_func(); | - |
802 | return d->sortOrder; never executed: return d->sortOrder; | 0 |
803 | } | - |
804 | | - |
805 | | - |
806 | | - |
807 | | - |
808 | | - |
809 | void QListWidget::editItem(QListWidgetItem *item) | - |
810 | { | - |
811 | QListWidgetPrivate * const d = d_func(); | - |
812 | edit(d->listModel()->index(item)); | - |
813 | } | 0 |
814 | | - |
815 | | - |
816 | | - |
817 | | - |
818 | | - |
819 | | - |
820 | | - |
821 | void QListWidget::openPersistentEditor(QListWidgetItem *item) | - |
822 | { | - |
823 | QListWidgetPrivate * const d = d_func(); | - |
824 | QModelIndex index = d->listModel()->index(item); | - |
825 | QAbstractItemView::openPersistentEditor(index); | - |
826 | } | 0 |
827 | | - |
828 | | - |
829 | | - |
830 | | - |
831 | | - |
832 | | - |
833 | void QListWidget::closePersistentEditor(QListWidgetItem *item) | - |
834 | { | - |
835 | QListWidgetPrivate * const d = d_func(); | - |
836 | QModelIndex index = d->listModel()->index(item); | - |
837 | QAbstractItemView::closePersistentEditor(index); | - |
838 | } | 0 |
839 | | - |
840 | | - |
841 | | - |
842 | | - |
843 | | - |
844 | | - |
845 | QWidget *QListWidget::itemWidget(QListWidgetItem *item) const | - |
846 | { | - |
847 | const QListWidgetPrivate * const d = d_func(); | - |
848 | QModelIndex index = d->listModel()->index(item); | - |
849 | return QAbstractItemView::indexWidget(index); never executed: return QAbstractItemView::indexWidget(index); | 0 |
850 | } | - |
851 | void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) | - |
852 | { | - |
853 | QListWidgetPrivate * const d = d_func(); | - |
854 | QModelIndex index = d->listModel()->index(item); | - |
855 | QAbstractItemView::setIndexWidget(index, widget); | - |
856 | } | 0 |
857 | bool QListWidget::isItemSelected(const QListWidgetItem *item) const | - |
858 | { | - |
859 | const QListWidgetPrivate * const d = d_func(); | - |
860 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
861 | return selectionModel()->isSelected(index); never executed: return selectionModel()->isSelected(index); | 0 |
862 | } | - |
863 | void QListWidget::setItemSelected(const QListWidgetItem *item, bool select) | - |
864 | { | - |
865 | QListWidgetPrivate * const d = d_func(); | - |
866 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
867 | | - |
868 | if (d->selectionMode == SingleSelection) { never evaluated: d->selectionMode == SingleSelection | 0 |
869 | selectionModel()->select(index, select | - |
870 | ? QItemSelectionModel::ClearAndSelect | - |
871 | : QItemSelectionModel::Deselect); | - |
872 | } else if (d->selectionMode != NoSelection) { never evaluated: d->selectionMode != NoSelection | 0 |
873 | selectionModel()->select(index, select | - |
874 | ? QItemSelectionModel::Select | - |
875 | : QItemSelectionModel::Deselect); | - |
876 | } | 0 |
877 | | - |
878 | } | - |
879 | | - |
880 | | - |
881 | | - |
882 | | - |
883 | | - |
884 | QList<QListWidgetItem*> QListWidget::selectedItems() const | - |
885 | { | - |
886 | const QListWidgetPrivate * const d = d_func(); | - |
887 | QModelIndexList indexes = selectionModel()->selectedIndexes(); | - |
888 | QList<QListWidgetItem*> items; | - |
889 | for (int i = 0; i < indexes.count(); ++i) evaluated: i < indexes.count() yes Evaluation Count:12 | yes Evaluation Count:5 |
| 5-12 |
890 | items.append(d->listModel()->at(indexes.at(i).row())); executed: items.append(d->listModel()->at(indexes.at(i).row())); Execution Count:12 | 12 |
891 | return items; executed: return items; Execution Count:5 | 5 |
892 | } | - |
893 | | - |
894 | | - |
895 | | - |
896 | | - |
897 | | - |
898 | | - |
899 | QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const | - |
900 | { | - |
901 | const QListWidgetPrivate * const d = d_func(); | - |
902 | QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()), | - |
903 | Qt::DisplayRole, text, -1, flags); | - |
904 | QList<QListWidgetItem*> items; | - |
905 | for (int i = 0; i < indexes.size(); ++i) never evaluated: i < indexes.size() | 0 |
906 | items.append(d->listModel()->at(indexes.at(i).row())); never executed: items.append(d->listModel()->at(indexes.at(i).row())); | 0 |
907 | return items; never executed: return items; | 0 |
908 | } | - |
909 | bool QListWidget::isItemHidden(const QListWidgetItem *item) const | - |
910 | { | - |
911 | return isRowHidden(row(item)); never executed: return isRowHidden(row(item)); | 0 |
912 | } | - |
913 | void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide) | - |
914 | { | - |
915 | setRowHidden(row(item), hide); | - |
916 | } executed: } Execution Count:182 | 182 |
917 | | - |
918 | | - |
919 | | - |
920 | | - |
921 | | - |
922 | | - |
923 | | - |
924 | void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint) | - |
925 | { | - |
926 | QListWidgetPrivate * const d = d_func(); | - |
927 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
928 | QListView::scrollTo(index, hint); | - |
929 | } | 0 |
930 | | - |
931 | | - |
932 | | - |
933 | | - |
934 | | - |
935 | | - |
936 | void QListWidget::clear() | - |
937 | { | - |
938 | QListWidgetPrivate * const d = d_func(); | - |
939 | selectionModel()->clear(); | - |
940 | d->listModel()->clear(); | - |
941 | } | 0 |
942 | | - |
943 | | - |
944 | | - |
945 | | - |
946 | | - |
947 | | - |
948 | | - |
949 | QStringList QListWidget::mimeTypes() const | - |
950 | { | - |
951 | return d_func()->listModel()->QAbstractListModel::mimeTypes(); executed: return d_func()->listModel()->QAbstractListModel::mimeTypes(); Execution Count:2 | 2 |
952 | } | - |
953 | QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*>) const | - |
954 | { | - |
955 | return d_func()->listModel()->internalMimeData(); never executed: return d_func()->listModel()->internalMimeData(); | 0 |
956 | } | - |
957 | bool QListWidget::dropMimeData(int index, const QMimeData *data, Qt::DropAction action) | - |
958 | { | - |
959 | QModelIndex idx; | - |
960 | int row = index; | - |
961 | int column = 0; | - |
962 | if (dropIndicatorPosition() == QAbstractItemView::OnItem) { never evaluated: dropIndicatorPosition() == QAbstractItemView::OnItem | 0 |
963 | | - |
964 | idx = model()->index(row, column); | - |
965 | row = -1; | - |
966 | column = -1; | - |
967 | } | 0 |
968 | return d_func()->listModel()->QAbstractListModel::dropMimeData(data, action , row, column, idx); never executed: return d_func()->listModel()->QAbstractListModel::dropMimeData(data, action , row, column, idx); | 0 |
969 | } | - |
970 | | - |
971 | | - |
972 | void QListWidget::dropEvent(QDropEvent *event) { | - |
973 | QListWidgetPrivate * const d = d_func(); | - |
974 | if (event->source() == this && d->movement != Static) { never evaluated: event->source() == this never evaluated: d->movement != Static | 0 |
975 | QListView::dropEvent(event); | - |
976 | return; | 0 |
977 | } | - |
978 | | - |
979 | if (event->source() == this && (event->dropAction() == Qt::MoveAction || never evaluated: event->source() == this never evaluated: event->dropAction() == Qt::MoveAction | 0 |
980 | dragDropMode() == QAbstractItemView::InternalMove)) { never evaluated: dragDropMode() == QAbstractItemView::InternalMove | 0 |
981 | QModelIndex topIndex; | - |
982 | int col = -1; | - |
983 | int row = -1; | - |
984 | if (d->dropOn(event, &row, &col, &topIndex)) { never evaluated: d->dropOn(event, &row, &col, &topIndex) | 0 |
985 | QList<QModelIndex> selIndexes = selectedIndexes(); | - |
986 | QList<QPersistentModelIndex> persIndexes; | - |
987 | for (int i = 0; i < selIndexes.count(); i++) never evaluated: i < selIndexes.count() | 0 |
988 | persIndexes.append(selIndexes.at(i)); never executed: persIndexes.append(selIndexes.at(i)); | 0 |
989 | | - |
990 | if (persIndexes.contains(topIndex)) never evaluated: persIndexes.contains(topIndex) | 0 |
991 | return; | 0 |
992 | qSort(persIndexes); | - |
993 | | - |
994 | QPersistentModelIndex dropRow = model()->index(row, col, topIndex); | - |
995 | | - |
996 | int r = row == -1 ? count() : (dropRow.row() >= 0 ? dropRow.row() : row); never evaluated: row == -1 | 0 |
997 | for (int i = 0; i < persIndexes.count(); ++i) { never evaluated: i < persIndexes.count() | 0 |
998 | const QPersistentModelIndex &pIndex = persIndexes.at(i); | - |
999 | d->listModel()->move(pIndex.row(), r); | - |
1000 | r = pIndex.row() + 1; | - |
1001 | } | 0 |
1002 | | - |
1003 | event->accept(); | - |
1004 | | - |
1005 | event->setDropAction(Qt::CopyAction); | - |
1006 | } | 0 |
1007 | } | 0 |
1008 | | - |
1009 | QListView::dropEvent(event); | - |
1010 | } | 0 |
1011 | | - |
1012 | | - |
1013 | | - |
1014 | | - |
1015 | | - |
1016 | | - |
1017 | Qt::DropActions QListWidget::supportedDropActions() const | - |
1018 | { | - |
1019 | const QListWidgetPrivate * const d = d_func(); | - |
1020 | return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; executed: return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; Execution Count:2 | 2 |
1021 | } | - |
1022 | | - |
1023 | | - |
1024 | | - |
1025 | | - |
1026 | | - |
1027 | | - |
1028 | | - |
1029 | QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const | - |
1030 | { | - |
1031 | const QListWidgetMimeData *lwd = qobject_cast<const QListWidgetMimeData*>(data); | - |
1032 | if (lwd) | 0 |
1033 | return lwd->items; never executed: return lwd->items; | 0 |
1034 | return QList<QListWidgetItem*>(); never executed: return QList<QListWidgetItem*>(); | 0 |
1035 | } | - |
1036 | | - |
1037 | | - |
1038 | | - |
1039 | | - |
1040 | | - |
1041 | QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const | - |
1042 | { | - |
1043 | const QListWidgetPrivate * const d = d_func(); | - |
1044 | return d->listModel()->index(item); never executed: return d->listModel()->index(item); | 0 |
1045 | } | - |
1046 | | - |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | | - |
1051 | QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const | - |
1052 | { | - |
1053 | const QListWidgetPrivate * const d = d_func(); | - |
1054 | if (d->isIndexValid(index)) never evaluated: d->isIndexValid(index) | 0 |
1055 | return d->listModel()->at(index.row()); never executed: return d->listModel()->at(index.row()); | 0 |
1056 | return 0; never executed: return 0; | 0 |
1057 | } | - |
1058 | | - |
1059 | | - |
1060 | | - |
1061 | | - |
1062 | void QListWidget::setModel(QAbstractItemModel * ) | - |
1063 | { | - |
1064 | qt_noop(); | - |
1065 | } | 0 |
1066 | | - |
1067 | | - |
1068 | | - |
1069 | | - |
1070 | bool QListWidget::event(QEvent *e) | - |
1071 | { | - |
1072 | return QListView::event(e); executed: return QListView::event(e); Execution Count:469 | 469 |
1073 | } | - |
1074 | | - |
1075 | | - |
1076 | | - |
1077 | | - |
| | |