Qt 4.8
qlistwidget.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qlistwidget.h"
43 
44 #ifndef QT_NO_LISTWIDGET
45 #include <qitemdelegate.h>
46 #include <private/qlistview_p.h>
47 #include <private/qwidgetitemdata_p.h>
48 #include <private/qlistwidget_p.h>
49 
51 
52 // workaround for VC++ 6.0 linker bug (?)
54 
56 {
57  Q_OBJECT
58 public:
60 };
61 
63 #include "qlistwidget.moc"
65 
67  : QAbstractListModel(parent)
68 {
69 }
70 
72 {
73  clear();
74 }
75 
77 {
78  for (int i = 0; i < items.count(); ++i) {
79  if (items.at(i)) {
80  items.at(i)->d->theid = -1;
81  items.at(i)->view = 0;
82  delete items.at(i);
83  }
84  }
85  items.clear();
86  reset();
87 }
88 
90 {
91  return items.value(row);
92 }
93 
95 {
96  if (!item)
97  return;
98  int row = items.indexOf(item); // ### use index(item) - it's faster
99  Q_ASSERT(row != -1);
100  beginRemoveRows(QModelIndex(), row, row);
101  items.at(row)->d->theid = -1;
102  items.at(row)->view = 0;
103  items.removeAt(row);
104  endRemoveRows();
105 }
106 
108 {
109  if (!item)
110  return;
111 
113  if (item->view && item->view->isSortingEnabled()) {
114  // sorted insertion
117  item->view->sortOrder(), item);
118  row = qMax(it - items.begin(), 0);
119  } else {
120  if (row < 0)
121  row = 0;
122  else if (row > items.count())
123  row = items.count();
124  }
125  beginInsertRows(QModelIndex(), row, row);
126  items.insert(row, item);
127  item->d->theid = row;
128  endInsertRows();
129 }
130 
131 void QListModel::insert(int row, const QStringList &labels)
132 {
133  const int count = labels.count();
134  if (count <= 0)
135  return;
137  if (view && view->isSortingEnabled()) {
138  // sorted insertion
139  for (int i = 0; i < count; ++i) {
140  QListWidgetItem *item = new QListWidgetItem(labels.at(i));
141  insert(row, item);
142  }
143  } else {
144  if (row < 0)
145  row = 0;
146  else if (row > items.count())
147  row = items.count();
148  beginInsertRows(QModelIndex(), row, row + count - 1);
149  for (int i = 0; i < count; ++i) {
150  QListWidgetItem *item = new QListWidgetItem(labels.at(i));
151  item->d->theid = row;
153  items.insert(row++, item);
154  }
155  endInsertRows();
156  }
157 }
158 
160 {
161  if (row < 0 || row >= items.count())
162  return 0;
163 
164  beginRemoveRows(QModelIndex(), row, row);
165  items.at(row)->d->theid = -1;
166  items.at(row)->view = 0;
167  QListWidgetItem *item = items.takeAt(row);
168  endRemoveRows();
169  return item;
170 }
171 
172 void QListModel::move(int srcRow, int dstRow)
173 {
174  if (srcRow == dstRow
175  || srcRow < 0 || srcRow >= items.count()
176  || dstRow < 0 || dstRow > items.count())
177  return;
178 
179  if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow))
180  return;
181  if (srcRow < dstRow)
182  --dstRow;
183  items.move(srcRow, dstRow);
184  endMoveRows();
185 }
186 
188 {
189  return parent.isValid() ? 0 : items.count();
190 }
191 
193 {
194  if (!item || !item->view || static_cast<const QListModel *>(item->view->model()) != this
195  || items.isEmpty())
196  return QModelIndex();
197  int row;
198  const int theid = item->d->theid;
199  if (theid >= 0 && theid < items.count() && items.at(theid) == item) {
200  row = theid;
201  } else { // we need to search for the item
202  row = items.lastIndexOf(item); // lastIndexOf is an optimization in favor of indexOf
203  if (row == -1) // not found
204  return QModelIndex();
205  item->d->theid = row;
206  }
207  return createIndex(row, 0, item);
208 }
209 
210 QModelIndex QListModel::index(int row, int column, const QModelIndex &parent) const
211 {
212  if (hasIndex(row, column, parent))
213  return createIndex(row, column, items.at(row));
214  return QModelIndex();
215 }
216 
218 {
219  if (!index.isValid() || index.row() >= items.count())
220  return QVariant();
221  return items.at(index.row())->data(role);
222 }
223 
224 bool QListModel::setData(const QModelIndex &index, const QVariant &value, int role)
225 {
226  if (!index.isValid() || index.row() >= items.count())
227  return false;
228  items.at(index.row())->setData(role, value);
229  return true;
230 }
231 
233 {
234  QMap<int, QVariant> roles;
235  if (!index.isValid() || index.row() >= items.count())
236  return roles;
237  QListWidgetItem *itm = items.at(index.row());
238  for (int i = 0; i < itm->d->values.count(); ++i) {
239  roles.insert(itm->d->values.at(i).role,
240  itm->d->values.at(i).value);
241  }
242  return roles;
243 }
244 
245 bool QListModel::insertRows(int row, int count, const QModelIndex &parent)
246 {
247  if (count < 1 || row < 0 || row > rowCount() || parent.isValid())
248  return false;
249 
250  beginInsertRows(QModelIndex(), row, row + count - 1);
252  QListWidgetItem *itm = 0;
253 
254  for (int r = row; r < row + count; ++r) {
255  itm = new QListWidgetItem;
256  itm->view = view;
257  itm->d->theid = r;
258  items.insert(r, itm);
259  }
260 
261  endInsertRows();
262  return true;
263 }
264 
265 bool QListModel::removeRows(int row, int count, const QModelIndex &parent)
266 {
267  if (count < 1 || row < 0 || (row + count) > rowCount() || parent.isValid())
268  return false;
269 
270  beginRemoveRows(QModelIndex(), row, row + count - 1);
271  QListWidgetItem *itm = 0;
272  for (int r = row; r < row + count; ++r) {
273  itm = items.takeAt(row);
274  itm->view = 0;
275  itm->d->theid = -1;
276  delete itm;
277  }
278  endRemoveRows();
279  return true;
280 }
281 
282 Qt::ItemFlags QListModel::flags(const QModelIndex &index) const
283 {
284  if (!index.isValid() || index.row() >= items.count() || index.model() != this)
285  return Qt::ItemIsDropEnabled; // we allow drops outside the items
286  return items.at(index.row())->flags();
287 }
288 
289 void QListModel::sort(int column, Qt::SortOrder order)
290 {
291  if (column != 0)
292  return;
293 
295 
297  for (int i = 0; i < items.count(); ++i) {
298  QListWidgetItem *item = items.at(i);
299  sorting[i].first = item;
300  sorting[i].second = i;
301  }
302 
304  qSort(sorting.begin(), sorting.end(), compare);
305  QModelIndexList fromIndexes;
306  QModelIndexList toIndexes;
307  for (int r = 0; r < sorting.count(); ++r) {
308  QListWidgetItem *item = sorting.at(r).first;
309  toIndexes.append(createIndex(r, 0, item));
310  fromIndexes.append(createIndex(sorting.at(r).second, 0, sorting.at(r).first));
311  items[r] = sorting.at(r).first;
312  }
313  changePersistentIndexList(fromIndexes, toIndexes);
314 
316 }
317 
325 void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int end)
326 {
327  if (column != 0)
328  return;
329 
330  int count = end - start + 1;
331  QVector < QPair<QListWidgetItem*,int> > sorting(count);
332  for (int i = 0; i < count; ++i) {
333  sorting[i].first = items.at(start + i);
334  sorting[i].second = start + i;
335  }
336 
338  qSort(sorting.begin(), sorting.end(), compare);
339 
340  QModelIndexList oldPersistentIndexes = persistentIndexList();
341  QModelIndexList newPersistentIndexes = oldPersistentIndexes;
344  bool changed = false;
345  for (int i = 0; i < count; ++i) {
346  int oldRow = sorting.at(i).second;
347  QListWidgetItem *item = tmp.takeAt(oldRow);
348  lit = sortedInsertionIterator(lit, tmp.end(), order, item);
349  int newRow = qMax(lit - tmp.begin(), 0);
350  lit = tmp.insert(lit, item);
351  if (newRow != oldRow) {
352  changed = true;
353  for (int j = i + 1; j < count; ++j) {
354  int otherRow = sorting.at(j).second;
355  if (oldRow < otherRow && newRow >= otherRow)
356  --sorting[j].second;
357  else if (oldRow > otherRow && newRow <= otherRow)
358  ++sorting[j].second;
359  }
360  for (int k = 0; k < newPersistentIndexes.count(); ++k) {
361  QModelIndex pi = newPersistentIndexes.at(k);
362  int oldPersistentRow = pi.row();
363  int newPersistentRow = oldPersistentRow;
364  if (oldPersistentRow == oldRow)
365  newPersistentRow = newRow;
366  else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow)
367  newPersistentRow = oldPersistentRow - 1;
368  else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow)
369  newPersistentRow = oldPersistentRow + 1;
370  if (newPersistentRow != oldPersistentRow)
371  newPersistentIndexes[k] = createIndex(newPersistentRow,
372  pi.column(), pi.internalPointer());
373  }
374  }
375  }
376 
377  if (changed) {
379  items = tmp;
380  changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes);
382  }
383 }
384 
387 {
388  return (*left.first) < (*right.first);
389 }
390 
393 {
394  return (*right.first) < (*left.first);
395 }
396 
400  Qt::SortOrder order, QListWidgetItem *item)
401 {
402  if (order == Qt::AscendingOrder)
403  return qLowerBound(begin, end, item, QListModelLessThan());
404  return qLowerBound(begin, end, item, QListModelGreaterThan());
405 }
406 
408 {
409  QModelIndex idx = index(item);
410  emit dataChanged(idx, idx);
411 }
412 
414 {
415  const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());
416  return view->mimeTypes();
417 }
418 
420 {
422 }
423 
425 {
426  QList<QListWidgetItem*> itemlist;
427  for (int i = 0; i < indexes.count(); ++i)
428  itemlist << at(indexes.at(i).row());
429  const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());
430 
431  cachedIndexes = indexes;
432  QMimeData *mimeData = view->mimeData(itemlist);
433  cachedIndexes.clear();
434  return mimeData;
435 }
436 
437 #ifndef QT_NO_DRAGANDDROP
439  int row, int column, const QModelIndex &index)
440 {
441  Q_UNUSED(column);
443  if (index.isValid())
444  row = index.row();
445  else if (row == -1)
446  row = items.count();
447 
448  return view->dropMimeData(row, data, action);
449 }
450 
451 Qt::DropActions QListModel::supportedDropActions() const
452 {
453  const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());
454  return view->supportedDropActions();
455 }
456 #endif // QT_NO_DRAGANDDROP
457 
611  : rtti(type), view(view), d(new QListWidgetItemPrivate(this)),
612  itemFlags(Qt::ItemIsSelectable
614  |Qt::ItemIsEnabled
616 {
617  if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
618  model->insert(model->rowCount(), this);
619 }
620 
638  : rtti(type), view(0), d(new QListWidgetItemPrivate(this)),
641  |Qt::ItemIsEnabled
643 {
644  setData(Qt::DisplayRole, text);
645  this->view = view;
646  if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
647  model->insert(model->rowCount(), this);
648 }
649 
668  QListWidget *view, int type)
669  : rtti(type), view(0), d(new QListWidgetItemPrivate(this)),
672  |Qt::ItemIsEnabled
674 {
675  setData(Qt::DisplayRole, text);
677  this->view = view;
678  if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
679  model->insert(model->rowCount(), this);
680 }
681 
686 {
687  if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
688  model->remove(this);
689  delete d;
690 }
691 
696 {
697  return new QListWidgetItem(*this);
698 }
699 
706 void QListWidgetItem::setData(int role, const QVariant &value)
707 {
708  bool found = false;
709  role = (role == Qt::EditRole ? Qt::DisplayRole : role);
710  for (int i = 0; i < d->values.count(); ++i) {
711  if (d->values.at(i).role == role) {
712  if (d->values.at(i).value == value)
713  return;
714  d->values[i].value = value;
715  found = true;
716  break;
717  }
718  }
719  if (!found)
720  d->values.append(QWidgetItemData(role, value));
721  if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
722  model->itemChanged(this);
723 }
724 
732 {
733  role = (role == Qt::EditRole ? Qt::DisplayRole : role);
734  for (int i = 0; i < d->values.count(); ++i)
735  if (d->values.at(i).role == role)
736  return d->values.at(i).value;
737  return QVariant();
738 }
739 
745 {
746  const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole);
748 }
749 
750 #ifndef QT_NO_DATASTREAM
751 
758 {
759  in >> d->values;
760 }
761 
768 {
769  out << d->values;
770 }
771 #endif // QT_NO_DATASTREAM
772 
787  : rtti(Type), view(0),
788  d(new QListWidgetItemPrivate(this)),
789  itemFlags(other.itemFlags)
790 {
791  d->values = other.d->values;
792 }
793 
803 {
804  d->values = other.d->values;
805  itemFlags = other.itemFlags;
806  return *this;
807 }
808 
809 #ifndef QT_NO_DATASTREAM
810 
824 {
825  item.write(out);
826  return out;
827 }
828 
842 {
843  item.read(in);
844  return in;
845 }
846 
847 #endif // QT_NO_DATASTREAM
848 
1021 void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
1022  itemFlags = aflags;
1023  if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
1024  model->itemChanged(this);
1025 }
1026 
1027 
1162 {
1163  Q_Q(QListWidget);
1164  q->QListView::setModel(new QListModel(q));
1165  // view signals
1166  QObject::connect(q, SIGNAL(pressed(QModelIndex)), q, SLOT(_q_emitItemPressed(QModelIndex)));
1167  QObject::connect(q, SIGNAL(clicked(QModelIndex)), q, SLOT(_q_emitItemClicked(QModelIndex)));
1168  QObject::connect(q, SIGNAL(doubleClicked(QModelIndex)),
1169  q, SLOT(_q_emitItemDoubleClicked(QModelIndex)));
1170  QObject::connect(q, SIGNAL(activated(QModelIndex)),
1171  q, SLOT(_q_emitItemActivated(QModelIndex)));
1172  QObject::connect(q, SIGNAL(entered(QModelIndex)), q, SLOT(_q_emitItemEntered(QModelIndex)));
1173  QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
1174  q, SLOT(_q_emitItemChanged(QModelIndex)));
1175  QObject::connect(q->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
1176  q, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex)));
1177  QObject::connect(q->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
1178  q, SIGNAL(itemSelectionChanged()));
1179  QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
1180  q, SLOT(_q_dataChanged(QModelIndex,QModelIndex)));
1181  QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort()));
1182 }
1183 
1185 {
1186  Q_Q(QListWidget);
1187  emit q->itemPressed(listModel()->at(index.row()));
1188 }
1189 
1191 {
1192  Q_Q(QListWidget);
1193  emit q->itemClicked(listModel()->at(index.row()));
1194 }
1195 
1197 {
1198  Q_Q(QListWidget);
1199  emit q->itemDoubleClicked(listModel()->at(index.row()));
1200 }
1201 
1203 {
1204  Q_Q(QListWidget);
1205  emit q->itemActivated(listModel()->at(index.row()));
1206 }
1207 
1209 {
1210  Q_Q(QListWidget);
1211  emit q->itemEntered(listModel()->at(index.row()));
1212 }
1213 
1215 {
1216  Q_Q(QListWidget);
1217  emit q->itemChanged(listModel()->at(index.row()));
1218 }
1219 
1221  const QModelIndex &previous)
1222 {
1223  Q_Q(QListWidget);
1224  QPersistentModelIndex persistentCurrent = current;
1225  QListWidgetItem *currentItem = listModel()->at(persistentCurrent.row());
1226  emit q->currentItemChanged(currentItem, listModel()->at(previous.row()));
1227 
1228  //persistentCurrent is invalid if something changed the model in response
1229  //to the currentItemChanged signal emission and the item was removed
1230  if (!persistentCurrent.isValid()) {
1231  currentItem = 0;
1232  }
1233 
1234  emit q->currentTextChanged(currentItem ? currentItem->text() : QString());
1235  emit q->currentRowChanged(persistentCurrent.row());
1236 }
1237 
1239 {
1240  if (sortingEnabled)
1241  model->sort(0, sortOrder);
1242 }
1243 
1245  const QModelIndex &bottomRight)
1246 {
1247  if (sortingEnabled && topLeft.isValid() && bottomRight.isValid())
1248  listModel()->ensureSorted(topLeft.column(), sortOrder,
1249  topLeft.row(), bottomRight.row());
1250 }
1251 
1459  : QListView(*new QListWidgetPrivate(), parent)
1460 {
1461  Q_D(QListWidget);
1462  d->setup();
1463 }
1464 
1470 {
1471 }
1472 
1481 {
1482  Q_D(const QListWidget);
1483  if (row < 0 || row >= d->model->rowCount())
1484  return 0;
1485  return d->listModel()->at(row);
1486 }
1487 
1495 {
1496  Q_D(const QListWidget);
1497  return d->listModel()->index(const_cast<QListWidgetItem*>(item)).row();
1498 }
1499 
1500 
1508 {
1509  Q_D(QListWidget);
1510  if (item && !item->view)
1511  d->listModel()->insert(row, item);
1512 }
1513 
1521 void QListWidget::insertItem(int row, const QString &label)
1522 {
1523  Q_D(QListWidget);
1524  d->listModel()->insert(row, new QListWidgetItem(label));
1525 }
1526 
1534 void QListWidget::insertItems(int row, const QStringList &labels)
1535 {
1536  Q_D(QListWidget);
1537  d->listModel()->insert(row, labels);
1538 }
1539 
1551 {
1552  Q_D(QListWidget);
1553  if (row < 0 || row >= d->model->rowCount())
1554  return 0;
1555  return d->listModel()->take(row);
1556 }
1557 
1566 int QListWidget::count() const
1567 {
1568  Q_D(const QListWidget);
1569  return d->model->rowCount();
1570 }
1571 
1576 {
1577  Q_D(const QListWidget);
1578  return d->listModel()->at(currentIndex().row());
1579 }
1580 
1581 
1589 {
1590  setCurrentRow(row(item));
1591 }
1592 
1600 void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command)
1601 {
1602  setCurrentRow(row(item), command);
1603 }
1604 
1615 int QListWidget::currentRow() const
1616 {
1617  return currentIndex().row();
1618 }
1619 
1621 {
1622  Q_D(QListWidget);
1623  QModelIndex index = d->listModel()->index(row);
1624  if (d->selectionMode == SingleSelection)
1626  else if (d->selectionMode == NoSelection)
1628  else
1630 }
1631 
1637 void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command)
1638 {
1639  Q_D(QListWidget);
1640  d->selectionModel->setCurrentIndex(d->listModel()->index(row), command);
1641 }
1642 
1649 {
1650  Q_D(const QListWidget);
1651  return d->listModel()->at(indexAt(p).row());
1652 
1653 }
1654 
1670 {
1671  Q_D(const QListWidget);
1672  QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item));
1673  return visualRect(index);
1674 }
1675 
1680 {
1681  Q_D(QListWidget);
1682  d->sortOrder = order;
1683  d->listModel()->sort(0, order);
1684 }
1685 
1700 {
1701  Q_D(QListWidget);
1702  d->sortingEnabled = enable;
1703 }
1704 
1706 {
1707  Q_D(const QListWidget);
1708  return d->sortingEnabled;
1709 }
1710 
1715 {
1716  Q_D(const QListWidget);
1717  return d->sortOrder;
1718 }
1719 
1725 {
1726  Q_D(QListWidget);
1727  edit(d->listModel()->index(item));
1728 }
1729 
1737 {
1738  Q_D(QListWidget);
1739  QModelIndex index = d->listModel()->index(item);
1741 }
1742 
1749 {
1750  Q_D(QListWidget);
1751  QModelIndex index = d->listModel()->index(item);
1753 }
1754 
1764 {
1765  Q_D(const QListWidget);
1766  QModelIndex index = d->listModel()->index(item);
1767  return QAbstractItemView::indexWidget(index);
1768 }
1769 
1786 {
1787  Q_D(QListWidget);
1788  QModelIndex index = d->listModel()->index(item);
1789  QAbstractItemView::setIndexWidget(index, widget);
1790 }
1791 
1800 {
1801  Q_D(const QListWidget);
1802  QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item));
1803  return selectionModel()->isSelected(index);
1804 }
1805 
1815 {
1816  Q_D(QListWidget);
1817  QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item));
1818 
1819  if (d->selectionMode == SingleSelection) {
1820  selectionModel()->select(index, select
1823  } else if (d->selectionMode != NoSelection) {
1824  selectionModel()->select(index, select
1827  }
1828 
1829 }
1830 
1836 {
1837  Q_D(const QListWidget);
1840  for (int i = 0; i < indexes.count(); ++i)
1841  items.append(d->listModel()->at(indexes.at(i).row()));
1842  return items;
1843 }
1844 
1850 QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const
1851 {
1852  Q_D(const QListWidget);
1853  QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()),
1854  Qt::DisplayRole, text, -1, flags);
1856  for (int i = 0; i < indexes.size(); ++i)
1857  items.append(d->listModel()->at(indexes.at(i).row()));
1858  return items;
1859 }
1860 
1869 {
1870  return isRowHidden(row(item));
1871 }
1872 
1881 {
1882  setRowHidden(row(item), hide);
1883 }
1884 
1892 {
1893  Q_D(QListWidget);
1894  QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item));
1895  QListView::scrollTo(index, hint);
1896 }
1897 
1904 {
1905  Q_D(QListWidget);
1906  selectionModel()->clear();
1907  d->listModel()->clear();
1908 }
1909 
1917 {
1918  return d_func()->listModel()->QAbstractListModel::mimeTypes();
1919 }
1920 
1930 {
1931  return d_func()->listModel()->internalMimeData();
1932 }
1933 
1934 #ifndef QT_NO_DRAGANDDROP
1935 
1943 {
1944  QModelIndex idx;
1945  int row = index;
1946  int column = 0;
1948  // QAbstractListModel::dropMimeData will overwrite on the index if row == -1 and column == -1
1949  idx = model()->index(row, column);
1950  row = -1;
1951  column = -1;
1952  }
1953  return d_func()->listModel()->QAbstractListModel::dropMimeData(data, action , row, column, idx);
1954 }
1955 
1958  Q_D(QListWidget);
1959  if (event->source() == this && d->movement != Static) {
1960  QListView::dropEvent(event);
1961  return;
1962  }
1963 
1964  if (event->source() == this && (event->dropAction() == Qt::MoveAction ||
1966  QModelIndex topIndex;
1967  int col = -1;
1968  int row = -1;
1969  if (d->dropOn(event, &row, &col, &topIndex)) {
1970  QList<QModelIndex> selIndexes = selectedIndexes();
1971  QList<QPersistentModelIndex> persIndexes;
1972  for (int i = 0; i < selIndexes.count(); i++)
1973  persIndexes.append(selIndexes.at(i));
1974 
1975  if (persIndexes.contains(topIndex))
1976  return;
1977  qSort(persIndexes); // The dropped items will remain in the same visual order.
1978 
1979  QPersistentModelIndex dropRow = model()->index(row, col, topIndex);
1980 
1981  int r = row == -1 ? count() : (dropRow.row() >= 0 ? dropRow.row() : row);
1982  for (int i = 0; i < persIndexes.count(); ++i) {
1983  const QPersistentModelIndex &pIndex = persIndexes.at(i);
1984  d->listModel()->move(pIndex.row(), r);
1985  r = pIndex.row() + 1; // Dropped items are inserted contiguously and in the right order.
1986  }
1987 
1988  event->accept();
1989  // Don't want QAbstractItemView to delete it because it was "moved" we already did it
1990  event->setDropAction(Qt::CopyAction);
1991  }
1992  }
1993 
1994  QListView::dropEvent(event);
1995 }
1996 
2002 Qt::DropActions QListWidget::supportedDropActions() const
2003 {
2004  Q_D(const QListWidget);
2005  return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction;
2006 }
2007 #endif // QT_NO_DRAGANDDROP
2008 
2015 {
2017  if (lwd)
2018  return lwd->items;
2019  return QList<QListWidgetItem*>();
2020 }
2021 
2027 {
2028  Q_D(const QListWidget);
2029  return d->listModel()->index(item);
2030 }
2031 
2037 {
2038  Q_D(const QListWidget);
2039  if (d->isIndexValid(index))
2040  return d->listModel()->at(index.row());
2041  return 0;
2042 }
2043 
2048 {
2049  Q_ASSERT(!"QListWidget::setModel() - Changing the model of the QListWidget is not allowed.");
2050 }
2051 
2056 {
2057  return QListView::event(e);
2058 }
2059 
2061 
2062 #include "moc_qlistwidget.cpp"
2063 
2064 #endif // QT_NO_LISTWIDGET
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
void setItemWidget(QListWidgetItem *item, QWidget *widget)
Sets the widget to be displayed in the give item.
QListWidgetItem * at(int row) const
Definition: qlistwidget.cpp:89
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
void _q_emitItemPressed(const QModelIndex &index)
virtual QListWidgetItem * clone() const
Creates an exact copy of the item.
int row() const
Returns the row this persistent model index refers to.
void openPersistentEditor(const QModelIndex &index)
Opens a persistent editor on the item at the given index.
QListWidgetItem & operator=(const QListWidgetItem &other)
Assigns other&#39;s data and flags to this item.
void _q_emitItemClicked(const QModelIndex &index)
int type
Definition: qmetatype.cpp:239
void remove(QListWidgetItem *item)
Definition: qlistwidget.cpp:94
bool isItemHidden(const QListWidgetItem *item) const
Returns true if the item is explicitly hidden; otherwise returns false.
virtual void clear()
Clears the selection model.
void setRowHidden(int row, bool hide)
If hide is true, the given row will be hidden; otherwise the row will be shown.
Definition: qlistview.cpp:573
QModelIndexList persistentIndexList() const
Returns the list of indexes stored as persistent indexes in the model.
QListWidgetItem * itemFromIndex(const QModelIndex &index) const
Returns a pointer to the QListWidgetItem assocated with the given index.
void clear()
Removes all the MIME type and data entries in the object.
Definition: qmimedata.cpp:613
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void dropEvent(QDropEvent *event)
Reimplemented Function
QPointer< QWidget > widget
void setCurrentItem(QListWidgetItem *item)
Sets the current item to item.
QList< QListWidgetItem * > selectedItems() const
Returns a list of all selected items in the list widget.
void editItem(QListWidgetItem *item)
Starts editing the item if it is editable.
QList< QListWidgetItem * > findItems(const QString &text, Qt::MatchFlags flags) const
Finds items with the text that matches the string text using the given flags.
virtual void read(QDataStream &in)
Reads the item from stream in.
QListWidgetItem * takeItem(int row)
Removes and returns the item from the given row in the list widget; otherwise returns 0...
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QDataStream & operator<<(QDataStream &out, const QListWidgetItem &item)
Writes the list widget item item to stream out.
QWidget * itemWidget(QListWidgetItem *item) const
Returns the widget displayed in the given item.
void _q_emitItemEntered(const QModelIndex &index)
void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)
Reimplemented Function
Definition: qlistview.cpp:597
T & first()
Returns a reference to the first item in the vector.
Definition: qvector.h:260
#define at(className, varName)
QModelIndexList selectedIndexes() const
Returns a list of all selected model item indexes.
#define SLOT(a)
Definition: qobjectdefs.h:226
static bool itemGreaterThan(const QPair< QListWidgetItem *, int > &left, const QPair< QListWidgetItem *, int > &right)
T1 first
Definition: qpair.h:65
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
DragDropMode dragDropMode() const
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
QListWidgetItemPrivate * d
Definition: qlistwidget.h:169
void setItemSelected(const QListWidgetItem *item, bool select)
Selects or deselects the given item depending on whether select is true of false. ...
void setIndexWidget(const QModelIndex &index, QWidget *widget)
Sets the given widget on the item at the given index, passing the ownership of the widget to the view...
bool isSortingEnabled() const
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
QMap< int, QVariant > itemData(const QModelIndex &index) const
Returns a map with values for all predefined roles in the model for the item at the given index...
The QListWidget class provides an item-based list widget.
Definition: qlistwidget.h:202
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
QListWidgetItem * item(int row) const
Returns the item that occupies the given row in the list if one has been set; otherwise returns 0...
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void itemChanged(QListWidgetItem *item)
bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false.
The QAbstractListModel class provides an abstract model that can be subclassed to create one-dimensio...
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
void _q_emitItemDoubleClicked(const QModelIndex &index)
void endInsertRows()
Ends a row insertion operation.
QListWidgetItem * itemAt(const QPoint &p) const
Returns a pointer to the item at the coordinates p.
static bool variantLessThan(const QVariant &v1, const QVariant &v2)
This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort.
void sort(int column, Qt::SortOrder order)
Sorts the model by column in the given order.
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QList< QListWidgetItem * > items
Definition: qlistwidget.cpp:59
DropIndicatorPosition dropIndicatorPosition() const
Returns the position of the drop indicator in relation to the closest item.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
void insertItem(int row, QListWidgetItem *item)
Inserts the item at the position in the list given by row.
#define Q_D(Class)
Definition: qglobal.h:2482
void endMoveRows()
Ends a row move operation.
void setModel(QAbstractItemModel *model)
void _q_emitItemChanged(const QModelIndex &index)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QWidget * indexWidget(const QModelIndex &index) const
Returns the widget for the item at the given index.
QModelIndex indexAt(const QPoint &p) const
Reimplemented Function
Definition: qlistview.cpp:1112
QListModel(QListWidget *parent)
Definition: qlistwidget.cpp:66
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list t...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
#define Q_Q(Class)
Definition: qglobal.h:2483
void scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint=EnsureVisible)
Scrolls the view if necessary to ensure that the item is visible.
int count() const
bool event(QEvent *e)
Reimplemented Function
Definition: qlistview.cpp:1693
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
void _q_emitCurrentItemChanged(const QModelIndex &current, const QModelIndex &previous)
virtual bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action)
Handles data supplied by an external drag and drop operation that ended with the given action in the ...
void move(int from, int to)
Moves the item at index position from to index position to.
Definition: qlist.h:628
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
#define SIGNAL(a)
Definition: qobjectdefs.h:227
bool insertRows(int row, int count=1, const QModelIndex &parent=QModelIndex())
On models that support this, inserts count rows into the model before the given row.
SortOrder
Definition: qnamespace.h:189
virtual QVariant data(int role) const
Returns the item&#39;s data for a given role.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool compare(const QVariant::Private *a, const QVariant::Private *b)
Compares a to b.
Definition: qvariant.cpp:383
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QStringList mimeTypes() const
Returns a list of MIME types that can be used to describe a list of model indexes.
int lastIndexOf(const T &t, int from=-1) const
Returns the index position of the last occurrence of value in the list, searching backward from index...
Definition: qlist.h:862
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QItemSelectionModel * selectionModel() const
Returns the current selection model.
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
bool isSelected(const QModelIndex &index) const
Returns true if the given model item index is selected.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
int row() const
Returns the row this model index refers to.
QDataStream & operator>>(QDataStream &in, QListWidgetItem &item)
Reads a list widget item from stream in into item.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
QList< QListWidgetItem * > items
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QModelIndex index(QListWidgetItem *item) const
QWidgetData * data
Definition: qwidget.h:815
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
void ensureSorted(int column, Qt::SortOrder order, int start, int end)
void sortItems(Qt::SortOrder order=Qt::AscendingOrder)
Sorts all the items in the list widget according to the specified order.
friend class QListModel
Definition: qlistwidget.h:65
void setCurrentRow(int row)
int rowCount(const QModelIndex &parent=QModelIndex()) const
Returns the number of rows under the given parent.
QVector< QWidgetItemData > values
QModelIndex currentIndex() const
Returns the model index of the current item.
virtual void write(QDataStream &out) const
Writes the item to stream out.
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
DropAction
Definition: qnamespace.h:1597
void endRemoveRows()
Ends a row removal operation.
void clear()
Removes all items from the list.
Definition: qlist.h:764
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
Qt::DropActions supportedDropActions() const
Returns the drop actions supported by this model.
virtual void setData(int role, const QVariant &value)
Sets the data for a given role to the given value.
QListWidget(QWidget *parent=0)
Constructs an empty QListWidget with the given parent.
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
void _q_emitItemActivated(const QModelIndex &index)
void insert(int row, QListWidgetItem *item)
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
~QListWidget()
Destroys the list widget and all its items.
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
#define Q_OBJECT
Definition: qobjectdefs.h:157
QModelIndexList cachedIndexes
void hide()
Hides the widget.
Definition: qwidget.h:501
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QModelIndex indexFromItem(QListWidgetItem *item) const
Returns the QModelIndex assocated with the given item.
The QListWidgetItem class provides an item for use with the QListWidget item view class...
Definition: qlistwidget.h:63
The QAbstractItemModel class provides the abstract interface for item model classes.
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
virtual QStringList mimeTypes() const
Returns a list of MIME types that can be used to describe a list of listwidget items.
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
static QList< QListWidgetItem * >::iterator sortedInsertionIterator(const QList< QListWidgetItem *>::iterator &begin, const QList< QListWidgetItem *>::iterator &end, Qt::SortOrder order, QListWidgetItem *item)
friend class QListWidgetItem
Definition: qlistwidget.h:209
QListWidgetItem * take(int row)
The QItemSelection class manages information about selected items in a model.
QRect visualRect(const QModelIndex &index) const
Reimplemented Function
Definition: qlistview.cpp:588
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
void setFlags(Qt::ItemFlags flags)
Sets the item flags for the list item to flags.
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
QList< QListWidgetItem * > items(const QMimeData *data) const
Returns a list of pointers to the items contained in the data object.
The QPersistentModelIndex class is used to locate data in a data model.
void insertItems(int row, const QStringList &labels)
Inserts items from the list of labels into the list, starting at the given row.
QRect visualItemRect(const QListWidgetItem *item) const
Returns the rectangle on the viewport occupied by the item at item.
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
Definition: qevent.cpp:2739
void setItemHidden(const QListWidgetItem *item, bool hide)
If hide is true, the item will be hidden; otherwise it will be shown.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
The QModelIndex class is used to locate data in a data model.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.
QListWidgetItem(QListWidget *view=0, int type=Type)
Constructs an empty list widget item of the specified type with the given parent. ...
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Returns the data stored under the given role for the item referred to by the index.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QModelIndexList selectedIndexes() const
Reimplemented Function
Definition: qlistview.cpp:1482
Definition: qnamespace.h:54
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
Qt::ItemFlags itemFlags
Definition: qlistwidget.h:170
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
virtual ~QListWidgetItem()
Destroys the list item.
void setSortingEnabled(bool enable)
QListWidget * view
Definition: qlistwidget.h:168
virtual bool operator<(const QListWidgetItem &other) const
Returns true if this item&#39;s text is less then other item&#39;s text; otherwise returns false...
virtual QMimeData * mimeData(const QList< QListWidgetItem *> items) const
Returns an object that contains a serialized description of the specified items.
QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
quint16 index
bool event(QEvent *e)
Reimplemented Function
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
QMimeData * internalMimeData() const
void move(int srcRow, int dstRow)
Qt::SortOrder sortOrder() const
QIcon icon() const
Returns the list item&#39;s icon.
Definition: qlistwidget.h:93
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
void clear()
Definition: qlistwidget.cpp:76
void closePersistentEditor(const QModelIndex &index)
Closes the persistent editor for the item at the given index.
int type() const
Returns the type passed to the QListWidgetItem constructor.
Definition: qlistwidget.h:163
Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
bool setData(const QModelIndex &index, const QVariant &value, int role)
Sets the role data for the item at index to value.
void clear()
Removes all items and selections in the view.
int row(const QListWidgetItem *item) const
Returns the row containing the given item.
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
Definition: qtestcase.cpp:2183
void openPersistentEditor(QListWidgetItem *item)
Opens an editor for the given item.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
bool(* LessThan)(const QPair< QListWidgetItem *, int > &, const QPair< QListWidgetItem *, int > &)
Definition: qlistwidget.cpp:53
static const KeyPair *const end
bool isItemSelected(const QListWidgetItem *item) const
Returns true if item is selected; otherwise returns false.
QListWidgetItem * currentItem() const
Returns the current item.
bool removeRows(int row, int count=1, const QModelIndex &parent=QModelIndex())
On models that support this, removes count rows starting with the given row under parent parent from ...
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
virtual Qt::DropActions supportedDropActions() const
Returns the drop actions supported by this view.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
Begins a row move operation.
int currentRow() const
QString text() const
Returns the list item&#39;s text.
Definition: qlistwidget.h:89
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
void closePersistentEditor(QListWidgetItem *item)
Closes the persistent editor for the given item.
void reset()
Resets the model to its original state in any attached views.
void dropEvent(QDropEvent *e)
Reimplemented Function
Definition: qlistview.cpp:917
#define text
Definition: qobjectdefs.h:80
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
int column() const
Returns the column this model index refers to.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
bool isRowHidden(int row) const
Returns true if the row is hidden; otherwise returns false.
Definition: qlistview.cpp:563
static bool itemLessThan(const QPair< QListWidgetItem *, int > &left, const QPair< QListWidgetItem *, int > &right)
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480