#ifndef KFILEITEMMODELROLESUPDATER_H
#define KFILEITEMMODELROLESUPDATER_H
+#include <config-nepomuk.h>
#include <libdolphin_export.h>
#include <KFileItem>
Q_OBJECT
public:
- KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = 0);
+ explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = 0);
virtual ~KFileItemModelRolesUpdater();
void setIconSize(const QSize& size);
QSet<QByteArray> roles() const;
/**
- * Sets the list of enabled thumbnail plugins.
+ * Sets the list of enabled thumbnail plugins that are used for previews.
* Per default all plugins enabled in the KConfigGroup "PreviewSettings"
* are used.
*
- * Note that this method doesn't cause already generated previews
- * to be regenerated.
- *
* For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator").
*
* @see enabledPlugins
void slotItemsChanged(const KItemRangeList& itemRanges,
const QSet<QByteArray>& roles);
+ /**
+ * Is invoked after a preview has been received successfully.
+ * @see startPreviewJob()
+ */
void slotGotPreview(const KFileItem& item, const QPixmap& pixmap);
+
+ /**
+ * Is invoked after generating a preview has failed.
+ * @see startPreviewJob()
+ */
void slotPreviewFailed(const KFileItem& item);
/**
* Is invoked when the preview job has been finished and
* removes the job from the m_previewJobs list.
+ * @see startPreviewJob()
*/
void slotPreviewJobFinished(KJob* job);
- void resolvePendingRoles();
void resolveNextPendingRoles();
+ /**
+ * Resolves items that have not been resolved yet after the change has been
+ * notified by slotItemsChanged(). Is invoked if the m_changedItemsTimer
+ * exceeds.
+ */
+ void resolveChangedItems();
+
private:
+ /**
+ * Updates the roles for the given item ranges. The roles for the currently
+ * visible items will get updated first.
+ */
+ void startUpdating(const KItemRangeList& itemRanges);
+
+ /**
+ * Creates previews for the items starting from the first item of the
+ * given list.
+ * @see slotGotPreview()
+ * @see slotPreviewFailed()
+ * @see slotPreviewJobFinished()
+ */
void startPreviewJob(const KFileItemList& items);
bool hasPendingRoles() const;
+ void resolvePendingRoles();
void resetPendingRoles();
- void triggerPendingRolesResolving(int count);
void sortAndResolveAllRoles();
void sortAndResolvePendingRoles();
KFileItemList sortedItems(const QSet<KFileItem>& items) const;
- static int subDirectoriesCount(const QString& path);
+ /**
+ * @return The number of items of the path \a path.
+ */
+ int subItemsCount(const QString& path) const;
private:
// Property for setPaused()/isPaused().
QSet<KFileItem> m_pendingInvisibleItems;
QList<KJob*> m_previewJobs;
- QTimer* m_resolvePendingRolesTimer;
+ // When downloading or copying large files, the slot slotItemsChanged()
+ // will be called periodically within a quite short delay. To prevent
+ // a high CPU-load by generating e.g. previews for each notification, the update
+ // will be postponed until no file change has been done within a longer period
+ // of time.
+ QTimer* m_changedItemsTimer;
+ QSet<KFileItem> m_changedItems;
+
+#ifdef HAVE_NEPOMUK
+ // True if roles must be resolved with the help of Nepomuk inside
+ // KFileItemModelRolesUpdater::rolesData().
+ bool m_resolveNepomukRoles;
+#endif
+
};
#endif