diff --git a/app/documentinfoprovider.h b/app/documentinfoprovider.h --- a/app/documentinfoprovider.h +++ b/app/documentinfoprovider.h @@ -45,10 +45,6 @@ virtual void thumbnailForDocument(const QUrl &url, ThumbnailGroup::Enum group, QPixmap* outPix, QSize* outFullSize) const Q_DECL_OVERRIDE; -private Q_SLOTS: - void emitBusyStateChanged(const QUrl&, bool); - void emitDocumentChanged(const QUrl&); - private: SortedDirModel* mDirModel; }; diff --git a/app/documentinfoprovider.cpp b/app/documentinfoprovider.cpp --- a/app/documentinfoprovider.cpp +++ b/app/documentinfoprovider.cpp @@ -37,11 +37,10 @@ : AbstractDocumentInfoProvider(model) { mDirModel = model; - connect(DocumentFactory::instance(), SIGNAL(documentBusyStateChanged(QUrl,bool)), - SLOT(emitBusyStateChanged(QUrl,bool))); - - connect(DocumentFactory::instance(), SIGNAL(documentChanged(QUrl)), - SLOT(emitDocumentChanged(QUrl))); + connect(DocumentFactory::instance(), &DocumentFactory::documentBusyStateChanged, + this, &AbstractDocumentInfoProvider::busyStateChanged); + connect(DocumentFactory::instance(), &DocumentFactory::documentChanged, + this, &AbstractDocumentInfoProvider::documentChanged); } void DocumentInfoProvider::thumbnailForDocument(const QUrl &url, ThumbnailGroup::Enum group, QPixmap* outPix, QSize* outFullSize) const @@ -89,22 +88,4 @@ } } -void DocumentInfoProvider::emitBusyStateChanged(const QUrl &url, bool busy) -{ - QModelIndex index = mDirModel->indexForUrl(url); - if (!index.isValid()) { - return; - } - busyStateChanged(index, busy); -} - -void DocumentInfoProvider::emitDocumentChanged(const QUrl &url) -{ - QModelIndex index = mDirModel->indexForUrl(url); - if (!index.isValid()) { - return; - } - documentChanged(index); -} - } // namespace diff --git a/lib/thumbnailview/abstractdocumentinfoprovider.h b/lib/thumbnailview/abstractdocumentinfoprovider.h --- a/lib/thumbnailview/abstractdocumentinfoprovider.h +++ b/lib/thumbnailview/abstractdocumentinfoprovider.h @@ -57,8 +57,8 @@ virtual void thumbnailForDocument(const QUrl &url, ThumbnailGroup::Enum, QPixmap* outPix, QSize* outFullSize) const = 0; Q_SIGNALS: - void busyStateChanged(const QModelIndex&, bool); - void documentChanged(const QModelIndex&); + void busyStateChanged(const QUrl& url, bool busy); + void documentChanged(const QUrl& url); }; } // namespace diff --git a/lib/thumbnailview/thumbnailview.h b/lib/thumbnailview/thumbnailview.h --- a/lib/thumbnailview/thumbnailview.h +++ b/lib/thumbnailview/thumbnailview.h @@ -190,14 +190,14 @@ void setBrokenThumbnail(const KFileItem&); /** - * Generate thumbnail for @a index. + * Generate thumbnail for url. */ - void updateThumbnail(const QModelIndex& index); + void updateThumbnail(const QUrl& url); /** - * Tells the view the busy state of the document pointed by the index has changed. + * Tells the view the busy state of the document pointed by the url has changed. */ - void updateThumbnailBusyState(const QModelIndex& index, bool); + void updateThumbnailBusyState(const QUrl& url, bool); /* * Cause a repaint of all busy indexes diff --git a/lib/thumbnailview/thumbnailview.cpp b/lib/thumbnailview/thumbnailview.cpp --- a/lib/thumbnailview/thumbnailview.cpp +++ b/lib/thumbnailview/thumbnailview.cpp @@ -447,10 +447,10 @@ { d->mDocumentInfoProvider = provider; if (provider) { - connect(provider, SIGNAL(busyStateChanged(QModelIndex,bool)), - SLOT(updateThumbnailBusyState(QModelIndex,bool))); - connect(provider, SIGNAL(documentChanged(QModelIndex)), - SLOT(updateThumbnail(QModelIndex))); + connect(provider, &AbstractDocumentInfoProvider::busyStateChanged, + this, &ThumbnailView::updateThumbnailBusyState); + connect(provider, &AbstractDocumentInfoProvider::documentChanged, + this, &ThumbnailView::updateThumbnail); } } @@ -869,22 +869,29 @@ } } -void ThumbnailView::updateThumbnail(const QModelIndex& index) +void ThumbnailView::updateThumbnail(const QUrl& url) { - KFileItem item = fileItemForIndex(index); - QUrl url = item.url(); + const ThumbnailForUrl::Iterator it = d->mThumbnailForUrl.find(url); + if (it == d->mThumbnailForUrl.end()) { + return; + } + if (d->mDocumentInfoProvider && d->mDocumentInfoProvider->isModified(url)) { - d->updateThumbnailForModifiedDocument(index); + d->updateThumbnailForModifiedDocument(it->mIndex); } else { - KFileItemList list; - list << item; - d->appendItemsToThumbnailProvider(list); + const KFileItem item = fileItemForIndex(it->mIndex); + d->appendItemsToThumbnailProvider(KFileItemList({ item })); } } -void ThumbnailView::updateThumbnailBusyState(const QModelIndex& _index, bool busy) +void ThumbnailView::updateThumbnailBusyState(const QUrl& url, bool busy) { - QPersistentModelIndex index(_index); + const ThumbnailForUrl::Iterator it = d->mThumbnailForUrl.find(url); + if (it == d->mThumbnailForUrl.end()) { + return; + } + + QPersistentModelIndex index(it->mIndex); if (busy && !d->mBusyIndexSet.contains(index)) { d->mBusyIndexSet << index; update(index);