Namespace sh::tools

namespace sh::tools

Auxiliary stuff.

class AtomicCounter
#include <atomiccounter.h>

Internal tool for reference counting.

Public Functions

AtomicCounter()
int value()
std::shared_ptr<AtomicCounter::Increment> increment()
int doIncValue()
int doDecValue()

Private Members

int _value = 0
QMutex _mutex
class Increment
#include <atomiccounter.h>

Public Functions

Increment(AtomicCounter *ac)
~Increment()

Private Members

AtomicCounter *_ac

Friends

friend class AtomicCounter
class Benchmarking : public QObject, public sh::base::Singleton
#include <benchmarking.h>

Tools for performance measurements.

Public Types

typedef QPair<QString, qint64> BenchmarkFrame

A pair of a benchmark keyname and a duration value.

Public Functions

Benchmarking()
void shutdown()

Shutdown down this singleton.

bool isAlive()

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

class Bookmark
#include <bookmarkmanager.h>

A bookmark.

Public Functions

Bookmark(QString id, QStringList folder, QString label, std::shared_ptr<const sh::filesystem::Eurl> eurl, QString tags)

Constructed only by the infrastructure and made available otherwise.

QString id()

The bookmark id (used in some methods of sh::tools::BookmarkManager).

QList<QString> folder()

The bookmark folder (the user interface calls it ‘Collections’).

QString label()

The bookmark label.

std::shared_ptr<const sh::filesystem::Eurl> eurl()

The location this bookmark points to.

QString tags()

Internal information for bookkeeping.

Can be used by external code for keeping track of dynamically created bookmarks.

Private Members

QString _id
QStringList _folder
QString _label
std::shared_ptr<const sh::filesystem::Eurl> _eurl
QString _tags
class BookmarkManager : public QObject, public sh::base::Singleton
#include <bookmarkmanager.h>

The bookmark manager.

Use it for getting or modifying bookmarks.

Public Functions

QList<std::shared_ptr<sh::tools::Bookmark>> getBookmarks()

Returns a list of all stored bookmarks.

bool hasBookmarks()

Checks if any bookmarks exist.

QString addBookmark(QList<QString> folder, QString label, std::shared_ptr<const sh::filesystem::Eurl> eurl, QString tags = QString())

Adds a new bookmark.

Return

The id of the new bookmark.

void removeBookmark(QString id)

Removes a bookmarks.

void changeBookmark(QString id, QString label, std::shared_ptr<const sh::filesystem::Eurl> eurl)

Changes data of a bookmark.

void changeBookmarkTags(QString id, QString tags)

Changes the tags of a bookmark.

void moveBookmarkUp(QString id)

Moves a bookmark up within its folder.

void moveBookmarkDown(QString id)

Moves a bookmark down within its folder.

void moveBookmarkToFolder(QString id, QList<QString> folder)

Changes to folder of a bookmark.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Signals

void changed()

Private Functions

BookmarkManager()
void moveBookmark(QString id, int direction)
void _changeBookmark(QString id, std::function<QString(std::shared_ptr<Bookmark>)> label, std::function<std::shared_ptr<const sh::filesystem::Eurl>(std::shared_ptr<Bookmark>)> eurl, std::function<QList<QString>(std::shared_ptr<Bookmark>)> folder, std::function<QString(std::shared_ptr<Bookmark>)> tags)
void readBookmarks()
void writeBookmarks()

Private Members

std::shared_ptr<sh::configuration::ConfigurationValue> cfgvalBookmarks
QList<std::shared_ptr<Bookmark>> _bookmarks
QMutex _bookmarksmutex
class DataExchange : public QObject, public sh::base::Singleton
#include <dataexchange.h>

Clipboard and DnD related tools.

Public Types

enum DataExchangeType

A kind of data exchange movement.

Values:

enumerator COPY
enumerator MOVE

Public Functions

bool containsFileEntries(const QMimeData*)

Checks if a QMimeData contains any file entries we understand.

QMimeData *getMimeDataFromFilesystemNodes(QList<std::shared_ptr<sh::filesystem::FilesystemNode>>, DataExchangeType type)

Returns a new QMimeData for a list of filesystem nodes and an exchange type.

std::shared_ptr<sh::actions::AbstractActionItem> createCopyAction(const QMimeData *src, std::shared_ptr<const sh::filesystem::Eurl> dest)

Returns a copy action for a source by QMimeData and a destination eurl.

std::shared_ptr<sh::actions::AbstractActionItem> createMoveAction(const QMimeData *src, std::shared_ptr<const sh::filesystem::Eurl> dest)

Returns a move action for a source by QMimeData and a destination eurl.

std::shared_ptr<sh::actions::AbstractActionItem> createPasteAction(const QMimeData *src, std::shared_ptr<const sh::filesystem::Eurl> dest)

Returns a paste action for a source by QMimeData and a destination eurl (copy or move by QMimeData).

QList<std::shared_ptr<const sh::filesystem::Eurl>> getSources(const QMimeData *src, bool *isCut = 0)

Returns a list of eurls (and if it is a cut/move exchange) from the QMimeData.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Public Static Attributes

QString FilelistTypeShallot = "x-special/shallot-copied-files"
QString FilelistTypeGnome = "x-special/gnome-copied-files"
QString FilelistTypeUrilist = "text/uri-list"
QString FilelistTypePlaintext = "text/plain"

Private Functions

DataExchange()

Private Static Attributes

QString linebreak = "\n"
template<class T>
class HistoryTracker
#include <historytracker.h>

A data structure for tracking a history of data.

It is a templated container It is typically used for tracking the directory history (used by sh::actions::common::ActionHistoryNavigate, et al).

Public Functions

HistoryTracker()
void visitValue(T v)
int count()
QList<HistoryEntry> forwardList()
QList<HistoryEntry> backwardList()
void revisitValue(int idx)

Public Members

const int HISTORY_SIZE = 10

Private Members

QList<T> _items
int _current = -1
class HistoryEntry
#include <historytracker.h>

Public Functions

HistoryEntry(int i, T v)
int index()
T value()

Private Members

int _index
T _value
class Jsonable
#include <misc.h>

An interface for objects which can return a json representation as QJsonObject.

Subclassed by sh::ui::web::WebDialog, sh::ui::web::WebFilePropertyDialog::WebFilePropertyDialogTabActionsView, sh::ui::web::WebFilePropertyDialog::WebFilePropertyDialogTabIconTextBannerView, sh::ui::web::WebFilePropertyDialog::WebFilePropertyDialogTabTableView, sh::ui::web::WebFilePropertyDialog::WebFilePropertyDialogTabTextView

Public Functions

QJsonObject toJson() = 0

Returns the json respesentation as QJsonObject.

class LocalFile : public QFile
#include <datastream.h>

A QFile (and a QIODevice) for local file access.

It also stores the information whether this is a temporary location or the permanent one.

Public Functions

LocalFile(QString &file, bool isTemp = false)
bool isTemp()

Private Members

bool _istemp
class LocalFilesystemWatcher : public QObject, public sh::base::Singleton
#include <localfilesystemwatcher.h>

Used for watching parts of the local filesystem.

Depending on the compile flags and your system, this functionality might not be available. If so, the methods are no-ops.

Public Functions

qint64 addFile(QString path)

Watches one more file.

See also removeFile().

void removeFile(qint64 id)

Stops watching a file (by the return value of addFile()).

qint64 addDirectory(QString path)

Watches one more directory.

See also removeDirectory().

void removeDirectory(qint64 id)

Stops watching a directory (by the return value of addDirectory()).

~LocalFilesystemWatcher()
void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Signals

void elementModified(QString name, QList<qint64> ids)
void elementDeleted(QString name, QList<qint64> ids)
void elementCreated(QString name, QList<qint64> ids)

Private Functions

LocalFilesystemWatcher()
void emitElementModified(QString name, QList<qint64> ids)
void emitElementDeleted(QString name, QList<qint64> ids)
void emitElementCreated(QString name, QList<qint64> ids)

Private Members

InotifyThread *inotifyThread
QMutex inotifymutex
QHash<int, QList<qint64>> inotifywd2ids
QHash<qint64, int> id2inotifywd
QHash<qint64, QString> id2path
qint64 nextEid = 0
QMutex inotifythreadmutex
QWaitCondition inotifythreadmutexwait

Friends

friend class InotifyThread
class InotifyThread : public QThread

Public Functions

InotifyThread(LocalFilesystemWatcher *watcher)

Friends

friend class LocalFilesystemWatcher
class LocalFilesystemWatcherConnector : public QObject, public sh::base::Singleton
#include <localfilesystemwatcherconnector.h>

Observes the list of file views via VisibleViews and controls LocalFilesystemWatcher with that for observing the filesystem for changes.

Public Functions

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Private Functions

LocalFilesystemWatcherConnector()
QList<QPair<std::shared_ptr<sh::filesystem::FilesystemNode>, sh::filesystemhandlers::LocalFilesystemHandler*>> getAllLocalParts(std::shared_ptr<filesystem::FilesystemNode> node)

Private Members

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QList<qint64>> dir2watcherids
QHash<qint64, std::shared_ptr<const sh::filesystem::Eurl>> watcherid2dir
class Misc
#include <misc.h>

Public Static Functions

QByteArray iconToPngByteArray(QIcon icon, int sizeInPt)

Computes a png representation for an icon.

QByteArray iconToBase64SrcEncoding(QIcon icon, int sizeInPt)

Computes a html-compatible ‘data:image/png;base64,…’ png representation for an icon.

QByteArray hash(QStringList data)

Hashes string data in a cryptographical way (with a salt).

Use with compareHash().

QByteArray hashUnsalted(QStringList data)

Hashes string data in a cryptographical way without a salt.

Use with compareHash() or just compare strings.

bool compareHash(QByteArray hash, QStringList data)

Check if a hash is matching to given string data.

QByteArray qjsonToJson(QJsonObject o)

Returns a json string for a QJsonObject, QJsonValue or QJsonArray.

QByteArray qjsonToJson(QJsonValue o)
QByteArray qjsonToJson(QJsonArray a)
QByteArray qmapToJson(QVariantMap m)

Returns a json string for a QVariantMap.

QByteArray jsonableToJson(Jsonable *a)

Returns a json string from a Jsonable.

QByteArray randomBytes(int length = 32)

Returns a random byte array.

QByteArray generateUniqueHash()

Returns a (mostly) random generated unique hash.

void makeHttpRequest(QUrl url, QByteArray *responseBody = nullptr, QString *mimeType = nullptr, int *httpStatus = nullptr)

Makes an http request (as a client).

httpStatus can return 0 for network errors and similar.

Private Functions

Misc()

Private Static Functions

QByteArray _hash(QStringList data, bool salted, QByteArray _withSalt)

Private Static Attributes

QByteArray _jundefined
QNetworkAccessManager _qnetwork
class OperationsCache : public QObject, public sh::base::Singleton
#include <operationscache.h>

A cached factory for readonly sh::filesystem::Operation instances.

You can use it for fetching an sh::filesystem::Operation for a certain sh::filesystem::Eurl. Two restrictions apply:

  • Data might be slightly outdated.

  • Just for read-only access.

Public Functions

std::shared_ptr<sh::filesystem::Operation> getOperationForContainer(std::shared_ptr<const sh::filesystem::Eurl> container)

Returns a cached sh::filesystem::Operation for a container (by eurl).

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Private Functions

OperationsCache()

Private Members

QHash<std::shared_ptr<const sh::filesystem::Eurl>, std::shared_ptr<sh::filesystem::Operation>> cache
QMutex cachemutex
class ReadDataDevice : public QIODevice
#include <datastream.h>

A QIODevice implementation, acting as an abstract base class for other subclasses.

The provided interface is not as generic but easier than the original one for many easier tasks.

Subclassed by sh::scripting::api::ApiReadDataDevice

Public Functions

ReadDataDevice()
QByteArray getdata() = 0

This method returns the next available chunk of data. It may return empty arrays whenever temporarily no data is available. Returning a null array (with QByteArray::isNull()==true) marks the end of the stream. .

Private Members

QByteArray current
int currentlen = 0
int currentconsumed = 0
class ThumbnailManager : public QObject, public sh::base::Singleton
#include <thumbnailmanager.h>

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
class ThumbnailProvider
#include <thumbnailmanager.h>

Subclassed by sh::scripting::api::ApiThumbnailProvider, sh::tools::thumbnailproviders::DefaultImageThumbnailProvider, sh::tools::thumbnailproviders::FfmpegVideoThumbnailProvider, sh::tools::thumbnailproviders::ImageMagickPdfThumbnailProvider, sh::tools::thumbnailproviders::PlaintextThumbnailProvider

Public Functions

void getThumbnail(sh::filesystem::Operation *operation, std::shared_ptr<sh::filesystem::FilesystemNode> node, QString contentType, int width, int height, QIcon *icon) = 0
class UserDirLock
#include <userdirlock.h>

Locks the Shallot user directory during exclusive usage.

This lock is rather heavy-weight and should be used only if necessary!

Public Functions

UserDirLock()

Is intended to be directly constructed from everywhere.

~UserDirLock()

Private Members

bool dounlock
QString slockpref
QString slockfile

Private Static Attributes

QThread *currentThread = 0
QMutex mutex
class VisibleViews : public sh::base::Singleton
#include <visibleviews.h>

Used for keeping track of which fileviews show which directories.

Whenever the view goes to other directories, this manager gets notified and redirects the notification to some other parts of the program.

Public Functions

std::shared_ptr<QObject> viewEnteredDirectory(std::shared_ptr<sh::filesystem::FilesystemNode> dir)

Called when a view enters the given directory node. .

void registerOnEnteredHandlers(std::function<void(std::shared_ptr<sh::filesystem::FilesystemNode> dir)> handler)

Registers a function to be called whenever the view just entered the given directory node.

void registerOnLeftHandlers(std::function<void(std::shared_ptr<sh::filesystem::FilesystemNode> dir)> handler)

Registers a function to be called whenever the view just left the given directory node.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Private Functions

VisibleViews()

Private Members

QHash<std::shared_ptr<sh::filesystem::FilesystemNode>, int> visibleDirs
QList<std::function<void(std::shared_ptr<sh::filesystem::FilesystemNode>)>> onenteredhandlers
QList<std::function<void(std::shared_ptr<sh::filesystem::FilesystemNode>)>> onlefthandlers
namespace accounts

Account and password storage.

See sh::tools::accounts::AccountsManager for more.

class AbstractAccountsProvider
#include <abstractaccountsprovider.h>

Abstract base class for accounts provider.

Implement this class (and register an instance of it) in order to add support for something like a password/account manager.

Subclassed by sh::tools::accounts::FallbackAccountsProvider, sh::tools::accounts::LibsecretAccountsProvider

Public Functions

AbstractAccountsProvider()
~AbstractAccountsProvider()
void findAccounts(std::shared_ptr<Account> pattern, QList<std::shared_ptr<Account>> &result) = 0

Finds account info by a given pattern.

bool storeAccount(std::shared_ptr<Account> account) = 0

Stores account infos.

class Account
#include <accountsmanager.h>

Account data (for accessing network drives).

Public Functions

Account() = default
Account(const Account &other) = default

Public Members

QString username
QString domain
QString server
int serverport = -1
QString path
QString protocol
QString authtype
QByteArray authinfo
class AccountsManager : public sh::base::Singleton
#include <accountsmanager.h>

Storage for account data (for accessing network drives).

Public Functions

QList<std::shared_ptr<Account>> findAccounts(std::shared_ptr<Account> pattern)

Finds account infos by a given pattern.

void storeAccount(std::shared_ptr<Account> account)

Stores account infos.

void registerProvider(std::shared_ptr<AbstractAccountsProvider> provider)

Registers a new accounts provider.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Private Functions

AccountsManager()

Private Members

QList<std::shared_ptr<AbstractAccountsProvider>> accountsproviders
QMutex mutex
class FallbackAccountsProvider : public sh::tools::accounts::AbstractAccountsProvider
#include <fallbackaccountsprovider.h>

A fallback accounts provider which at least stores user names (i.e. no passwords) locally on disk.

Public Functions

FallbackAccountsProvider()
void findAccounts(std::shared_ptr<Account> pattern, QList<std::shared_ptr<Account>> &result)

Finds account info by a given pattern.

bool storeAccount(std::shared_ptr<Account> account)

Stores account infos.

Public Static Functions

void doInitialize()
void doShutdown()

Private Functions

QList<std::shared_ptr<Account>> _find_rem_account_helper(std::shared_ptr<Account> pattern, bool remove)

Private Members

QString accountsdir
class LibsecretAccountsProvider : public sh::tools::accounts::AbstractAccountsProvider
#include <libsecretaccountsprovider.h>

An accounts provider based on gnome-keyring.

Public Functions

LibsecretAccountsProvider()
void findAccounts(std::shared_ptr<Account> pattern, QList<std::shared_ptr<Account>> &result)

Finds account info by a given pattern.

bool storeAccount(std::shared_ptr<Account> account)

Stores account infos.

Public Static Functions

void doInitialize()
void doShutdown()

Private Members

QByteArray sauthtype = QString("authtype").toUtf8()
QByteArray sdomain = QString("domain").toUtf8()
QByteArray spath = QString("object").toUtf8()
QByteArray sprotocol = QString("protocol").toUtf8()
QByteArray sserver = QString("server").toUtf8()
QByteArray sserverport = QString("port").toUtf8()
QByteArray susername = QString("user").toUtf8()
namespace filetypes

Tools for determining a file’s type (pdf, image, mp3, et al) and ways how to deal with that.

See sh::tools::filetypes::FileTypeManager for more.

class FileTypeManager : public QObject, public sh::base::Singleton
#include <filetypemanager.h>

Utilities for dealing with file types.

It can determine the type of a file (png, plaintext, html, …), it can provide information about how to open them with an external program, and more.

For most tasks it uses a pluggable interface. Actual implementations of strategies for those tasks reside in separate classes in this namespace.

Public Functions

QString determineMimetype(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl)

Determines the mimetype for one file.

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items)

Determines the mimetypes for a list of files.

QList<std::shared_ptr<OpenMethod>> getOpenMethods(QString mimetype, QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes)

Determines how to open a file with a given mimetype with an external program.

QList<std::shared_ptr<OpenMethod>> getAllOpenMethods()

Returns a list of all known infos how to open a file external programs.

This has roughly one entry for each installed program on the user’s system, which can graphically open files.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Private Functions

FileTypeManager(QObject *parent = 0)

Private Members

QList<std::shared_ptr<MimetypeDeterminationStrategy>> _mimetypeDeterminationMethods
QList<std::shared_ptr<OpenMethodDeterminationStrategy>> _openMethodDeterminationMethods
QList<std::shared_ptr<MimetypeInformationRetrievalStrategy>> _mimetypeInformationRetrievalMethods
QMutex _mutex
class MimetypeDeterminationStrategy
#include <filetypemanager.h>

Abstract base class for a mimetype determination strategy.

Subclassed by sh::tools::filetypes::FreedesktopOrgToolsMimetypeDeterminationStrategy, sh::tools::filetypes::SuffixListMimetypeDeterminationStrategy, sh::tools::filetypes::UnixFileToolMimetypeDeterminationStrategy

Public Functions

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items) = 0
~MimetypeDeterminationStrategy()
class MimetypeInformationRetrievalStrategy
#include <filetypemanager.h>

Abstract base class for mimetype information retrieval strategy.

Subclassed by sh::tools::filetypes::FreeDesktopOrgMimetypeInformationRetrievalStrategy

Public Functions

QStringList getMimetypeSubclasses(QString mimetype)
~MimetypeInformationRetrievalStrategy()
class OpenMethodDeterminationStrategy
#include <filetypemanager.h>

Abstract base class for a ‘open method’ determination strategy.

Subclassed by sh::tools::filetypes::FreedesktopOrgToolsOpenMethodDeterminationStrategy, sh::tools::filetypes::UserDefinedOpenMethodDeterminationStrategy

Public Functions

QList<std::shared_ptr<OpenMethod>> getOpenMethods(QString mimetype, QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0
~OpenMethodDeterminationStrategy()
class FreeDesktopOrgMimetypeInformationRetrievalStrategy : public sh::tools::filetypes::FileTypeManager::MimetypeInformationRetrievalStrategy
#include <freedesktoporgmimetypeinformationretrievalstrategy.h>

Tries to determine some mimetype information with the freedesktop.org specs.

Public Functions

FreeDesktopOrgMimetypeInformationRetrievalStrategy()
QStringList getMimetypeSubclasses(QString mimetype)

Private Members

QHash<QString, QStringList> _mimeSubclassOf
QMutex _mutex
QWaitCondition _cond_inited
bool _inited = false
class MimetypeInfo : public QXmlDefaultHandler

Public Functions

MimetypeInfo() = default
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)

Public Members

QStringList subClassOf
class FreedesktopOrgToolsMimetypeDeterminationStrategy : public sh::tools::filetypes::FileTypeManager::MimetypeDeterminationStrategy
#include <freedesktoporgtoolsmimetypedeterminationmethod.h>

Tries to determine a file’s mimetype with the freedesktop.org tools.

Public Functions

FreedesktopOrgToolsMimetypeDeterminationStrategy(sh::tools::filetypes::FileTypeManager *manager)
QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items)

Private Members

QMutex _mutex
QString _pathToFileTool
const QRegularExpression _reMimetype

Private Static Attributes

std::shared_ptr<sh::configuration::ConfigurationValue> cfgvalXdgmimePath = sh::configuration::ConfigurationManager::instance()->registerConfigValue("sh::tools::filetypes::FreedesktopOrgToolsMimetypeDeterminationStrategy.XdgmimePath", "/usr/bin/xdg-mime", sh::configuration::ConfigurationValue::valueTypeLocalFilePath(), QObject::tr("Path to the 'xdg-mime' tool"), sh::configuration::ConfigurationCategory::CategoryExternalTools, QObject::tr("This tool is possibly used for file type detection."))
class FreedesktopOrgToolsOpenMethodDeterminationStrategy : public sh::tools::filetypes::FileTypeManager::OpenMethodDeterminationStrategy
#include <freedesktoporgtoolsopenmethoddeterminationmethod.h>

Tries to determine a ‘open method’ for a file with the freedesktop.org tools.

Public Functions

FreedesktopOrgToolsOpenMethodDeterminationStrategy()
~FreedesktopOrgToolsOpenMethodDeterminationStrategy()
QList<std::shared_ptr<sh::tools::filetypes::OpenMethod>> getOpenMethods(QString mimetype, QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes)

Private Functions

QString _parseValue(QStringList content, QString key)
void _parseExecLine(QString execline, QString *command, QStringList *arguments)
QString _escapeExecLineToken(QString s)

Private Members

QMultiMap<QString, ApplicationEntry*> _mimetype2applicationEntry
QMutex _mutex
QWaitCondition _cond_inited
bool _inited = false
struct ApplicationEntry

Public Members

QString name
QStringList mimetypes
QString command
QStringList commandargs
QIcon icon
bool hidden
struct OpenMethod
#include <filetypemanager.h>

Commandline and infos for opening a file with an external program.

Public Functions

OpenMethod(QString name, QString command, QStringList arguments, QIcon icon = QIcon(), int precedence = 0)

Public Members

const QString name
const QString command
const QStringList arguments
const QIcon icon
const int precedence
class SuffixListMimetypeDeterminationStrategy : public sh::tools::filetypes::FileTypeManager::MimetypeDeterminationStrategy
#include <suffixlistmimetypedeterminationmethod.h>

Tries to determine a file’s mimetype with an internal lookup table of file extensions.

Public Functions

SuffixListMimetypeDeterminationStrategy()
QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items)

Private Members

QHash<QString, QString> _suffixToMimetype
QMutex _mutex
class UnixFileToolMimetypeDeterminationStrategy : public sh::tools::filetypes::FileTypeManager::MimetypeDeterminationStrategy
#include <unixfiletoolmimetypedeterminationmethod.h>

Tries to determine a file’s mimetype with the unix file tool.

Public Functions

UnixFileToolMimetypeDeterminationStrategy(sh::tools::filetypes::FileTypeManager *manager)
QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items)

Public Static Attributes

std::shared_ptr<sh::configuration::ConfigurationValue> cfgvalFilePath = sh::configuration::ConfigurationManager::instance()->registerConfigValue("sh::tools::filetypes::UnixFileToolMimetypeDeterminationStrategy.FilePath", "/usr/bin/file", sh::configuration::ConfigurationValue::valueTypeLocalFilePath(), QObject::tr("Path to the 'file' tool"), sh::configuration::ConfigurationCategory::CategoryExternalTools, QObject::tr("This tool is possibly used for file type detection."))

Private Members

QString _pathToFileTool
const QRegularExpression _reMimetype
QMutex _mutex
class UserDefinedOpenMethodDeterminationStrategy : public sh::tools::filetypes::FileTypeManager::OpenMethodDeterminationStrategy, public sh::base::Singleton
#include <userdefinedopenmethoddeterminationstrategy.h>

Tries to determine a ‘open method’ for a file by information the user stored before.

Public Functions

QList<std::shared_ptr<sh::tools::filetypes::OpenMethod>> getOpenMethods(QString mimetype, QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) override
void storeCustomOpenMethod(QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes, QString mimetype, std::shared_ptr<sh::tools::filetypes::OpenMethod> m, bool rememberForMimetype, std::shared_ptr<const sh::filesystem::Eurl> rememberForDirectory, bool rememberForFile)

Stores a custom open method.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

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

Private Functions

UserDefinedOpenMethodDeterminationStrategy()

Private Members

QMutex _mutex
namespace thumbnailproviders

Thumbnail providers.

Subclasses of sh::tools::ThumbnailProvider (and possibly some auxiliary stuff). Those classes are used for generating thumbnail pictures for files.

class DefaultImageThumbnailProvider : public sh::tools::ThumbnailProvider
#include <defaultimagethumbnailprovider.h>

Thumbnail provider for images.

Public Functions

DefaultImageThumbnailProvider() = default
void getThumbnail(sh::filesystem::Operation *operation, std::shared_ptr<sh::filesystem::FilesystemNode> node, QString contentType, int width, int height, QIcon *icon) override

Public Static Functions

void doInitialize()
void doShutdown()
class FfmpegVideoThumbnailProvider : public QObject, public sh::tools::ThumbnailProvider
#include <ffmpegvideothumbnailprovider.h>

Thumbnail provider for videos using the ffmpeg tool.

Public Functions

FfmpegVideoThumbnailProvider()
void getThumbnail(sh::filesystem::Operation *operation, std::shared_ptr<sh::filesystem::FilesystemNode> node, QString contentType, int width, int height, QIcon *icon) override

Public Static Functions

void doInitialize()
void doShutdown()

Private Members

QString pathToFfmpegTool
QString pathToFfprobeTool
const QRegularExpression reDuration
QMutex mutexReDuration

Private Static Attributes

std::shared_ptr<sh::configuration::ConfigurationValue> cfgvalFfmpegPath = sh::configuration::ConfigurationManager::instance()->registerConfigValue("sh::tools::thumbnailproviders::FfmpegVideoThumbnailProvider.FfmpegPath", "/usr/bin/ffmpeg", sh::configuration::ConfigurationValue::valueTypeLocalFilePath(), QObject::tr("Path to the 'ffmpeg' tool"), sh::configuration::ConfigurationCategory::CategoryExternalTools, QObject::tr("This tool is possibly used for getting infos about video files."))
class ImageMagickPdfThumbnailProvider : public QObject, public sh::tools::ThumbnailProvider
#include <imagemagickpdfthumbnailprovider.h>

Thumbnail provider for videos using the ffmpeg tool.

Public Functions

ImageMagickPdfThumbnailProvider()
void getThumbnail(sh::filesystem::Operation *operation, std::shared_ptr<sh::filesystem::FilesystemNode> node, QString contentType, int width, int height, QIcon *icon) override

Public Static Functions

void doInitialize()
void doShutdown()

Private Members

QString pathToImagemagickConvertTool

Private Static Attributes

std::shared_ptr<sh::configuration::ConfigurationValue> cfgvalImagemagickConvertPath = sh::configuration::ConfigurationManager::instance()->registerConfigValue("sh::tools::thumbnailproviders::ImageMagickPdfThumbnailProvider.ImagemagickConvertPath", "/usr/bin/convert", sh::configuration::ConfigurationValue::valueTypeLocalFilePath(), QObject::tr("Path to the 'convert' tool of ImageMagick"), sh::configuration::ConfigurationCategory::CategoryExternalTools, QObject::tr("This tool is used for getting thumbnails of some file types."))
class PlaintextThumbnailProvider : public sh::tools::ThumbnailProvider
#include <plaintextthumbnailprovider.h>

Thumbnail provider for plain text.

Public Functions

PlaintextThumbnailProvider()
void getThumbnail(sh::filesystem::Operation *operation, std::shared_ptr<sh::filesystem::FilesystemNode> node, QString contentType, int width, int height, QIcon *icon) override

Public Static Functions

void doInitialize()
void doShutdown()

Private Members

QColor brandingcolor