Namespace sh::filesystem

namespace sh::filesystem

Filesystem model and auxiliary logic.

Enums

enum SizeFormatting

Values:

enumerator SizeFormattingModePrefixes
enumerator SizeFormattingModePlainBytes
enum FilesystemNodeType

Enumeration of types a sh::filesystem::FilesystemNode can have.

Values:

enumerator NONE = 0

No type specified or does not exist.

enumerator File = 1

Usual file.

enumerator FIRSTTYPE = File

The first type (used for generating int ranges).

enumerator Directory

Directory.

enumerator Link

Link.

enumerator Unknown

Unknown.

enumerator LASTPHYSICALTYPE = Unknown

The last physical type, excluding internal magic types (used for generating int ranges).

enumerator SpecialTreeOnlyDirectory

Special kind of directory which behaves differently.

enumerator Invalid

This return type means that the type can’t be determined. It should not occur in typical situations.

enumerator LASTTYPE = SpecialTreeOnlyDirectory

The last type (used for generating int ranges).

class AdhocFilesystemNodeList : public sh::filesystem::FilesystemNodeList
#include <filesystemnodelist.h>

This FilesystemNodeList subclass is used for spontanously fetching a fresh list of node children.

Node additions and removals will not touch the model.

Node instances inside it will be deleted together with this list.

Public Functions

AdhocFilesystemNodeList()

Is intended to be directly constructed from everywhere.

~AdhocFilesystemNodeList()
void addItems(QSet<std::shared_ptr<FilesystemNode>> nodes)
void addItem(std::shared_ptr<FilesystemNode> node)
void removeItems(QSet<std::shared_ptr<FilesystemNode>> nodes)
void removeItem(std::shared_ptr<FilesystemNode> node)
void resetItems(sh::filesystem::FilesystemNodeType type, QSet<std::shared_ptr<FilesystemNode>> nodes)
std::shared_ptr<FilesystemNode> mynode()

Returns the node which owns this children list. The result may be 0 for non model-backed lists.

void addItems(QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Adds items to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

void addItem(std::shared_ptr<sh::filesystem::FilesystemNode> node) = 0

Adds an item to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

void removeItems(QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Removes nodes from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void removeItem(std::shared_ptr<sh::filesystem::FilesystemNode> node) = 0

Removes a node from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void resetItems(sh::filesystem::FilesystemNodeType type, QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Resets the list for a given node type to a given new list of children nodes.

bool contains(std::shared_ptr<FilesystemNode> node)

Checks if this list contains a given node.

const QList<std::shared_ptr<sh::filesystem::FilesystemNode>> *nodes()

Returns the list of nodes currently stored in this instance.

class DetailColumn : public std::enable_shared_from_this<DetailColumn>
#include <detailcolumn.h>

Abstract base class for a detail column (on filesystem nodes).

Those can e.g. be seen in the file list view, but can also be queried internally by other places in code.

It encapsulates the retrieval logic and metadata for one piece of additional information a sh::filesystem::FilesystemNode can have (e.g. the filesize). Retrieving the values is designed to be asynchronous. Each instance represents one column, while the actual logic is implemented in subclasses. For a new detail column, subclass this class and implement at least determineValue.

Subclassed by sh::detailcolumns::DetailColumnCustomAttributes, sh::detailcolumns::DetailColumnDirectSymlinkTarget, sh::detailcolumns::DetailColumnExtendedAttributes, sh::detailcolumns::DetailColumnFilesize, sh::detailcolumns::DetailColumnMimetype, sh::detailcolumns::DetailColumnMtime, sh::detailcolumns::DetailColumnResolvedSymlink, sh::filesystemhandlers::SharcFilesystemHandler::ArchivedSizeDetailColumn, sh::scripting::api::ApiDetailColumn

Public Functions

QString name()

The internal unique name.

QString displayName()

The display name.

bool isValueAvailable(std::shared_ptr<FilesystemNode> node)

Checks if a value for this detail is available for one given node.

QVariant value(std::shared_ptr<FilesystemNode> node, bool ignoreAged = false)

Returns the value for this detail for one given node.

Parameters
  • ignoreAged: If no value should be returned which is older than the last request (not useful for nearly all cases).

QString displayValue(std::shared_ptr<FilesystemNode> node, const sh::filesystem::FilesystemModelFileviewProxy *viewmodel)

Returns the stringified value for this details for one given node considering the configuration of a view.

bool isVisible()

If this detail shall be a visible column in the view.

QVariant requestValue(std::shared_ptr<FilesystemNode> node, sh::filesystem::Operation *op = 0, bool withNodeValues = false, bool withOperationsCache = true)

Requests to determine the value for this detail for one given node. Blocks until the value is available. Get it with the value method afterwards.

bool sort_doTypediff()

If sorting should separate files and directories.

int sort_order(std::shared_ptr<FilesystemNode> n1, std::shared_ptr<FilesystemNode> n2)

The sorting order.

uint displayIndex()

Controls which place this column should get in the user interface.

QVariant computeValue(std::shared_ptr<FilesystemNode> node, sh::filesystem::Operation *op)

Returns a freshly determined value for this column and the given node. It neither asks nor populates any caches or storages.

int defaultWidth()
bool isRightAligned()
~DetailColumn()
void applyValueByEurl(std::shared_ptr<const sh::filesystem::Eurl> eurl, sh::filesystem::Operation *op, QVariant value)

Applies the detail value to a given eurl (without using any caches).

Used for transferring some details when a file transfer occurs.

Optionally implement the one of the applyValueBy… methods and register the instance with sh::filesystem::FilesystemOperation::addTransferrableDetailColumn. For performance reasons, you should decide to implement applyValueByEurl.

void applyValueByNode(std::shared_ptr<FilesystemNode> node, sh::filesystem::Operation *op, QVariant value)

Applies the detail value to a given node (without using any caches).

Used for transferring some details when a file transfer occurs.

Optionally implement the one of the applyValueBy… methods and register the instance with sh::filesystem::FilesystemOperation::addTransferrableDetailColumn. For performance reasons, you should decide to implement applyValueByEurl.

Public Static Functions

QVariant VALUE_UNAVAILABLE()

A special value expressing that the value is not yet available.

void registerKnownDetailColumn(QString name, std::shared_ptr<DetailColumn> column)
std::shared_ptr<DetailColumn> findKnownDetailColumn(QString name)

Public Static Attributes

const uint DISPLAYINDEX_CORE = 10000
const uint DISPLAYINDEX_INTERESTING = 20000
const uint DISPLAYINDEX_EXOTIC = 30000

Private Members

QString _displayName
QString _name
uint _displayIndex
bool _sort_doTypediff
int _defaultWidth
bool _isRightAligned

Private Static Attributes

QMap<QString, std::shared_ptr<DetailColumn>> _knownDetailColumns
QMutex _knownDetailColumnsMutex

Friends

friend class sh::filesystem::FilesystemNode
class Eurl : public std::enable_shared_from_this<Eurl>
#include <eurl.h>

Filesystem paths.

A Extended Uniform Resource Locator is something like a URL.

It is more general since it can also be nested. It is something like zip:/[]//zippedfolder/zippedfile.

You get Eurl instances only from the factory methods. There will never be two instances with the same textual value.

Please note: Instances can be associated with any kind of elements in the filesystem (files, directories, links, …). It might also point to something which does not exist at all. The documentation sometimes explicitly makes a difference between those kinds (files, directories, links, …; often called ‘node type’). But it often uses the term ‘file’ implicitly while meaning all kinds of elements; assuming that e.g. a directory is just a special kind of a file. It should be clear from the particular context which meaning applies.

Public Functions

QString asString() const

Returns the textual value. This is what Eurl.fromString would expect as parameter.

QString hostname() const

Returns the hostname part (from the outer url of this Eurl). Examples: "livingroom-pc" for smb://livingroom-pc/foo/bar/baz. "" for .

QString path() const

Returns the path part (from the outer url of this Eurl). Examples: "/foo/bar/baz" for smb://livingroom-pc/foo/bar/baz. "/foo/bar/baz" for . "/" for .

QString basename() const

Returns the last path segment. This is the text behind the last slash. Examples: "baz" for . "" for .

QString scheme() const

Returns the scheme (from the outer url of this shallot.Eurl). This is what comes before the ://. Example: "file" for .

std::shared_ptr<const Eurl> outerUrl() const

Returns a new Eurl containing only the outer part of this one (strips the embeddings). Example: foobar://host/foo/bar/baz for foobar:/[zip:/[]//d/e]//foo/bar/baz.

std::shared_ptr<const Eurl> outermostInnerEurl() const

Returns a new Eurl containing only the embedding of this one. Example: zip:/[]//d/e for foobar:/[zip:/[]//d/e]//foo/bar/baz.

std::shared_ptr<const Eurl> withAppendedSegment(QString basename) const

Returns a new Eurl from this one with “/basename” appended. The parameter is assumed to be a single path segment.

std::shared_ptr<const Eurl> withAppendedSegments(QString path) const

Returns a new Eurl with path segments “/pa/t/h/” appended. The parameter may contain "/"s for dividing path segments.

std::shared_ptr<const Eurl> root() const

Returns the root Eurl from this one. Example: zip:/[]// for zip:/[]//foo/bar/baz.

std::shared_ptr<const Eurl> enwrapWithOuterUrl(QString scheme, QString hostname, QString path) const

Returns a new Eurl containing this one packed as embedding and new outer parts scheme, hostname and path. Example: scheme:/[]/hostname/p/a/t/h for .

std::shared_ptr<const Eurl> parentSegment() const

Returns the parent Eurl. At first, this traverses path segments. For a root path eurl with embeddings, it returns the embedding. If none are available, it returns 0. Examples: foo://host/foo for foo://host/foo/bar. foo://host/ for foo://host/boo. foo:/[bar://host/goo]/anotherhost/ for foo:/[bar://host/goo]/anotherhost/boo. bar://host/foo for foo:/[bar://host/foo]/host/. 0 for foo://host/.

bool hasInnerUrls() const

Checks if this Eurl has embeddings. Examples: true for foo:/[bar:///foo]/host/. false for foo://host/.

bool outerUrlIsRootDirectory() const

Checks if this Eurl is a root path (with or without embeddings). Examples: true for foo://host/. false for foo://host/a. true for foo:/[bar:///goo]/host/. false for foo:/[bar:///goo]/host/a. true for foo:/[bar:///goo]//. false for foo:/[bar:///goo]//a.

bool hasParentSegment() const

Checks if this Eurl has a parent segment. This indicates if Eurl.parentSegment would return 0.

bool isPrefixOf(std::shared_ptr<const Eurl> longer) const

Checks if this Eurl is a prefix of another one. This is not an equivalent to a string comparison but it checks parent relationships according to Eurl.parentSegment.

Eurl(QString eurlstring)

Constructed only by the infrastructure and made available otherwise.

~Eurl()

Public Static Functions

std::shared_ptr<const Eurl> fromString(QString eurlstring)

Constructs a new Eurl by string (what Eurl.asString would return).

std::shared_ptr<const Eurl> create(QString scheme, QString hostname, QString path)

Constructs a new Eurl by scheme name, hostname and a path.

std::shared_ptr<const Eurl> create(QString scheme, const Eurl *inner, QString hostname, QString path)

Constructs a new Eurl by scheme name, an inner eurl, a hostname and a path.

void filenameCheck(QString filename)

Checks if a name is a valid filename. If not, EurlMisformattedException is thrown.

void doInitialize()
void doShutdown()

Public Static Attributes

const QChar WRAPPER_BEGIN = '['

The character marking the begin of an embedding.

const QChar WRAPPER_END = ']'

The character marking the end of an embedding.

const QString FORBIDDEN_FILENAME_CHARACTERS = QString("/")

Characters which are forbidden in filenames.

Private Members

const QString _eurlstring
std::shared_ptr<const Eurl> _cache_parentsegment = 0
std::shared_ptr<const Eurl> _cache_outerurl = 0
bool _cache_outerurl_isthis = false
std::shared_ptr<const Eurl> _cache_outermostinnereurl = 0
std::shared_ptr<const Eurl> _cache_root = 0
bool _cache_root_isthis = false
QString _cache_basename
QString _cache_hostname
QString _cache_path
QString _cache_scheme

Private Static Functions

QString check_scheme(QString scheme)
QString check_inner(QString inner)
QString check_hostname(QString hostname)
QString check_path(QString path)
QString check_filename(QString filename)
QString _escape(QString s)
QString _unescape(QString s)
std::shared_ptr<const Eurl> createNOCHECK(QString scheme, const Eurl *inner, QString hostname, QString path)
std::shared_ptr<const Eurl> fromStringNOCHECK(QString eurlstring)

Private Static Attributes

QHash<QChar, QString> _escapemap
QMutex _escapemapmutex
QMutex _mutex
QHash<QString, std::weak_ptr<const Eurl>> _eurluniverse
class EurlMisformattedException : public sh::exceptions::ArgumentException
#include <eurl.h>

Shallot exception for invalid input in Eurl creation methods.

Public Functions

EurlMisformattedException(sh::exceptions::ExceptionData data)
QString message() const
QString name() const
QString classes() const
QString details() const
QString callstack() const
QString auxiliary() const
QString customValue(QString key) const
bool isRuntimeException() const
bool isProgramException() const
bool isRetryable() const
bool isResumeable() const
bool isDetailsAreInteresting() const
int autoRetryRecommendedIn() const
void setResumeable(bool v)
void setReTryable(bool v)
void setCustomValue(QString key, QString value)
bool isClass(QString classname)
sh::exceptions::ExceptionData data()

Public Static Functions

template<class Handler>
std::shared_ptr<RegisterHandler<Handler>> createRegisterHandler(Handler handler, QStack<Handler> *stack)
void executeGuarded(std::function<void()> fctint flags = 0, )

Executes some code with some standard exection handling around.

Parameters
  • fct: The code to execute guarded.

  • flags: Flags of ExecuteGuardFlag for choosing the behavior.

void executeGuarded_errorpanel(std::function<void()> fctint flags = 0, )
QString _demangle(QString l)
void exceptionDialog(sh::exceptions::Exception &e, bool *doRetry)

Public Static Attributes

const QString UNDEFINED_ERROR_OCCURRED = QObject::tr("An unspecified error occurred.")
const QString SHALLOT_MUST_CLOSE_TEXT = QObject::tr("Your Shallot process is disturbed by an error and needs to be closed now. You can try if starting Shallot again solves the issue. If you are interested in technical details, please take a look at the log.")
const QString Value_isShallotException = "_isShallotException"
class FilesystemHandler : public QObject
#include <filesystemhandler.h>

Abstract base class for a custom filesystem handler.

Subclass and register it for implementing a new virtual filesystem, which lets new nodes appear somewhere in the filesystem tree and controls how to handle them.

Use sh::filesystem::FilesystemHandlerRegister for registration.

For executing some actions or checks on a filesystem, you should not use those handlers directly, but the higher-level sh::filesystem::FilesystemOperation class.

Subclassed by sh::filesystemhandlers::ArchiveFilesystemHandler, sh::filesystemhandlers::GnomeIOFilesystemHandler, sh::filesystemhandlers::LocalFilesystemHandler, sh::filesystemhandlers::SharcFilesystemHandler, sh::scripting::api::ApiFilesystemHandler, sh::search::SearchFilesystemHandler

Public Functions

FilesystemHandler(sh::filesystem::FilesystemModel *model)

Is (for subclasses) intended to be directly constructed and registered once.

~FilesystemHandler()
void itemlist(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, sh::filesystem::FilesystemNodeType type, sh::filesystem::FilesystemNodeListEditor *list) = 0

Determine a list of subelements in a certain directory.

void configureItems(sh::filesystem::Operation *op, QList<std::shared_ptr<FilesystemNode>> nodes)

Configure newly created nodes (e.g. setting another icon or changing the display name).

sh::filesystem::FilesystemNodeType getType(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Determine if a file is regular, or a dir, or a link, …

qint64 getSize(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Determine the size of a file.

QDateTime getMtime(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Determine the mtime of a file.

void setMtime(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, QDateTime time) = 0

Set the mtime of a file.

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

Determine mime type of a file.

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

Resolve a link.

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

Fetches the list of available extended attributes for an entry.

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

Returns the site of value for one extended attribute for an entry.

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

Returns the value for one extended attribute for an entry.

void setExtendedAttribute(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, QString attribute, QByteArray value)

Sets the value for one extended attribute for an entry.

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

Removes one extended attributes for an entry.

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

Returns the custom attributes for an entry.

In contrast to extended attributes, the custom attributes are not directly stored in the filesystem this way, but handle implementation specific aspects (like permissions).

void setCustomAttribute(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, QString attribute, QString value)

Sets the value for one custom attribute for an entry.

See also getCustomAttributes.

bool canGetFileContent(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Returns if it is allowed to get the content of a certain file.

std::shared_ptr<QIODevice> getFileContent(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Get the content of a file.

bool canCreateDirectory(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Returns if it is allowed to create subdirectories in a certain directory.

void createDirectory(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Create a directory.

bool canCreateLink(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Returns if it is allowed to create a link in a certain directory.

void createLink(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, QString target) = 0

Create a link.

bool canCreateFile(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Returns if it is allowed to create files in a certain directory.

void createFile(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, QIODevice *content, HandlerTransfer *handlertransfer) = 0

Creates a file with some content.

It may use handlertransfer for some better integration, like cancel support and progress monitoring.

bool canDeleteItem(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Returns if it is allowed to delete a certain file/directory/link/….

void deleteItem(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl) = 0

Delete a file/directory/link/…

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

Deletes a directory only of it is empty.

bool canRenameItem(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> src) = 0

Returns if it is allowed to rename a certain file, directory, link, … (see renameItem).

void renameItem(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> src, QString destpath) = 0

Renames an item to another path.

It can be a simple filename change or also changes in the deeper path segments.

QList<std::shared_ptr<sh::actions::AbstractActionItem>> getActions(const QList<std::shared_ptr<const sh::filesystem::Eurl>> eurls) = 0

Returns a list of actions (see former example) for showing for certain files.

bool requiresResolvedLinks()

Returns if this handler requires to be used by the engine with resolved links.

void viewEnteredDirectory(std::shared_ptr<const sh::filesystem::Eurl>)

Callback for preparing stuff when the view entered some directory (e.g. for enabling watchers). See also viewLeftDirectory.

void viewLeftDirectory(std::shared_ptr<const sh::filesystem::Eurl>)

Callback for preparing stuff when the view left some directory. See also viewEnteredDirectory.

bool isWellKnownScheme()

Returns if the scheme for this handler is a well known one (which external programs typically would understand).

void search(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl, std::function<void(std::shared_ptr<const sh::filesystem::Eurl>, QList<std::shared_ptr<sh::search::SearchCriterion>>, sh::filesystem::FilesystemNodeType ftype)> addfile, std::function<void(std::shared_ptr<const sh::filesystem::Eurl>)> visitdir, QList<std::shared_ptr<sh::search::SearchCriterion>> criteria, )

Helps searching for files.

Override this method with a behavior identical to the default, if a specialized implementation can be much faster than the default one.

void customizeUi(std::shared_ptr<sh::filesystem::FilesystemNode> node, bool *showSearchPanel)

Creates a custom gui, which becomes part of the fileview.

sh::filesystem::FilesystemModel *model()

A convenience shortcut to the sh::filesystem::FilesystemModel (a singleton).

class HandlerTransfer
#include <filesystemhandler.h>

Subclassed by sh::filesystem::FilesystemOperation::MyHandlerTransfer, sh::filesystem::FilesystemOperationTransfers::SingleStepMonitor

Public Functions

void respectCancel()
void incrementTransferredBytes(qint64 donebytes)
~HandlerTransfer()
class FilesystemHandlerRegister : public QObject, public sh::base::Singleton
#include <filesystemhandlerregister.h>

A register of filesystem handlers.

Each active (i.e. referred to by existing nodes) instance of sh::filesystem::FilesystemHandler must be registered here.

Public Functions

void addHandler(QString scheme, std::shared_ptr<sh::filesystem::FilesystemHandler> handler)

Registers a filesystem handler.

Parameters
  • scheme: The scheme (very first part of a sh::filesystem::Eurl) for which the handler is responsible for.

  • handler: The filesystem handler.

std::shared_ptr<sh::filesystem::FilesystemHandler> findHandler(QString scheme)

Finds a filesystem handler by scheme.

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

FilesystemHandlerRegister()

Private Members

QHash<QString, std::shared_ptr<sh::filesystem::FilesystemHandler>> handlers
QMutex mutex
class FilesystemModel : public QAbstractItemModel, public sh::base::Singleton
#include <filesystemmodel.h>

The filesystem model.

This is the engine which creates and manages sh::filesystem::FilesystemNode nodes. Filesystem nodes are used on many places for all kinds of operations.

Public Functions

std::shared_ptr<sh::filesystem::FilesystemNode> rootNode()

The sh::filesystem::FilesystemNode which is the root node of the entire model. It is the parent for all toplevel nodes.

QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
Qt::ItemFlags flags(const QModelIndex &index) const
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
QModelIndex parent(const QModelIndex &index) const
int rowCount(const QModelIndex &parent = QModelIndex()) const
int columnCount(const QModelIndex &parent = QModelIndex()) const
sh::filesystem::FilesystemModelFileviewProxy *createFileviewProxy(QModelIndex root, bool withtooltip, std::function<void(std::shared_ptr<sh::filesystem::FilesystemNode>)> onBecomesInvalid)

Creates a sh::filesystem::FilesystemModelFileviewProxy for presenting the content of a directory.

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

Get a list of qt model indexes for a sh::filesystem::Eurl.

If nodes for this eurl are unknown to the model so far, it tries to build them. In typical cases, this list either contains one element, or is empty if the filesystem handlers decide that this file does not exist. But in some cases, there is also more than one index for one sh::filesystem::Eurl (when the sh::filesystem::Eurl appears on more than one place in the tree).

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

Get a list of sh::filesystem::FilesystemNode for a sh::filesystem::Eurl.

If it is unknown to the model so far, it tries to build them. In typical cases, this list either contains one element, or is empty if the filesystem handlers decide that this file does not exist. But in some cases, there is also more than one node for one sh::filesystem::Eurl (when the sh::filesystem::Eurl appears on more than one place in the tree). It only returns nodes, which are ‘alive’, i.e. which have a living parent and which are a child of this parent.

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

Returns a list of sh::filesystem::FilesystemNode for a sh::filesystem::Eurl. It only considers the current state of the in-memory model. It will only return nodes which are already known to the model so far. This operation is cheaper and handling only the known nodes is sufficient in many situations. In typical cases, this list either contains one element, or is empty. But in some cases, there is also more than one node for one sh::filesystem::Eurl (when the sh::filesystem::Eurl appears on more than one place in the tree). It only returns nodes, which are ‘alive’, i.e. which have a living parent and which are a child of this parent.

std::shared_ptr<sh::filesystem::FilesystemNode> getNodeForIndex(const QModelIndex index) const

Returns the sh::filesystem::FilesystemNode for a qt model index (in the main model).

QModelIndex getIndexForNode(std::shared_ptr<sh::filesystem::FilesystemNode> node)

Returns a qt model index (in the main model) for a sh::filesystem::FilesystemNode.

std::shared_ptr<sh::filesystem::FilesystemNode> createFilesystemNode(std::shared_ptr<const sh::filesystem::Eurl> eurl, sh::filesystem::FilesystemHandler *handler, sh::filesystem::FilesystemNodeType nodetype, bool isHidden, std::shared_ptr<sh::filesystem::FilesystemNode> parent, bool doinsert = true, bool showInitialLoadingLabel = true)

Creates a new sh::filesystem::FilesystemNode for placing it into the model.

If such a node (with the same eurl for the same parent node) does not exist, it generates a new one. If there already is such a node alive, but currently not placed in the model, it recycles this one. This can happen when references exist to a node which is not yet inserted or which is removed meanwhile. It is not allowed to call this method when such a node already exists in the model.

Use this function for getting a sh::filesystem::FilesystemNode, which is to be added to the model now or later. Depending on some parameter values, a call directly adds the node to the filesystem model (not e.g. when doinsert is false or parentnode is 0) It is typically used within a sh::filesystem::FilesystemHandler implementation.

std::shared_ptr<sh::filesystem::FilesystemNode> getOrCreateFilesystemNode(std::shared_ptr<const sh::filesystem::Eurl> neweurl, sh::filesystem::FilesystemHandler *handler, sh::filesystem::FilesystemNodeType nodetype, bool isHidden, std::shared_ptr<sh::filesystem::FilesystemNode> parent, bool doinsert = true, bool showInitialLoadingLabel = true, bool *pIsNew = 0)

Returns a sh::filesystem::FilesystemNode for using it as a child node in the model.

It either creates a new one, if there currently is no node for this eurl in this parentnode, or returns the existing one. Even for existing ones, this call can change the nodetype of that node.

Depending on some parameter values, a call directly adds the node to the filesystem model (not e.g. when doinsert is false or parent is 0).

void refreshData(std::shared_ptr<const sh::filesystem::Eurl> eurl, bool forceFindParent = false, bool withDetails = true)

Request to refresh the internal model information for a sh::filesystem::Eurl. This may be a place which is already known (then a change of some metadata or the removal is detected) or a formerly unknown place (then new nodes get inserted in the model).

void addOpenNodeHelper(int index, std::function<QList<std::shared_ptr<sh::filesystem::FilesystemNode>>(std::shared_ptr<const sh::filesystem::Eurl>)> openNodeHelper)

Registers a helper method for ‘opening’ (mounting, activating, …) locations on demand.

Only used in very rare cases.

~FilesystemModel()
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

FilesystemModel()
QList<std::shared_ptr<sh::filesystem::FilesystemNode>> _findNodesForEurl_helper(std::shared_ptr<const sh::filesystem::Eurl> eurl)
QList<std::shared_ptr<sh::filesystem::FilesystemNode>> openRootEurl(std::shared_ptr<const sh::filesystem::Eurl> eurl)
void _subitemFetchingStateChanged(std::shared_ptr<sh::filesystem::FilesystemNode> node, bool value)

Private Members

QList< std::function< QList< std::shared_ptr< sh::filesystem::FilesystemNode > >std::shared_ptr< const sh::filesystem::Eurl >)> > _openNodeHelpers
QMap< int, std::function< QList< std::shared_ptr< sh::filesystem::FilesystemNode > >std::shared_ptr< const sh::filesystem::Eurl >)> > _openNodeHelpersMap
std::shared_ptr<sh::filesystem::FilesystemNode> rootnode
QMutex mutex
QHash<std::shared_ptr<const sh::filesystem::Eurl>, std::weak_ptr<sh::filesystem::FilesystemNode>> eurl2node
QMutex eurl2nodemutex
QMutex _nodeDataMutex
QMutex _openNodeHelpersMutex

Friends

friend class FilesystemNode
friend class LoadOnDemandPlaceholderFilesystemNode
friend class ModelBackedFilesystemNodeList
friend class ::sh::filesystem::DetailColumn
class FilesystemModelDirectoryTreeProxy : public QSortFilterProxyModel, public sh::base::Singleton
#include <filesystemmodeldirectorytreeproxy.h>

A filesystem proxy model for the directory tree.

It has a special sorting and filtering behavior.

Used internally, mostly for the user interface.

Public Functions

void enforceVisibility(std::shared_ptr<FilesystemNode> node)

Marks a node as visible in the directory tree, even if it is a hidden node.

void deEnforceVisibility(std::shared_ptr<FilesystemNode> node)

Unmarks a node for being visible even if hidden (reverses enforceVisibility()).

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

FilesystemModelDirectoryTreeProxy()
class FilesystemModelDirectoryTreeProxyVisibilityEnforcements : public QObject, public sh::base::Singleton
#include <filesystemmodeldirectorytreeproxyvisibilityenforcements.h>

Maintains a list of currently visible directories (i.e. the current one in each view) and controls enforced visibility of them in the directory tree.

Public Functions

void nodeEnteredView(std::shared_ptr<FilesystemNode> node)

Called when a view enters the given directory node.

void nodeLeftView(std::shared_ptr<FilesystemNode> node)

Called when a view leaves the given directory node.

void nodeCollapsedInTree(std::shared_ptr<FilesystemNode> node)

Called when a directory node is collapsed in the directory tree.

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

FilesystemModelDirectoryTreeProxyVisibilityEnforcements()
bool _addenforcement(std::shared_ptr<FilesystemNode> node, std::shared_ptr<FilesystemNode> hnode)

Private Members

QMultiMap<std::shared_ptr<FilesystemNode>, QObject*> _enterednodesrepresentatives
QList<std::tuple<std::weak_ptr<FilesystemNode>, QList<std::shared_ptr<FilesystemNode>>>> hiddenForcedVisibles
class FilesystemModelFileviewProxy : public QSortFilterProxyModel
#include <filesystemmodelfileviewproxy.h>

A filesystem proxy model for a fileview.

It regards the sorting and filtering behavior set up for the connected fileview.

Used internally, mostly for the user interface.

Public Functions

FilesystemModelFileviewProxy(QModelIndex root, bool withtooltip, QObject *parent = 0)

Constructed only indirectly.

void setSizeFormattingMode(SizeFormatting mode)
SizeFormatting getSizeFormattingMode() const
void setHiddenFilesVisible(bool v)
bool getHiddenFilesVisible() const
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
void triggerReloadData()
void setThumbnail(bool enabled, int size = 32)
bool getThumbnailEnabled()
int getThumbnailSize()
class FilesystemModelSubtreeProxy : public QAbstractItemModel
#include <filesystemmodelsubtreeproxy.h>

A filesystem proxy model for setting a new root node to an existing fileview proxy.

Used internally, mostly for the user interface.

Public Functions

FilesystemModelSubtreeProxy(QModelIndex root, sh::filesystem::FilesystemModelFileviewProxy *upperproxy)

Constructed only indirectly.

QVariant data(const QModelIndex &index, int role) const
Qt::ItemFlags flags(const QModelIndex &index) const
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
QModelIndex parent(const QModelIndex &index) const
int rowCount(const QModelIndex &parent = QModelIndex()) const
int columnCount(const QModelIndex &parent = QModelIndex()) const
QModelIndex mapFromSource(const QModelIndex mi) const
QModelIndex mapToSource(const QModelIndex mi) const

Signals

void becomesInvalid(std::shared_ptr<sh::filesystem::FilesystemNode> bestValid)

Private Members

bool _inChangeTransaction
std::shared_ptr<sh::filesystem::FilesystemNode> _rootnode
QPersistentModelIndex _rootindex
sh::filesystem::FilesystemModel *mainmodel
sh::filesystem::FilesystemModelFileviewProxy *_upperproxy
class FilesystemNode : public QObject, public std::enable_shared_from_this<FilesystemNode>
#include <filesystemnode.h>

A representation of a location in the filesystem tree.

It represents filesystem nodes like a file or a directory in sh::filesystem::FilesystemModel.

Please note: Instances can be associated with any kind of elements in the filesystem (files, directories, links, …). It might also point to something which does not exist at all (see parentnode). The documentation sometimes explicitly makes a difference between those kinds (files, directories, links, …; often called ‘node type’). But it often uses the term ‘file’ implicitly while meaning all kinds of elements; assuming that e.g. a directory is just a special kind of a file. It should be clear from the particular context which meaning applies.

Subclassed by sh::filesystem::LoadOnDemandPlaceholderFilesystemNode

Public Functions

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

Returns the sh::filesystem::Eurl entry address.

sh::filesystem::FilesystemModel *model()

Convenience shortcut to the sh::filesystem::FilesystemModel.

QString displayName()

Returns the display name (what the user interface displays).

void setDisplayName(QString displayname)

Sets the display name (what the user interface displays).

sh::filesystem::FilesystemHandler *handler()

Returns the handler which is responsible for this node. This should be the same as sh::filesystem::FilesystemHandlerRegister.findHandler(eurl.scheme).

int nodetype()

Returns the FilesystemNodeType node type.

int childnodeCount()

Returns the number of children nodes.

std::shared_ptr<sh::filesystem::FilesystemNode> childnode(int i)

Returns i-th child node.

sh::filesystem::ModelBackedFilesystemNodeList *childnodes()

Returns the list of children.

std::shared_ptr<sh::filesystem::FilesystemNode> parentnode() const

Returns the parent node.

This is 0 if the node does not exist in the model (i.e. not yet inserted or removed afterwards). In most cases, this can be interpreted as ‘file currently does not exist’.

int index()

Returns the index of this node in the parent’s list of children.

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

Adds a new child. Not allowed to call more than once for a node.

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

Removes a new child. Not allowed to call more than once for a node.

bool isFetchingSubitems()

Checks if currently subitems are fetched (i.e. the ‘loading’ node is shown).

QIcon icon()

Returns the node icon.

void setIcon(QIcon icon)

Sets the node icon.

bool isHidden()

Returns if the node is hidden.

Note: It’s not difficult for the user to also show the hidden items.

void setHidden(bool v)

Sets if the node is hidden.

See also isHidden().

void addDetail(std::shared_ptr<sh::filesystem::DetailColumn> column)

Adds a detail to this node.

std::shared_ptr<sh::filesystem::DetailColumn> getDetailColumnByIndex(int index)

Returns the i-th detail column registered to this node.

int getDetailColumnsCount() const

Returns the number of detail columns registered to this node.

bool isRootNode() const

Checks if this is the root node of the model.

bool isConfigured() const

Checks if this node was already configured by a handler.

void requestDetails(bool force = true)

Requests to fetch details for this node.

bool isAlive() const

Checks if this node currently exists in the model.

QList<std::shared_ptr<sh::filesystem::FilesystemNode>> linkDestinationNodes() const

Returns the list of link source nodes. If this node is a link, the link destination nodes may influence the behavior and appearance of this node.

This information does not come from inside but must be set from outside the model implementation.

void setLinkDestinationNodes(QList<std::shared_ptr<sh::filesystem::FilesystemNode>> linkdestinations)

Sets the list of link destination nodes. If this node is a link, the link destination nodes may influence the behavior and appearance of this node.

void requestContainedItems(sh::filesystem::FilesystemNodeType type = FilesystemNodeType::NONE)

Requests to fetch the children of this node with help of the filesystem handler.

FilesystemNode(sh::filesystem::FilesystemModel *model, std::shared_ptr<const sh::filesystem::Eurl> eurl, QString displayname, sh::filesystem::FilesystemHandler *handler, FilesystemNodeType nodetype, bool ishidden)

Constructed only by the infrastructure and made available otherwise.

Signals

void removed()

Is emitted when this node is not placed in the tree anymore. This does not mean the physical deletion of the instance, but just means it is not alive from now on.

void _detailsAvailable()

Is emitted when values for detail columns arrived.

void iconChanged()

Is emitted when the icon changed.

void isHiddenChanged()

Is emitted when the hidden flag changed.

Private Functions

void setDetail(std::shared_ptr<sh::filesystem::DetailColumn> column, QVariant value)
int getInsertPositionForDetailColumn(std::shared_ptr<sh::filesystem::DetailColumn> newCol)

Friends

friend class sh::filesystem::FilesystemModel
friend class sh::filesystem::DetailColumn
friend class LoadOnDemandPlaceholderFilesystemNode
friend class sh::filesystem::FilesystemModelFileviewProxy
friend class sh::filesystem::FilesystemModelSubtreeProxy
friend class sh::filesystem::ModelBackedFilesystemNodeList
class FilesystemNodeList : public QObject
#include <filesystemnodelist.h>

A data structure for children lists of filesystem nodes.

Different subclasses exist with different behaviors and use cases.

Subclassed by sh::filesystem::AdhocFilesystemNodeList, sh::filesystem::ModelBackedFilesystemNodeList

Public Functions

void addItems(QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Adds items to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

void addItem(std::shared_ptr<sh::filesystem::FilesystemNode> node) = 0

Adds an item to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

void removeItems(QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Removes nodes from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void removeItem(std::shared_ptr<sh::filesystem::FilesystemNode> node) = 0

Removes a node from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void resetItems(sh::filesystem::FilesystemNodeType type, QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Resets the list for a given node type to a given new list of children nodes.

std::shared_ptr<sh::filesystem::FilesystemNode> mynode() = 0

Returns the node which owns this children list. The result may be 0 for non model-backed lists.

bool contains(std::shared_ptr<FilesystemNode> node)

Checks if this list contains a given node.

const QList<std::shared_ptr<sh::filesystem::FilesystemNode>> *nodes()

Returns the list of nodes currently stored in this instance.

class FilesystemNodeListEditor
#include <filesystemnodelist.h>

A list editor for easily modifying a FilesystemNodeList.

Mainly used for listing child nodes in sh::filesystem::FilesystemHandler.itemlist. In most cases, you should just use setItems.

Public Functions

FilesystemNodeListEditor(FilesystemNodeList *list, std::shared_ptr<const sh::filesystem::Eurl> parenteurl, sh::filesystem::FilesystemNodeType nodestype)

Constructed only by the infrastructure and made available otherwise.

~FilesystemNodeListEditor()
void setItems(QList<QString> items)

Sets a new list content. This function is all you need in most situations. For iteratively adding nodes, which makes the intermediate results visible in the user interface, see addItem.

void beginIterativeAdding()

Must be called before you begin to iteratively fill the children list (e.g. with addItem). You must also call endIterativeAdding afterwards.

void addItem(QString item)

Adds a new children to the list, directly showing that in the user interface, while you can proceed filling the list. Please read beginIterativeAdding as well! In most cases, you don’t need this function.

std::shared_ptr<FilesystemNode> addCustomItem(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString displayname = QString(), sh::filesystem::FilesystemHandler *handler = 0)

Adds a new children to the list, directly showing that in the user interface, while you can proceed filling the list. Please read beginIterativeAdding as well! In most cases, you don’t need this function.

Note: If you specify a handler, it must be the one matching to eurl’s scheme.

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

Adds a new children to the list, directly showing that in the user interface, while you can proceed filling the list. Please read beginIterativeAdding as well! In most cases, you don’t need this function.

void endIterativeAdding()

Must be called after you iteratively filled the children list with addItem. This automatically removes all the old nodes, which you haven’t added in this session.

void setItemsAreHosts()

After this call, the addItem method will consider the given names as hostnames instead of new path segments. The resulting sh::filesystem::Eurl will differ accordingly. This only makes sense as children for root eurls.

FilesystemNodeList *rawlist()

Returns the FilesystemNodeList backend. You should rarely need it.

Private Functions

std::shared_ptr<const sh::filesystem::Eurl> getChildEurl(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString item)

Private Members

FilesystemNodeList *_list
std::shared_ptr<const sh::filesystem::Eurl> _parenteurl
sh::filesystem::FilesystemNodeType _nodestype
std::shared_ptr<sh::filesystem::FilesystemNode> _parentnode
sh::filesystem::FilesystemModel *_model
sh::filesystem::FilesystemHandler *_handler
bool _itemsAreHosts = false
bool _beganAddingIteratively = false
QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> _iterativeAddingsBeforeState

Private Static Attributes

QSet<FilesystemNodeList*> _pendingIterativeAddings
QMutex _pendingMutex
QWaitCondition _iterativeAddingPossibleCondition
class FilesystemOperation
#include <filesystemoperation.h>

A high-level interface for filesystem operations.

It is always based on the transaction of a Operation instance (which also gives you access to a FilesystemOperation object).

Some calls optionally allow to give an own instance of sh::filesystem::FilesystemOperationProgressMonitor for some additional functionality. Please note that not all calls provide all those functionality (some do not use e.g. the conflict resolution at all). If not provided, a default behavior is applied.

Public Functions

FilesystemOperation(sh::filesystem::Operation *operation)

Constructed only by the infrastructure and made available otherwise.

QList<std::shared_ptr<const sh::filesystem::Eurl>> itemlist(std::shared_ptr<const sh::filesystem::Eurl> eurl, sh::filesystem::FilesystemNodeType type = sh::filesystem::FilesystemNodeType::NONE)

Gets a list of shallot.sh::filesystem::FilesystemNode nodes in a directory (optionally filter by given types).

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

Gets the shallot.sh::filesystem::FilesystemNodeType node type for an entry.

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

Gets the file size for an entry.

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

Gets the link target for an entry (if it is a link).

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

Can we get the file content for an entry?

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

Gets the file content for an entry as QIODevice.

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

Can we create a given directory?

void createDirectory(std::shared_ptr<const sh::filesystem::Eurl> eurl, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Creates a directory.

Parameters
  • progressmon: An optional progress monitor.

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

Can we create a given link?

void createLink(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString target, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Creates a link.

Parameters
  • progressmon: An optional progress monitor.

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

Can we create a given file?

void createFile(std::shared_ptr<const sh::filesystem::Eurl> eurl, QIODevice *content, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Creates a file.

Parameters
  • progressmon: An optional progress monitor.

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

Can we delete a given entry?

void deleteItem(std::shared_ptr<const sh::filesystem::Eurl> eurl, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Delete an entry.

Parameters
  • progressmon: An optional progress monitor.

void deleteDirectoryIfEmpty(std::shared_ptr<const sh::filesystem::Eurl> eurl, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Delete a directory entry if empty.

Parameters
  • progressmon: An optional progress monitor.

bool canMoveItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest = 0)

Checks if it is allowed to move a certain item.

If the destination is known as well, it might help to pass it as well.

This does not guarantee success in the transfer, but is just a cheap early check.

void moveItems(QList<std::shared_ptr<const sh::filesystem::Eurl>> src, std::shared_ptr<const sh::filesystem::Eurl> dest, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Moves entries.

Parameters
  • dest: The requested new common parent directory.

  • progressmon: An optional progress monitor.

void moveItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Moves an entry.

Parameters
  • dest: The new location (not the new parent).

  • progressmon: An optional progress monitor.

bool canCopyItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const Eurl> dest = 0)

Checks if it is allowed to copy a certain item.

If the destination is known as well, it might help to pass it as well.

This does not guarantee success in the transfer, but is just a cheap early check.

void copyItems(QList<std::shared_ptr<const sh::filesystem::Eurl>> src, std::shared_ptr<const sh::filesystem::Eurl> dest, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Copies entries.

Parameters
  • dest: The requested new common parent directory.

  • progressmon: An optional progress monitor.

void copyItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> progressmon = 0)

Copies an entry.

Parameters
  • dest: The new location (not the new parent).

  • progressmon: An optional progress monitor.

QList<std::shared_ptr<FilesystemNode>> resolveNodeLink(std::shared_ptr<FilesystemNode> node, bool recursive = true, bool excludeOwn = false)

Resolve a link as node with or without recursion.

std::shared_ptr<const sh::filesystem::Eurl> resolveEurlLink(std::shared_ptr<const sh::filesystem::Eurl> eurl, bool recursive = true, bool excludeOwn = false, int tries = 100)

Resolve a link as sh::filesystem::Eurl with or without recursion.

QList<QString> listExtendedAttributes(std::shared_ptr<const sh::filesystem::Eurl> eurl)
quint64 getExtendedAttributeSize(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString attribute)
QByteArray getExtendedAttribute(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString attribute)
void setExtendedAttribute(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString attribute, QByteArray value)
void removeExtendedAttribute(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString attribute)

Public Static Functions

void addTransferrableDetailColumn(int index, std::shared_ptr<sh::filesystem::DetailColumn> detailColumn)

Registers a detail column for transferring it when file transfer take place.

Parameters
  • index: An integer which controls the order of transferring.

QList<std::shared_ptr<sh::filesystem::DetailColumn>> transferrableDetailColumns()

A list of all detail columns which are registered becoming transferred in file transfers.

Private Functions

std::shared_ptr<sh::filesystem::FilesystemHandler> _handler(std::shared_ptr<const sh::filesystem::Eurl> eurl)
std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> _monitor(std::shared_ptr<sh::filesystem::FilesystemOperationProgressMonitor> m)
std::shared_ptr<const sh::filesystem::Eurl> _resolveIfNeeded(std::shared_ptr<sh::filesystem::FilesystemHandler> handler, std::shared_ptr<const sh::filesystem::Eurl> eurl)

Private Members

Operation *_operation

Private Static Attributes

QMap<int, std::shared_ptr<sh::filesystem::DetailColumn>> _detailColumnsMap
QList<std::shared_ptr<sh::filesystem::DetailColumn>> _detailColumns
QMutex _detailColumnsMutex

Friends

friend class FilesystemOperationTransfers
class MyHandlerTransfer : public sh::filesystem::FilesystemHandler::HandlerTransfer

Public Functions

MyHandlerTransfer(sh::filesystem::FilesystemOperationProgressMonitor *progressmon = 0)
~MyHandlerTransfer()
void respectCancel()
void incrementTransferredBytes(qint64 donebytes)

Private Members

sh::filesystem::FilesystemOperationProgressMonitor *_progressmon
class FilesystemOperationProgressMonitor : public std::enable_shared_from_this<FilesystemOperationProgressMonitor>
#include <filesystemoperationtransfers.h>

Implement this class and use an instance of it as parameter in some methods of sh::filesystem::FilesystemOperation for some additional functionality.

This includes monitoring the progress, specifying a resolution when conflicts in the filesystem would occur and more.

It also makes sense to directly instantiate this class in some cases.

Subclassed by sh::actions::common::ActionAbstractTransferTree::MyFilesystemOperationProgressMonitor, sh::scripting::api::ApiFilesystemOperationProgressMonitor

Public Functions

FilesystemOperationProgressMonitor(sh::actions::ActionExecutionInfo *actionExecution = 0)

Is intended to be directly constructed from everywhere.

Parameters

bool hasItemInfo()

Checks if this progress monitor provides information about how many items of a certain total number are transferred so far.

quint64 doneItems()

Checks how many items are transferred so far.

quint64 allItems()

Checks how many items are to be transferred in total (as predicted in the current moment).

bool hasBytesInfo()

Checks if this progress monitor provides information about how many byte of a certain total number are transferred so far.

quint64 doneBytes()

Checks how many bytes are transferred so far.

quint64 allBytes()

Checks how many bytes are to be transferred in total (as predicted in the current moment).

QString getItemInfoFrom()

Returns the current source of transfer (as textual information).

QString getItemInfoTo()

Returns the current destination of transfer (as textual information).

QString estimation()

Returns the current performance and time estimation (as textual information).

~FilesystemOperationProgressMonitor()

Private Functions

void setProgress(quint64 doneitems, quint64 allitems, quint64 donebytes, quint64 allbytes)

Used by FilesystemOperationTransfers for setting status changes.

void incProgress(quint64 doneitems, quint64 allitems, quint64 donebytes, quint64 allbytes)

Used by FilesystemOperationTransfers for setting status changes.

void setItemInfo(QString from, QString to)

Used by FilesystemOperationTransfers for setting status changes.

void setEstimation(QString estimation)

Used by FilesystemOperationTransfers for setting status changes.

void _enablestatistics()
void _computestatistics()
void _triggerchanged()
void _stoptriggerchanged()

Private Members

QDateTime _laststatistictime
quint64 _laststatisticdonebytes = 0
quint64 _laststatisticdoneitems = 0
double _statisticbytespeed = 0.0
double _statisticitemspeed = 0.0
int _statisticcountdown = 4
QMutex _mutex
QMutex _triggermutex
quint64 _allitems = 0
quint64 _doneitems = 0
quint64 _allbytes = 0
quint64 _donebytes = 0
bool _triggerchanged_changedrunning = false
bool _triggerchanged_changedrunagain = false
bool _triggerchanged_stopped = false
QString _itemfrom
QString _itemto
QString _estimation
QList<std::shared_ptr<const sh::filesystem::Eurl>> changes
bool _begancomputestatistics = false

Friends

friend class FilesystemOperationTransfers
friend class FilesystemOperation
class FilesystemOperationTransfers
#include <filesystemoperationtransfers.h>

Used by FilesystemOperation for managing the execution of transfer operations.

This class is only used directly by FilesystemOperation (but some inner class might be interesting).

Public Functions

FilesystemOperationTransfers(FilesystemOperation *filesystem, std::shared_ptr<FilesystemOperationProgressMonitor> progressmon)

Constructed only by the infrastructure and made available otherwise.

void executestepqueue()

Executes the queue.

The execution model is as follows: The complete queue of OperationStepClass steps becomes expanded, filesystem conflicts gets resolved and then all steps become executed.

In detail:

At first there is an interleaved process of expanding all steps (see OperationStepClass::expand) and checking/resolving filesystem conflicts in the fresh tree (see doreview). It checks all steps in the queue for conflicts (e.g. destination already exists). It expands each step which has no conflicts (by enqueueing it to the stepqueue). After those checks, it asks FilesystemOperationProgressMonitor::resolveConflicts for a resolution for all outstanding conflicts. With all the steps, which were (or are) in conflict, the entire process becomes repeated. This ends when all steps are expanded and no open conflicts exist anymore.

When this process is done, the execution phase begins. It iterates the queue. It takes the (in FIFO manner) first element (if one is there, otherwise stops). For that step, it makes a late-time conflict check at first. If a conflict appears, it becomes temporarily unexpanded. A resolution loop as above will run for this element, eventually leading to re-expansion. After the check, when no conflicts are open, it executes the step.

void addMoveItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest)

adds one move transfer into the queue.

void addCopyItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest)

adds one copy transfer into the queue.

~FilesystemOperationTransfers()

Private Functions

void _compile_moveItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, QList<OperationStepClass*> *result, QList<OperationStepClass*> withExpansion)

Adds a move transfer step into given list.

void _compile_copyItem(std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, QList<OperationStepClass*> *result, QList<OperationStepClass*> withExpansion)

Adds a copy transfer step into given list.

void computeProgress()

Computes the current progress (how many items/bytes are transferred from which total?) and notifies the progress monitor.

bool doreview(QList<OperationStepClass*> reviewsteps)

Makes checks if the given queue has conflicts and for asks resolveConflicts how to handle them.

For each non-conflicting step, it triggers its expansion, thereby modifying the stepqueue.

It returns when no open conflicts exist.

Return

If there were any conflicts.

Private Members

QList<OperationStepClass*> stepqueue

The queue of steps for execution.

OperationStepClass *currentstep = 0

The step which is currently in execution (or 0).

QList<OperationStepClass*> donesteps

Steps which were already executed.

FilesystemOperation *filesystem
std::shared_ptr<FilesystemOperationProgressMonitor> progressmon
class OperationStep
#include <filesystemoperationtransfers.h>

One step of execution in a transfer operation by FilesystemOperation.

It is typically about a certain source and destination in the filesystem. It also can stay in conflict (due to checks from FilesystemOperationTransfers::doreview) and provides methods for resolving them (in FilesystemOperationTransfers::FilesystemOperationProgressMonitor::resolveConflicts).

Different subclasses implement distinct kinds of operations (e.g. copying or deleting).

Subclassed by sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> source, std::shared_ptr<const sh::filesystem::Eurl> destination)

Constructed only by the infrastructure and made available otherwise.

QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

~OperationStep()

Friends

friend class FilesystemOperationTransfers
class OperationStep_ApplyDirectoryDetails : public sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep_ApplyDirectoryDetails(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> item, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, QList<OperationStepClass*> withExpansion)
void execute(Operation *op)

Implement this and handle the execution part of this step here.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> _detailvals
quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class OperationStep_CopyDirectory : public sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep_CopyDirectory(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, QList<OperationStepClass*> withExpansion)
void execute(Operation *op)

Implement this and handle the execution part of this step here.

QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class OperationStep_CopyFile : public sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep_CopyFile(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, QList<OperationStepClass*> withExpansion)
void execute(Operation *op)

Implement this and handle the execution part of this step here.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class OperationStep_CopyLink : public sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep_CopyLink(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, QList<OperationStepClass*> withExpansion)
void execute(Operation *op)

Implement this and handle the execution part of this step here.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class OperationStep_DeleteItem : public sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep_DeleteItem(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> src, std::shared_ptr<const sh::filesystem::Eurl> dest, QList<OperationStepClass*> withExpansion)
void execute(Operation *op)

Implement this and handle the execution part of this step here.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class OperationStep_RenameItem : public sh::filesystem::FilesystemOperationTransfers::OperationStepClass

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStep_RenameItem(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> src, QString destpath, QList<OperationStepClass*> withExpansion)
QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

void execute(Operation *op)

Implement this and handle the execution part of this step here.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class OperationStepClass : public sh::filesystem::FilesystemOperationTransfers::OperationStep

A base class for all implementations.

They are used from inside FilesystemOperationTransfers::executestepqueue.

Subclassed by sh::filesystem::FilesystemOperationTransfers::OperationStep_ApplyDirectoryDetails, sh::filesystem::FilesystemOperationTransfers::OperationStep_CopyDirectory, sh::filesystem::FilesystemOperationTransfers::OperationStep_CopyFile, sh::filesystem::FilesystemOperationTransfers::OperationStep_CopyLink, sh::filesystem::FilesystemOperationTransfers::OperationStep_DeleteItem, sh::filesystem::FilesystemOperationTransfers::OperationStep_RenameItem

Public Types

enum ConflictResolution

Enumeration of ways how to resolve a filesystem conflict.

Values:

enumerator Skip

Skip this element.

enumerator OverwriteDestination

Overwrite the destination.

enumerator RenameDestinationBefore

Rename the file at the destination before transferring.

enumerator UseDifferentDestinationName

Transfer to another destination filename.

enumerator MergeDirectories

Merge source into destination directory (recursively).

enumerator Unresolved

No strategy.

enumerator Indirect

Indirectly solved. Only set by the engine.

Public Functions

OperationStepClass(FilesystemOperationTransfers *transfers, std::shared_ptr<const sh::filesystem::Eurl> source, std::shared_ptr<const Eurl> destination, QList<OperationStepClass*> withExpansion)
void execute(Operation *op) = 0

Implement this and handle the execution part of this step here.

QList<OperationStepClass*> expand()

Implement this and handle the expansion part of this step here.

bool checkconflicts(Operation *op)

Implement this for customizing the conflict checking.

bool hasOwnProgressIncreaseHandling()

If it takes care on its own to signal increases in the transfer progress.

void _unexpand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

void _expand(QList<OperationStepClass*> *intlist)

Bookkeeping in FilesystemOperationTransfers.

~OperationStepClass()
QList<QPair<sh::filesystem::DetailColumn*, QVariant>> getFileDetails(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> source)
void applyFileDetails(sh::filesystem::Operation *op, QList<QPair<sh::filesystem::DetailColumn*, QVariant>> values, std::shared_ptr<const sh::filesystem::Eurl> destination)
QString conflictDescription()

The description of the conflict (if any) as text.

ConflictResolution conflictResolution()

The currently chosen conflict resolution.

QString conflictResolution_renameDestinationBeforeTo()

Returns new destination name (if current conflict resolution is ConflictResolution::RenameDestinationBefore).

QString conflictResolution_differentDestinationNameTo()

Returns new destination name (if current conflict resolution is ConflictResolution::UseDifferentDestinationName).

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

Returns the source location to be transferred (if specified).

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

Returns the destination location (if specified).

This is the complete target path, never the parent directory of the new element.

This is the original destination location. See also effectiveDestination.

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

Returns the real destination location with conflict resolution applied.

int sourcetype()

Returns the node type of the source.

Should be overwritten in subclasses whenever it can determine the source type faster than the infrastructure.

void setConflictResolve_Skip()

Set conflict resolution to ConflictResolution::Skip.

void setConflictResolve_OverwriteDestination()

Set conflict resolution to ConflictResolution::OverwriteDestination.

void setConflictResolve_RenameDestinationBefore(QString newname)

Set conflict resolution to ConflictResolution::RenameDestinationBefore.

void setConflictResolve_UseDifferentDestinationName(QString newname)

Set conflict resolution to ConflictResolution::UseDifferentDestinationName.

void setConflictResolve_MergeDirectories()

Set conflict resolution to ConflictResolution::MergeDirectories.

See also setConflictResolve_MergeDirectories_isAllowed.

bool setConflictResolve_MergeDirectories_checkAllowed()

Checks if conflict resolution ConflictResolution::MergeDirectories is allowed.

Public Members

quint64 _cntItems = 0

Number of items to be transferred in this step (used for progress monitoring).

quint64 _cntBytes = 0

Number of byte to be transferred in this step (used for progress monitoring).

bool _isExpanded = false

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _expandnodes

Bookkeeping in FilesystemOperationTransfers.

OperationStepClass *_parentnode = 0

Bookkeeping in FilesystemOperationTransfers.

bool _deleteonunexpand = true

Bookkeeping in FilesystemOperationTransfers.

QList<OperationStepClass*> _withExpansion
class SingleStepMonitor : public sh::filesystem::FilesystemHandler::HandlerTransfer

Used for managing detailled progress changes about a single step.

Public Functions

SingleStepMonitor(OperationStepClass *step)
void respectCancel()
void incrementTransferredBytes(qint64 donebytes)
~SingleStepMonitor()

Private Members

OperationStepClass *step
qint64 _donebytes = 0
class LoadOnDemandPlaceholderFilesystemNode : public sh::filesystem::FilesystemNode
#include <filesystemnode.h>

A special node, which is unselectable and shows a ‘loading’ label.

It does not correspond to a file, directory or similar which actually exists. It is also never parent or a child of another node.

They are used internally by the filesystem model.

Public Functions

QString displayName()

Returns the display name (what the user interface displays).

void requestDetails(bool force)

Requests to fetch details for this node.

LoadOnDemandPlaceholderFilesystemNode(std::shared_ptr<sh::filesystem::FilesystemNode> parent)

Constructed only by the infrastructure and made available otherwise.

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

Returns the sh::filesystem::Eurl entry address.

sh::filesystem::FilesystemModel *model()

Convenience shortcut to the sh::filesystem::FilesystemModel.

void setDisplayName(QString displayname)

Sets the display name (what the user interface displays).

sh::filesystem::FilesystemHandler *handler()

Returns the handler which is responsible for this node. This should be the same as sh::filesystem::FilesystemHandlerRegister.findHandler(eurl.scheme).

int nodetype()

Returns the FilesystemNodeType node type.

int childnodeCount()

Returns the number of children nodes.

std::shared_ptr<sh::filesystem::FilesystemNode> childnode(int i)

Returns i-th child node.

sh::filesystem::ModelBackedFilesystemNodeList *childnodes()

Returns the list of children.

std::shared_ptr<sh::filesystem::FilesystemNode> parentnode() const

Returns the parent node.

This is 0 if the node does not exist in the model (i.e. not yet inserted or removed afterwards). In most cases, this can be interpreted as ‘file currently does not exist’.

int index()

Returns the index of this node in the parent’s list of children.

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

Adds a new child. Not allowed to call more than once for a node.

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

Removes a new child. Not allowed to call more than once for a node.

bool isFetchingSubitems()

Checks if currently subitems are fetched (i.e. the ‘loading’ node is shown).

QIcon icon()

Returns the node icon.

void setIcon(QIcon icon)

Sets the node icon.

bool isHidden()

Returns if the node is hidden.

Note: It’s not difficult for the user to also show the hidden items.

void setHidden(bool v)

Sets if the node is hidden.

See also isHidden().

void addDetail(std::shared_ptr<sh::filesystem::DetailColumn> column)

Adds a detail to this node.

std::shared_ptr<sh::filesystem::DetailColumn> getDetailColumnByIndex(int index)

Returns the i-th detail column registered to this node.

int getDetailColumnsCount() const

Returns the number of detail columns registered to this node.

bool isRootNode() const

Checks if this is the root node of the model.

bool isConfigured() const

Checks if this node was already configured by a handler.

bool isAlive() const

Checks if this node currently exists in the model.

QList<std::shared_ptr<sh::filesystem::FilesystemNode>> linkDestinationNodes() const

Returns the list of link source nodes. If this node is a link, the link destination nodes may influence the behavior and appearance of this node.

This information does not come from inside but must be set from outside the model implementation.

void setLinkDestinationNodes(QList<std::shared_ptr<sh::filesystem::FilesystemNode>> linkdestinations)

Sets the list of link destination nodes. If this node is a link, the link destination nodes may influence the behavior and appearance of this node.

void requestContainedItems(sh::filesystem::FilesystemNodeType type = FilesystemNodeType::NONE)

Requests to fetch the children of this node with help of the filesystem handler.

Signals

void removed()

Is emitted when this node is not placed in the tree anymore. This does not mean the physical deletion of the instance, but just means it is not alive from now on.

void _detailsAvailable()

Is emitted when values for detail columns arrived.

void iconChanged()

Is emitted when the icon changed.

void isHiddenChanged()

Is emitted when the hidden flag changed.

Private Members

bool loading

Friends

friend class sh::filesystem::FilesystemModel
class ModelBackedFilesystemNodeList : public sh::filesystem::FilesystemNodeList
#include <filesystemnodelist.h>

This FilesystemNodeList subclass builds a part of the filesystem model.

The listed nodes are actually owned and handled by a sh::filesystem::FilesystemNode. Node additions and removals will directly influence the model.

Public Functions

ModelBackedFilesystemNodeList(sh::filesystem::FilesystemNode *node)

Constructed only internally.

void addItems(QSet<std::shared_ptr<FilesystemNode>> nodes)
void addItem(std::shared_ptr<FilesystemNode> node)
void removeItems(QSet<std::shared_ptr<FilesystemNode>> nodes)
void removeItem(std::shared_ptr<FilesystemNode> node)
void resetItems(sh::filesystem::FilesystemNodeType type, QSet<std::shared_ptr<FilesystemNode>> nodes)
std::shared_ptr<FilesystemNode> mynode()

Returns the node which owns this children list. The result may be 0 for non model-backed lists.

void clear()

Clears the entire list. This is not a high-level operation, but something only used internally (not part of the interface).

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

Adds an item to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

This list is safe against removing from later item lists. Only removePermanentItem removes it. See also addItem.

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

Removes a permanent node from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void addItems(QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Adds items to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

void addItem(std::shared_ptr<sh::filesystem::FilesystemNode> node) = 0

Adds an item to this list. In a model-backed list, this triggers the internal model mounting calls. It is not allowed to call this method twice with the same node.

void removeItems(QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Removes nodes from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void removeItem(std::shared_ptr<sh::filesystem::FilesystemNode> node) = 0

Removes a node from this list. In a model-backed list, this triggers the internal model unmounting calls. It is not allowed to call this method with a node, which is not contained in that list.

void resetItems(sh::filesystem::FilesystemNodeType type, QSet<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0

Resets the list for a given node type to a given new list of children nodes.

bool contains(std::shared_ptr<FilesystemNode> node)

Checks if this list contains a given node.

const QList<std::shared_ptr<sh::filesystem::FilesystemNode>> *nodes()

Returns the list of nodes currently stored in this instance.

Private Functions

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

Private Members

QSet<sh::filesystem::FilesystemNode*> _permanentnodes
sh::filesystem::FilesystemNode *_mynode
sh::filesystem::FilesystemModel *mymodel
class Operation : public QObject
#include <operation.h>

A operation surrounds a completed series of steps in the filesystem.

For some steps to execute in the filesystem (i.e. not only the local one but the entire Eurl universe), it fetches intermediate files, caches them and writes them back to their real location afterwards.

It provides transaction-like operations for committing/dropping those intermediate files. A high-level interface for file management is avaiable in filesystem.

It is allowed to create new instances from scratch, but you should check if you implicitely have an instance available in your situation, or if sh::tools::OperationsCache is an option.

Public Functions

Operation(QObject *parent = 0)

Often constructed by the infrastructure and made available, but can also be constructed directly.

quint64 getFreeCacheSpace()

Returns the free disk space (in bytes) available for operations like fetchContainerFile() or fetchFile().

QString fetchContainerFile(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString namehint)

Fetches the container file for a eurl locally and returns the local path. Use this with care and only if needed. In many cases working with streams is the better way!

QString fetchContainerFile(std::shared_ptr<const sh::filesystem::Eurl> eurl)
QString fetchFile(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString namehint)

Fetches a file locally and returns the local path. Use this with care and only if needed. In many cases working with streams is the better way!

QString fetchFile(std::shared_ptr<const sh::filesystem::Eurl> eurl)
void abort()

Aborts transaction dropping all pending changes.

void commit()

Commits transaction applying all pending changes.

void enableDetailsCache()

Enable details caching.

bool isDetailsCacheEnabled()

Is details caching enabled?

void storeDetailInCache(std::shared_ptr<const sh::filesystem::Eurl> eurl, sh::filesystem::DetailColumn *column, QVariant value)

Stores a column detail in cache.

QVariant getDetailFromCache(std::shared_ptr<const sh::filesystem::Eurl> eurl, const sh::filesystem::DetailColumn *column)

Gets a column value from cache.

QList<std::shared_ptr<const sh::filesystem::Eurl>> pendingCommits()

Returns a list of sh::filesystem::Eurl items which are marked for commit.

QString getTempDir()

Creates a fresh temporary folder and returns the path to it.

void setCustomData(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString key, QVariant data)

Stores custom data.

QVariant getCustomData(std::shared_ptr<const sh::filesystem::Eurl> eurl, QString key)

Gets stored custom data.

void setMaxAllowedSizeRatioPerPart(double v)

Sets a maximum part of available disk space for usage. This is exotic functionality you typically don’t need. .

Parameters
  • v: A ratio (between 0 and 1) of the available disk space which one part maximally may cost.

sh::filesystem::FilesystemOperation *filesystem()

Gets the sh::filesystem::FilesystemOperation filesystem operation object.

~Operation()

Public Static Functions

void writeIODeviceToFile(QIODevice *content, QString filepath)

Low-level function for writing a QIODevice content to a local path.

Private Members

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> files
QSet<std::shared_ptr<const sh::filesystem::Eurl>> fileIsTemporary
QList<QString> tempDirs
bool _detailsCacheEnabled = false
QHash<std::shared_ptr<const sh::filesystem::Eurl>, QMap<QString, QVariant>> _customData
QHash<const sh::filesystem::DetailColumn*, QHash<std::shared_ptr<const sh::filesystem::Eurl>, QVariant>> _detailsCache
sh::filesystem::FilesystemOperation *_filesystemOperation
double _maxAllowedSizeRatioPerPart
QMutex operationlock

Private Static Attributes

QMutex _tempfilemutex
QString _tempdir
class MaxAllowedSizeRatioPerPartExceededException : public sh::exceptions::IOException
#include <operation.h>

IO exception raised when the value in setMaxAllowedSizeRatioPerPart() was exceeded.

Public Functions

MaxAllowedSizeRatioPerPartExceededException()
QString message() const
QString name() const
QString classes() const
QString details() const
QString callstack() const
QString auxiliary() const
QString customValue(QString key) const
bool isRuntimeException() const
bool isProgramException() const
bool isRetryable() const
bool isResumeable() const
bool isDetailsAreInteresting() const
int autoRetryRecommendedIn() const
void setResumeable(bool v)
void setReTryable(bool v)
void setCustomValue(QString key, QString value)
bool isClass(QString classname)
sh::exceptions::ExceptionData data()

Public Static Functions

template<class Handler>
std::shared_ptr<RegisterHandler<Handler>> createRegisterHandler(Handler handler, QStack<Handler> *stack)
void executeGuarded(std::function<void()> fctint flags = 0, )

Executes some code with some standard exection handling around.

Parameters
  • fct: The code to execute guarded.

  • flags: Flags of ExecuteGuardFlag for choosing the behavior.

void executeGuarded_errorpanel(std::function<void()> fctint flags = 0, )
QString _demangle(QString l)
void exceptionDialog(sh::exceptions::Exception &e, bool *doRetry)

Public Static Attributes

const QString UNDEFINED_ERROR_OCCURRED = QObject::tr("An unspecified error occurred.")
const QString SHALLOT_MUST_CLOSE_TEXT = QObject::tr("Your Shallot process is disturbed by an error and needs to be closed now. You can try if starting Shallot again solves the issue. If you are interested in technical details, please take a look at the log.")
const QString Value_isShallotException = "_isShallotException"