Qt Mobility Reference Documentation

QML MessageModel Element

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

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:

Roletype

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

count : int

Holds the number of messages matching the filter.

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


filter : MessageFilter

The MessageFilter specifying the messages to provide.


limit : int

Holds the maximum number of messages to retrieve.

A value of zero (default) will retrieve all messages.


sortBy : enumeration

Specifies the role to sort by:


sortOrder : enumeration

Specifies the sort order:


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.


Method Documentation

MessageModel::removeMessage ( index )

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


MessageModel::showMessage ( index )

Displays the message at index using the system message client.


X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.