connect(m_controller, SIGNAL(viewportEntered()),
this, SLOT(clearHoverInformation()));
- m_iconManager = new IconManager(this, m_dolphinModel);
-
applyViewProperties(url);
m_topLayout->addWidget(itemView());
}
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
new KMimeTypeResolver(view, m_dolphinModel);
+ m_iconManager = new IconManager(view, m_proxyModel);
+
m_topLayout->insertWidget(1, view);
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
m_detailsView = 0;
m_columnView = 0;
m_fileItemDelegate = 0;
+ m_iconManager = 0;
}
}
#include "iconmanager.h"
#include "dolphinmodel.h"
+#include "dolphinsortfilterproxymodel.h"
#include <kiconeffect.h>
#include <kio/previewjob.h>
#include <konqmimedata.h>
#include <QApplication>
+#include <QAbstractItemView>
#include <QClipboard>
#include <QIcon>
-IconManager::IconManager(QObject* parent, DolphinModel* model) :
+IconManager::IconManager(QAbstractItemView* parent, DolphinSortFilterProxyModel* model) :
QObject(parent),
m_showPreview(false),
+ m_view(parent),
m_previewJobs(),
- m_dolphinModel(model),
+ m_dolphinModel(0),
+ m_proxyModel(model),
m_cutItemsCache()
{
- connect(model->dirLister(), SIGNAL(newItems(const KFileItemList&)),
+ m_dolphinModel = static_cast<DolphinModel*>(m_proxyModel->sourceModel());
+ connect(m_dolphinModel->dirLister(), SIGNAL(newItems(const KFileItemList&)),
this, SLOT(generatePreviews(const KFileItemList&)));
QClipboard* clipboard = QApplication::clipboard();
return;
}
- KIO::PreviewJob* job = KIO::filePreview(items, 128);
+ const QRect visibleArea = m_view->viewport()->rect();
+
+ // Order the items in a way that the preview for the visible items
+ // is generated first, as this improves the feeled performance a lot.
+ KFileItemList orderedItems;
+ foreach (KFileItem item, items) {
+ const QModelIndex dirIndex = m_dolphinModel->indexForItem(item);
+ const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+ const QRect itemRect = m_view->visualRect(proxyIndex);
+ if (itemRect.intersects(visibleArea)) {
+ orderedItems.insert(0, item);
+ } else {
+ orderedItems.append(item);
+ }
+ }
+
+ KIO::PreviewJob* job = KIO::filePreview(orderedItems, 128);
connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
this, SLOT(replaceIcon(const KFileItem&, const QPixmap&)));
connect(job, SIGNAL(finished(KJob*)),
}
}
-
void IconManager::slotPreviewJobFinished(KJob* job)
{
const int index = m_previewJobs.indexOf(job);
#ifndef ICONMANAGER_H
#define ICONMANAGER_H
+#include <kfileitem.h>
#include <kurl.h>
#include <QList>
#include <QPixmap>
class DolphinModel;
-class KFileItem;
-class KFileItemList;
+class DolphinSortFilterProxyModel;
class KJob;
+class QAbstractItemView;
/**
* @brief Manages the icon state of a directory model.
Q_OBJECT
public:
- IconManager(QObject* parent, DolphinModel* model);
+ IconManager(QAbstractItemView* parent, DolphinSortFilterProxyModel* model);
virtual ~IconManager();
void setShowPreview(bool show);
bool showPreview() const;
QPixmap pixmap;
};
- bool m_showPreview;
- QList<KJob*> m_previewJobs;
- DolphinModel* m_dolphinModel;
+ bool m_showPreview;
- QList<CutItem> m_cutItemsCache;
+ QAbstractItemView* m_view;
+ QList<KJob*> m_previewJobs;
+ DolphinModel* m_dolphinModel;
+ DolphinSortFilterProxyModel* m_proxyModel;
+
+ QList<CutItem> m_cutItemsCache;
};
inline bool IconManager::showPreview() const