X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/bd88f237b1cb87eadc69ca3925b9bd237cd2ff43..0f0d14d4c236eee7f1df4f0c21c60f6b784dab75:/src/kitemviews/kfileitemmodelrolesupdater.h diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index aa47f1756..b881b73e4 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -20,37 +20,33 @@ #ifndef KFILEITEMMODELROLESUPDATER_H #define KFILEITEMMODELROLESUPDATER_H -#include +#include "dolphin_export.h" +#include "kitemviews/kitemmodelbase.h" #include -#include - -#include +#include #include #include #include #include -class KDirWatch; +class KDirectoryContentsCounter; class KFileItemModel; -class KJob; class QPixmap; class QTimer; +class KOverlayIconPlugin; -#ifdef HAVE_NEPOMUK - namespace Nepomuk2 - { - class ResourceWatcher; - class Resource; - } -#else - // Required for the slot applyChangedNepomukRoles() that - // cannot be ifdefined due to moc. - namespace Nepomuk2 +namespace KIO { + class PreviewJob; +} + +#ifdef HAVE_BALOO + namespace Baloo { - class Resource; + class FileMonitor; } + #include #endif /** @@ -92,13 +88,13 @@ class QTimer; * 3. Finally, the entire process is repeated for any items that might have * changed in the mean time. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemModelRolesUpdater : public QObject +class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject { Q_OBJECT public: - explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = 0); - virtual ~KFileItemModelRolesUpdater(); + explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = nullptr); + ~KFileItemModelRolesUpdater() override; void setIconSize(const QSize& size); QSize iconSize() const; @@ -158,10 +154,21 @@ public: */ QStringList enabledPlugins() const; + /** + * Sets the maximum file size of local files for which + * previews will be generated (if enabled). A value of 0 + * indicates no file size limit. + * Per default the value from KConfigGroup "PreviewSettings" + * MaximumSize is used, 0 otherwise. + * @param size + */ + void setLocalFileSizePreviewLimit(qlonglong size); + qlonglong localFileSizePreviewLimit() const; + private slots: void slotItemsInserted(const KItemRangeList& itemRanges); void slotItemsRemoved(const KItemRangeList& itemRanges); - void slotItemsMoved(const KItemRange& itemRange, QList movedToIndexes); + void slotItemsMoved(const KItemRange& itemRange, const QList &movedToIndexes); void slotItemsChanged(const KItemRangeList& itemRanges, const QSet& roles); void slotSortRoleChanged(const QByteArray& current, @@ -187,6 +194,11 @@ private slots: */ void slotPreviewJobFinished(); + /** + * Is invoked when one of the KOverlayIconPlugin emit the signal that an overlay has changed + */ + void slotOverlaysChanged(const QUrl& url, const QStringList&); + /** * Resolves the sort role of the next item in m_pendingSortRole, applies it * to the model, and invokes itself if there are any pending items left. If @@ -208,14 +220,10 @@ private slots: */ void resolveRecentlyChangedItems(); - void applyChangedNepomukRoles(const Nepomuk2::Resource& resource); + void applyChangedBalooRoles(const QString& file); + void applyChangedBalooRolesForItem(const KFileItem& file); - /** - * Is invoked if a directory watched by KDirWatch got dirty. Updates - * the "isExpandable"- and "size"-roles of the item that matches to - * the given path. - */ - void slotDirWatchDirty(const QString& path); + void slotDirectoryContentsCountReceived(const QString& path, int count, long size); private: /** @@ -224,13 +232,22 @@ private: void startUpdating(); /** - * Creates previews for the items starting from the first item of the - * given list. + * Loads the icons for the visible items. After 200 ms, the function + * stops determining mime types and only loads preliminary icons. + * This is a compromise that prevents that + * (a) the GUI is blocked for more than 200 ms, and + * (b) "unknown" icons could be shown in the view. + */ + void updateVisibleIcons(); + + /** + * Creates previews for the items starting from the first item in + * m_pendingPreviewItems. * @see slotGotPreview() * @see slotPreviewFailed() * @see slotPreviewJobFinished() */ - void startPreviewJob(const KFileItemList items); + void startPreviewJob(); /** * Ensures that icons, previews, and other roles are determined for any @@ -249,8 +266,8 @@ private: ResolveFast, ResolveAll }; - bool applyResolvedRoles(const KFileItem& item, ResolveHint hint); - QHash rolesData(const KFileItem& item) const; + bool applyResolvedRoles(int index, ResolveHint hint); + QHash rolesData(const KFileItem& item); /** * @return The number of items of the path \a path. @@ -307,15 +324,11 @@ private: QSet m_roles; QSet m_resolvableRoles; QStringList m_enabledPlugins; + qulonglong m_localFileSizePreviewLimit; // Items for which the sort role still has to be determined. QSet m_pendingSortRoleItems; - // While the sort role is being resolved, we also keep the indexes - // in a sorted list. The reason is that this enables us to determine - // both the sort role and the icon for the visible items first. - QList m_pendingSortRoleIndexes; - // Indexes of items which still have to be handled by // resolveNextPendingRoles(). QList m_pendingIndexes; @@ -324,7 +337,7 @@ private: // A new preview job will be started from them once the first one finishes. KFileItemList m_pendingPreviewItems; - KJob* m_previewJob; + KIO::PreviewJob* m_previewJob; // When downloading or copying large files, the slot slotItemsChanged() // will be called periodically within a quite short delay. To prevent @@ -337,12 +350,13 @@ private: // Items which have not been changed repeatedly recently. QSet m_changedItems; - KDirWatch* m_dirWatcher; - mutable QSet m_watchedDirs; // Required as sadly KDirWatch does not offer a getter method - // to get all watched directories. -#ifdef HAVE_NEPOMUK - Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher; - mutable QHash m_nepomukUriItems; + KDirectoryContentsCounter* m_directoryContentsCounter; + + QList m_overlayIconsPlugin; + +#ifdef HAVE_BALOO + Baloo::FileMonitor* m_balooFileMonitor; + Baloo::IndexerConfig m_balooConfig; #endif };