| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | #include "qlistwidget.h" | - |
| 41 | | - |
| 42 | #ifndef QT_NO_LISTWIDGET | - |
| 43 | #include <qitemdelegate.h> | - |
| 44 | #include <private/qlistview_p.h> | - |
| 45 | #include <private/qwidgetitemdata_p.h> | - |
| 46 | #include <private/qlistwidget_p.h> | - |
| 47 | | - |
| 48 | #include <algorithm> | - |
| 49 | | - |
| 50 | QT_BEGIN_NAMESPACE | - |
| 51 | | - |
| 52 | | - |
| 53 | typedef bool(*LessThan)(const QPair<QListWidgetItem*,int>&,const QPair<QListWidgetItem*,int>&); | - |
| 54 | | - |
| 55 | class QListWidgetMimeData : public QMimeData | - |
| 56 | { | - |
| 57 | Q_OBJECT | - |
| 58 | public: | - |
| 59 | QList<QListWidgetItem*> items; | - |
| 60 | }; | - |
| 61 | | - |
| 62 | QT_BEGIN_INCLUDE_NAMESPACE | - |
| 63 | #include "qlistwidget.moc" | - |
| 64 | QT_END_INCLUDE_NAMESPACE | - |
| 65 | | - |
| 66 | QListModel::QListModel(QListWidget *parent) | - |
| 67 | : QAbstractListModel(parent) | - |
| 68 | { | - |
| 69 | } | - |
| 70 | | - |
| 71 | QListModel::~QListModel() | - |
| 72 | { | - |
| 73 | clear(); | - |
| 74 | } | - |
| 75 | | - |
| 76 | void QListModel::clear() | - |
| 77 | { | - |
| 78 | beginResetModel(); | - |
| 79 | for (int i = 0; i < items.count(); ++i) { | - |
| 80 | if (items.at(i)) { | - |
| 81 | items.at(i)->d->theid = -1; | - |
| 82 | items.at(i)->view = 0; | - |
| 83 | delete items.at(i); | - |
| 84 | } | - |
| 85 | } | - |
| 86 | items.clear(); | - |
| 87 | endResetModel(); | - |
| 88 | } | - |
| 89 | | - |
| 90 | QListWidgetItem *QListModel::at(int row) const | - |
| 91 | { | - |
| 92 | return items.value(row); | - |
| 93 | } | - |
| 94 | | - |
| 95 | void QListModel::remove(QListWidgetItem *item) | - |
| 96 | { | - |
| 97 | if (!item) | - |
| 98 | return; | - |
| 99 | int row = items.indexOf(item); | - |
| 100 | Q_ASSERT(row != -1); | - |
| 101 | beginRemoveRows(QModelIndex(), row, row); | - |
| 102 | items.at(row)->d->theid = -1; | - |
| 103 | items.at(row)->view = 0; | - |
| 104 | items.removeAt(row); | - |
| 105 | endRemoveRows(); | - |
| 106 | } | - |
| 107 | | - |
| 108 | void QListModel::insert(int row, QListWidgetItem *item) | - |
| 109 | { | - |
| 110 | if (!item) | - |
| 111 | return; | - |
| 112 | | - |
| 113 | item->view = qobject_cast<QListWidget*>(QObject::parent()); | - |
| 114 | if (item->view && item->view->isSortingEnabled()) { | - |
| 115 | | - |
| 116 | QList<QListWidgetItem*>::iterator it; | - |
| 117 | it = sortedInsertionIterator(items.begin(), items.end(), | - |
| 118 | item->view->sortOrder(), item); | - |
| 119 | row = qMax(it - items.begin(), 0); | - |
| 120 | } else { | - |
| 121 | if (row < 0) | - |
| 122 | row = 0; | - |
| 123 | else if (row > items.count()) | - |
| 124 | row = items.count(); | - |
| 125 | } | - |
| 126 | beginInsertRows(QModelIndex(), row, row); | - |
| 127 | items.insert(row, item); | - |
| 128 | item->d->theid = row; | - |
| 129 | endInsertRows(); | - |
| 130 | } | - |
| 131 | | - |
| 132 | void QListModel::insert(int row, const QStringList &labels) | - |
| 133 | { | - |
| 134 | const int count = labels.count(); | - |
| 135 | if (count <= 0) | - |
| 136 | return; | - |
| 137 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
| 138 | if (view && view->isSortingEnabled()) { | - |
| 139 | | - |
| 140 | for (int i = 0; i < count; ++i) { | - |
| 141 | QListWidgetItem *item = new QListWidgetItem(labels.at(i)); | - |
| 142 | insert(row, item); | - |
| 143 | } | - |
| 144 | } else { | - |
| 145 | if (row < 0) | - |
| 146 | row = 0; | - |
| 147 | else if (row > items.count()) | - |
| 148 | row = items.count(); | - |
| 149 | beginInsertRows(QModelIndex(), row, row + count - 1); | - |
| 150 | for (int i = 0; i < count; ++i) { | - |
| 151 | QListWidgetItem *item = new QListWidgetItem(labels.at(i)); | - |
| 152 | item->d->theid = row; | - |
| 153 | item->view = qobject_cast<QListWidget*>(QObject::parent()); | - |
| 154 | items.insert(row++, item); | - |
| 155 | } | - |
| 156 | endInsertRows(); | - |
| 157 | } | - |
| 158 | } | - |
| 159 | | - |
| 160 | QListWidgetItem *QListModel::take(int row) | - |
| 161 | { | - |
| 162 | if (row < 0 || row >= items.count()) | - |
| 163 | return 0; | - |
| 164 | | - |
| 165 | beginRemoveRows(QModelIndex(), row, row); | - |
| 166 | items.at(row)->d->theid = -1; | - |
| 167 | items.at(row)->view = 0; | - |
| 168 | QListWidgetItem *item = items.takeAt(row); | - |
| 169 | endRemoveRows(); | - |
| 170 | return item; | - |
| 171 | } | - |
| 172 | | - |
| 173 | void QListModel::move(int srcRow, int dstRow) | - |
| 174 | { | - |
| 175 | if (srcRow == dstRow | - |
| 176 | || srcRow < 0 || srcRow >= items.count() | - |
| 177 | || dstRow < 0 || dstRow > items.count()) | - |
| 178 | return; | - |
| 179 | | - |
| 180 | if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow)) | - |
| 181 | return; | - |
| 182 | if (srcRow < dstRow) | - |
| 183 | --dstRow; | - |
| 184 | items.move(srcRow, dstRow); | - |
| 185 | endMoveRows(); | - |
| 186 | } | - |
| 187 | | - |
| 188 | int QListModel::rowCount(const QModelIndex &parent) const | - |
| 189 | { | - |
| 190 | return parent.isValid() ? 0 : items.count(); | - |
| 191 | } | - |
| 192 | | - |
| 193 | QModelIndex QListModel::index(QListWidgetItem *item) const | - |
| 194 | { | - |
| 195 | if (!item || !item->view || static_cast<const QListModel *>(item->view->model()) != this | - |
| 196 | || items.isEmpty()) | - |
| 197 | return QModelIndex(); | - |
| 198 | int row; | - |
| 199 | const int theid = item->d->theid; | - |
| 200 | if (theid >= 0 && theid < items.count() && items.at(theid) == item) { | - |
| 201 | row = theid; | - |
| 202 | } else { | - |
| 203 | row = items.lastIndexOf(item); | - |
| 204 | if (row == -1) | - |
| 205 | return QModelIndex(); | - |
| 206 | item->d->theid = row; | - |
| 207 | } | - |
| 208 | return createIndex(row, 0, item); | - |
| 209 | } | - |
| 210 | | - |
| 211 | QModelIndex QListModel::index(int row, int column, const QModelIndex &parent) const | - |
| 212 | { | - |
| 213 | if (hasIndex(row, column, parent)) | - |
| 214 | return createIndex(row, column, items.at(row)); | - |
| 215 | return QModelIndex(); | - |
| 216 | } | - |
| 217 | | - |
| 218 | QVariant QListModel::data(const QModelIndex &index, int role) const | - |
| 219 | { | - |
| 220 | if (!index.isValid() || index.row() >= items.count()) | - |
| 221 | return QVariant(); | - |
| 222 | return items.at(index.row())->data(role); | - |
| 223 | } | - |
| 224 | | - |
| 225 | bool QListModel::setData(const QModelIndex &index, const QVariant &value, int role) | - |
| 226 | { | - |
| 227 | if (!index.isValid() || index.row() >= items.count()) | - |
| 228 | return false; | - |
| 229 | items.at(index.row())->setData(role, value); | - |
| 230 | return true; | - |
| 231 | } | - |
| 232 | | - |
| 233 | QMap<int, QVariant> QListModel::itemData(const QModelIndex &index) const | - |
| 234 | { | - |
| 235 | QMap<int, QVariant> roles; | - |
| 236 | if (!index.isValid() || index.row() >= items.count()) | - |
| 237 | return roles; | - |
| 238 | QListWidgetItem *itm = items.at(index.row()); | - |
| 239 | for (int i = 0; i < itm->d->values.count(); ++i) { | - |
| 240 | roles.insert(itm->d->values.at(i).role, | - |
| 241 | itm->d->values.at(i).value); | - |
| 242 | } | - |
| 243 | return roles; | - |
| 244 | } | - |
| 245 | | - |
| 246 | bool QListModel::insertRows(int row, int count, const QModelIndex &parent) | - |
| 247 | { | - |
| 248 | if (count < 1 || row < 0 || row > rowCount() || parent.isValid()) | - |
| 249 | return false; | - |
| 250 | | - |
| 251 | beginInsertRows(QModelIndex(), row, row + count - 1); | - |
| 252 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
| 253 | QListWidgetItem *itm = 0; | - |
| 254 | | - |
| 255 | for (int r = row; r < row + count; ++r) { | - |
| 256 | itm = new QListWidgetItem; | - |
| 257 | itm->view = view; | - |
| 258 | itm->d->theid = r; | - |
| 259 | items.insert(r, itm); | - |
| 260 | } | - |
| 261 | | - |
| 262 | endInsertRows(); | - |
| 263 | return true; | - |
| 264 | } | - |
| 265 | | - |
| 266 | bool QListModel::removeRows(int row, int count, const QModelIndex &parent) | - |
| 267 | { | - |
| 268 | if (count < 1 || row < 0 || (row + count) > rowCount() || parent.isValid()) | - |
| 269 | return false; | - |
| 270 | | - |
| 271 | beginRemoveRows(QModelIndex(), row, row + count - 1); | - |
| 272 | QListWidgetItem *itm = 0; | - |
| 273 | for (int r = row; r < row + count; ++r) { | - |
| 274 | itm = items.takeAt(row); | - |
| 275 | itm->view = 0; | - |
| 276 | itm->d->theid = -1; | - |
| 277 | delete itm; | - |
| 278 | } | - |
| 279 | endRemoveRows(); | - |
| 280 | return true; | - |
| 281 | } | - |
| 282 | | - |
| 283 | Qt::ItemFlags QListModel::flags(const QModelIndex &index) const | - |
| 284 | { | - |
| 285 | if (!index.isValid() || index.row() >= items.count() || index.model() != this) | - |
| 286 | return Qt::ItemIsDropEnabled; | - |
| 287 | return items.at(index.row())->flags(); | - |
| 288 | } | - |
| 289 | | - |
| 290 | void QListModel::sort(int column, Qt::SortOrder order) | - |
| 291 | { | - |
| 292 | if (column != 0) | - |
| 293 | return; | - |
| 294 | | - |
| 295 | emit layoutAboutToBeChanged(); | - |
| 296 | | - |
| 297 | QVector < QPair<QListWidgetItem*,int> > sorting(items.count()); | - |
| 298 | for (int i = 0; i < items.count(); ++i) { | - |
| 299 | QListWidgetItem *item = items.at(i); | - |
| 300 | sorting[i].first = item; | - |
| 301 | sorting[i].second = i; | - |
| 302 | } | - |
| 303 | | - |
| 304 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); | - |
| 305 | std::sort(sorting.begin(), sorting.end(), compare); | - |
| 306 | QModelIndexList fromIndexes; | - |
| 307 | QModelIndexList toIndexes; | - |
| 308 | const int sortingCount = sorting.count(); | - |
| 309 | fromIndexes.reserve(sortingCount); | - |
| 310 | toIndexes.reserve(sortingCount); | - |
| 311 | for (int r = 0; r < sortingCount; ++r) { | - |
| 312 | QListWidgetItem *item = sorting.at(r).first; | - |
| 313 | toIndexes.append(createIndex(r, 0, item)); | - |
| 314 | fromIndexes.append(createIndex(sorting.at(r).second, 0, sorting.at(r).first)); | - |
| 315 | items[r] = sorting.at(r).first; | - |
| 316 | } | - |
| 317 | changePersistentIndexList(fromIndexes, toIndexes); | - |
| 318 | | - |
| 319 | emit layoutChanged(); | - |
| 320 | } | - |
| 321 | | - |
| 322 | | - |
| 323 | | - |
| 324 | | - |
| 325 | | - |
| 326 | | - |
| 327 | | - |
| 328 | | - |
| 329 | void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int end) | - |
| 330 | { | - |
| 331 | if (column != 0) | - |
| 332 | return; | - |
| 333 | | - |
| 334 | int count = end - start + 1; | - |
| 335 | QVector < QPair<QListWidgetItem*,int> > sorting(count); | - |
| 336 | for (int i = 0; i < count; ++i) { | - |
| 337 | sorting[i].first = items.at(start + i); | - |
| 338 | sorting[i].second = start + i; | - |
| 339 | } | - |
| 340 | | - |
| 341 | LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); | - |
| 342 | std::sort(sorting.begin(), sorting.end(), compare); | - |
| 343 | | - |
| 344 | QModelIndexList oldPersistentIndexes = persistentIndexList(); | - |
| 345 | QModelIndexList newPersistentIndexes = oldPersistentIndexes; | - |
| 346 | QList<QListWidgetItem*> tmp = items; | - |
| 347 | QList<QListWidgetItem*>::iterator lit = tmp.begin(); | - |
| 348 | bool changed = false; | - |
| 349 | for (int i = 0; i < count; ++i) { | - |
| 350 | int oldRow = sorting.at(i).second; | - |
| 351 | int tmpitepos = lit - tmp.begin(); | - |
| 352 | QListWidgetItem *item = tmp.takeAt(oldRow); | - |
| 353 | if (tmpitepos > tmp.size()) | - |
| 354 | --tmpitepos; | - |
| 355 | lit = tmp.begin() + tmpitepos; | - |
| 356 | lit = sortedInsertionIterator(lit, tmp.end(), order, item); | - |
| 357 | int newRow = qMax(lit - tmp.begin(), 0); | - |
| 358 | lit = tmp.insert(lit, item); | - |
| 359 | if (newRow != oldRow) { | - |
| 360 | changed = true; | - |
| 361 | for (int j = i + 1; j < count; ++j) { | - |
| 362 | int otherRow = sorting.at(j).second; | - |
| 363 | if (oldRow < otherRow && newRow >= otherRow) | - |
| 364 | --sorting[j].second; | - |
| 365 | else if (oldRow > otherRow && newRow <= otherRow) | - |
| 366 | ++sorting[j].second; | - |
| 367 | } | - |
| 368 | for (int k = 0; k < newPersistentIndexes.count(); ++k) { | - |
| 369 | QModelIndex pi = newPersistentIndexes.at(k); | - |
| 370 | int oldPersistentRow = pi.row(); | - |
| 371 | int newPersistentRow = oldPersistentRow; | - |
| 372 | if (oldPersistentRow == oldRow) | - |
| 373 | newPersistentRow = newRow; | - |
| 374 | else if (oldRow < oldPersistentRow && newRow >= oldPersistentRow) | - |
| 375 | newPersistentRow = oldPersistentRow - 1; | - |
| 376 | else if (oldRow > oldPersistentRow && newRow <= oldPersistentRow) | - |
| 377 | newPersistentRow = oldPersistentRow + 1; | - |
| 378 | if (newPersistentRow != oldPersistentRow) | - |
| 379 | newPersistentIndexes[k] = createIndex(newPersistentRow, | - |
| 380 | pi.column(), pi.internalPointer()); | - |
| 381 | } | - |
| 382 | } | - |
| 383 | } | - |
| 384 | | - |
| 385 | if (changed) { | - |
| 386 | emit layoutAboutToBeChanged(); | - |
| 387 | items = tmp; | - |
| 388 | changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes); | - |
| 389 | emit layoutChanged(); | - |
| 390 | } | - |
| 391 | } | - |
| 392 | | - |
| 393 | bool QListModel::itemLessThan(const QPair<QListWidgetItem*,int> &left, | - |
| 394 | const QPair<QListWidgetItem*,int> &right) | - |
| 395 | { | - |
| 396 | return (*left.first) < (*right.first); | - |
| 397 | } | - |
| 398 | | - |
| 399 | bool QListModel::itemGreaterThan(const QPair<QListWidgetItem*,int> &left, | - |
| 400 | const QPair<QListWidgetItem*,int> &right) | - |
| 401 | { | - |
| 402 | return (*right.first) < (*left.first); | - |
| 403 | } | - |
| 404 | | - |
| 405 | QList<QListWidgetItem*>::iterator QListModel::sortedInsertionIterator( | - |
| 406 | const QList<QListWidgetItem*>::iterator &begin, | - |
| 407 | const QList<QListWidgetItem*>::iterator &end, | - |
| 408 | Qt::SortOrder order, QListWidgetItem *item) | - |
| 409 | { | - |
| 410 | if (order == Qt::AscendingOrder) | - |
| 411 | return std::lower_bound(begin, end, item, QListModelLessThan()); | - |
| 412 | return std::lower_bound(begin, end, item, QListModelGreaterThan()); | - |
| 413 | } | - |
| 414 | | - |
| 415 | void QListModel::itemChanged(QListWidgetItem *item) | - |
| 416 | { | - |
| 417 | QModelIndex idx = index(item); | - |
| 418 | emit dataChanged(idx, idx); | - |
| 419 | } | - |
| 420 | | - |
| 421 | QStringList QListModel::mimeTypes() const | - |
| 422 | { | - |
| 423 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
| 424 | return view->mimeTypes(); | - |
| 425 | } | - |
| 426 | | - |
| 427 | QMimeData *QListModel::internalMimeData() const | - |
| 428 | { | - |
| 429 | return QAbstractItemModel::mimeData(cachedIndexes); | - |
| 430 | } | - |
| 431 | | - |
| 432 | QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const | - |
| 433 | { | - |
| 434 | QList<QListWidgetItem*> itemlist; | - |
| 435 | const int indexesCount = indexes.count(); | - |
| 436 | itemlist.reserve(indexesCount); | - |
| 437 | for (int i = 0; i < indexesCount; ++i) | - |
| 438 | itemlist << at(indexes.at(i).row()); | - |
| 439 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
| 440 | | - |
| 441 | cachedIndexes = indexes; | - |
| 442 | QMimeData *mimeData = view->mimeData(itemlist); | - |
| 443 | cachedIndexes.clear(); | - |
| 444 | return mimeData; | - |
| 445 | } | - |
| 446 | | - |
| 447 | #ifndef QT_NO_DRAGANDDROP | - |
| 448 | bool QListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - |
| 449 | int row, int column, const QModelIndex &index) | - |
| 450 | { | - |
| 451 | Q_UNUSED(column); | - |
| 452 | QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); | - |
| 453 | if (index.isValid()) | - |
| 454 | row = index.row(); | - |
| 455 | else if (row == -1) | - |
| 456 | row = items.count(); | - |
| 457 | | - |
| 458 | return view->dropMimeData(row, data, action); | - |
| 459 | } | - |
| 460 | | - |
| 461 | Qt::DropActions QListModel::supportedDropActions() const | - |
| 462 | { | - |
| 463 | const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent()); | - |
| 464 | return view->supportedDropActions(); | - |
| 465 | } | - |
| 466 | #endif // QT_NO_DRAGANDDROP | - |
| 467 | | - |
| 468 | | - |
| 469 | | - |
| 470 | | - |
| 471 | | - |
| 472 | | - |
| 473 | | - |
| 474 | | - |
| 475 | | - |
| 476 | | - |
| 477 | | - |
| 478 | | - |
| 479 | | - |
| 480 | | - |
| 481 | | - |
| 482 | | - |
| 483 | | - |
| 484 | | - |
| 485 | | - |
| 486 | | - |
| 487 | | - |
| 488 | | - |
| 489 | | - |
| 490 | | - |
| 491 | | - |
| 492 | | - |
| 493 | | - |
| 494 | | - |
| 495 | | - |
| 496 | | - |
| 497 | | - |
| 498 | | - |
| 499 | | - |
| 500 | | - |
| 501 | | - |
| 502 | | - |
| 503 | | - |
| 504 | | - |
| 505 | | - |
| 506 | | - |
| 507 | | - |
| 508 | | - |
| 509 | | - |
| 510 | | - |
| 511 | | - |
| 512 | | - |
| 513 | | - |
| 514 | | - |
| 515 | | - |
| 516 | | - |
| 517 | | - |
| 518 | | - |
| 519 | | - |
| 520 | | - |
| 521 | | - |
| 522 | | - |
| 523 | | - |
| 524 | | - |
| 525 | | - |
| 526 | | - |
| 527 | | - |
| 528 | | - |
| 529 | | - |
| 530 | | - |
| 531 | | - |
| 532 | | - |
| 533 | | - |
| 534 | | - |
| 535 | | - |
| 536 | | - |
| 537 | | - |
| 538 | | - |
| 539 | | - |
| 540 | | - |
| 541 | | - |
| 542 | | - |
| 543 | | - |
| 544 | | - |
| 545 | | - |
| 546 | | - |
| 547 | | - |
| 548 | | - |
| 549 | | - |
| 550 | | - |
| 551 | | - |
| 552 | | - |
| 553 | | - |
| 554 | | - |
| 555 | | - |
| 556 | | - |
| 557 | | - |
| 558 | | - |
| 559 | | - |
| 560 | | - |
| 561 | | - |
| 562 | | - |
| 563 | | - |
| 564 | | - |
| 565 | | - |
| 566 | | - |
| 567 | | - |
| 568 | | - |
| 569 | | - |
| 570 | | - |
| 571 | | - |
| 572 | | - |
| 573 | | - |
| 574 | | - |
| 575 | | - |
| 576 | | - |
| 577 | | - |
| 578 | | - |
| 579 | | - |
| 580 | | - |
| 581 | | - |
| 582 | | - |
| 583 | | - |
| 584 | | - |
| 585 | | - |
| 586 | | - |
| 587 | | - |
| 588 | | - |
| 589 | | - |
| 590 | | - |
| 591 | | - |
| 592 | | - |
| 593 | | - |
| 594 | | - |
| 595 | | - |
| 596 | | - |
| 597 | | - |
| 598 | | - |
| 599 | | - |
| 600 | QListWidgetItem::QListWidgetItem(QListWidget *view, int type) | - |
| 601 | : rtti(type), view(view), d(new QListWidgetItemPrivate(this)), | - |
| 602 | itemFlags(Qt::ItemIsSelectable | - |
| 603 | |Qt::ItemIsUserCheckable | - |
| 604 | |Qt::ItemIsEnabled | - |
| 605 | |Qt::ItemIsDragEnabled) | - |
| 606 | { | - |
| 607 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
| 608 | model->insert(model->rowCount(), this); | - |
| 609 | } | - |
| 610 | | - |
| 611 | | - |
| 612 | | - |
| 613 | | - |
| 614 | | - |
| 615 | | - |
| 616 | | - |
| 617 | | - |
| 618 | | - |
| 619 | | - |
| 620 | | - |
| 621 | | - |
| 622 | | - |
| 623 | | - |
| 624 | | - |
| 625 | | - |
| 626 | | - |
| 627 | QListWidgetItem::QListWidgetItem(const QString &text, QListWidget *view, int type) | - |
| 628 | : rtti(type), view(0), d(new QListWidgetItemPrivate(this)), | - |
| 629 | itemFlags(Qt::ItemIsSelectable | - |
| 630 | |Qt::ItemIsUserCheckable | - |
| 631 | |Qt::ItemIsEnabled | - |
| 632 | |Qt::ItemIsDragEnabled) | - |
| 633 | { | - |
| 634 | setData(Qt::DisplayRole, text); | - |
| 635 | this->view = view; | - |
| 636 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
| 637 | model->insert(model->rowCount(), this); | - |
| 638 | } | - |
| 639 | | - |
| 640 | | - |
| 641 | | - |
| 642 | | - |
| 643 | | - |
| 644 | | - |
| 645 | | - |
| 646 | | - |
| 647 | | - |
| 648 | | - |
| 649 | | - |
| 650 | | - |
| 651 | | - |
| 652 | | - |
| 653 | | - |
| 654 | | - |
| 655 | | - |
| 656 | | - |
| 657 | QListWidgetItem::QListWidgetItem(const QIcon &icon,const QString &text, | - |
| 658 | QListWidget *view, int type) | - |
| 659 | : rtti(type), view(0), d(new QListWidgetItemPrivate(this)), | - |
| 660 | itemFlags(Qt::ItemIsSelectable | - |
| 661 | |Qt::ItemIsUserCheckable | - |
| 662 | |Qt::ItemIsEnabled | - |
| 663 | |Qt::ItemIsDragEnabled) | - |
| 664 | { | - |
| 665 | setData(Qt::DisplayRole, text); | - |
| 666 | setData(Qt::DecorationRole, icon); | - |
| 667 | this->view = view; | - |
| 668 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
| 669 | model->insert(model->rowCount(), this); | - |
| 670 | } | - |
| 671 | | - |
| 672 | | - |
| 673 | | - |
| 674 | | - |
| 675 | QListWidgetItem::~QListWidgetItem() | - |
| 676 | { | - |
| 677 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
| 678 | model->remove(this); | - |
| 679 | delete d; | - |
| 680 | } | - |
| 681 | | - |
| 682 | | - |
| 683 | | - |
| 684 | | - |
| 685 | QListWidgetItem *QListWidgetItem::clone() const | - |
| 686 | { | - |
| 687 | return new QListWidgetItem(*this); | - |
| 688 | } | - |
| 689 | | - |
| 690 | | - |
| 691 | | - |
| 692 | | - |
| 693 | | - |
| 694 | | - |
| 695 | | - |
| 696 | void QListWidgetItem::setData(int role, const QVariant &value) | - |
| 697 | { | - |
| 698 | bool found = false; | - |
| 699 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); | - |
| 700 | for (int i = 0; i < d->values.count(); ++i) { | - |
| 701 | if (d->values.at(i).role == role) { | - |
| 702 | if (d->values.at(i).value == value) | - |
| 703 | return; | - |
| 704 | d->values[i].value = value; | - |
| 705 | found = true; | - |
| 706 | break; | - |
| 707 | } | - |
| 708 | } | - |
| 709 | if (!found) | - |
| 710 | d->values.append(QWidgetItemData(role, value)); | - |
| 711 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
| 712 | model->itemChanged(this); | - |
| 713 | } | - |
| 714 | | - |
| 715 | | - |
| 716 | | - |
| 717 | | - |
| 718 | | - |
| 719 | | - |
| 720 | | - |
| 721 | QVariant QListWidgetItem::data(int role) const | - |
| 722 | { | - |
| 723 | role = (role == Qt::EditRole ? Qt::DisplayRole : role); | - |
| 724 | for (int i = 0; i < d->values.count(); ++i) | - |
| 725 | if (d->values.at(i).role == role) | - |
| 726 | return d->values.at(i).value; | - |
| 727 | return QVariant(); | - |
| 728 | } | - |
| 729 | | - |
| 730 | | - |
| 731 | | - |
| 732 | | - |
| 733 | | - |
| 734 | bool QListWidgetItem::operator<(const QListWidgetItem &other) const | - |
| 735 | { | - |
| 736 | const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole); | - |
| 737 | return QAbstractItemModelPrivate::variantLessThan(v1, v2); | - |
| 738 | } | - |
| 739 | | - |
| 740 | #ifndef QT_NO_DATASTREAM | - |
| 741 | | - |
| 742 | | - |
| 743 | | - |
| 744 | | - |
| 745 | | - |
| 746 | | - |
| 747 | void QListWidgetItem::read(QDataStream &in) | - |
| 748 | { | - |
| 749 | in >> d->values; | - |
| 750 | } | - |
| 751 | | - |
| 752 | | - |
| 753 | | - |
| 754 | | - |
| 755 | | - |
| 756 | | - |
| 757 | void QListWidgetItem::write(QDataStream &out) const | - |
| 758 | { | - |
| 759 | out << d->values; | - |
| 760 | } | - |
| 761 | #endif // QT_NO_DATASTREAM | - |
| 762 | | - |
| 763 | | - |
| 764 | | - |
| 765 | | - |
| 766 | | - |
| 767 | | - |
| 768 | | - |
| 769 | | - |
| 770 | | - |
| 771 | | - |
| 772 | | - |
| 773 | QListWidgetItem::QListWidgetItem(const QListWidgetItem &other) | - |
| 774 | : rtti(Type), view(0), | - |
| 775 | d(new QListWidgetItemPrivate(this)), | - |
| 776 | itemFlags(other.itemFlags) | - |
| 777 | { | - |
| 778 | d->values = other.d->values; | - |
| 779 | } | - |
| 780 | | - |
| 781 | | - |
| 782 | | - |
| 783 | | - |
| 784 | | - |
| 785 | | - |
| 786 | | - |
| 787 | | - |
| 788 | | - |
| 789 | QListWidgetItem &QListWidgetItem::operator=(const QListWidgetItem &other) | - |
| 790 | { | - |
| 791 | d->values = other.d->values; | - |
| 792 | itemFlags = other.itemFlags; | - |
| 793 | return *this; | - |
| 794 | } | - |
| 795 | | - |
| 796 | #ifndef QT_NO_DATASTREAM | - |
| 797 | | - |
| 798 | | - |
| 799 | | - |
| 800 | | - |
| 801 | | - |
| 802 | | - |
| 803 | | - |
| 804 | | - |
| 805 | | - |
| 806 | | - |
| 807 | QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item) | - |
| 808 | { | - |
| 809 | item.write(out); | - |
| 810 | return out; | - |
| 811 | } | - |
| 812 | | - |
| 813 | | - |
| 814 | | - |
| 815 | | - |
| 816 | | - |
| 817 | | - |
| 818 | | - |
| 819 | | - |
| 820 | | - |
| 821 | | - |
| 822 | QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) | - |
| 823 | { | - |
| 824 | item.read(in); | - |
| 825 | return in; | - |
| 826 | } | - |
| 827 | | - |
| 828 | #endif // QT_NO_DATASTREAM | - |
| 829 | | - |
| 830 | | - |
| 831 | | - |
| 832 | | - |
| 833 | | - |
| 834 | | - |
| 835 | | - |
| 836 | | - |
| 837 | | - |
| 838 | | - |
| 839 | | - |
| 840 | | - |
| 841 | | - |
| 842 | | - |
| 843 | | - |
| 844 | | - |
| 845 | | - |
| 846 | | - |
| 847 | | - |
| 848 | | - |
| 849 | | - |
| 850 | | - |
| 851 | | - |
| 852 | | - |
| 853 | | - |
| 854 | | - |
| 855 | | - |
| 856 | | - |
| 857 | | - |
| 858 | | - |
| 859 | | - |
| 860 | | - |
| 861 | | - |
| 862 | | - |
| 863 | | - |
| 864 | | - |
| 865 | | - |
| 866 | | - |
| 867 | | - |
| 868 | | - |
| 869 | | - |
| 870 | | - |
| 871 | | - |
| 872 | | - |
| 873 | | - |
| 874 | | - |
| 875 | | - |
| 876 | | - |
| 877 | | - |
| 878 | | - |
| 879 | | - |
| 880 | | - |
| 881 | | - |
| 882 | | - |
| 883 | | - |
| 884 | | - |
| 885 | | - |
| 886 | | - |
| 887 | | - |
| 888 | | - |
| 889 | | - |
| 890 | | - |
| 891 | | - |
| 892 | | - |
| 893 | | - |
| 894 | | - |
| 895 | | - |
| 896 | | - |
| 897 | | - |
| 898 | | - |
| 899 | | - |
| 900 | | - |
| 901 | | - |
| 902 | | - |
| 903 | | - |
| 904 | | - |
| 905 | | - |
| 906 | | - |
| 907 | | - |
| 908 | | - |
| 909 | | - |
| 910 | | - |
| 911 | | - |
| 912 | | - |
| 913 | | - |
| 914 | | - |
| 915 | | - |
| 916 | | - |
| 917 | | - |
| 918 | | - |
| 919 | | - |
| 920 | | - |
| 921 | | - |
| 922 | | - |
| 923 | | - |
| 924 | | - |
| 925 | | - |
| 926 | | - |
| 927 | | - |
| 928 | | - |
| 929 | | - |
| 930 | | - |
| 931 | | - |
| 932 | | - |
| 933 | | - |
| 934 | | - |
| 935 | | - |
| 936 | | - |
| 937 | | - |
| 938 | | - |
| 939 | | - |
| 940 | | - |
| 941 | | - |
| 942 | | - |
| 943 | | - |
| 944 | | - |
| 945 | | - |
| 946 | | - |
| 947 | | - |
| 948 | | - |
| 949 | | - |
| 950 | | - |
| 951 | | - |
| 952 | | - |
| 953 | | - |
| 954 | void QListWidgetItem::setFlags(Qt::ItemFlags aflags) { | - |
| 955 | itemFlags = aflags; | - |
| 956 | if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0)) | - |
| 957 | model->itemChanged(this); | - |
| 958 | } | - |
| 959 | | - |
| 960 | | - |
| 961 | | - |
| 962 | | - |
| 963 | | - |
| 964 | | - |
| 965 | | - |
| 966 | | - |
| 967 | | - |
| 968 | | - |
| 969 | | - |
| 970 | | - |
| 971 | | - |
| 972 | | - |
| 973 | | - |
| 974 | | - |
| 975 | | - |
| 976 | | - |
| 977 | | - |
| 978 | | - |
| 979 | | - |
| 980 | | - |
| 981 | | - |
| 982 | | - |
| 983 | | - |
| 984 | | - |
| 985 | | - |
| 986 | | - |
| 987 | | - |
| 988 | | - |
| 989 | | - |
| 990 | | - |
| 991 | | - |
| 992 | | - |
| 993 | | - |
| 994 | | - |
| 995 | | - |
| 996 | | - |
| 997 | | - |
| 998 | | - |
| 999 | | - |
| 1000 | | - |
| 1001 | | - |
| 1002 | | - |
| 1003 | | - |
| 1004 | | - |
| 1005 | | - |
| 1006 | | - |
| 1007 | | - |
| 1008 | | - |
| 1009 | | - |
| 1010 | | - |
| 1011 | | - |
| 1012 | | - |
| 1013 | | - |
| 1014 | | - |
| 1015 | | - |
| 1016 | | - |
| 1017 | | - |
| 1018 | | - |
| 1019 | | - |
| 1020 | | - |
| 1021 | | - |
| 1022 | | - |
| 1023 | | - |
| 1024 | | - |
| 1025 | | - |
| 1026 | | - |
| 1027 | | - |
| 1028 | | - |
| 1029 | | - |
| 1030 | | - |
| 1031 | | - |
| 1032 | | - |
| 1033 | | - |
| 1034 | | - |
| 1035 | | - |
| 1036 | | - |
| 1037 | | - |
| 1038 | | - |
| 1039 | | - |
| 1040 | | - |
| 1041 | | - |
| 1042 | | - |
| 1043 | | - |
| 1044 | | - |
| 1045 | | - |
| 1046 | | - |
| 1047 | | - |
| 1048 | | - |
| 1049 | | - |
| 1050 | | - |
| 1051 | | - |
| 1052 | | - |
| 1053 | | - |
| 1054 | | - |
| 1055 | | - |
| 1056 | | - |
| 1057 | | - |
| 1058 | void QListWidgetPrivate::setup() | - |
| 1059 | { | - |
| 1060 | Q_Q(QListWidget); | - |
| 1061 | q->QListView::setModel(new QListModel(q)); | - |
| 1062 | | - |
| 1063 | QObject::connect(q, SIGNAL(pressed(QModelIndex)), q, SLOT(_q_emitItemPressed(QModelIndex))); | - |
| 1064 | QObject::connect(q, SIGNAL(clicked(QModelIndex)), q, SLOT(_q_emitItemClicked(QModelIndex))); | - |
| 1065 | QObject::connect(q, SIGNAL(doubleClicked(QModelIndex)), | - |
| 1066 | q, SLOT(_q_emitItemDoubleClicked(QModelIndex))); | - |
| 1067 | QObject::connect(q, SIGNAL(activated(QModelIndex)), | - |
| 1068 | q, SLOT(_q_emitItemActivated(QModelIndex))); | - |
| 1069 | QObject::connect(q, SIGNAL(entered(QModelIndex)), q, SLOT(_q_emitItemEntered(QModelIndex))); | - |
| 1070 | QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), | - |
| 1071 | q, SLOT(_q_emitItemChanged(QModelIndex))); | - |
| QObject::connect(q->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), | |
| q, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex))); | |
| 1072 | QObject::connect(q->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), | - |
| q, SIGNAL(itemSelectionChanged()));QObject::connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), | |
| 1073 | q, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); | - |
| 1074 | QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), q, SLOT(_q_sort())); | - |
| 1075 | } never executed: end of block | 0 |
| 1076 | | - |
| 1077 | void QListWidgetPrivate::_q_emitItemPressed(const QModelIndex &index) | - |
| 1078 | { | - |
| 1079 | Q_Q(QListWidget); | - |
| 1080 | emit q->itemPressed(listModel()->at(index.row())); | - |
| 1081 | } | - |
| 1082 | | - |
| 1083 | void QListWidgetPrivate::_q_emitItemClicked(const QModelIndex &index) | - |
| 1084 | { | - |
| 1085 | Q_Q(QListWidget); | - |
| 1086 | emit q->itemClicked(listModel()->at(index.row())); | - |
| 1087 | } | - |
| 1088 | | - |
| 1089 | void QListWidgetPrivate::_q_emitItemDoubleClicked(const QModelIndex &index) | - |
| 1090 | { | - |
| 1091 | Q_Q(QListWidget); | - |
| 1092 | emit q->itemDoubleClicked(listModel()->at(index.row())); | - |
| 1093 | } | - |
| 1094 | | - |
| 1095 | void QListWidgetPrivate::_q_emitItemActivated(const QModelIndex &index) | - |
| 1096 | { | - |
| 1097 | Q_Q(QListWidget); | - |
| 1098 | emit q->itemActivated(listModel()->at(index.row())); | - |
| 1099 | } | - |
| 1100 | | - |
| 1101 | void QListWidgetPrivate::_q_emitItemEntered(const QModelIndex &index) | - |
| 1102 | { | - |
| 1103 | Q_Q(QListWidget); | - |
| 1104 | emit q->itemEntered(listModel()->at(index.row())); | - |
| 1105 | } | - |
| 1106 | | - |
| 1107 | void QListWidgetPrivate::_q_emitItemChanged(const QModelIndex &index) | - |
| 1108 | { | - |
| 1109 | Q_Q(QListWidget); | - |
| 1110 | emit q->itemChanged(listModel()->at(index.row())); | - |
| 1111 | } | - |
| 1112 | | - |
| 1113 | void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, | - |
| 1114 | const QModelIndex &previous) | - |
| 1115 | { | - |
| 1116 | Q_Q(QListWidget); | - |
| 1117 | QPersistentModelIndex persistentCurrent = current; | - |
| 1118 | QListWidgetItem *currentItem = listModel()->at(persistentCurrent.row()); | - |
| 1119 | emit q->currentItemChanged(currentItem, listModel()->at(previous.row())); | - |
| 1120 | | - |
| 1121 | | - |
| 1122 | | - |
| 1123 | if (!persistentCurrent.isValid()) { | - |
| 1124 | currentItem = 0; | - |
| 1125 | } | - |
| 1126 | | - |
| 1127 | emit q->currentTextChanged(currentItem ? currentItem->text() : QString()); | - |
| 1128 | emit q->currentRowChanged(persistentCurrent.row()); | - |
| 1129 | } | - |
| 1130 | | - |
| 1131 | void QListWidgetPrivate::_q_sort() | - |
| 1132 | { | - |
| 1133 | if (sortingEnabled) | - |
| 1134 | model->sort(0, sortOrder); | - |
| 1135 | } | - |
| 1136 | | - |
| 1137 | void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, | - |
| 1138 | const QModelIndex &bottomRight) | - |
| 1139 | { | - |
| 1140 | if (sortingEnabled && topLeft.isValid() && bottomRight.isValid()) | - |
| 1141 | listModel()->ensureSorted(topLeft.column(), sortOrder, | - |
| 1142 | topLeft.row(), bottomRight.row()); | - |
| 1143 | } | - |
| 1144 | | - |
| 1145 | | - |
| 1146 | | - |
| 1147 | | - |
| 1148 | | - |
| 1149 | | - |
| 1150 | | - |
| 1151 | | - |
| 1152 | | - |
| 1153 | | - |
| 1154 | | - |
| 1155 | | - |
| 1156 | | - |
| 1157 | | - |
| 1158 | | - |
| 1159 | | - |
| 1160 | | - |
| 1161 | | - |
| 1162 | | - |
| 1163 | | - |
| 1164 | | - |
| 1165 | | - |
| 1166 | | - |
| 1167 | | - |
| 1168 | | - |
| 1169 | | - |
| 1170 | | - |
| 1171 | | - |
| 1172 | | - |
| 1173 | | - |
| 1174 | | - |
| 1175 | | - |
| 1176 | | - |
| 1177 | | - |
| 1178 | | - |
| 1179 | | - |
| 1180 | | - |
| 1181 | | - |
| 1182 | | - |
| 1183 | | - |
| 1184 | | - |
| 1185 | | - |
| 1186 | | - |
| 1187 | | - |
| 1188 | | - |
| 1189 | | - |
| 1190 | | - |
| 1191 | | - |
| 1192 | | - |
| 1193 | | - |
| 1194 | | - |
| 1195 | | - |
| 1196 | | - |
| 1197 | | - |
| 1198 | | - |
| 1199 | | - |
| 1200 | | - |
| 1201 | | - |
| 1202 | | - |
| 1203 | | - |
| 1204 | | - |
| 1205 | | - |
| 1206 | | - |
| 1207 | | - |
| 1208 | | - |
| 1209 | | - |
| 1210 | | - |
| 1211 | | - |
| 1212 | | - |
| 1213 | | - |
| 1214 | | - |
| 1215 | | - |
| 1216 | | - |
| 1217 | | - |
| 1218 | | - |
| 1219 | | - |
| 1220 | | - |
| 1221 | | - |
| 1222 | | - |
| 1223 | | - |
| 1224 | | - |
| 1225 | | - |
| 1226 | | - |
| 1227 | | - |
| 1228 | | - |
| 1229 | | - |
| 1230 | | - |
| 1231 | | - |
| 1232 | | - |
| 1233 | | - |
| 1234 | | - |
| 1235 | | - |
| 1236 | | - |
| 1237 | | - |
| 1238 | | - |
| 1239 | | - |
| 1240 | | - |
| 1241 | | - |
| 1242 | | - |
| 1243 | | - |
| 1244 | | - |
| 1245 | | - |
| 1246 | | - |
| 1247 | | - |
| 1248 | | - |
| 1249 | | - |
| 1250 | | - |
| 1251 | | - |
| 1252 | | - |
| 1253 | | - |
| 1254 | | - |
| 1255 | | - |
| 1256 | | - |
| 1257 | | - |
| 1258 | | - |
| 1259 | | - |
| 1260 | | - |
| 1261 | | - |
| 1262 | | - |
| 1263 | | - |
| 1264 | | - |
| 1265 | | - |
| 1266 | | - |
| 1267 | | - |
| 1268 | | - |
| 1269 | | - |
| 1270 | | - |
| 1271 | | - |
| 1272 | | - |
| 1273 | | - |
| 1274 | | - |
| 1275 | | - |
| 1276 | | - |
| 1277 | | - |
| 1278 | | - |
| 1279 | | - |
| 1280 | | - |
| 1281 | | - |
| 1282 | | - |
| 1283 | | - |
| 1284 | | - |
| 1285 | | - |
| 1286 | | - |
| 1287 | | - |
| 1288 | | - |
| 1289 | | - |
| 1290 | | - |
| 1291 | | - |
| 1292 | | - |
| 1293 | | - |
| 1294 | | - |
| 1295 | | - |
| 1296 | | - |
| 1297 | | - |
| 1298 | | - |
| 1299 | | - |
| 1300 | | - |
| 1301 | | - |
| 1302 | | - |
| 1303 | | - |
| 1304 | | - |
| 1305 | | - |
| 1306 | | - |
| 1307 | | - |
| 1308 | | - |
| 1309 | | - |
| 1310 | | - |
| 1311 | | - |
| 1312 | | - |
| 1313 | | - |
| 1314 | | - |
| 1315 | | - |
| 1316 | | - |
| 1317 | | - |
| 1318 | | - |
| 1319 | | - |
| 1320 | | - |
| 1321 | | - |
| 1322 | | - |
| 1323 | | - |
| 1324 | | - |
| 1325 | | - |
| 1326 | | - |
| 1327 | | - |
| 1328 | | - |
| 1329 | | - |
| 1330 | | - |
| 1331 | | - |
| 1332 | | - |
| 1333 | | - |
| 1334 | | - |
| 1335 | | - |
| 1336 | | - |
| 1337 | | - |
| 1338 | QListWidget::QListWidget(QWidget *parent) | - |
| 1339 | : QListView(*new QListWidgetPrivate(), parent) | - |
| 1340 | { | - |
| 1341 | Q_D(QListWidget); | - |
| 1342 | d->setup(); | - |
| 1343 | } | - |
| 1344 | | - |
| 1345 | | - |
| 1346 | | - |
| 1347 | | - |
| 1348 | | - |
| 1349 | QListWidget::~QListWidget() | - |
| 1350 | { | - |
| 1351 | } | - |
| 1352 | | - |
| 1353 | | - |
| 1354 | | - |
| 1355 | | - |
| 1356 | | - |
| 1357 | void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel) | - |
| 1358 | { | - |
| 1359 | Q_D(QListWidget); | - |
| 1360 | | - |
| 1361 | if (d->selectionModel) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 1362 | QObject::disconnect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), | - |
| 1363 | this, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex))); | - |
| 1364 | QObject::disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), | - |
| 1365 | this, SIGNAL(itemSelectionChanged())); | - |
| 1366 | } never executed: end of block | 0 |
| 1367 | | - |
| 1368 | QListView::setSelectionModel(selectionModel); | - |
| 1369 | | - |
| 1370 | if (d->selectionModel)| TRUE | never evaluated | | FALSE | never evaluated |
{| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 1371 | QObject::connect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), | - |
| 1372 | this, SLOT(_q_emitCurrentItemChanged(QModelIndex,QModelIndex))); | - |
| 1373 | QObject::connect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), | - |
| 1374 | this, SIGNAL(itemSelectionChanged())); | - |
| 1375 | } never executed: end of block | 0 |
| 1376 | } never executed: end of block | 0 |
| 1377 | | - |
| 1378 | | - |
| 1379 | | - |
| 1380 | | - |
| 1381 | | - |
| 1382 | | - |
| 1383 | | - |
| 1384 | | - |
| 1385 | QListWidgetItem *QListWidget::item(int row) const | - |
| 1386 | { | - |
| 1387 | Q_D(const QListWidget); | - |
| 1388 | if (row < 0 || row >= d->model->rowCount()) | - |
| 1389 | return 0; | - |
| 1390 | return d->listModel()->at(row); | - |
| 1391 | } | - |
| 1392 | | - |
| 1393 | | - |
| 1394 | | - |
| 1395 | | - |
| 1396 | | - |
| 1397 | | - |
| 1398 | | - |
| 1399 | int QListWidget::row(const QListWidgetItem *item) const | - |
| 1400 | { | - |
| 1401 | Q_D(const QListWidget); | - |
| 1402 | return d->listModel()->index(const_cast<QListWidgetItem*>(item)).row(); | - |
| 1403 | } | - |
| 1404 | | - |
| 1405 | | - |
| 1406 | | - |
| 1407 | | - |
| 1408 | | - |
| 1409 | | - |
| 1410 | | - |
| 1411 | | - |
| 1412 | void QListWidget::insertItem(int row, QListWidgetItem *item) | - |
| 1413 | { | - |
| 1414 | Q_D(QListWidget); | - |
| 1415 | if (item && !item->view) | - |
| 1416 | d->listModel()->insert(row, item); | - |
| 1417 | } | - |
| 1418 | | - |
| 1419 | | - |
| 1420 | | - |
| 1421 | | - |
| 1422 | | - |
| 1423 | | - |
| 1424 | | - |
| 1425 | | - |
| 1426 | void QListWidget::insertItem(int row, const QString &label) | - |
| 1427 | { | - |
| 1428 | Q_D(QListWidget); | - |
| 1429 | d->listModel()->insert(row, new QListWidgetItem(label)); | - |
| 1430 | } | - |
| 1431 | | - |
| 1432 | | - |
| 1433 | | - |
| 1434 | | - |
| 1435 | | - |
| 1436 | | - |
| 1437 | | - |
| 1438 | | - |
| 1439 | void QListWidget::insertItems(int row, const QStringList &labels) | - |
| 1440 | { | - |
| 1441 | Q_D(QListWidget); | - |
| 1442 | d->listModel()->insert(row, labels); | - |
| 1443 | } | - |
| 1444 | | - |
| 1445 | | - |
| 1446 | | - |
| 1447 | | - |
| 1448 | | - |
| 1449 | | - |
| 1450 | | - |
| 1451 | | - |
| 1452 | | - |
| 1453 | | - |
| 1454 | | - |
| 1455 | QListWidgetItem *QListWidget::takeItem(int row) | - |
| 1456 | { | - |
| 1457 | Q_D(QListWidget); | - |
| 1458 | if (row < 0 || row >= d->model->rowCount()) | - |
| 1459 | return 0; | - |
| 1460 | return d->listModel()->take(row); | - |
| 1461 | } | - |
| 1462 | | - |
| 1463 | | - |
| 1464 | | - |
| 1465 | | - |
| 1466 | | - |
| 1467 | | - |
| 1468 | int QListWidget::count() const | - |
| 1469 | { | - |
| 1470 | Q_D(const QListWidget); | - |
| 1471 | return d->model->rowCount(); | - |
| 1472 | } | - |
| 1473 | | - |
| 1474 | | - |
| 1475 | | - |
| 1476 | | - |
| 1477 | QListWidgetItem *QListWidget::currentItem() const | - |
| 1478 | { | - |
| 1479 | Q_D(const QListWidget); | - |
| 1480 | return d->listModel()->at(currentIndex().row()); | - |
| 1481 | } | - |
| 1482 | | - |
| 1483 | | - |
| 1484 | | - |
| 1485 | | - |
| 1486 | | - |
| 1487 | | - |
| 1488 | | - |
| 1489 | | - |
| 1490 | void QListWidget::setCurrentItem(QListWidgetItem *item) | - |
| 1491 | { | - |
| 1492 | setCurrentRow(row(item)); | - |
| 1493 | } | - |
| 1494 | | - |
| 1495 | | - |
| 1496 | | - |
| 1497 | | - |
| 1498 | | - |
| 1499 | void QListWidget::setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command) | - |
| 1500 | { | - |
| 1501 | setCurrentRow(row(item), command); | - |
| 1502 | } | - |
| 1503 | | - |
| 1504 | | - |
| 1505 | | - |
| 1506 | | - |
| 1507 | | - |
| 1508 | | - |
| 1509 | | - |
| 1510 | | - |
| 1511 | int QListWidget::currentRow() const | - |
| 1512 | { | - |
| 1513 | return currentIndex().row(); | - |
| 1514 | } | - |
| 1515 | | - |
| 1516 | void QListWidget::setCurrentRow(int row) | - |
| 1517 | { | - |
| 1518 | Q_D(QListWidget); | - |
| 1519 | QModelIndex index = d->listModel()->index(row); | - |
| 1520 | if (d->selectionMode == SingleSelection) | - |
| 1521 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); | - |
| 1522 | else if (d->selectionMode == NoSelection) | - |
| 1523 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate); | - |
| 1524 | else | - |
| 1525 | selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); | - |
| 1526 | } | - |
| 1527 | | - |
| 1528 | | - |
| 1529 | | - |
| 1530 | | - |
| 1531 | | - |
| 1532 | | - |
| 1533 | void QListWidget::setCurrentRow(int row, QItemSelectionModel::SelectionFlags command) | - |
| 1534 | { | - |
| 1535 | Q_D(QListWidget); | - |
| 1536 | d->selectionModel->setCurrentIndex(d->listModel()->index(row), command); | - |
| 1537 | } | - |
| 1538 | | - |
| 1539 | | - |
| 1540 | | - |
| 1541 | | - |
| 1542 | | - |
| 1543 | | - |
| 1544 | QListWidgetItem *QListWidget::itemAt(const QPoint &p) const | - |
| 1545 | { | - |
| 1546 | Q_D(const QListWidget); | - |
| 1547 | return d->listModel()->at(indexAt(p).row()); | - |
| 1548 | | - |
| 1549 | } | - |
| 1550 | | - |
| 1551 | | - |
| 1552 | | - |
| 1553 | | - |
| 1554 | | - |
| 1555 | | - |
| 1556 | | - |
| 1557 | | - |
| 1558 | | - |
| 1559 | | - |
| 1560 | | - |
| 1561 | | - |
| 1562 | | - |
| 1563 | | - |
| 1564 | | - |
| 1565 | QRect QListWidget::visualItemRect(const QListWidgetItem *item) const | - |
| 1566 | { | - |
| 1567 | Q_D(const QListWidget); | - |
| 1568 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
| 1569 | return visualRect(index); | - |
| 1570 | } | - |
| 1571 | | - |
| 1572 | | - |
| 1573 | | - |
| 1574 | | - |
| 1575 | void QListWidget::sortItems(Qt::SortOrder order) | - |
| 1576 | { | - |
| 1577 | Q_D(QListWidget); | - |
| 1578 | d->sortOrder = order; | - |
| 1579 | d->listModel()->sort(0, order); | - |
| 1580 | } | - |
| 1581 | | - |
| 1582 | | - |
| 1583 | | - |
| 1584 | | - |
| 1585 | | - |
| 1586 | | - |
| 1587 | | - |
| 1588 | | - |
| 1589 | | - |
| 1590 | | - |
| 1591 | | - |
| 1592 | void QListWidget::setSortingEnabled(bool enable) | - |
| 1593 | { | - |
| 1594 | Q_D(QListWidget); | - |
| 1595 | d->sortingEnabled = enable; | - |
| 1596 | } | - |
| 1597 | | - |
| 1598 | bool QListWidget::isSortingEnabled() const | - |
| 1599 | { | - |
| 1600 | Q_D(const QListWidget); | - |
| 1601 | return d->sortingEnabled; | - |
| 1602 | } | - |
| 1603 | | - |
| 1604 | | - |
| 1605 | | - |
| 1606 | | - |
| 1607 | Qt::SortOrder QListWidget::sortOrder() const | - |
| 1608 | { | - |
| 1609 | Q_D(const QListWidget); | - |
| 1610 | return d->sortOrder; | - |
| 1611 | } | - |
| 1612 | | - |
| 1613 | | - |
| 1614 | | - |
| 1615 | | - |
| 1616 | | - |
| 1617 | void QListWidget::editItem(QListWidgetItem *item) | - |
| 1618 | { | - |
| 1619 | Q_D(QListWidget); | - |
| 1620 | edit(d->listModel()->index(item)); | - |
| 1621 | } | - |
| 1622 | | - |
| 1623 | | - |
| 1624 | | - |
| 1625 | | - |
| 1626 | | - |
| 1627 | | - |
| 1628 | | - |
| 1629 | void QListWidget::openPersistentEditor(QListWidgetItem *item) | - |
| 1630 | { | - |
| 1631 | Q_D(QListWidget); | - |
| 1632 | QModelIndex index = d->listModel()->index(item); | - |
| 1633 | QAbstractItemView::openPersistentEditor(index); | - |
| 1634 | } | - |
| 1635 | | - |
| 1636 | | - |
| 1637 | | - |
| 1638 | | - |
| 1639 | | - |
| 1640 | | - |
| 1641 | void QListWidget::closePersistentEditor(QListWidgetItem *item) | - |
| 1642 | { | - |
| 1643 | Q_D(QListWidget); | - |
| 1644 | QModelIndex index = d->listModel()->index(item); | - |
| 1645 | QAbstractItemView::closePersistentEditor(index); | - |
| 1646 | } | - |
| 1647 | | - |
| 1648 | | - |
| 1649 | | - |
| 1650 | | - |
| 1651 | | - |
| 1652 | | - |
| 1653 | | - |
| 1654 | | - |
| 1655 | QWidget *QListWidget::itemWidget(QListWidgetItem *item) const | - |
| 1656 | { | - |
| 1657 | Q_D(const QListWidget); | - |
| 1658 | QModelIndex index = d->listModel()->index(item); | - |
| 1659 | return QAbstractItemView::indexWidget(index); | - |
| 1660 | } | - |
| 1661 | | - |
| 1662 | | - |
| 1663 | | - |
| 1664 | | - |
| 1665 | | - |
| 1666 | | - |
| 1667 | | - |
| 1668 | | - |
| 1669 | | - |
| 1670 | | - |
| 1671 | | - |
| 1672 | | - |
| 1673 | | - |
| 1674 | void QListWidget::setItemWidget(QListWidgetItem *item, QWidget *widget) | - |
| 1675 | { | - |
| 1676 | Q_D(QListWidget); | - |
| 1677 | QModelIndex index = d->listModel()->index(item); | - |
| 1678 | QAbstractItemView::setIndexWidget(index, widget); | - |
| 1679 | } | - |
| 1680 | | - |
| 1681 | | - |
| 1682 | | - |
| 1683 | | - |
| 1684 | | - |
| 1685 | | - |
| 1686 | | - |
| 1687 | | - |
| 1688 | bool QListWidget::isItemSelected(const QListWidgetItem *item) const | - |
| 1689 | { | - |
| 1690 | Q_D(const QListWidget); | - |
| 1691 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
| 1692 | return selectionModel()->isSelected(index); | - |
| 1693 | } | - |
| 1694 | | - |
| 1695 | | - |
| 1696 | | - |
| 1697 | | - |
| 1698 | | - |
| 1699 | | - |
| 1700 | | - |
| 1701 | | - |
| 1702 | | - |
| 1703 | void QListWidget::setItemSelected(const QListWidgetItem *item, bool select) | - |
| 1704 | { | - |
| 1705 | Q_D(QListWidget); | - |
| 1706 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
| 1707 | | - |
| 1708 | if (d->selectionMode == SingleSelection) { | - |
| 1709 | selectionModel()->select(index, select | - |
| 1710 | ? QItemSelectionModel::ClearAndSelect | - |
| 1711 | : QItemSelectionModel::Deselect); | - |
| 1712 | } else if (d->selectionMode != NoSelection) { | - |
| 1713 | selectionModel()->select(index, select | - |
| 1714 | ? QItemSelectionModel::Select | - |
| 1715 | : QItemSelectionModel::Deselect); | - |
| 1716 | } | - |
| 1717 | | - |
| 1718 | } | - |
| 1719 | | - |
| 1720 | | - |
| 1721 | | - |
| 1722 | | - |
| 1723 | | - |
| 1724 | QList<QListWidgetItem*> QListWidget::selectedItems() const | - |
| 1725 | { | - |
| 1726 | Q_D(const QListWidget); | - |
| 1727 | QModelIndexList indexes = selectionModel()->selectedIndexes(); | - |
| 1728 | QList<QListWidgetItem*> items; | - |
| 1729 | const int numIndexes = indexes.count(); | - |
| 1730 | items.reserve(numIndexes); | - |
| 1731 | for (int i = 0; i < numIndexes; ++i) | - |
| 1732 | items.append(d->listModel()->at(indexes.at(i).row())); | - |
| 1733 | return items; | - |
| 1734 | } | - |
| 1735 | | - |
| 1736 | | - |
| 1737 | | - |
| 1738 | | - |
| 1739 | | - |
| 1740 | | - |
| 1741 | QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFlags flags) const | - |
| 1742 | { | - |
| 1743 | Q_D(const QListWidget); | - |
| 1744 | QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()), | - |
| 1745 | Qt::DisplayRole, text, -1, flags); | - |
| 1746 | QList<QListWidgetItem*> items; | - |
| 1747 | const int indexesSize = indexes.size(); | - |
| 1748 | items.reserve(indexesSize); | - |
| 1749 | for (int i = 0; i < indexesSize; ++i) | - |
| 1750 | items.append(d->listModel()->at(indexes.at(i).row())); | - |
| 1751 | return items; | - |
| 1752 | } | - |
| 1753 | | - |
| 1754 | | - |
| 1755 | | - |
| 1756 | | - |
| 1757 | | - |
| 1758 | | - |
| 1759 | | - |
| 1760 | | - |
| 1761 | bool QListWidget::isItemHidden(const QListWidgetItem *item) const | - |
| 1762 | { | - |
| 1763 | return isRowHidden(row(item)); | - |
| 1764 | } | - |
| 1765 | | - |
| 1766 | | - |
| 1767 | | - |
| 1768 | | - |
| 1769 | | - |
| 1770 | | - |
| 1771 | | - |
| 1772 | | - |
| 1773 | void QListWidget::setItemHidden(const QListWidgetItem *item, bool hide) | - |
| 1774 | { | - |
| 1775 | setRowHidden(row(item), hide); | - |
| 1776 | } | - |
| 1777 | | - |
| 1778 | | - |
| 1779 | | - |
| 1780 | | - |
| 1781 | | - |
| 1782 | | - |
| 1783 | | - |
| 1784 | void QListWidget::scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint) | - |
| 1785 | { | - |
| 1786 | Q_D(QListWidget); | - |
| 1787 | QModelIndex index = d->listModel()->index(const_cast<QListWidgetItem*>(item)); | - |
| 1788 | QListView::scrollTo(index, hint); | - |
| 1789 | } | - |
| 1790 | | - |
| 1791 | | - |
| 1792 | | - |
| 1793 | | - |
| 1794 | | - |
| 1795 | | - |
| 1796 | void QListWidget::clear() | - |
| 1797 | { | - |
| 1798 | Q_D(QListWidget); | - |
| 1799 | selectionModel()->clear(); | - |
| 1800 | d->listModel()->clear(); | - |
| 1801 | } | - |
| 1802 | | - |
| 1803 | | - |
| 1804 | | - |
| 1805 | | - |
| 1806 | | - |
| 1807 | | - |
| 1808 | | - |
| 1809 | QStringList QListWidget::mimeTypes() const | - |
| 1810 | { | - |
| 1811 | return d_func()->listModel()->QAbstractListModel::mimeTypes(); | - |
| 1812 | } | - |
| 1813 | | - |
| 1814 | | - |
| 1815 | | - |
| 1816 | | - |
| 1817 | | - |
| 1818 | | - |
| 1819 | | - |
| 1820 | | - |
| 1821 | | - |
| 1822 | #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) | - |
| 1823 | QMimeData *QListWidget::mimeData(const QList<QListWidgetItem *> &items) const | - |
| 1824 | #else | - |
| 1825 | QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*> items) const | - |
| 1826 | #endif | - |
| 1827 | { | - |
| 1828 | Q_D(const QListWidget); | - |
| 1829 | | - |
| 1830 | QModelIndexList &cachedIndexes = d->listModel()->cachedIndexes; | - |
| 1831 | | - |
| 1832 | | - |
| 1833 | if (cachedIndexes.isEmpty()) { | - |
| 1834 | cachedIndexes.reserve(items.count()); | - |
| 1835 | foreach (QListWidgetItem *item, items) | - |
| 1836 | cachedIndexes << indexFromItem(item); | - |
| 1837 | | - |
| 1838 | QMimeData *result = d->listModel()->internalMimeData(); | - |
| 1839 | | - |
| 1840 | cachedIndexes.clear(); | - |
| 1841 | return result; | - |
| 1842 | } | - |
| 1843 | | - |
| 1844 | return d->listModel()->internalMimeData(); | - |
| 1845 | } | - |
| 1846 | | - |
| 1847 | #ifndef QT_NO_DRAGANDDROP | - |
| 1848 | | - |
| 1849 | | - |
| 1850 | | - |
| 1851 | | - |
| 1852 | | - |
| 1853 | | - |
| 1854 | | - |
| 1855 | bool QListWidget::dropMimeData(int index, const QMimeData *data, Qt::DropAction action) | - |
| 1856 | { | - |
| 1857 | QModelIndex idx; | - |
| 1858 | int row = index; | - |
| 1859 | int column = 0; | - |
| 1860 | if (dropIndicatorPosition() == QAbstractItemView::OnItem) { | - |
| 1861 | | - |
| 1862 | idx = model()->index(row, column); | - |
| 1863 | row = -1; | - |
| 1864 | column = -1; | - |
| 1865 | } | - |
| 1866 | return d_func()->listModel()->QAbstractListModel::dropMimeData(data, action , row, column, idx); | - |
| 1867 | } | - |
| 1868 | | - |
| 1869 | | - |
| 1870 | void QListWidget::dropEvent(QDropEvent *event) { | - |
| 1871 | Q_D(QListWidget); | - |
| 1872 | if (event->source() == this && d->movement != Static) { | - |
| 1873 | QListView::dropEvent(event); | - |
| 1874 | return; | - |
| 1875 | } | - |
| 1876 | | - |
| 1877 | if (event->source() == this && (event->dropAction() == Qt::MoveAction || | - |
| 1878 | dragDropMode() == QAbstractItemView::InternalMove)) { | - |
| 1879 | QModelIndex topIndex; | - |
| 1880 | int col = -1; | - |
| 1881 | int row = -1; | - |
| 1882 | if (d->dropOn(event, &row, &col, &topIndex)) { | - |
| 1883 | QList<QModelIndex> selIndexes = selectedIndexes(); | - |
| 1884 | QList<QPersistentModelIndex> persIndexes; | - |
| 1885 | const int selIndexesCount = selIndexes.count(); | - |
| 1886 | persIndexes.reserve(selIndexesCount); | - |
| 1887 | for (int i = 0; i < selIndexesCount; i++) | - |
| 1888 | persIndexes.append(selIndexes.at(i)); | - |
| 1889 | | - |
| 1890 | if (persIndexes.contains(topIndex)) | - |
| 1891 | return; | - |
| 1892 | std::sort(persIndexes.begin(), persIndexes.end()); | - |
| 1893 | | - |
| 1894 | QPersistentModelIndex dropRow = model()->index(row, col, topIndex); | - |
| 1895 | | - |
| 1896 | int r = row == -1 ? count() : (dropRow.row() >= 0 ? dropRow.row() : row); | - |
| 1897 | for (int i = 0; i < persIndexes.count(); ++i) { | - |
| 1898 | const QPersistentModelIndex &pIndex = persIndexes.at(i); | - |
| 1899 | d->listModel()->move(pIndex.row(), r); | - |
| 1900 | r = pIndex.row() + 1; | - |
| 1901 | } | - |
| 1902 | | - |
| 1903 | event->accept(); | - |
| 1904 | | - |
| 1905 | event->setDropAction(Qt::CopyAction); | - |
| 1906 | } | - |
| 1907 | } | - |
| 1908 | | - |
| 1909 | QListView::dropEvent(event); | - |
| 1910 | } | - |
| 1911 | | - |
| 1912 | | - |
| 1913 | | - |
| 1914 | | - |
| 1915 | | - |
| 1916 | | - |
| 1917 | Qt::DropActions QListWidget::supportedDropActions() const | - |
| 1918 | { | - |
| 1919 | Q_D(const QListWidget); | - |
| 1920 | return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; | - |
| 1921 | } | - |
| 1922 | #endif // QT_NO_DRAGANDDROP | - |
| 1923 | | - |
| 1924 | | - |
| 1925 | | - |
| 1926 | | - |
| 1927 | | - |
| 1928 | | - |
| 1929 | QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const | - |
| 1930 | { | - |
| 1931 | const QListWidgetMimeData *lwd = qobject_cast<const QListWidgetMimeData*>(data); | - |
| 1932 | if (lwd) | - |
| 1933 | return lwd->items; | - |
| 1934 | return QList<QListWidgetItem*>(); | - |
| 1935 | } | - |
| 1936 | | - |
| 1937 | | - |
| 1938 | | - |
| 1939 | | - |
| 1940 | | - |
| 1941 | QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const | - |
| 1942 | { | - |
| 1943 | Q_D(const QListWidget); | - |
| 1944 | return d->listModel()->index(item); | - |
| 1945 | } | - |
| 1946 | | - |
| 1947 | | - |
| 1948 | | - |
| 1949 | | - |
| 1950 | | - |
| 1951 | QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const | - |
| 1952 | { | - |
| 1953 | Q_D(const QListWidget); | - |
| 1954 | if (d->isIndexValid(index)) | - |
| 1955 | return d->listModel()->at(index.row()); | - |
| 1956 | return 0; | - |
| 1957 | } | - |
| 1958 | | - |
| 1959 | | - |
| 1960 | | - |
| 1961 | | - |
| 1962 | void QListWidget::setModel(QAbstractItemModel * ) | - |
| 1963 | { | - |
| 1964 | Q_ASSERT(!"QListWidget::setModel() - Changing the model of the QListWidget is not allowed."); | - |
| 1965 | } | - |
| 1966 | | - |
| 1967 | | - |
| 1968 | | - |
| 1969 | | - |
| 1970 | bool QListWidget::event(QEvent *e) | - |
| 1971 | { | - |
| 1972 | return QListView::event(e); | - |
| 1973 | } | - |
| 1974 | | - |
| 1975 | QT_END_NAMESPACE | - |
| 1976 | | - |
| 1977 | #include "moc_qlistwidget.cpp" | - |
| 1978 | #include "moc_qlistwidget_p.cpp" | - |
| 1979 | | - |
| 1980 | #endif // QT_NO_LISTWIDGET | - |
| | |