Commit ea22bed7 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Do not constantly restart the thumbnail generation timer on data changes

Otherwise we're delaying thumbnail generation until the entire directory
has finished loading, which can be a long time for a directory with a
lot of items.
parent da77f501
...@@ -211,7 +211,9 @@ struct ThumbnailViewPrivate ...@@ -211,7 +211,9 @@ struct ThumbnailViewPrivate
mThumbnailProvider->removePendingItems(); mThumbnailProvider->removePendingItems();
} }
mSmoothThumbnailQueue.clear(); mSmoothThumbnailQueue.clear();
mScheduledThumbnailGenerationTimer.start(); if (!mScheduledThumbnailGenerationTimer.isActive()) {
mScheduledThumbnailGenerationTimer.start();
}
} }
void updateThumbnailForModifiedDocument(const QModelIndex& index) void updateThumbnailForModifiedDocument(const QModelIndex& index)
...@@ -516,13 +518,18 @@ void ThumbnailView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, i ...@@ -516,13 +518,18 @@ void ThumbnailView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, i
// Removing rows might make new images visible, make sure their thumbnail // Removing rows might make new images visible, make sure their thumbnail
// is generated // is generated
d->mScheduledThumbnailGenerationTimer.start(); if (!d->mScheduledThumbnailGenerationTimer.isActive()) {
d->mScheduledThumbnailGenerationTimer.start();
}
} }
void ThumbnailView::rowsInserted(const QModelIndex& parent, int start, int end) void ThumbnailView::rowsInserted(const QModelIndex& parent, int start, int end)
{ {
QListView::rowsInserted(parent, start, end); QListView::rowsInserted(parent, start, end);
d->mScheduledThumbnailGenerationTimer.start();
if (!d->mScheduledThumbnailGenerationTimer.isActive()) {
d->mScheduledThumbnailGenerationTimer.start();
}
if (isVisible()) { if (isVisible()) {
emit rowsInsertedSignal(parent, start, end); emit rowsInsertedSignal(parent, start, end);
...@@ -560,7 +567,7 @@ void ThumbnailView::dataChanged(const QModelIndex& topLeft, const QModelIndex& b ...@@ -560,7 +567,7 @@ void ThumbnailView::dataChanged(const QModelIndex& topLeft, const QModelIndex& b
} }
} }
} }
if (thumbnailsNeedRefresh) { if (thumbnailsNeedRefresh && !d->mScheduledThumbnailGenerationTimer.isActive()) {
d->mScheduledThumbnailGenerationTimer.start(); d->mScheduledThumbnailGenerationTimer.start();
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment