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 |
(since Esri::ArcGISRuntime 200.2) QFuture<Esri::ArcGISRuntime::Attachment *> | addAttachmentAsync(QIODevice &ioDevice, const QString &contentType, const QString &name, QObject *parent = nullptr) |
(since Esri::ArcGISRuntime 200.2) QFuture<void> | deleteAttachmentAsync(Esri::ArcGISRuntime::Attachment *attachment) |
(since Esri::ArcGISRuntime 200.2) QFuture<void> | deleteAttachmentAsync(int index) |
(since Esri::ArcGISRuntime 200.2) QFuture<void> | deleteAttachmentsAsync(const QList<Esri::ArcGISRuntime::Attachment *> &attachments) |
(since Esri::ArcGISRuntime 200.2) QFuture<void> | deleteAttachmentsAsync(int index, int count = 1) |
(since Esri::ArcGISRuntime 200.2) QFuture<QList<Esri::ArcGISRuntime::Attachment *>> | fetchAttachmentsAsync(QObject *parent = nullptr) |
(since Esri::ArcGISRuntime 200.2) QFuture<void> | updateAttachmentAsync(Esri::ArcGISRuntime::Attachment *attachment, QIODevice &ioDevice, const QString &contentType, const QString &name) |
(since Esri::ArcGISRuntime 200.2) 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:
Role | Type | Description | AttachmentRoles |
---|---|---|---|
name | QString | The name of the attachment. | AttachmentNameRole |
contentType | QString | The MIME type of the attachment file. | AttachmentContentTypeRole |
dataFetched | bool | Whether the attachment data has already been retrieved. | AttachmentDataFetchedRole |
size | qint64 | The size of the attachment in bytes. | AttachmentSizeRole |
attachmentUrl | QUrl | The URL of the attachment. | AttachmentUrlRole |
attachmentId | qint64 | The ID of the attachment (since 100.1) | AttachmentIdRole |
Relevant samples:
- Edit feature attachments: Add, delete, and download attachments for features from a service.
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.
Constant | Value | Description |
---|---|---|
Esri::ArcGISRuntime::AttachmentListModel::AttachmentNameRole | Qt::UserRole + 1 | The name of the attachment. |
Esri::ArcGISRuntime::AttachmentListModel::AttachmentContentTypeRole | Qt::UserRole + 2 | The MIME type of the attachment file. |
Esri::ArcGISRuntime::AttachmentListModel::AttachmentDataFetchedRole | Qt::UserRole + 3 | Whether the attachment data has already been retrieved. |
Esri::ArcGISRuntime::AttachmentListModel::AttachmentSizeRole | Qt::UserRole + 4 | The size of the attachment in bytes. |
Esri::ArcGISRuntime::AttachmentListModel::AttachmentUrlRole | Qt::UserRole + 5 | The URL of the attachment. |
Esri::ArcGISRuntime::AttachmentListModel::AttachmentIdRole | Qt::UserRole + 6 | The ID of the attachment (since 100.1). |
Member Function Documentation
[override virtual noexcept]
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.
[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.