AttachmentListModel Class

Attachments available for an ArcGISFeature."> AttachmentListModel Class | ArcGISQtCpp
  • AttachmentListModel
  • class Esri::ArcGISRuntime::AttachmentListModel

    A list model storing a list of Attachments available for an ArcGISFeature. More...

    Header: #include <AttachmentListModel.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: QAbstractListModel

    Public Types

    enum AttachmentRoles { AttachmentNameRole, AttachmentContentTypeRole, AttachmentDataFetchedRole, AttachmentSizeRole, AttachmentUrlRole, AttachmentIdRole }

    Public Functions

    virtual ~AttachmentListModel() override
    QFuture<Esri::ArcGISRuntime::Attachment *> addAttachmentAsync(QIODevice &ioDevice, const QString &contentType, const QString &name, QObject *parent = nullptr)
    QFuture<void> deleteAttachmentAsync(Esri::ArcGISRuntime::Attachment *attachment)
    QFuture<void> deleteAttachmentAsync(int index)
    QFuture<void> deleteAttachmentsAsync(const QList<Esri::ArcGISRuntime::Attachment *> &attachments)
    QFuture<void> deleteAttachmentsAsync(int index, int count = 1)
    QFuture<QList<Esri::ArcGISRuntime::Attachment *>> fetchAttachmentsAsync(QObject *parent = nullptr)
    bool isAutoApplyEdits() const
    bool isAutoFetchAttachments() const
    void setAutoApplyEdits(bool autoApplyEdits)
    void setAutoFetchAttachments(bool autoFetchAttachments)
    QFuture<void> updateAttachmentAsync(Esri::ArcGISRuntime::Attachment *attachment, QIODevice &ioDevice, const QString &contentType, const QString &name)
    QFuture<void> updateAttachmentAsync(int index, QIODevice &ioDevice, const QString &contentType, const QString &name)

    Reimplemented Public Functions

    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override

    Signals

    void errorOccurred(const Esri::ArcGISRuntime::Error &error)

    Detailed Description

    Modifying this model (adding, updating, or deleting) will update the attachments that belong to the corresponding ArcGIS feature.

    By default, attachment edits will be automatically applied back to the server if the ArcGIS feature belongs to a ServiceFeatureTable. Attachments will also automatically be fetched each time an attachment edit operation completes. This class contains members to change this default behavior.

    This class is a subclass of QAbstractListModel.

    The model returns data for the following roles:

    RoleTypeDescriptionAttachmentRoles
    nameQStringThe name of the attachment.AttachmentNameRole
    contentTypeQStringThe MIME type of the attachment file.AttachmentContentTypeRole
    dataFetchedboolWhether the attachment data has already been retrieved.AttachmentDataFetchedRole
    sizeqint64The size of the attachment in bytes.AttachmentSizeRole
    attachmentUrlQUrlThe URL of the attachment.AttachmentUrlRole
    attachmentIdqint64The ID of the attachment (since 100.1)AttachmentIdRole

    See also ArcGISFeature, setAutoFetchAttachments, and setAutoApplyEdits.

    Member Type Documentation

    enum AttachmentListModel::AttachmentRoles

    This enum specifies the custom roles which can be used with AttachmentListModel::data.

    ConstantValueDescription
    Esri::ArcGISRuntime::AttachmentListModel::AttachmentNameRoleQt::UserRole + 1The name of the attachment.
    Esri::ArcGISRuntime::AttachmentListModel::AttachmentContentTypeRoleQt::UserRole + 2The MIME type of the attachment file.
    Esri::ArcGISRuntime::AttachmentListModel::AttachmentDataFetchedRoleQt::UserRole + 3Whether the attachment data has already been retrieved.
    Esri::ArcGISRuntime::AttachmentListModel::AttachmentSizeRoleQt::UserRole + 4The size of the attachment in bytes.
    Esri::ArcGISRuntime::AttachmentListModel::AttachmentUrlRoleQt::UserRole + 5The URL of the attachment.
    Esri::ArcGISRuntime::AttachmentListModel::AttachmentIdRoleQt::UserRole + 6The ID of the attachment (since 100.1).

    Member Function Documentation

    [override virtual] AttachmentListModel::~AttachmentListModel()

    Destructor.

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::Attachment *> AttachmentListModel::addAttachmentAsync(QIODevice &ioDevice, const QString &contentType, const QString &name, QObject *parent = nullptr)

    Adds a new feature attachment.

    • ioDevice - The file or other IO device to read that contains the attachment data.
    • contentType - The MIME type of the new attachment.
    • name - The name to give the new attachment.
    • parent - The optional parent QObject

    If ioDevice cannot be read, the attachment is added without data.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [override virtual] QVariant AttachmentListModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const

    Reimplements: QAbstractItemModel::data(const QModelIndex &index, int role) const.

    Returns the data stored under the given role for the attachment referred to by the index.

    • index. The index in the model for which to return data.
    • role. The role for which to return data.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> AttachmentListModel::deleteAttachmentAsync(Esri::ArcGISRuntime::Attachment *attachment)

    Deletes an existing attachment from this feature.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> AttachmentListModel::deleteAttachmentAsync(int index)

    Deletes an existing attachment from this feature using its index in the model.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> AttachmentListModel::deleteAttachmentsAsync(const QList<Esri::ArcGISRuntime::Attachment *> &attachments)

    Deletes a list of existing attachments from this feature.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> AttachmentListModel::deleteAttachmentsAsync(int index, int count = 1)

    Deletes existing attachments from this feature using a starting index and count from beginning index in the model.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [signal] void AttachmentListModel::errorOccurred(const Esri::ArcGISRuntime::Error &error)

    Signal emitted when an error occurs.

    • error - Details about the error.

    [since Esri::ArcGISRuntime 200.2] QFuture<QList<Esri::ArcGISRuntime::Attachment *>> AttachmentListModel::fetchAttachmentsAsync(QObject *parent = nullptr)

    Fetches the attachments that belong to this feature. parent - The optional parent QObject Attachments are returned in descending order based on their id.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    bool AttachmentListModel::isAutoApplyEdits() const

    Returns true if the model will automatically apply attachment edits back to the server.

    By default, automatically applying attachment edits is enabled. Only applicable if the model is bound to a ServiceFeatureTable.

    bool AttachmentListModel::isAutoFetchAttachments() const

    Returns true if the model will attempt to fetch attachments

    Note that fetchAttachmentsCompleted will emit when automatic fetching of attachments has completed.

    See also setAutoFetchAttachments.

    void AttachmentListModel::setAutoApplyEdits(bool autoApplyEdits)

    Set autoApplyEdits to true to have the model automatically apply attachment edits back to the server.

    By default, automatically applying attachment edits is enabled. Only applicable if the model is bound to a ServiceFeatureTable.

    See also isAutoApplyEdits().

    void AttachmentListModel::setAutoFetchAttachments(bool autoFetchAttachments)

    Sets whether the model will automatically fetch attachments after an attachment edit operation completes.

    • autoFetchAttachments - Whether to fetch attachments automatically. The default value is true.

    When instantiated, the model always fetches attachments. This setting only limits subsequent attachment fetches.

    See also isAutoFetchAttachments().

    [since Esri::ArcGISRuntime 200.2] QFuture<void> AttachmentListModel::updateAttachmentAsync(Esri::ArcGISRuntime::Attachment *attachment, QIODevice &ioDevice, const QString &contentType, const QString &name)

    Updates an existing attachment

    • attachment - The Attachment describing the attachment to update.
    • ioDevice - The file or other IO device to read that contains the attachment data.
    • contentType - The MIME type of the attachment.
    • name - The name to give the attachment.

    If ioDevice cannot be read, the attachment's data is removed.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<void> AttachmentListModel::updateAttachmentAsync(int index, QIODevice &ioDevice, const QString &contentType, const QString &name)

    Updates an existing attachment

    • index - The index in the model.
    • ioDevice - The file or other IO device to read that contains the attachment data.
    • contentType - The MIME type of the attachment.
    • name - The name to give the attachment.

    If ioDevice cannot be read, the attachment's data is removed.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.