Changeset View
Changeset View
Standalone View
Standalone View
lib/thumbnailview/thumbnailview.cpp
Show First 20 Lines • Show All 441 Lines • ▼ Show 20 Line(s) | |||||
442 | { | 442 | { | ||
443 | return d->mThumbnailViewHelper; | 443 | return d->mThumbnailViewHelper; | ||
444 | } | 444 | } | ||
445 | 445 | | |||
446 | void ThumbnailView::setDocumentInfoProvider(AbstractDocumentInfoProvider* provider) | 446 | void ThumbnailView::setDocumentInfoProvider(AbstractDocumentInfoProvider* provider) | ||
447 | { | 447 | { | ||
448 | d->mDocumentInfoProvider = provider; | 448 | d->mDocumentInfoProvider = provider; | ||
449 | if (provider) { | 449 | if (provider) { | ||
450 | connect(provider, SIGNAL(busyStateChanged(QModelIndex,bool)), | 450 | connect(provider, &AbstractDocumentInfoProvider::busyStateChanged, | ||
451 | SLOT(updateThumbnailBusyState(QModelIndex,bool))); | 451 | this, &ThumbnailView::updateThumbnailBusyState); | ||
452 | connect(provider, SIGNAL(documentChanged(QModelIndex)), | 452 | connect(provider, &AbstractDocumentInfoProvider::documentChanged, | ||
453 | SLOT(updateThumbnail(QModelIndex))); | 453 | this, &ThumbnailView::updateThumbnail); | ||
454 | } | 454 | } | ||
455 | } | 455 | } | ||
456 | 456 | | |||
457 | AbstractDocumentInfoProvider* ThumbnailView::documentInfoProvider() const | 457 | AbstractDocumentInfoProvider* ThumbnailView::documentInfoProvider() const | ||
458 | { | 458 | { | ||
459 | return d->mDocumentInfoProvider; | 459 | return d->mDocumentInfoProvider; | ||
460 | } | 460 | } | ||
461 | 461 | | |||
▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Line(s) | 803 | for (int row = 0; row < model()->rowCount(); ++row) { | |||
864 | } | 864 | } | ||
865 | } | 865 | } | ||
866 | 866 | | |||
867 | if (!itemMap.isEmpty()) { | 867 | if (!itemMap.isEmpty()) { | ||
868 | d->appendItemsToThumbnailProvider(itemMap.values()); | 868 | d->appendItemsToThumbnailProvider(itemMap.values()); | ||
869 | } | 869 | } | ||
870 | } | 870 | } | ||
871 | 871 | | |||
872 | void ThumbnailView::updateThumbnail(const QModelIndex& index) | 872 | void ThumbnailView::updateThumbnail(const QUrl& url) | ||
873 | { | 873 | { | ||
874 | KFileItem item = fileItemForIndex(index); | 874 | const ThumbnailForUrl::Iterator it = d->mThumbnailForUrl.find(url); | ||
875 | QUrl url = item.url(); | 875 | if (it == d->mThumbnailForUrl.end()) { | ||
876 | return; | ||||
877 | } | ||||
878 | | ||||
876 | if (d->mDocumentInfoProvider && d->mDocumentInfoProvider->isModified(url)) { | 879 | if (d->mDocumentInfoProvider && d->mDocumentInfoProvider->isModified(url)) { | ||
877 | d->updateThumbnailForModifiedDocument(index); | 880 | d->updateThumbnailForModifiedDocument(it->mIndex); | ||
878 | } else { | 881 | } else { | ||
879 | KFileItemList list; | 882 | const KFileItem item = fileItemForIndex(it->mIndex); | ||
880 | list << item; | 883 | d->appendItemsToThumbnailProvider(KFileItemList({ item })); | ||
881 | d->appendItemsToThumbnailProvider(list); | | |||
882 | } | 884 | } | ||
883 | } | 885 | } | ||
884 | 886 | | |||
885 | void ThumbnailView::updateThumbnailBusyState(const QModelIndex& _index, bool busy) | 887 | void ThumbnailView::updateThumbnailBusyState(const QUrl& url, bool busy) | ||
886 | { | 888 | { | ||
887 | QPersistentModelIndex index(_index); | 889 | const ThumbnailForUrl::Iterator it = d->mThumbnailForUrl.find(url); | ||
890 | if (it == d->mThumbnailForUrl.end()) { | ||||
891 | return; | ||||
892 | } | ||||
893 | | ||||
894 | QPersistentModelIndex index(it->mIndex); | ||||
888 | if (busy && !d->mBusyIndexSet.contains(index)) { | 895 | if (busy && !d->mBusyIndexSet.contains(index)) { | ||
889 | d->mBusyIndexSet << index; | 896 | d->mBusyIndexSet << index; | ||
890 | update(index); | 897 | update(index); | ||
891 | if (d->mBusyAnimationTimeLine->state() != QTimeLine::Running) { | 898 | if (d->mBusyAnimationTimeLine->state() != QTimeLine::Running) { | ||
892 | d->mBusyAnimationTimeLine->start(); | 899 | d->mBusyAnimationTimeLine->start(); | ||
893 | } | 900 | } | ||
894 | } else if (!busy && d->mBusyIndexSet.remove(index)) { | 901 | } else if (!busy && d->mBusyIndexSet.remove(index)) { | ||
895 | update(index); | 902 | update(index); | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |