mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
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
This commit is contained in:
parent
4e43b5465f
commit
1ab719d490
4 changed files with 80 additions and 14 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include <kfileitem.h>
|
#include <kfileitem.h>
|
||||||
#include <kio/previewjob.h>
|
#include <kio/previewjob.h>
|
||||||
#include <kiconeffect.h>
|
#include <kiconeffect.h>
|
||||||
|
#include <kjob.h>
|
||||||
#include <kmimetyperesolver.h>
|
#include <kmimetyperesolver.h>
|
||||||
#include <konqmimedata.h>
|
#include <konqmimedata.h>
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
|
||||||
m_dirLister(0),
|
m_dirLister(0),
|
||||||
m_dolphinModel(0),
|
m_dolphinModel(0),
|
||||||
m_proxyModel(0),
|
m_proxyModel(0),
|
||||||
|
m_previewJob(0),
|
||||||
m_dragging(false),
|
m_dragging(false),
|
||||||
m_dropRect()
|
m_dropRect()
|
||||||
{
|
{
|
||||||
|
@ -132,6 +134,11 @@ DolphinColumnWidget::~DolphinColumnWidget()
|
||||||
delete m_dolphinModel;
|
delete m_dolphinModel;
|
||||||
m_dolphinModel = 0;
|
m_dolphinModel = 0;
|
||||||
m_dirLister = 0; // deleted by m_dolphinModel
|
m_dirLister = 0; // deleted by m_dolphinModel
|
||||||
|
|
||||||
|
if (m_previewJob != 0) {
|
||||||
|
m_previewJob->kill();
|
||||||
|
m_previewJob = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinColumnWidget::setDecorationSize(const QSize& size)
|
void DolphinColumnWidget::setDecorationSize(const QSize& size)
|
||||||
|
@ -356,19 +363,27 @@ void DolphinColumnWidget::generatePreviews(const KFileItemList& items)
|
||||||
// for generatePreviews(), showPreview() and isCutItem()
|
// for generatePreviews(), showPreview() and isCutItem()
|
||||||
|
|
||||||
if (m_view->m_controller->dolphinView()->showPreview()) {
|
if (m_view->m_controller->dolphinView()->showPreview()) {
|
||||||
KIO::PreviewJob* job = KIO::filePreview(items, 128);
|
if (m_previewJob != 0) {
|
||||||
connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
|
m_previewJob->kill();
|
||||||
this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
|
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 DolphinColumnWidget::showPreview(const KFileItem& item, const QPixmap& pixmap)
|
void DolphinColumnWidget::replaceIcon(const KFileItem& item, const QPixmap& pixmap)
|
||||||
{
|
{
|
||||||
// TODO: same implementation as in DolphinView; create helper class
|
// TODO: same implementation as in DolphinView; create helper class
|
||||||
// for generatePreviews(), showPreview() and isCutItem()
|
// for generatePreviews(), showPreview() and isCutItem()
|
||||||
|
|
||||||
Q_ASSERT(!item.isNull());
|
Q_ASSERT(!item.isNull());
|
||||||
if (item.url().directory() != m_dirLister->url().path()) {
|
const bool showPreview = m_view->m_controller->dolphinView()->showPreview();
|
||||||
|
if (!showPreview || (item.url().directory() != m_dirLister->url().path())) {
|
||||||
// the preview job is still working on items of an older URL, hence
|
// the preview job is still working on items of an older URL, hence
|
||||||
// the item is not part of the directory model anymore
|
// the item is not part of the directory model anymore
|
||||||
return;
|
return;
|
||||||
|
@ -394,6 +409,12 @@ void DolphinColumnWidget::slotEntered(const QModelIndex& index)
|
||||||
m_view->m_controller->emitItemEntered(item);
|
m_view->m_controller->emitItemEntered(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinColumnWidget::slotPreviewJobFinished(KJob* job)
|
||||||
|
{
|
||||||
|
Q_ASSERT(job == m_previewJob);
|
||||||
|
m_previewJob = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinColumnWidget::activate()
|
void DolphinColumnWidget::activate()
|
||||||
{
|
{
|
||||||
setFocus(Qt::OtherFocusReason);
|
setFocus(Qt::OtherFocusReason);
|
||||||
|
|
|
@ -31,9 +31,14 @@ class DolphinColumnView;
|
||||||
class DolphinModel;
|
class DolphinModel;
|
||||||
class DolphinSortFilterProxyModel;
|
class DolphinSortFilterProxyModel;
|
||||||
class KDirLister;
|
class KDirLister;
|
||||||
|
class KJob;
|
||||||
class KFileItem;
|
class KFileItem;
|
||||||
class KFileItemList;
|
class KFileItemList;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
|
namespace KIO
|
||||||
|
{
|
||||||
|
class PreviewJob;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents one column inside the DolphinColumnView and has been
|
* Represents one column inside the DolphinColumnView and has been
|
||||||
|
@ -124,10 +129,16 @@ private slots:
|
||||||
* Replaces the icon of the item \a item by the preview pixmap
|
* Replaces the icon of the item \a item by the preview pixmap
|
||||||
* \a pixmap.
|
* \a pixmap.
|
||||||
*/
|
*/
|
||||||
void showPreview(const KFileItem& item, const QPixmap& pixmap);
|
void replaceIcon(const KFileItem& item, const QPixmap& pixmap);
|
||||||
|
|
||||||
void slotEntered(const QModelIndex& index);
|
void slotEntered(const QModelIndex& index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is invoked when the preview job has been finished and
|
||||||
|
* set m_previewJob to 0.
|
||||||
|
*/
|
||||||
|
void slotPreviewJobFinished(KJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Used by DolphinColumnWidget::setActive(). */
|
/** Used by DolphinColumnWidget::setActive(). */
|
||||||
void activate();
|
void activate();
|
||||||
|
@ -157,6 +168,8 @@ private:
|
||||||
DolphinModel* m_dolphinModel;
|
DolphinModel* m_dolphinModel;
|
||||||
DolphinSortFilterProxyModel* m_proxyModel;
|
DolphinSortFilterProxyModel* m_proxyModel;
|
||||||
|
|
||||||
|
KIO::PreviewJob* m_previewJob;
|
||||||
|
|
||||||
bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
|
bool m_dragging; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
|
||||||
QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
|
QRect m_dropRect; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <kio/deletejob.h>
|
#include <kio/deletejob.h>
|
||||||
#include <kio/netaccess.h>
|
#include <kio/netaccess.h>
|
||||||
#include <kio/previewjob.h>
|
#include <kio/previewjob.h>
|
||||||
|
#include <kjob.h>
|
||||||
#include <kmimetyperesolver.h>
|
#include <kmimetyperesolver.h>
|
||||||
#include <konqmimedata.h>
|
#include <konqmimedata.h>
|
||||||
#include <konq_operations.h>
|
#include <konq_operations.h>
|
||||||
|
@ -75,7 +76,8 @@ DolphinView::DolphinView(QWidget* parent,
|
||||||
m_selectionModel(0),
|
m_selectionModel(0),
|
||||||
m_dolphinModel(dolphinModel),
|
m_dolphinModel(dolphinModel),
|
||||||
m_dirLister(dirLister),
|
m_dirLister(dirLister),
|
||||||
m_proxyModel(proxyModel)
|
m_proxyModel(proxyModel),
|
||||||
|
m_previewJob(0)
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
m_topLayout = new QVBoxLayout(this);
|
m_topLayout = new QVBoxLayout(this);
|
||||||
|
@ -128,6 +130,10 @@ DolphinView::DolphinView(QWidget* parent,
|
||||||
|
|
||||||
DolphinView::~DolphinView()
|
DolphinView::~DolphinView()
|
||||||
{
|
{
|
||||||
|
if (m_previewJob != 0) {
|
||||||
|
m_previewJob->kill();
|
||||||
|
m_previewJob = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const KUrl& DolphinView::url() const
|
const KUrl& DolphinView::url() const
|
||||||
|
@ -568,17 +574,25 @@ void DolphinView::triggerItem(const KFileItem& item)
|
||||||
void DolphinView::generatePreviews(const KFileItemList& items)
|
void DolphinView::generatePreviews(const KFileItemList& items)
|
||||||
{
|
{
|
||||||
if (m_controller->dolphinView()->showPreview()) {
|
if (m_controller->dolphinView()->showPreview()) {
|
||||||
KIO::PreviewJob* job = KIO::filePreview(items, 128);
|
if (m_previewJob != 0) {
|
||||||
connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
|
m_previewJob->kill();
|
||||||
this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
|
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());
|
Q_ASSERT(!item.isNull());
|
||||||
if (item.url().directory() != m_dirLister->url().path()) {
|
if (!m_showPreview || (item.url().directory() != m_dirLister->url().path())) {
|
||||||
// the preview job is still working on items of an older URL, hence
|
// 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
|
// the item is not part of the directory model anymore
|
||||||
return;
|
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()
|
void DolphinView::cutSelectedItems()
|
||||||
{
|
{
|
||||||
QMimeData* mimeData = new QMimeData();
|
QMimeData* mimeData = new QMimeData();
|
||||||
|
|
|
@ -52,6 +52,10 @@ class DolphinMainWindow;
|
||||||
class DolphinSortFilterProxyModel;
|
class DolphinSortFilterProxyModel;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class ViewProperties;
|
class ViewProperties;
|
||||||
|
namespace KIO
|
||||||
|
{
|
||||||
|
class PreviewJob;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short Represents a view for the directory content.
|
* @short Represents a view for the directory content.
|
||||||
|
@ -541,7 +545,7 @@ private slots:
|
||||||
* Replaces the icon of the item \a item by the preview pixmap
|
* Replaces the icon of the item \a item by the preview pixmap
|
||||||
* \a pixmap.
|
* \a pixmap.
|
||||||
*/
|
*/
|
||||||
void showPreview(const KFileItem& item, const QPixmap& pixmap);
|
void replaceIcon(const KFileItem& item, const QPixmap& pixmap);
|
||||||
|
|
||||||
void emitSelectionChangedSignal();
|
void emitSelectionChangedSignal();
|
||||||
|
|
||||||
|
@ -614,6 +618,12 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void slotDeleteFileFinished(KJob* job);
|
void slotDeleteFileFinished(KJob* job);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is invoked when the preview job has been finished and
|
||||||
|
* set m_previewJob to 0.
|
||||||
|
*/
|
||||||
|
void slotPreviewJobFinished(KJob* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadDirectory(const KUrl& url, bool reload = false);
|
void loadDirectory(const KUrl& url, bool reload = false);
|
||||||
|
|
||||||
|
@ -696,6 +706,8 @@ private:
|
||||||
KDirLister* m_dirLister;
|
KDirLister* m_dirLister;
|
||||||
DolphinSortFilterProxyModel* m_proxyModel;
|
DolphinSortFilterProxyModel* m_proxyModel;
|
||||||
|
|
||||||
|
KIO::PreviewJob* m_previewJob;
|
||||||
|
|
||||||
QList<CutItem> m_cutItemsCache;
|
QList<CutItem> m_cutItemsCache;
|
||||||
|
|
||||||
KUrl m_rootUrl;
|
KUrl m_rootUrl;
|
||||||
|
|
Loading…
Reference in a new issue