Skip to content

Class QFieldCloudUtils

ClassList > QFieldCloudUtils

Inherits the following classes: QObject

Public Static Functions

Type Name
Q_INVOKABLE void addPendingAttachments (const QString & username, const QString & projectId, const QStringList & fileNames, QFieldCloudConnection * cloudConnection=nullptr, const bool & checkSumCheck=false)
Q_INVOKABLE QString documentationFromErrorString (const QString & errorString)
const QMultiMap< QString, QString > getPendingAttachments (const QString & username)
Returns the list of attachments that have not yet been uploaded to the cloud.
Q_INVOKABLE const QString getProjectId (const QString & fileName)
Q_INVOKABLE bool hasPendingAttachments (const QString & username)
Returns TRUE if pending attachments are detected.
bool isCloudAction (const QgsMapLayer * layer)
const QString localCloudDirectory ()
const QString localProjectFilePath (const QString & username, const QString & projectId)
const QVariant projectSetting (const QString & projectId, const QString & setting, const QVariant & defaultValue=QVariant())
Gets a setting value for project with given__projectId from the permanent storage. Return__defaultValue if not present.
void removePendingAttachment (const QString & username, const QString & projectId, const QString & fileName)
Removes a fileName for a given__projectId to the pending attachments list.
void setLocalCloudDirectory (const QString & path)
void setProjectSetting (const QString & projectId, const QString & setting, const QVariant & value)
Sets a setting to a given__value for project with given__projectId to the permanent storage.
Q_INVOKABLE QString userFriendlyErrorString (const QString & errorString)

Public Static Functions Documentation

function addPendingAttachments

static Q_INVOKABLE void QFieldCloudUtils::addPendingAttachments (
    const QString & username,
    const QString & projectId,
    const QStringList & fileNames,
    QFieldCloudConnection * cloudConnection=nullptr,
    const bool & checkSumCheck=false
) 

Adds an array of files and/or folders for a given cloud project to the pending upload attachments list. If checkSumCheck is true, checks file checksums with the server; otherwise, adds all files without validation.

Parameters:

  • projectId The project ID for which files are added.
  • fileNames The list of file and/or folder path(s) to be added.
  • cloudConnection The cloud connection used to fetch file data.
  • checkSumCheck Whether to validate files by comparing checksums with the server.

function documentationFromErrorString

static Q_INVOKABLE QString QFieldCloudUtils::documentationFromErrorString (
    const QString & errorString
) 

Returns a documentation page hyperlink related to the provided error string.

Parameters:

  • errorString the error string to be processed

Returns:

The hyperlink to the documentation page related to the provided error code, or an empty string if no match is found.


function getPendingAttachments

Returns the list of attachments that have not yet been uploaded to the cloud.

static const QMultiMap< QString, QString > QFieldCloudUtils::getPendingAttachments (
    const QString & username
) 

function getProjectId

static Q_INVOKABLE const QString QFieldCloudUtils::getProjectId (
    const QString & fileName
) 

Returns the cloud project ID for a given file path.

This function checks if the given file path is under the QField local cloud directory. If it is, it extracts and returns the project ID (UUID-like string) from the path. Otherwise, it returns a null QString.

Parameters:

  • fileName Full path to a file or directory inside a cloud project

Returns:

QString Project ID if found; otherwise, an empty string


function hasPendingAttachments

Returns TRUE if pending attachments are detected.

static Q_INVOKABLE bool QFieldCloudUtils::hasPendingAttachments (
    const QString & username
) 

function isCloudAction

static bool QFieldCloudUtils::isCloudAction (
    const QgsMapLayer * layer
) 

Returns if the layer action has do be handled with QFieldCloud.

Parameters:

  • layer to be checked

Returns:

const bool true if the layer has the action not selected 'no_action' (on online databases) or 'remove'


function localCloudDirectory

static const QString QFieldCloudUtils::localCloudDirectory () 

Returns the path to the local cloud directory. By default inside the user profile unless overwritten with setLocalCloudDirectory

Note:

The returned path will never have have a trailing '/' or '\' .


function localProjectFilePath

static const QString QFieldCloudUtils::localProjectFilePath (
    const QString & username,
    const QString & projectId
) 

Returns the file path to the locally-stored cloud project file.


function projectSetting

Gets a setting value for project with given__projectId from the permanent storage. Return__defaultValue if not present.

static const QVariant QFieldCloudUtils::projectSetting (
    const QString & projectId,
    const QString & setting,
    const QVariant & defaultValue=QVariant()
) 

function removePendingAttachment

Removes a fileName for a given__projectId to the pending attachments list.

static void QFieldCloudUtils::removePendingAttachment (
    const QString & username,
    const QString & projectId,
    const QString & fileName
) 

function setLocalCloudDirectory

static void QFieldCloudUtils::setLocalCloudDirectory (
    const QString & path
) 

Sets the local cloud directory. Must be set before the first call to localCloudDirectory.


function setProjectSetting

Sets a setting to a given__value for project with given__projectId to the permanent storage.

static void QFieldCloudUtils::setProjectSetting (
    const QString & projectId,
    const QString & setting,
    const QVariant & value
) 

function userFriendlyErrorString

static Q_INVOKABLE QString QFieldCloudUtils::userFriendlyErrorString (
    const QString & errorString
) 

Returns a user-friendly error message.

Parameters:

  • errorString the error string to be processed.

Returns:

A user-friendly error message that will be displayed to the user, translated based on received error code.



The documentation for this class was generated from the following file src/core/utils/qfieldcloudutils.h