AttachmentListModel Class

  • 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

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Types

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

    Public Functions

    virtual ~AttachmentListModel() override
    Esri::ArcGISRuntime::TaskWatcher addAttachment(QFile *file, const QString &contentType, const QString &name)
    Esri::ArcGISRuntime::TaskWatcher deleteAttachment(Esri::ArcGISRuntime::Attachment *attachment)
    Esri::ArcGISRuntime::TaskWatcher deleteAttachment(int index)
    Esri::ArcGISRuntime::TaskWatcher deleteAttachments(const QList<Esri::ArcGISRuntime::Attachment *> &attachments)
    Esri::ArcGISRuntime::TaskWatcher deleteAttachments(int index, int count = 1)
    Esri::ArcGISRuntime::TaskWatcher fetchAttachments()
    bool isAutoApplyEdits() const
    bool isAutoFetchAttachments() const
    void setAutoApplyEdits(bool autoApplyEdits)
    void setAutoFetchAttachments(bool autoFetchAttachments)
    Esri::ArcGISRuntime::TaskWatcher updateAttachment(Esri::ArcGISRuntime::Attachment *attachment, QFile *file, const QString &contentType, const QString &name)
    Esri::ArcGISRuntime::TaskWatcher updateAttachment(int index, QFile *file, const QString &contentType, const QString &name)

    Reimplemented Public Functions

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

    Signals

    void addAttachmentCompleted(QUuid taskId, Esri::ArcGISRuntime::Attachment *attachment)
    void deleteAttachmentCompleted(QUuid taskId)
    void deleteAttachmentsCompleted(QUuid taskId)
    void errorOccurred(Esri::ArcGISRuntime::Error error)
    void fetchAttachmentsCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::Attachment *> &attachments)
    void updateAttachmentCompleted(QUuid taskId)

    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

    [signal] void AttachmentListModel::addAttachmentCompleted(QUuid taskId, Esri::ArcGISRuntime::Attachment *attachment)

    Signal emitted when an attachment has finished being added to the feature.

    • taskId - The task ID of the asynchronous task.
    • attachment - The new attachment for the added attachment.

    The returned Attachment object has the AttachmentListModel as its parent.

    See also Returned QObjects Parenting.

    [signal] void AttachmentListModel::deleteAttachmentCompleted(QUuid taskId)

    Signal emitted when an attachment has been deleted from a feature.

    • taskId - The task ID of the asynchronous task.

    [signal] void AttachmentListModel::deleteAttachmentsCompleted(QUuid taskId)

    Signal emitted when attachments have been deleted from a feature.

    • taskId - The task ID of the asynchronous task.

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

    Signal emitted when an error occurs.

    • error - Details about the error.

    [signal] void AttachmentListModel::fetchAttachmentsCompleted(QUuid taskId, const QList<Esri::ArcGISRuntime::Attachment *> &attachments)

    Signal emitted when attachments have finished being fetched from a feature.

    • taskId - The task ID of the asynchronous task.
    • attachments - The list of attachments that were fetched from the feature.

    The returned Attachment objects have the AttachmentListModel as their parent.

    See also Returned QObjects Parenting.

    [signal] void AttachmentListModel::updateAttachmentCompleted(QUuid taskId)

    Signal emitted when an attachment has been updated in a feature.

    • taskId - The task ID of the asynchronous task.

    [override virtual] AttachmentListModel::~AttachmentListModel()

    Destructor.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::addAttachment(QFile *file, const QString &contentType, const QString &name)

    Adds a new feature attachment and returns a TaskWatcher for the asynchronous task.

    • file - The file to read that contains the attachment data.
    • contentType - The MIME type of the new attachment.
    • name - The name to give the new attachment.

    If file does not exist, the attachment is added without data.

    [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.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::deleteAttachment(Esri::ArcGISRuntime::Attachment *attachment)

    Deletes an existing attachment from this feature and returns a TaskWatcher for the asynchronous task.

    List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::deleteAttachment(int index)

    Deletes an existing attachment from this feature using its index in the model and returns the a TaskWatcher for the asynchronous task.

    List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::deleteAttachments(const QList<Esri::ArcGISRuntime::Attachment *> &attachments)

    Deletes a list of existing attachments from this feature and returns a TaskWatcher for the asynchronous task.

    List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::deleteAttachments(int index, int count = 1)

    Deletes existing attachments from this feature using a starting index and count from beginning index in the model and returns a TaskWatcher for the asynchronous task.

    List models do not take ownership of the objects they contain. Therefore, removing or clearing objects from the list model will not delete those objects. An RAII technique should be used to ensure that memory is properly deallocated.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::fetchAttachments()

    Fetches the attachments that belong to this feature and returns the a TaskWatcher for the asynchronous task.

    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

    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().

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::updateAttachment(Esri::ArcGISRuntime::Attachment *attachment, QFile *file, const QString &contentType, const QString &name)

    Updates an existing attachment and returns the task ID for the asynchronous task.

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

    If file does not exist, the attachment's data is removed.

    Esri::ArcGISRuntime::TaskWatcher AttachmentListModel::updateAttachment(int index, QFile *file, const QString &contentType, const QString &name)

    Updates a feature attachment referenced at a given index in the model, and returns the task ID for the asynchronous task.

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

    If file does not exist, the attachment's data is removed.

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