MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QML MessageModel Element

The MessageModel element provides access to messages. More...

This element was introduced in Mobility 1.1.

Properties

Signals

Methods

Detailed Description

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.

Property Documentation

read-onlycount : int

Holds the number of messages matching the filter.

If limit is set then there will be at most limit messages.

This property group was introduced in Mobility 1.1.


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.


Signal Documentation

MessageModel::messageAdded ()

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.


Method Documentation

MessageModel::removeMessage ( index )

Remove the message at index from the mail store and the originating server (if applicable).

This documentation was introduced in Mobility 1.1.


MessageModel::showMessage ( index )

Displays the message at index using the system message client.

This documentation was introduced in Mobility 1.1.