Skip To Content ArcGIS for Developers Sign In Dashboard

PortalItemCommentListModel Class

(Esri::ArcGISRuntime::PortalItemCommentListModel)

Represents the list of comments relating to a PortalItem. More...

Header: #include <PortalItemCommentListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Iterable<PortalItemComment *> (private)

Public Types

enum PortalItemCommentRoles { PortalItemCommentCommentRole, PortalItemCommentCommentIdRole, PortalItemCommentCreatedRole, PortalItemCommentOwnerRole }

Public Functions

~PortalItemCommentListModel()
PortalItemComment *at(int index) const
bool contains(PortalItemComment *portalItemComment) const
PortalItemComment *first() const
int indexOf(PortalItemComment *portalItemComment) const
bool isEmpty() const
PortalItemComment *last() const
int size() const

Reimplemented Public Functions

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

Signals

void errorOccurred(Esri::ArcGISRuntime::Error error)
void portalItemCommentAdded(int index)
void portalItemCommentRemoved(int index)

Additional Inherited Members

Detailed Description

Represents the list of comments relating to a PortalItem.

Comments can be retrieved by calling fetchComments on a PortalItem and accessed via the {PortalItem::comments} {comments} method after the task is complete.

The model returns data for the following roles:

RoleTypeDescriptionSublayerRoles
commentQStringThe text of the comment.PortalItemCommentCommentRole
commentIdQStringThe ID of the comment.PortalItemCommentCommentIdRole
createdQDateTimeThe date the comment was created.PortalItemCommentCreatedRole
ownerQStringThe username of the user that added the comment.PortalItemCommentOwnerRole

Example:

Accessing various roles of the model from within a QML delegate:

Text{
    anchors.fill: parent
    // acccess the comment, commentId, created and owner roles of the model
    text: "comment:" + comment + "; ID:" + commentId + "; created:" + created + "; owner: " + owner
    wrapMode: Text.WrapAnywhere
}

See also PortalUser, PortalItemComment, and PortalItem.

Member Type Documentation

enum PortalItemCommentListModel::PortalItemCommentRoles

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

ConstantValueDescription
Esri::ArcGISRuntime::PortalItemCommentListModel::PortalItemCommentCommentRoleQt::UserRole + 1The text of the comment.
Esri::ArcGISRuntime::PortalItemCommentListModel::PortalItemCommentCommentIdRoleQt::UserRole + 2The ID of the comment.
Esri::ArcGISRuntime::PortalItemCommentListModel::PortalItemCommentCreatedRoleQt::UserRole + 3The date the comment was created.
Esri::ArcGISRuntime::PortalItemCommentListModel::PortalItemCommentOwnerRoleQt::UserRole + 4The username of the user that added the comment.

Member Function Documentation

PortalItemCommentListModel::~PortalItemCommentListModel()

Destructor.

PortalItemComment *PortalItemCommentListModel::at(int index) const

Returns the PortalItemComment at the specified index.

bool PortalItemCommentListModel::contains(PortalItemComment *portalItemComment) const

Returns true if the list model contains the PortalItemComment portalItemComment.

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

Reimplemented from QAbstractItemModel::data().

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

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

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

Signal emitted when an error occurs.

  • error - Details about the error.

PortalItemComment *PortalItemCommentListModel::first() const

Returns the first PortalItemComment in the list model.

int PortalItemCommentListModel::indexOf(PortalItemComment *portalItemComment) const

Returns the index of the PortalItemComment portalItemComment.

bool PortalItemCommentListModel::isEmpty() const

Returns whether the list model is empty (contains no comments).

PortalItemComment *PortalItemCommentListModel::last() const

Returns the last PortalItemComment in the list model.

[signal] void PortalItemCommentListModel::portalItemCommentAdded(int index)

Signal emitted when a PortalItemComment is added to the list model.

index is the index of the added PortalItemComment.

[signal] void PortalItemCommentListModel::portalItemCommentRemoved(int index)

Signal emitted when a PortalItemComment is removed from the list model.

index is the index of the removed PortalItemComment.

int PortalItemCommentListModel::size() const

Returns the number of comments contained in the list model.


Feedback on this topic?