The MessageModel element provides access to messages. More...
This element was introduced in Mobility 1.1.
This element is part of the QtMobility.messaging 1.1 module.
MessageModel provides a model of messages from the message store. The contents of the model can be specified via a filter, and sorted via the sortBy and sortOrder properties. The model is automatically updated if the contents of the store change.
The following roles are supported by the model:
Role | type |
---|---|
subject | string |
type | enumeration
|
size | int |
sender | string |
to | List<string> |
date | Date |
receivedDate | Date |
priority | enumeration
|
body | string |
ready | bool |
Note: since the body can be large and may need to be fetched from the server it is recommended that viewing the body be a user action, and the body role not be bound to until needed. If the body has not yet been downloaded, it will be requested. body will remain undefined until it has been retrieved.
The ready role is true if the message meta data has been retrieved; otherwise false. Since MessageModel threaded, all messages are initially not ready, and will become ready once the data is available.
The following example displays the subject, sender and date of all messages sorted in descending order by timestamp:
import Qt 4.7 import QtMobility.messaging 1.1 Rectangle { width: 320 height: 480 ListView { id: list anchors.fill: parent model: MessageModel { sortBy: MessageModel.Timestamp sortOrder: MessageModel.DescendingOrder } delegate: Item { id: wrapper height: 32; width: list.width Text { id: subjText; text: subject; font.pixelSize: 13; x: 3 } Text { text: sender; color: "gray"; font.pixelSize: 9 x: 3; width: parent.width-100; anchors.top: subjText.bottom; anchors.topMargin: 3 elide: Text.ElideRight } Text { text: date; color: "gray"; font.pixelSize: 9 anchors.right: parent.right anchors.top: subjText.bottom; anchors.topMargin: 3 } } } }
See also MessageFilter.
read-onlycount : int |
filter : MessageFilter |
The MessageFilter specifying the messages to provide.
This property group was introduced in Mobility 1.1.
limit : int |
Holds the maximum number of messages to retrieve.
A value of zero (default) will retrieve all messages.
This property group was introduced in Mobility 1.1.
sortBy : enumeration |
Specifies the role to sort by:
This property group was introduced in Mobility 1.1.
sortOrder : enumeration |
Specifies the sort order:
This property group was introduced in Mobility 1.1.
This handler is called when a message that matches the filter criteria is added to the store. The model will be updated shortly and will include the new message.
This documentation was introduced in Mobility 1.1.
Remove the message at index from the mail store and the originating server (if applicable).
This documentation was introduced in Mobility 1.1.
Displays the message at index using the system message client.
This documentation was introduced in Mobility 1.1.