diff options
Diffstat (limited to 'src/iconmanager.cpp')
| -rw-r--r-- | src/iconmanager.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp index cde15b00b..fb522fd99 100644 --- a/src/iconmanager.cpp +++ b/src/iconmanager.cpp @@ -135,32 +135,35 @@ void IconManager::updateCutItems() void IconManager::dispatchPreviewQueue() { - const int previewsCount = m_previews.count(); - if (previewsCount == 0) { - return; - } + int previewsCount = m_previews.count(); + if (previewsCount > 0) { + // Applying the previews to the model must be done step by step + // in larger blocks: Applying a preview immediately when getting the signal + // 'gotPreview()' from the PreviewJob is too expensive, as a relayout + // of the view would be triggered for each single preview. - // Applying the previews to the model must be done step by step - // in larger blocks: Applying a preview immediately when getting the signal - // 'gotPreview()' from the PreviewJob is too expensive, as a relayout - // of the view would be triggered for each single preview. + int dispatchCount = 30; + if (dispatchCount > m_previews.count()) { + dispatchCount = m_previews.count(); + } - int dispatchCount = 30; - if (dispatchCount > previewsCount) { - dispatchCount = previewsCount; - } + for (int i = 0; i < dispatchCount; ++i) { + const Preview& preview = m_previews.first(); + replaceIcon(preview.item, preview.pixmap); + m_previews.pop_front(); + } - for (int i = 0; i < dispatchCount; ++i) { - const Preview& preview = m_previews.first(); - replaceIcon(preview.item, preview.pixmap); - m_previews.pop_front(); + previewsCount = m_previews.count(); } - if (m_previews.count() > 0) { - // there are still pending previews; if no preview job is - // working, poll more aggressively: - const int timeout = (m_previewJobs.count() > 0) ? 200 : 10; - m_previewTimer->start(timeout); + const bool workingPreviewJobs = (m_previewJobs.count() > 0); + if (workingPreviewJobs) { + // poll for previews as long as not all preview jobs are finished + m_previewTimer->start(200); + } else if (previewsCount > 0) { + // all preview jobs are finished but there are still pending previews + // in the queue -> poll more aggressively + m_previewTimer->start(10); } } |
