X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/aba4462e0238d6075e8822d56a78372eacfa7d2e..9281664e5b1e492087604264b145b390e8880e81:/src/kitemviews/kfileitemmodelrolesupdater.h diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index a03ab513a..56e28ce72 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -12,8 +12,8 @@ #include +#include "config-dolphin.h" #include -#include #include #include @@ -26,16 +26,17 @@ class QPixmap; class QTimer; class KOverlayIconPlugin; -namespace KIO { - class PreviewJob; +namespace KIO +{ +class PreviewJob; } -#ifdef HAVE_BALOO - namespace Baloo - { - class FileMonitor; - } - #include +#if HAVE_BALOO +namespace Baloo +{ +class FileMonitor; +} +#include #endif /** @@ -82,12 +83,15 @@ class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject Q_OBJECT public: - explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = nullptr); + explicit KFileItemModelRolesUpdater(KFileItemModel *model, QObject *parent = nullptr); ~KFileItemModelRolesUpdater() override; - void setIconSize(const QSize& size); + void setIconSize(const QSize &size); QSize iconSize() const; + void setDevicePixelRatio(qreal devicePixelRatio); + qreal devicePixelRatio() const; + /** * Sets the range of items that are visible currently. The roles * of visible items are resolved first. @@ -123,7 +127,7 @@ public: /** * Sets the roles that should be resolved asynchronously. */ - void setRoles(const QSet& roles); + void setRoles(const QSet &roles); QSet roles() const; /** @@ -131,11 +135,11 @@ public: * Per default all plugins enabled in the KConfigGroup "PreviewSettings" * are used. * - * For a list of available plugins, call KServiceTypeTrader::self()->query("ThumbCreator"). + * For a list of available plugins, call KIO::PreviewJob::availableThumbnailerPlugins(). * * @see enabledPlugins */ - void setEnabledPlugins(const QStringList& list); + void setEnabledPlugins(const QStringList &list); /** * Returns the list of enabled thumbnail plugins. @@ -172,16 +176,17 @@ public: * this method will be called repeatedly with increasing values * for this parameter. */ - void setHoverSequenceState(const QUrl& itemUrl, int seqIdx); + void setHoverSequenceState(const QUrl &itemUrl, int seqIdx); + +Q_SIGNALS: + void previewJobFinished(); // For unit testing private Q_SLOTS: - void slotItemsInserted(const KItemRangeList& itemRanges); - void slotItemsRemoved(const KItemRangeList& itemRanges); - void slotItemsMoved(const KItemRange& itemRange, const QList &movedToIndexes); - void slotItemsChanged(const KItemRangeList& itemRanges, - const QSet& roles); - void slotSortRoleChanged(const QByteArray& current, - const QByteArray& previous); + void slotItemsInserted(const KItemRangeList &itemRanges); + void slotItemsRemoved(const KItemRangeList &itemRanges); + void slotItemsMoved(KItemRange itemRange, const QList &movedToIndexes); + void slotItemsChanged(const KItemRangeList &itemRanges, const QSet &roles); + void slotSortRoleChanged(const QByteArray ¤t, const QByteArray &previous); /** * Is invoked after a preview has been received successfully. @@ -190,7 +195,7 @@ private Q_SLOTS: * * @see startPreviewJob() */ - void slotGotPreview(const KFileItem& item, const QPixmap& pixmap); + void slotGotPreview(const KFileItem &item, const QPixmap &pixmap); /** * Is invoked after generating a preview has failed. @@ -199,7 +204,7 @@ private Q_SLOTS: * * @see startPreviewJob() */ - void slotPreviewFailed(const KFileItem& item); + void slotPreviewFailed(const KFileItem &item); /** * Is invoked when the preview job has been finished. Starts a new preview @@ -215,12 +220,12 @@ private Q_SLOTS: /** * Is invoked after a hover sequence preview has been received successfully. */ - void slotHoverSequenceGotPreview(const KFileItem& item, const QPixmap& pixmap); + void slotHoverSequenceGotPreview(const KFileItem &item, const QPixmap &pixmap); /** * Is invoked after generating a hover sequence preview has failed. */ - void slotHoverSequencePreviewFailed(const KFileItem& item); + void slotHoverSequencePreviewFailed(const KFileItem &item); /** * Is invoked when a hover sequence preview job is finished. May start another @@ -235,7 +240,7 @@ private Q_SLOTS: /** * Is invoked when one of the KOverlayIconPlugin emit the signal that an overlay has changed */ - void slotOverlaysChanged(const QUrl& url, const QStringList&); + void slotOverlaysChanged(const QUrl &url, const QStringList &); /** * Resolves the sort role of the next item in m_pendingSortRole, applies it @@ -258,10 +263,10 @@ private Q_SLOTS: */ void resolveRecentlyChangedItems(); - void applyChangedBalooRoles(const QString& file); - void applyChangedBalooRolesForItem(const KFileItem& file); + void applyChangedBalooRoles(const QString &file); + void applyChangedBalooRolesForItem(const KFileItem &file); - void slotDirectoryContentsCountReceived(const QString& path, int count, long size); + void slotDirectoryContentsCountReceived(const QString &path, int count, long long size); private: /** @@ -291,9 +296,10 @@ private: * Transforms a raw preview image, applying scale and frame. * * @param pixmap A raw preview image from a PreviewJob. + * @param overlays the overlays to add to the pixmap * @return The scaled and decorated preview image. */ - QPixmap transformPreviewPixmap(const QPixmap& pixmap); + QPixmap transformPreviewPixmap(const QPixmap &pixmap); /** * Starts a PreviewJob for loading the next hover sequence image. @@ -318,12 +324,9 @@ private: void applySortProgressToModel(); - enum ResolveHint { - ResolveFast, - ResolveAll - }; + enum ResolveHint { ResolveFast, ResolveAll }; bool applyResolvedRoles(int index, ResolveHint hint); - QHash rolesData(const KFileItem& item); + QHash rolesData(const KFileItem &item, int index); /** * Must be invoked if a property has been changed that affects @@ -337,14 +340,18 @@ private: void trimHoverSequenceLoadedItems(); + void resetSizeData(const int index, const int size = 0); + + void recountDirectoryItems(const QList directories); + private: - enum State { - Idle, - Paused, - ResolvingSortRole, - ResolvingAllRoles, - PreviewJobRunning - }; + QSize cacheSize(); + /** + * enqueue directory size counting for KFileItem item at index + */ + void startDirectorySizeCounting(const KFileItem &item, int index); + + enum State { Idle, Paused, ResolvingSortRole, ResolvingAllRoles, PreviewJobRunning }; State m_state; @@ -369,8 +376,9 @@ private: // previews and other expensive roles are determined again. QSet m_finishedItems; - KFileItemModel* m_model; + KFileItemModel *m_model; QSize m_iconSize; + qreal m_devicePixelRatio; int m_firstVisibleIndex; int m_lastVisibleIndex; int m_maximumVisibleItems; @@ -378,7 +386,6 @@ private: QSet m_resolvableRoles; QStringList m_enabledPlugins; qulonglong m_localFileSizePreviewLimit; - bool m_scanDirectories; // Items for which the sort role still has to be determined. QSet m_pendingSortRoleItems; @@ -391,13 +398,13 @@ private: // A new preview job will be started from them once the first one finishes. KFileItemList m_pendingPreviewItems; - KIO::PreviewJob* m_previewJob; + KIO::PreviewJob *m_previewJob; // Info about the item that the user currently hovers, and the current sequence // index for thumb generation. KFileItem m_hoverSequenceItem; int m_hoverSequenceIndex; - KIO::PreviewJob* m_hoverSequencePreviewJob; + KIO::PreviewJob *m_hoverSequencePreviewJob; int m_hoverSequenceNumSuccessiveFailures; std::list m_hoverSequenceLoadedItems; @@ -406,18 +413,18 @@ private: // 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_recentlyChangedItemsTimer; + QTimer *m_recentlyChangedItemsTimer; QSet m_recentlyChangedItems; // Items which have not been changed repeatedly recently. QSet m_changedItems; - KDirectoryContentsCounter* m_directoryContentsCounter; + KDirectoryContentsCounter *m_directoryContentsCounter; - QList m_overlayIconsPlugin; + QList m_overlayIconsPlugin; -#ifdef HAVE_BALOO - Baloo::FileMonitor* m_balooFileMonitor; +#if HAVE_BALOO + Baloo::FileMonitor *m_balooFileMonitor; Baloo::IndexerConfig m_balooConfig; #endif };