X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/525fdd8afc1468dc72e6a150cf75dee4c330bdcd..2df7bd34758cf02db0300ffb99b78e7dbf55a791:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 0b8fe5883..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 @@ -147,6 +153,7 @@ void DolphinView::setActive(bool active) } m_active = active; + m_selectionModel->clearSelection(); QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color(); if (active) { @@ -567,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; } @@ -816,7 +831,7 @@ void DolphinView::updateCutItems() void DolphinView::showHoverInformation(const KFileItem& item) { - if (hasSelection()) { + if (hasSelection() || !m_active) { return; } @@ -825,7 +840,9 @@ void DolphinView::showHoverInformation(const KFileItem& item) void DolphinView::clearHoverInformation() { - emit requestItemInfo(KFileItem()); + if (m_active) { + emit requestItemInfo(KFileItem()); + } } @@ -867,7 +884,9 @@ void DolphinView::createView() m_selectionModel = view->selectionModel(); } - m_selectionModel->setParent(this); //Reparent the selection model. We do not want it to be deleted when we delete the model + // reparent the selection model, as it should not be deleted + // when deleting the model + m_selectionModel->setParent(this); view->setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -1104,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();