virtual ~IconManager();
void setShowPreview(bool show);
bool showPreview() const;
+ void updatePreviews();
private slots:
/**
- * Updates the icons of for each item in \a items by making hidden
- * items semitransparent and generating previews. The current preview
- * settings (maximum size, 'Show Preview' menu) are respected.
+ * Generates previews for the items \a items asynchronously.
*/
- void updateIcons(const KFileItemList& items);
+ void generatePreviews(const KFileItemList &items);
/**
- * Replaces the icon of the item \a item by the preview pixmap
- * \a pixmap.
+ * Adds the preview \a pixmap for the item \a item to the preview
+ * queue and starts a timer which will dispatch the preview queue
+ * later.
*/
- void replaceIcon(const KFileItem& item, const QPixmap& pixmap);
+ void addToPreviewQueue(const KFileItem& item, const QPixmap& pixmap);
/**
* Is invoked when the preview job has been finished and
/** Synchronizes the item icon with the clipboard of cut items. */
void updateCutItems();
+ /**
+ * Dispatches the preview queue m_previews block by block within
+ * time slices.
+ */
+ void dispatchPreviewQueue();
+
private:
+ /**
+ * Replaces the icon of the item with the \a url by the preview pixmap
+ * \a pixmap.
+ */
+ void replaceIcon(const KUrl& url, const QPixmap& pixmap);
+
/**
* Returns true, if the item \a item has been cut into
* the clipboard.
/** Applies an item effect to all cut items. */
void applyCutItemEffect();
- /** Applies an item effect to the hidden item \a hiddenItem. */
- void applyHiddenItemEffect(const KFileItem& hiddenItem);
+ /**
+ * Applies a frame around the icon. False is returned if
+ * no frame has been added because the icon is too small.
+ */
+ bool applyImageFrame(QPixmap& icon);
+
+ /**
+ * Resizes the icon to \a maxSize if the icon size does not
+ * fit into the maximum size. The aspect ratio of the icon
+ * is kept.
+ */
+ void limitToSize(QPixmap& icon, const QSize& maxSize);
+
+ /** Kills all ongoing preview jobs. */
+ void killJobs();
private:
/**
- * Remembers the original pixmap for an item before
- * the cut effect is applied.
+ * Remembers the pixmap for an item specified by an URL.
*/
- struct CutItem
+ struct ItemInfo
{
KUrl url;
QPixmap pixmap;
bool m_showPreview;
QAbstractItemView* m_view;
+ QTimer* m_previewTimer;
QList<KJob*> m_previewJobs;
DolphinModel* m_dolphinModel;
DolphinSortFilterProxyModel* m_proxyModel;
- QList<CutItem> m_cutItemsCache;
+ QList<ItemInfo> m_cutItemsCache;
+ QList<ItemInfo> m_previews;
};
inline bool IconManager::showPreview() const