LiveDocument Class

Identifies a workspace document. More...

Header: #include <LiveDocument>

Public Functions

LiveDocument(const QString &relativeFilePath)
LiveDocument()
QString absoluteFilePathIn(const QDir &workspace) const
QString errorString() const
bool existsIn(const QDir &workspace) const
bool isFileIn(const QDir &workspace) const
bool isNull() const
bool mapsToResource(const ResourceMap &resourceMap) const
QString relativeFilePath() const
QUrl runtimeLocation(const QDir &workspace, const ResourceMap &resourceMap) const

Static Public Members

LiveDocument resolve(const QDir &workspace, const QString &filePath)
LiveDocument resolve(const QDir &workspace, const ResourceMap &resourceMap, const QString &filePath)
LiveDocument resolve(const QDir &workspace, const ResourceMap &resourceMap, const QUrl &fileUrl)
QString toFilePath(const QUrl &url)
QUrl toUrl(const QString &filePath)

Detailed Description

On the LiveHubEngine side, i.e. where the QmlLive Bench is running, it always represents a document on file system, under the workspace directory.

On the LiveNodeEngine side, i.e. on the QmlLive Runtime side, it represents a document that may exist either on file system or in a Qt resource. In either case the document is identified by the relative path of the original file under the workspace directory on the LiveHubEngine side. See runtimeLocation().

Member Function Documentation

LiveDocument::LiveDocument(const QString &relativeFilePath)

Constructs instance for the given relativeFilePath.

The relativeFilePath MUST NOT be an empty string, it MUST be a relative path, and when resolved relatively to a directory it MUST NOT resolve to a path outside of the directory.

LiveDocument::LiveDocument()

Constructs a null instance.

See also isNull() and errorString().

QString LiveDocument::absoluteFilePathIn(const QDir &workspace) const

Returns the absolute file path within a workspace, including the file name.

QString LiveDocument::errorString() const

When called just after resolve(), existsIn(), isFileIn() or mapsToResource() failed, returns a descriptive message suitable for displaying in user interface. When called in other context, the result is undefined.

bool LiveDocument::existsIn(const QDir &workspace) const

Returns true if this document exists in the given workspace directory.

See also errorString().

bool LiveDocument::isFileIn(const QDir &workspace) const

Returns true if this document exists as a regular file (or a symbolic link to a regular file) in the given workspace directory.

Symbolic links resolution applies.

See also errorString().

bool LiveDocument::isNull() const

Returns true if this is a null instance.

A null instance has been either contructed with the default constructor or the resolve() call failed.

See also errorString().

bool LiveDocument::mapsToResource(const ResourceMap &resourceMap) const

Returns true if the runtime location of the document is in a Qt resource. This is determined using the given resourceMap.

See also runtimeLocation(), LiveNodeEngine::resourceMap(), and errorString().

QString LiveDocument::relativeFilePath() const

Returns the relative file path including the file name.

[static] LiveDocument LiveDocument::resolve(const QDir &workspace, const QString &filePath)

Constructs a non-null instance unless the filePath resolves outside of the workspace directory.

filePath may be an absolute or relative file path to a file which is NOT required to exist.

See also isNull() and errorString().

[static] LiveDocument LiveDocument::resolve(const QDir &workspace, const ResourceMap &resourceMap, const QString &filePath)

Constructs a non-null instance for filePath that either resolves to a path under the workspace directory or determines a Qt resource for which a mapping exists in the given resourceMap.

filePath may be an absolute or relative file path to a file or a Qt resource path (starting with ":/" ). In either case the file is NOT required to exist,

See also isNull() and errorString().

[static] LiveDocument LiveDocument::resolve(const QDir &workspace, const ResourceMap &resourceMap, const QUrl &fileUrl)

Constructs a non-null instance for fileUrl that either resolves to a path under the workspace directory or determines a Qt resource for which a mapping exists in the given resourceMap.

fileUrl may be an URL representing a local file or a Qt resource path (e.g. "qrc:/example/icon.png"). In either case the file is NOT required to exist,

See also isNull() and errorString().

QUrl LiveDocument::runtimeLocation(const QDir &workspace, const ResourceMap &resourceMap) const

Determines the runtime location of the document. On LiveNodeEngine side a document may exist either on file system (under the given workspace) or in a Qt resource (determined using the given resourceMap).

Example:

LiveDocument document = ...;
LiveNodeEngine *engine = ...;
QFile file(document.runtimeLocation(engine->workspace(), *engine->resourceMap()));

See also mapsToResource() and LiveNodeEngine::resourceMap().

[static] QString LiveDocument::toFilePath(const QUrl &url)

Converts a local/Qt resource url to file path

[static] QUrl LiveDocument::toUrl(const QString &filePath)

Converts a local/Qt resource filePath to URL

© 2019 Luxoft Sweden AB. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.