From 1ab719d490d467218d65f2b03b3ec0ec717515b5 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 11 Dec 2007 19:19:44 +0000 Subject: fixed issue that turning off the preview during the preview job still was active did not work as expected TODO for 4.1: provide a preview helper class which can be shared between DolphinView and the special use case of DolphinColumnViewWidget BUG: 153816 svn path=/trunk/KDE/kdebase/apps/; revision=747348 --- src/dolphinview.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/dolphinview.cpp') diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index d4609d382..dcabe8329 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -75,7 +76,8 @@ DolphinView::DolphinView(QWidget* parent, m_selectionModel(0), m_dolphinModel(dolphinModel), m_dirLister(dirLister), - m_proxyModel(proxyModel) + m_proxyModel(proxyModel), + m_previewJob(0) { setFocusPolicy(Qt::StrongFocus); m_topLayout = new QVBoxLayout(this); @@ -128,6 +130,10 @@ DolphinView::DolphinView(QWidget* parent, DolphinView::~DolphinView() { + if (m_previewJob != 0) { + m_previewJob->kill(); + m_previewJob = 0; + } } const KUrl& DolphinView::url() const @@ -568,17 +574,25 @@ void DolphinView::triggerItem(const KFileItem& item) void DolphinView::generatePreviews(const KFileItemList& items) { if (m_controller->dolphinView()->showPreview()) { - KIO::PreviewJob* job = KIO::filePreview(items, 128); - connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)), - this, SLOT(showPreview(const KFileItem&, const QPixmap&))); + if (m_previewJob != 0) { + m_previewJob->kill(); + m_previewJob = 0; + } + + m_previewJob = KIO::filePreview(items, 128); + connect(m_previewJob, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)), + this, SLOT(replaceIcon(const KFileItem&, const QPixmap&))); + connect(m_previewJob, SIGNAL(finished(KJob*)), + this, SLOT(slotPreviewJobFinished(KJob*))); } } -void DolphinView::showPreview(const KFileItem& item, const QPixmap& pixmap) +void DolphinView::replaceIcon(const KFileItem& item, const QPixmap& pixmap) { Q_ASSERT(!item.isNull()); - if (item.url().directory() != m_dirLister->url().path()) { - // the preview job is still working on items of an older URL, hence + if (!m_showPreview || (item.url().directory() != m_dirLister->url().path())) { + // the preview has been deactivated in the meanwhile or the preview + // job is still working on items of an older URL, hence // the item is not part of the directory model anymore return; } @@ -1109,6 +1123,12 @@ void DolphinView::slotDeleteFileFinished(KJob* job) } } +void DolphinView::slotPreviewJobFinished(KJob* job) +{ + Q_ASSERT(job == m_previewJob); + m_previewJob = 0; +} + void DolphinView::cutSelectedItems() { QMimeData* mimeData = new QMimeData(); -- cgit v1.3