Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kfileplacesmodel.cpp
Show First 20 Lines • Show All 320 Lines • ▼ Show 20 Line(s) | 253 | #endif | |||
---|---|---|---|---|---|
321 | 321 | | |||
322 | connect(d->bookmarkManager, SIGNAL(changed(QString,QString)), | 322 | connect(d->bookmarkManager, SIGNAL(changed(QString,QString)), | ||
323 | this, SLOT(_k_reloadBookmarks())); | 323 | this, SLOT(_k_reloadBookmarks())); | ||
324 | connect(d->bookmarkManager, SIGNAL(bookmarksChanged(QString)), | 324 | connect(d->bookmarkManager, SIGNAL(bookmarksChanged(QString)), | ||
325 | this, SLOT(_k_reloadBookmarks())); | 325 | this, SLOT(_k_reloadBookmarks())); | ||
326 | 326 | | |||
327 | d->_k_reloadBookmarks(); | 327 | d->_k_reloadBookmarks(); | ||
328 | QTimer::singleShot(0, this, SLOT(_k_initDeviceList())); | 328 | QTimer::singleShot(0, this, SLOT(_k_initDeviceList())); | ||
329 | } | 329 | } | ||
ervin: Would be nice to unit test that guy | |||||
330 | 330 | | |||
331 | KFilePlacesModel::~KFilePlacesModel() | 331 | KFilePlacesModel::~KFilePlacesModel() | ||
332 | { | 332 | { | ||
333 | delete d; | 333 | delete d; | ||
334 | } | 334 | } | ||
335 | 335 | | |||
336 | QUrl KFilePlacesModel::url(const QModelIndex &index) const | 336 | QUrl KFilePlacesModel::url(const QModelIndex &index) const | ||
337 | { | 337 | { | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 415 | { | |||
416 | if (!index.isValid()) { | 416 | if (!index.isValid()) { | ||
417 | return UnknownType; | 417 | return UnknownType; | ||
418 | } | 418 | } | ||
419 | 419 | | |||
420 | KFilePlacesItem *item = static_cast<KFilePlacesItem *>(index.internalPointer()); | 420 | KFilePlacesItem *item = static_cast<KFilePlacesItem *>(index.internalPointer()); | ||
421 | return item->groupType(); | 421 | return item->groupType(); | ||
422 | } | 422 | } | ||
423 | 423 | | |||
424 | QModelIndexList KFilePlacesModel::groupIndexes(const KFilePlacesModel::GroupType type) const | ||||
425 | { | ||||
426 | if (type == UnknownType) { | ||||
427 | return QModelIndexList(); | ||||
428 | } | ||||
429 | | ||||
430 | QModelIndexList indexes; | ||||
431 | const int rows = rowCount(); | ||||
only call rowCount once: for (int row = 0, c = rowCount(); row < c; ++row) { mwolff: only call rowCount once:
```
for (int row = 0, c = rowCount(); row < c; ++row) {
``` | |||||
432 | for (int row = 0; row < rows ; ++row) { | ||||
433 | const QModelIndex current = index(row, 0); | ||||
434 | if (groupType(current) == type) { | ||||
435 | indexes << current; | ||||
436 | } | ||||
437 | } | ||||
438 | | ||||
439 | return indexes; | ||||
440 | } | ||||
441 | | ||||
424 | QVariant KFilePlacesModel::data(const QModelIndex &index, int role) const | 442 | QVariant KFilePlacesModel::data(const QModelIndex &index, int role) const | ||
425 | { | 443 | { | ||
426 | if (!index.isValid()) { | 444 | if (!index.isValid()) { | ||
427 | return QVariant(); | 445 | return QVariant(); | ||
428 | } | 446 | } | ||
429 | 447 | | |||
430 | KFilePlacesItem *item = static_cast<KFilePlacesItem *>(index.internalPointer()); | 448 | KFilePlacesItem *item = static_cast<KFilePlacesItem *>(index.internalPointer()); | ||
431 | return item->data(role); | 449 | return item->data(role); | ||
▲ Show 20 Lines • Show All 803 Lines • Show Last 20 Lines |
Would be nice to unit test that guy