The identifying string for this component is "QtMobility.messaging". Use this in the QML import statement.
The Messaging QML plugin supplies filters to search for messages with particular values for various properties in the message. The Message itself is represented by a model called a MessageModel. This model supplies a rich selection of properties to display or to use as filter criteria. We can also construct a series of filters and combine them using the MessageIntersectionFilter and MessageUnionFilter to represent a logical 'and' and 'or' of the results. Other properties also give control over the filter logic, such as MessageFilter::negated and the Comparators.
A filter query is made of various parts. Below is a list of some of the things that may be used to construct a search
Component | Description |
---|---|
filter | This property of MessageModel acts as the container for a constructed MessageFilter. |
MessageIntersectionFilter | AND a list of filter conditions together. |
MessageUnionFilter | OR a list of filter conditions together. |
comparator | The boolean comparison against a value in the conditions e.g. LessThan |
type | Contains a set of message fields including timestamp, folder, priority. |
sortBy | The message field used as the basis for the sort of a result. |
sortOrder | Select Ascending or Descending sort order of the sortBy data. |
As an example consider the follow QML code which has a MessageModel element containing a filter. The filter is made up of an intersection of the message Size less than 1024 AND a union of (Sender is "martin" AND Subject does not include "re:") OR Sender includes "don".
Notice the use of the property value which contains the tested value. The MessageModel sets the sortBy and sortOrder so that the results are ordered by Timestamp in DescendingOrder.
import QtMobility.messaging 1.1 model: MessageModel { sortBy: MessageModel.Timestamp sortOrder: MessageModel.DescendingOrder filter: MessageIntersectionFilter { MessageFilter { type: MessageFilter.Size value: 1024 comparator: MessageFilter.LessThan } MessageUnionFilter { MessageIntersectionFilter { MessageFilter { type: MessageFilter.Sender value: "martin" comparator: MessageFilter.Includes } MessageFilter { negated: true type: MessageFilter.Subject value: "re:" comparator: MessageFilter.Includes } } MessageFilter { type: MessageFilter.Sender value: "don" comparator: MessageFilter.Includes } } } }
The MessageModel element provides access to the returned list of results allowing both control of the list and access to the data of particular messages.
In the following snippet of code the delegate, of the unshown ListView element, accesses various fields of each message in the list to display a meaningful list of message items.
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 } }
The code displays a list of messages showing the sender and subject details. The MessageModel element also enables the use of the platform message display tool so that after a message is selected it can be correctly displayed.
The MessageFilter element specifies a message filter for MessageModel | |
The MessageIntersectionFilter element specifies an insection of MessageFilter | |
The MessageModel element provides access to messages. | |
The MessageUnionFilter element specifies a union of MessageFilter |