Class sh::tools::ThumbnailManager

class sh::tools::ThumbnailManager : public QObject, public sh::base::Singleton

Creates thumbnail images for filesystem nodes.

This is a cached source.

Public Functions

void requestThumbnail(std::shared_ptr<sh::filesystem::FilesystemNode> node, int width, int height, std::function<void(QIcon)> callback = 0)

Requests a thumbnail in a given size for a given node.

Parameters
  • callback: Called when the thumbnail is ready.

bool getThumbnail(std::shared_ptr<sh::filesystem::FilesystemNode> node, int width, int height, QIcon *result, bool *outdated = 0, bool *refreshRequested = 0)

Returns a thumbnail in a given size for a given node from the current cache.

void invalidateCache()

Invalidates the thumbnail cache.

void addThumbnailProvider(int index, std::shared_ptr<ThumbnailProvider> provider)

Adds a thumbnail provider.

void doInitialize()

Executes singleton initialization.

void shutdown()

Shutdown down this singleton.

bool isAlive()

Returns if this singleton is alive (true until its shutdown begins).

Signals

void thumbnailAvailable(std::shared_ptr<sh::filesystem::FilesystemNode> node)

Emitted when a new thumbnail is available.

Public Static Attributes

const int REGISTER_THUMBNAILPROVIDER_INDEX_CORE = 1000000

Base value for display indexes of core (i.e. very important) thumbnail providers.

Used in ThumbnailProvider::addThumbnailProvider.

const int REGISTER_THUMBNAILPROVIDER_INDEX_NORMAL = 2000000

Base value for display indexes of thumbnail providers with normal importance.

Used in ThumbnailProvider::addThumbnailProvider.

const int REGISTER_THUMBNAILPROVIDER_INDEX_EXOTIC = 3000000

Base value for display indexes of exotic thumbnail providers.

Used in ThumbnailProvider::addThumbnailProvider.

const int REGISTER_THUMBNAILPROVIDER_INDEX_FALLBACK = 4000000

Base value for display indexes of fallback thumbnail providers (those who try to get something when everything else failed).

Used in ThumbnailProvider::addThumbnailProvider.

Private Functions

ThumbnailManager()
void worker()
void _enforce_capacity()

Private Members

QHash<sh::filesystem::FilesystemNode*, Thumbnail*> thumbnails
QMutex thumbnailslock
QList<ThumbnailRequest> requestQueue
int maxworkers
int runningworkers
QMutex workermutex
int capacity
qint64 _curr_accessTime = 0
QHash<int, std::shared_ptr<ThumbnailProvider>> _thumbnailProviderMap
QList<std::shared_ptr<ThumbnailProvider>> _thumbnailProviders
QMutex _thumbnailProvidersMutex
class Thumbnail

Public Functions

Thumbnail(QIcon icon, qint64 validUntil, qint64 accessTime, std::weak_ptr<sh::filesystem::FilesystemNode> node, int width, int height)

Public Members

QIcon icon
qint64 validUntil
qint64 accessTime
bool refreshRequested
std::weak_ptr<sh::filesystem::FilesystemNode> node
int width
int height
class ThumbnailRequest

Public Functions

ThumbnailRequest(std::weak_ptr<sh::filesystem::FilesystemNode> node, int width, int height, QList<std::function<void(QIcon)>> callbacks)
bool operator==(ThumbnailRequest const &b)

Public Members

std::weak_ptr<sh::filesystem::FilesystemNode> node
int width
int height
QList<std::function<void(QIcon)>> callbacks
class ThumbnailSortStruct

Public Functions

ThumbnailSortStruct(sh::filesystem::FilesystemNode *node, qint64 accessTime)

Public Members

sh::filesystem::FilesystemNode *node
qint64 accessTime