Line | Source | Count |
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 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 {}; | - |
18 | public: | - |
19 | QList<QListWidgetItem*> items; | - |
20 | }; | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | QListModel::QListModel(QListWidget *parent) | - |
26 | : QAbstractListModel(parent) | - |
27 | { | - |
28 | } | - |
29 | | - |
30 | QListModel::~QListModel() | - |
31 | { | - |
32 | clear(); | - |
33 | } | - |
34 | | - |
35 | void QListModel::clear() | - |
36 | { | - |
37 | beginResetModel(); | - |
38 | for (int i = 0; i < items.count(); ++i) { | - |
39 | if (items.at(i)) { | - |
40 | items.at(i)->d->theid = -1; | - |
41 | items.at(i)->view = 0; | - |
42 | delete items.at(i); | - |
43 | } | - |
44 | } | - |
45 | items.clear(); | - |
46 | endResetModel(); | - |
47 | } | - |
48 | | - |
49 | QListWidgetItem *QListModel::at(int row) const | - |
50 | { | - |
51 | return items.value(row); | - |
52 | } | - |
53 | | - |
54 | void QListModel::remove(QListWidgetItem *item) | - |
55 | { | - |
56 | if (!item) | - |
57 | return; | - |
58 | int row = items.indexOf(item); | - |
59 | ((!(row != -1)) ? qt_assert("row != -1",__FILE__,94100) : 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 | } | - |
66 | | - |
67 | void QListModel::insert(int row, QListWidgetItem *item) | - |
68 | { | - |
69 | if (!item) | - |
70 | return; | - |
71 | | - |
72 | item->view = qobject_cast<QListWidget*>(QObject::parent()); | - |
73 | if (item->view && item->view->isSortingEnabled()) { | - |
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 | } else { | - |
80 | if (row < 0) | - |
81 | row = 0; | - |
82 | else if (row > items.count()) | - |
83 | row = items.count(); | - |
84 | } | - |
85 | beginInsertRows(QModelIndex(), row, row); | - |
86 | items.insert(row, item); | - |
87 | item->d->theid = row; | - |
88 | endInsertRows(); | - |
89 | } | - |
90 | | - |
91 | void QListModel::insert(int row, const QStringList &labels) | - |
92 | { | - |
93 | const int count = labels.count(); | - |
94 | if (count <= 0) | - |
95 | return; | - |
96 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
97 | if (view && view->isSortingEnabled()) { | - |
98 | | - |
99 | for (int i = 0; i < count; ++i) { | - |
100 | QListWidgetItem *item = new QListWidgetItem(labels.at(i)); | - |
101 | insert(row, item); | - |
102 | } | - |
103 | } else { | - |
104 | if (row < 0) | - |
105 | row = 0; | - |
106 | else if (row > items.count()) | - |
107 | row = items.count(); | - |
108 | beginInsertRows(QModelIndex(), row, row + count - 1); | - |
109 | for (int i = 0; i < count; ++i) { | - |
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 | } | - |
115 | endInsertRows(); | - |
116 | } | - |
117 | } | - |
118 | | - |
119 | QListWidgetItem *QListModel::take(int row) | - |
120 | { | - |
121 | if (row < 0 || row >= items.count()) | - |
122 | return 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 item; | - |
130 | } | - |
131 | | - |
132 | void QListModel::move(int srcRow, int dstRow) | - |
133 | { | - |
134 | if (srcRow == dstRow | - |
135 | || srcRow < 0 || srcRow >= items.count() | - |
136 | || dstRow < 0 || dstRow > items.count()) | - |
137 | return; | - |
138 | | - |
139 | if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow)) | - |
140 | return; | - |
141 | if (srcRow < dstRow) | - |
142 | --dstRow; | - |
143 | items.move(srcRow, dstRow); | - |
144 | endMoveRows(); | - |
145 | } | - |
146 | | - |
147 | int QListModel::rowCount(const QModelIndex &parent) const | - |
148 | { | - |
149 | return parent.isValid() ? 0 : items.count(); | - |
150 | } | - |
151 | | - |
152 | QModelIndex QListModel::index(QListWidgetItem *item) const | - |
153 | { | - |
154 | if (!item || !item->view || static_cast<const QListModel *>(item->view->model()) != this | - |
155 | || items.isEmpty()) | - |
156 | return QModelIndex(); | - |
157 | int row; | - |
158 | const int theid = item->d->theid; | - |
159 | if (theid >= 0 && theid < items.count() && items.at(theid) == item) { | - |
160 | row = theid; | - |
161 | } else { | - |
162 | row = items.lastIndexOf(item); | - |
163 | if (row == -1) | - |
164 | return QModelIndex(); | - |
165 | item->d->theid = row; | - |
166 | } | - |
167 | return createIndex(row, 0, item); | - |
168 | } | - |
169 | | - |
170 | QModelIndex QListModel::index(int row, int column, const QModelIndex &parent) const | - |
171 | { | - |
172 | if (hasIndex(row, column, parent)) | - |
173 | return createIndex(row, column, items.at(row)); | - |
174 | return QModelIndex(); | - |
175 | } | - |
176 | | - |
177 | QVariant QListModel::data(const QModelIndex &index, int role) const | - |
178 | { | - |
179 | if (!index.isValid() || index.row() >= items.count()) | - |
180 | return QVariant(); | - |
181 | return items.at(index.row())->data(role); | - |
182 | } | - |
183 | | - |
184 | bool QListModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
185 | { | - |
186 | if (!index.isValid() || index.row() >= items.count()) | - |
187 | return false; | - |
188 | items.at(index.row())->setData(role, value); | - |
189 | return true; | - |
190 | } | - |
191 | | - |
192 | QMap<int, QVariant> QListModel::itemData(const QModelIndex &index) const | - |
193 | { | - |
194 | QMap<int, QVariant> roles; | - |
195 | if (!index.isValid() || index.row() >= items.count()) | - |
196 | return roles; | - |
197 | QListWidgetItem *itm = items.at(index.row()); | - |
198 | for (int i = 0; i < itm->d->values.count(); ++i) { | - |
199 | roles.insert(itm->d->values.at(i).role, | - |
200 | itm->d->values.at(i).value); | - |
201 | } | - |
202 | return roles; | - |
203 | } | - |
204 | | - |
205 | bool QListModel::insertRows(int row, int count, const QModelIndex &parent) | - |
206 | { | - |
207 | if (count < 1 || row < 0 || row > rowCount() || parent.isValid()) | - |
208 | return false; | - |
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) { | - |
215 | itm = new QListWidgetItem; | - |
216 | itm->view = view; | - |
217 | itm->d->theid = r; | - |
218 | items.insert(r, itm); | - |
219 | } | - |
220 | | - |
221 | endInsertRows(); | - |
222 | return true; | - |
223 | } | - |
224 | | - |
225 | bool QListModel::removeRows(int row, int count, const QModelIndex &parent) | - |
226 | { | - |
227 | if (count < 1 || row < 0 || (row + count) > rowCount() || parent.isValid()) | - |
228 | return false; | - |
229 | | - |
230 | beginRemoveRows(QModelIndex(), row, row + count - 1); | - |
231 | QListWidgetItem *itm = 0; | - |
232 | for (int r = row; r < row + count; ++r) { | - |
233 | itm = items.takeAt(row); | - |
234 | itm->view = 0; | - |
235 | itm->d->theid = -1; | - |
236 | delete itm; | - |
237 | } | - |
238 | endRemoveRows(); | - |
239 | return true; | - |
240 | } | - |
241 | | - |
242 | Qt::ItemFlags QListModel::flags(const QModelIndex &index) const | - |
243 | { | - |
244 | if (!index.isValid() || index.row() >= items.count() || index.model() != this) | - |
245 | return Qt::ItemIsDropEnabled; | - |
246 | return items.at(index.row())->flags(); | - |
247 | } | - |
248 | | - |
249 | void QListModel::sort(int column, Qt::SortOrder order) | - |
250 | { | - |
251 | if (column != 0) | - |
252 | return; | - |
253 | | - |
254 | layoutAboutToBeChanged(); | - |
255 | | - |
256 | QVector < QPair<QListWidgetItem*,int> > sorting(items.count()); | - |
257 | for (int i = 0; i < items.count(); ++i) { | - |
258 | QListWidgetItem *item = items.at(i); | - |
259 | sorting[i].first = item; | - |
260 | sorting[i].second = i; | - |
261 | } | - |
262 | | - |
263 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); | - |
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) { | - |
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 | } | - |
276 | changePersistentIndexList(fromIndexes, toIndexes); | - |
277 | | - |
278 | layoutChanged(); | - |
279 | } | - |
280 | void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int end) | - |
281 | { | - |
282 | if (column != 0) | - |
283 | return; | - |
284 | | - |
285 | int count = end - start + 1; | - |
286 | QVector < QPair<QListWidgetItem*,int> > sorting(count); | - |
287 | for (int i = 0; i < count; ++i) { | - |
288 | sorting[i].first = items.at(start + i); | - |
289 | sorting[i].second = start + i; | - |
290 | } | - |
291 | | - |
292 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); | - |
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) { | - |
301 | int oldRow = sorting.at(i).second; | - |
302 | int tmpitepos = lit - tmp.begin(); | - |
303 | QListWidgetItem *item = tmp.takeAt(oldRow); | - |
304 | if (tmpitepos > tmp.size()) | - |
305 | --tmpitepos; | - |
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) { | - |
311 | changed = true; | - |
312 | for (int j = i + 1; j < count; ++j) { | - |
313 | int otherRow = sorting.at(j).second; | - |
314 | if (oldRow < otherRow && newRow >= otherRow) | - |
315 | --sorting[j].second; | - |
316 | else if (oldRow > otherRow && newRow <= otherRow) | - |
317 | ++sorting[j].second; | - |
318 | } | - |
319 | for (int k = 0; k < newPersistentIndexes.count(); ++k) { | - |
320 | QModelIndex pi = newPersistentIndexes.at(k); | - |
321 | int oldPersistentRow = pi.row(); | - |
322 | int newPersistentRow = oldPersistentRow; | - |
323 | if (oldPersistentRow == oldRow) | - |
324 | newPersistentRow = newRow; | - |
325 | else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow) | - |
326 | newPersistentRow = oldPersistentRow - 1; | - |
327 | else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow) | - |
328 | newPersistentRow = oldPersistentRow + 1; | - |
329 | if (newPersistentRow != oldPersistentRow) | - |
330 | newPersistentIndexes[k] = createIndex(newPersistentRow, | - |
331 | pi.column(), pi.internalPointer()); | - |
332 | } | - |
333 | } | - |
334 | } | - |
335 | | - |
336 | if (changed) { | - |
337 | layoutAboutToBeChanged(); | - |
338 | items = tmp; | - |
339 | changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes); | - |
340 | layoutChanged(); | - |
341 | } | - |
342 | } | - |
343 | | - |
344 | bool QListModel::itemLessThan(const QPair<QListWidgetItem*,int> &left, | - |
345 | const QPair<QListWidgetItem*,int> &right) | - |
346 | { | - |
347 | return (*left.first) < (*right.first); | - |
348 | } | - |
349 | | - |
350 | bool QListModel::itemGreaterThan(const QPair<QListWidgetItem*,int> &left, | - |
351 | const QPair<QListWidgetItem*,int> &right) | - |
352 | { | - |
353 | return (*right.first) < (*left.first); | - |
354 | } | - |
355 | | - |
356 | QList<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) | - |
362 | return std::lower_bound(begin, end, item, QListModelLessThan()); | - |
363 | return std::lower_bound(begin, end, item, QListModelGreaterThan()); | - |
364 | } | - |
365 | | - |
366 | void QListModel::itemChanged(QListWidgetItem *item) | - |
367 | { | - |
368 | QModelIndex idx = index(item); | - |
369 | dataChanged(idx, idx); | - |
370 | } | - |
371 | | - |
372 | QStringList QListModel::mimeTypes() const | - |
373 | { | - |
374 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
375 | return view->mimeTypes(); | - |
376 | } | - |
377 | | - |
378 | QMimeData *QListModel::internalMimeData() const | - |
379 | { | - |
380 | return QAbstractItemModel::mimeData(cachedIndexes); | - |
381 | } | - |
382 | | - |
383 | QMimeData *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) | - |
389 | itemlist << at(indexes.at(i).row()); | - |
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 mimeData; | - |
396 | } | - |
397 | | - |
398 | | - |
399 | bool 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()) | - |
405 | row = index.row(); | - |
406 | else if (row == -1) | - |
407 | row = items.count(); | - |
408 | | - |
409 | return view->dropMimeData(row, data, action); | - |
410 | } | - |
411 | | - |
412 | Qt::DropActions QListModel::supportedDropActions() const | - |
413 | { | - |
414 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
415 | return view->supportedDropActions(); | - |
416 | } | - |
417 | QListWidgetItem::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 ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
425 | model->insert(model->rowCount(), this); | - |
426 | } | - |
427 | QListWidgetItem::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 ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
437 | model->insert(model->rowCount(), this); | - |
438 | } | - |
439 | QListWidgetItem::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 ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
451 | model->insert(model->rowCount(), this); | - |
452 | } | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | QListWidgetItem::~QListWidgetItem() | - |
458 | { | - |
459 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
460 | model->remove(this); | - |
461 | delete d; | - |
462 | } | - |
463 | | - |
464 | | - |
465 | | - |
466 | | - |
467 | QListWidgetItem *QListWidgetItem::clone() const | - |
468 | { | - |
469 | return new QListWidgetItem(*this); | - |
470 | } | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | | - |
478 | void QListWidgetItem::setData(int role, const QVariant &value) | - |
479 | { | - |
480 | bool found = false; | - |
481 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); | - |
482 | for (int i = 0; i < d->values.count(); ++i) { | - |
483 | if (d->values.at(i).role == role) { | - |
484 | if (d->values.at(i).value == value) | - |
485 | return; | - |
486 | d->values[i].value = value; | - |
487 | found = true; | - |
488 | break; | - |
489 | } | - |
490 | } | - |
491 | if (!found) | - |
492 | d->values.append(QWidgetItemData(role, value)); | - |
493 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
494 | model->itemChanged(this); | - |
495 | } | - |
496 | | - |
497 | | - |
498 | | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | QVariant QListWidgetItem::data(int role) const | - |
504 | { | - |
505 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); | - |
506 | for (int i = 0; i < d->values.count(); ++i) | - |
507 | if (d->values.at(i).role == role) | - |
508 | return d->values.at(i).value; | - |
509 | return QVariant(); | - |
510 | } | - |
511 | | - |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | bool QListWidgetItem::operator<(const QListWidgetItem &other) const | - |
517 | { | - |
518 | const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); | - |
519 | return QAbstractItemModelPrivate::variantLessThan(v1, v2); | - |
520 | } | - |
521 | void QListWidgetItem::read(QDataStream &in) | - |
522 | { | - |
523 | in >> d->values; | - |
524 | } | - |
525 | | - |
526 | | - |
527 | | - |
528 | | - |
529 | | - |
530 | | - |
531 | void QListWidgetItem::write(QDataStream &out) const | - |
532 | { | - |
533 | out << d->values; | - |
534 | } | - |
535 | QListWidgetItem::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 | } | - |
542 | QListWidgetItem &QListWidgetItem::operator=(const QListWidgetItem &other) | - |
543 | { | - |
544 | d->values = other.d->values; | - |
545 | itemFlags = other.itemFlags; | - |
546 | return *this; | - |
547 | } | - |
548 | QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item) | - |
549 | { | - |
550 | item.write(out); | - |
551 | return out; | - |
552 | } | - |
553 | QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) | - |
554 | { | - |
555 | item.read(in); | - |
556 | return in; | - |
557 | } | - |
558 | void QListWidgetItem::setFlags(Qt::ItemFlags aflags) { | - |
559 | itemFlags = aflags; | - |
560 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
561 | model->itemChanged(this); | - |
562 | } | - |
563 | void 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__ ":" "1057""1063"), q, qFlagLocation("1""_q_emitItemPressed(QModelIndex)" "\0" __FILE__ ":" "1057""1063")); | - |
569 | QObject::connect(q, qFlagLocation("2""clicked(QModelIndex)" "\0" __FILE__ ":" "1058""1064"), q, qFlagLocation("1""_q_emitItemClicked(QModelIndex)" "\0" __FILE__ ":" "1058""1064")); | - |
570 | QObject::connect(q, qFlagLocation("2""doubleClicked(QModelIndex)" "\0" __FILE__ ":" "1059""1065"), | - |
571 | q, qFlagLocation("1""_q_emitItemDoubleClicked(QModelIndex)" "\0" __FILE__ ":" "1060""1066")); | - |
572 | QObject::connect(q, qFlagLocation("2""activated(QModelIndex)" "\0" __FILE__ ":" "1061""1067"), | - |
573 | q, qFlagLocation("1""_q_emitItemActivated(QModelIndex)" "\0" __FILE__ ":" "1062""1068")); | - |
574 | QObject::connect(q, qFlagLocation("2""entered(QModelIndex)" "\0" __FILE__ ":" "1063""1069"), q, qFlagLocation("1""_q_emitItemEntered(QModelIndex)" "\0" __FILE__ ":" "1063""1069")); | - |
575 | QObject::connect(model, qFlagLocation("2""dataChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1064""1070"), | - |
576 | q, qFlagLocation("1""_q_emitItemChanged(QModelIndex)" "\0" __FILE__ ":" "1065")); | - |
| QObject::connect(q->selectionModel(), qFlagLocation("2""currentChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1066"), | |
| q, qFlagLocation("1""_q_emitCurrentItemChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1067")); | |
| QObject::connect(q->selectionModel(), qFlagLocation("2""selectionChanged(QItemSelection,QItemSelection)" "\0" __FILE__ ":" "1068"), | |
| q, qFlagLocation("2""itemSelectionChanged()" "\0" __FILE__ ":" "1069""1071")); | |
577 | QObject::connect(model, qFlagLocation("2""dataChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1070""1072"), | - |
578 | q, qFlagLocation("1""_q_dataChanged(QModelIndex,QModelIndex)" "\0" __FILE__ ":" "1071""1073")); | - |
579 | QObject::connect(model, qFlagLocation("2""columnsRemoved(QModelIndex,int,int)" "\0" __FILE__ ":" "1072""1074"), q, qFlagLocation("1""_q_sort()" "\0" __FILE__ ":" "1072""1074")); | - |
580 | } never executed: end of block | 0 |
581 | | - |
582 | void QListWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) | - |
583 | { | - |
584 | QListWidget * const q = q_func(); | - |
585 | q->itemPressed(listModel()->at(index.row())); | - |
586 | } | - |
587 | | - |
588 | void QListWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) | - |
589 | { | - |
590 | QListWidget * const q = q_func(); | - |
591 | q->itemClicked(listModel()->at(index.row())); | - |
592 | } | - |
593 | | - |
594 | void QListWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) | - |
595 | { | - |
596 | QListWidget * const q = q_func(); | - |
597 | q->itemDoubleClicked(listModel()->at(index.row())); | - |
598 | } | - |
599 | | - |
600 | void QListWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) | - |
601 | { | - |
602 | QListWidget * const q = q_func(); | - |
603 | q->itemActivated(listModel()->at(index.row())); | - |
604 | } | - |
605 | | - |
606 | void QListWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) | - |
607 | { | - |
608 | QListWidget * const q = q_func(); | - |
609 | q->itemEntered(listModel()->at(index.row())); | - |
610 | } | - |
611 | | - |
612 | void QListWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) | - |
613 | { | - |
614 | QListWidget * const q = q_func(); | - |
615 | q->itemChanged(listModel()->at(index.row())); | - |
616 | } | - |
617 | | - |
618 | void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, | - |
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()) { | - |
629 | currentItem = 0; | - |
630 | } | - |
631 | | - |
632 | q->currentTextChanged(currentItem ? currentItem->text() : QString()); | - |
633 | q->currentRowChanged(persistentCurrent.row()); | - |
634 | } | - |
635 | | - |
636 | void QListWidgetPrivate::_q_sort() | - |
637 | { | - |
638 | if (sortingEnabled) | - |
639 | model->sort(0, sortOrder); | - |
640 | } | - |
641 | | - |
642 | void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, | - |
643 | const QModelIndex &bottomRight) | - |
644 | { | - |
645 | if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()) | - |
646 | listModel()->ensureSorted(topLeft.column(), sortOrder, | - |
647 | topLeft.row(), bottomRight.row()); | - |
648 | } | - |
649 | QListWidget::QListWidget(QWidget *parent) | - |
650 | : QListView(*new QListWidgetPrivate(), parent) | - |
651 | { | - |
652 | QListWidgetPrivate * const d = d_func(); | - |
653 | d->setup(); | - |
654 | } | - |
655 | | - |
656 | | - |
657 | | - |
658 | | - |
659 | | - |
660 | QListWidget::~QListWidget() | - |
661 | { | - |
662 | } | - |
663 | | - |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel) | - |
669 | { | - |
670 | QListWidgetPrivate * const d = d_func(); | - |
671 | | - |
672 | if (d->selectionModelTRUE | never evaluated | FALSE | never 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->selectionModelTRUE | never evaluated | FALSE | never 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 |
688 | QListWidgetItem *QListWidget::item(int row) const | - |
689 | { | - |
690 | const QListWidgetPrivate * const d = d_func(); | - |
691 | if (row < 0 || row >= d->model->rowCount()) | - |
692 | return 0; | - |
693 | return d->listModel()->at(row); | - |
694 | } | - |
695 | | - |
696 | | - |
697 | | - |
698 | | - |
699 | | - |
700 | | - |
701 | | - |
702 | int QListWidget::row(const QListWidgetItem *item) const | - |
703 | { | - |
704 | const QListWidgetPrivate * const d = d_func(); | - |
705 | return d->listModel()->index(const_cast<QListWidgetItem*>(item)).row(); | - |
706 | } | - |
707 | void QListWidget::insertItem(int row, QListWidgetItem *item) | - |
708 | { | - |
709 | QListWidgetPrivate * const d = d_func(); | - |
710 | if (item && !item->view) | - |
711 | d->listModel()->insert(row, item); | - |
712 | } | - |
713 | void QListWidget::insertItem(int row, const QString &label) | - |
714 | { | - |
715 | QListWidgetPrivate * const d = d_func(); | - |
716 | d->listModel()->insert(row, new QListWidgetItem(label)); | - |
717 | } | - |
718 | void QListWidget::insertItems(int row, const QStringList &labels) | - |
719 | { | - |
720 | QListWidgetPrivate * const d = d_func(); | - |
721 | d->listModel()->insert(row, labels); | - |
722 | } | - |
723 | QListWidgetItem *QListWidget::takeItem(int row) | - |
724 | { | - |
725 | QListWidgetPrivate * const d = d_func(); | - |
726 | if (row < 0 || row >= d->model->rowCount()) | - |
727 | return 0; | - |
728 | return d->listModel()->take(row); | - |
729 | } | - |
730 | | - |
731 | | - |
732 | | - |
733 | | - |
734 | | - |
735 | | - |
736 | int QListWidget::count() const | - |
737 | { | - |
738 | const QListWidgetPrivate * const d = d_func(); | - |
739 | return d->model->rowCount(); | - |
740 | } | - |
741 | | - |
742 | | - |
743 | | - |
744 | | - |
745 | QListWidgetItem *QListWidget::currentItem() const | - |
746 | { | - |
747 | const QListWidgetPrivate * const d = d_func(); | - |
748 | return d->listModel()->at(currentIndex().row()); | - |
749 | } | - |
750 | void QListWidget::setCurrentItem(QListWidgetItem *item) | - |
751 | { | - |
752 | setCurrentRow(row(item)); | - |
753 | } | - |
754 | | - |
755 | | - |
756 | | - |
757 | | - |
758 | | - |
759 | void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command) | - |
760 | { | - |
761 | setCurrentRow(row(item), command); | - |
762 | } | - |
763 | int QListWidget::currentRow() const | - |
764 | { | - |
765 | return currentIndex().row(); | - |
766 | } | - |
767 | | - |
768 | void QListWidget::setCurrentRow(int row) | - |
769 | { | - |
770 | QListWidgetPrivate * const d = d_func(); | - |
771 | QModelIndex index = d->listModel()->index(row); | - |
772 | if (d->selectionMode == SingleSelection) | - |
773 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | - |
774 | else if (d->selectionMode == NoSelection) | - |
775 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - |
776 | else | - |
777 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); | - |
778 | } | - |
779 | | - |
780 | | - |
781 | | - |
782 | | - |
783 | | - |
784 | | - |
785 | void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command) | - |
786 | { | - |
787 | QListWidgetPrivate * const d = d_func(); | - |
788 | d->selectionModel->setCurrentIndex(d->listModel()->index(row), command); | - |
789 | } | - |
790 | | - |
791 | | - |
792 | | - |
793 | | - |
794 | | - |
795 | | - |
796 | QListWidgetItem *QListWidget::itemAt(const QPoint &p) const | - |
797 | { | - |
798 | const QListWidgetPrivate * const d = d_func(); | - |
799 | return d->listModel()->at(indexAt(p).row()); | - |
800 | | - |
801 | } | - |
802 | QRect 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 visualRect(index); | - |
807 | } | - |
808 | | - |
809 | | - |
810 | | - |
811 | | - |
812 | void QListWidget::sortItems(Qt::SortOrder order) | - |
813 | { | - |
814 | QListWidgetPrivate * const d = d_func(); | - |
815 | d->sortOrder = order; | - |
816 | d->listModel()->sort(0, order); | - |
817 | } | - |
818 | void QListWidget::setSortingEnabled(bool enable) | - |
819 | { | - |
820 | QListWidgetPrivate * const d = d_func(); | - |
821 | d->sortingEnabled = enable; | - |
822 | } | - |
823 | | - |
824 | bool QListWidget::isSortingEnabled() const | - |
825 | { | - |
826 | const QListWidgetPrivate * const d = d_func(); | - |
827 | return d->sortingEnabled; | - |
828 | } | - |
829 | | - |
830 | | - |
831 | | - |
832 | | - |
833 | Qt::SortOrder QListWidget::sortOrder() const | - |
834 | { | - |
835 | const QListWidgetPrivate * const d = d_func(); | - |
836 | return d->sortOrder; | - |
837 | } | - |
838 | | - |
839 | | - |
840 | | - |
841 | | - |
842 | | - |
843 | void QListWidget::editItem(QListWidgetItem *item) | - |
844 | { | - |
845 | QListWidgetPrivate * const d = d_func(); | - |
846 | edit(d->listModel()->index(item)); | - |
847 | } | - |
848 | | - |
849 | | - |
850 | | - |
851 | | - |
852 | | - |
853 | | - |
854 | | - |
855 | void QListWidget::openPersistentEditor(QListWidgetItem *item) | - |
856 | { | - |
857 | QListWidgetPrivate * const d = d_func(); | - |
858 | QModelIndex index = d->listModel()->index(item); | - |
859 | QAbstractItemView::openPersistentEditor(index); | - |
860 | } | - |
861 | | - |
862 | | - |
863 | | - |
864 | | - |
865 | | - |
866 | | - |
867 | void QListWidget::closePersistentEditor(QListWidgetItem *item) | - |
868 | { | - |
869 | QListWidgetPrivate * const d = d_func(); | - |
870 | QModelIndex index = d->listModel()->index(item); | - |
871 | QAbstractItemView::closePersistentEditor(index); | - |
872 | } | - |
873 | QWidget *QListWidget::itemWidget(QListWidgetItem *item) const | - |
874 | { | - |
875 | const QListWidgetPrivate * const d = d_func(); | - |
876 | QModelIndex index = d->listModel()->index(item); | - |
877 | return QAbstractItemView::indexWidget(index); | - |
878 | } | - |
879 | void 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 | } | - |
885 | bool 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 selectionModel()->isSelected(index); | - |
890 | } | - |
891 | void 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) { | - |
897 | selectionModel()->select(index, select | - |
898 | ? QItemSelectionModel::ClearAndSelect | - |
899 | : QItemSelectionModel::Deselect); | - |
900 | } else if (d->selectionMode != NoSelection) { | - |
901 | selectionModel()->select(index, select | - |
902 | ? QItemSelectionModel::Select | - |
903 | : QItemSelectionModel::Deselect); | - |
904 | } | - |
905 | | - |
906 | } | - |
907 | | - |
908 | | - |
909 | | - |
910 | | - |
911 | | - |
912 | QList<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) | - |
920 | items.append(d->listModel()->at(indexes.at(i).row())); | - |
921 | return items; | - |
922 | } | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | QList<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) | - |
938 | items.append(d->listModel()->at(indexes.at(i).row())); | - |
939 | return items; | - |
940 | } | - |
941 | bool QListWidget::isItemHidden(const QListWidgetItem *item) const | - |
942 | { | - |
943 | return isRowHidden(row(item)); | - |
944 | } | - |
945 | void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide) | - |
946 | { | - |
947 | setRowHidden(row(item), hide); | - |
948 | } | - |
949 | | - |
950 | | - |
951 | | - |
952 | | - |
953 | | - |
954 | | - |
955 | | - |
956 | void 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 | } | - |
962 | | - |
963 | | - |
964 | | - |
965 | | - |
966 | | - |
967 | | - |
968 | void QListWidget::clear() | - |
969 | { | - |
970 | QListWidgetPrivate * const d = d_func(); | - |
971 | selectionModel()->clear(); | - |
972 | d->listModel()->clear(); | - |
973 | } | - |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | | - |
979 | | - |
980 | | - |
981 | QStringList QListWidget::mimeTypes() const | - |
982 | { | - |
983 | return d_func()->listModel()->QAbstractListModel::mimeTypes(); | - |
984 | } | - |
985 | QMimeData *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()) { | - |
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); | - |
997 | | - |
998 | QMimeData *result = d->listModel()->internalMimeData(); | - |
999 | | - |
1000 | cachedIndexes.clear(); | - |
1001 | return result; | - |
1002 | } | - |
1003 | | - |
1004 | return d->listModel()->internalMimeData(); | - |
1005 | } | - |
1006 | bool 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) { | - |
1012 | | - |
1013 | idx = model()->index(row, column); | - |
1014 | row = -1; | - |
1015 | column = -1; | - |
1016 | } | - |
1017 | return d_func()->listModel()->QAbstractListModel::dropMimeData(data, action , row, column, idx); | - |
1018 | } | - |
1019 | | - |
1020 | | - |
1021 | void QListWidget::dropEvent(QDropEvent *event) { | - |
1022 | QListWidgetPrivate * const d = d_func(); | - |
1023 | if (event->source() == this && d->movement != Static) { | - |
1024 | QListView::dropEvent(event); | - |
1025 | return; | - |
1026 | } | - |
1027 | | - |
1028 | if (event->source() == this && (event->dropAction() == Qt::MoveAction || | - |
1029 | dragDropMode() == QAbstractItemView::InternalMove)) { | - |
1030 | QModelIndex topIndex; | - |
1031 | int col = -1; | - |
1032 | int row = -1; | - |
1033 | if (d->dropOn(event, &row, &col, &topIndex)) { | - |
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++) | - |
1039 | persIndexes.append(selIndexes.at(i)); | - |
1040 | | - |
1041 | if (persIndexes.contains(topIndex)) | - |
1042 | return; | - |
1043 | std::sort(persIndexes.begin(), persIndexes.end()); | - |
1044 | | - |
1045 | QPersistentModelIndex dropRow = model()->index(row, col, topIndex); | - |
1046 | | - |
1047 | int r = row == -1 ? count() : (dropRow.row() >= 0 ? dropRow.row() : row); | - |
1048 | for (int i = 0; i < persIndexes.count(); ++i) { | - |
1049 | const QPersistentModelIndex &pIndex = persIndexes.at(i); | - |
1050 | d->listModel()->move(pIndex.row(), r); | - |
1051 | r = pIndex.row() + 1; | - |
1052 | } | - |
1053 | | - |
1054 | event->accept(); | - |
1055 | | - |
1056 | event->setDropAction(Qt::CopyAction); | - |
1057 | } | - |
1058 | } | - |
1059 | | - |
1060 | QListView::dropEvent(event); | - |
1061 | } | - |
1062 | | - |
1063 | | - |
1064 | | - |
1065 | | - |
1066 | | - |
1067 | | - |
1068 | Qt::DropActions QListWidget::supportedDropActions() const | - |
1069 | { | - |
1070 | const QListWidgetPrivate * const d = d_func(); | - |
1071 | return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; | - |
1072 | } | - |
1073 | | - |
1074 | | - |
1075 | | - |
1076 | | - |
1077 | | - |
1078 | | - |
1079 | | - |
1080 | QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const | - |
1081 | { | - |
1082 | const QListWidgetMimeData *lwd = qobject_cast<const QListWidgetMimeData*>(data); | - |
1083 | if (lwd) | - |
1084 | return lwd->items; | - |
1085 | return QList<QListWidgetItem*>(); | - |
1086 | } | - |
1087 | | - |
1088 | | - |
1089 | | - |
1090 | | - |
1091 | | - |
1092 | QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const | - |
1093 | { | - |
1094 | const QListWidgetPrivate * const d = d_func(); | - |
1095 | return d->listModel()->index(item); | - |
1096 | } | - |
1097 | | - |
1098 | | - |
1099 | | - |
1100 | | - |
1101 | | - |
1102 | QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const | - |
1103 | { | - |
1104 | const QListWidgetPrivate * const d = d_func(); | - |
1105 | if (d->isIndexValid(index)) | - |
1106 | return d->listModel()->at(index.row()); | - |
1107 | return 0; | - |
1108 | } | - |
1109 | | - |
1110 | | - |
1111 | | - |
1112 | | - |
1113 | void 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__,19371964) : qt_noop()); | - |
1116 | } | - |
1117 | | - |
1118 | | - |
1119 | | - |
1120 | | - |
1121 | bool QListWidget::event(QEvent *e) | - |
1122 | { | - |
1123 | return QListView::event(e); | - |
1124 | } | - |
1125 | | - |
1126 | | - |
1127 | | - |
| | |