qlistwidget.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9