Skip To Content ArcGIS for Developers Sign In Dashboard

AttachmentListModel Class

(Esri::ArcGISRuntime::AttachmentListModel)

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

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

Public Types

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

Public Functions

~AttachmentListModel()
TaskWatcher addAttachment(QFile *file, const QString &contentType, const QString &name)
TaskWatcher deleteAttachment(Attachment *attachment)
TaskWatcher deleteAttachment(int index)
TaskWatcher deleteAttachments(const QList<Attachment *> &attachments)
TaskWatcher deleteAttachments(int index, int count = 1)
TaskWatcher fetchAttachments()
bool isAutoApplyEdits() const
bool isAutoFetchAttachments() const
void setAutoApplyEdits(bool autoApplyEdits)
void setAutoFetchAttachments(bool autoFetchAttachments)
TaskWatcher updateAttachment(Attachment *attachment, QFile *file, const QString &contentType, const QString &name)
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

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)

Additional Inherited Members

Detailed Description

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

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

AttachmentListModel::~AttachmentListModel()

Destructor.

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.

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

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

Reimplemented from QAbstractItemModel::data().

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.

TaskWatcher AttachmentListModel::deleteAttachment(Attachment *attachment)

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

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.

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

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

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

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.

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

TaskWatcher AttachmentListModel::fetchAttachments()

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

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

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

TaskWatcher AttachmentListModel::updateAttachment(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.

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.

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

Feedback on this topic?