Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

QMailMessageListModel Class Reference
[QtMessagingModule, QtPimModule]

The QMailMessageListModel class provides access to a list of stored messages. More...

    #include <QMailMessageListModel>

This class is under development and is subject to change.

Inherits QAbstractListModel.

Public Types

Public Functions

Signals

Additional Inherited Members


Detailed Description

The QMailMessageListModel class provides access to a list of stored messages.

The QQMailMessageListModel presents a list of all the messages currently stored in the message store. By using the setKey() and sortKey() functions it is possible to have the model represent specific user filtered subsets of messages sorted in a particular order.

The QMailMessageListModel is a descendant of QAbstractListModel, so it is suitable for use with the Qt View classes such as QListView to visually represent lists of messages.

The model listens for changes reported by the QMailStore, and automatically synchronizes its content with that of the store. This behaviour can be optionally or temporarily disabled by calling the setIgnoreMailStoreUpdates() function.

Messages can be extracted from the view with the idFromIndex() function and the resultant id can be used to load a message from the store.

For filters or sorting not provided by the QMailMessageListModel it is recommended that QSortFilterProxyModel is used to wrap the model to provide custom sorting and filtering.

See also QMailMessage and QSortFilterProxyModel.


Member Type Documentation

enum QMailMessageListModel::Roles

Represents common display roles of a message. These roles are used to display common message elements in a view and its attached delegates.

ConstantValueDescription
QMailMessageListModel::MessageAddressTextRoleQt::UserRoleThe address text of a message. This a can represent a name if the address is tied to a contact in the addressbook and represents either the incoming or outgoing address depending on the message direction.
QMailMessageListModel::MessageSubjectTextRole?The subject of a message. For-non email messages this may represent the body text of a message.
QMailMessageListModel::MessageFilterTextRole?The MessageAddressTextRole concatenated with the MessageSubjectTextRole. This can be used by filtering classes to filter messages based on the text of these commonly displayed roles.
QMailMessageListModel::MessageTimeStampTextRole?The timestamp of a message. "Recieved" or "Sent" is prepended to the timestamp string depending on the message direction.
QMailMessageListModel::MessageTypeIconRole?An Icon representing the type of the message.
QMailMessageListModel::MessageStatusIconRole?An Icon representing the status of the message. e.g Read, Unread, Downloaded
QMailMessageListModel::MessageDirectionIconRole?An Icon representing the incoming or outgoing direction of a message.
QMailMessageListModel::MessagePresenceIconRole?An Icon representing the presence status of the contact associated with the MessageAddressTextRole.
QMailMessageListModel::MessageBodyTextRole?The body of a message represented as text.
QMailMessageListModel::MessageIdRole?The QMailMessageId value identifying the message.


Member Function Documentation

QMailMessageListModel::QMailMessageListModel ( QObject * parent = 0 )

Constructs a QMailMessageListModel with a parent parent.

By default, the model will match all messages in the database, and display them in the order they were submitted, and mail store updates are not ignored.

See also setKey(), setSortKey(), and setIgnoreMailStoreUpdates().

QMailMessageListModel::~QMailMessageListModel ()   [virtual]

Deletes the QMailMessageListModel object.

QMailMessageId QMailMessageListModel::idFromIndex ( const QModelIndex & index ) const

Returns the QMailMessageId of the message represented by the QModelIndex index. If the index is not valid an invalid QMailMessageId is returned.

bool QMailMessageListModel::ignoreMailStoreUpdates () const

Returns true if the model has been set to ignore updates emitted by the mail store; otherwise returns false.

See also setIgnoreMailStoreUpdates().

QModelIndex QMailMessageListModel::indexFromId ( const QMailMessageId & id ) const

Returns the QModelIndex that represents the message with QMailMessageId id. If the id is not conatained in this model, an invalid QModelIndex is returned.

bool QMailMessageListModel::isEmpty () const

Returns true if the model contains no messages.

QMailMessageKey QMailMessageListModel::key () const

Returns the QMailMessageKey used to populate the contents of this model.

See also setKey().

void QMailMessageListModel::modelChanged ()   [signal]

Signal emitted when the data set represented by the model is changed. Unlike modelReset(), the modelChanged() signal can not be emitted as a result of changes occurring in the current data set.

void QMailMessageListModel::setIgnoreMailStoreUpdates ( bool ignore )

Sets whether or not mail store updates are ignored to ignore.

If ignoring updates is set to true, the model will ignore updates reported by the mail store. If set to false, the model will automatically synchronize its content in reaction to updates reported by the mail store.

If updates are ignored, signals such as rowInserted and dataChanged will not be emitted; instead, the modelReset signal will be emitted when the model is later changed to stop ignoring mail store updates, and detailed change information will not be accessible.

See also ignoreMailStoreUpdates().

void QMailMessageListModel::setKey ( const QMailMessageKey & key )

Sets the QMailMessageKey used to populate the contents of the model to key. If the key is empty, the model is populated with all the messages from the database.

See also key().

void QMailMessageListModel::setSortKey ( const QMailMessageSortKey & sortKey )

Sets the QMailMessageSortKey used to sort the contents of the model to sortKey. If the sort key is invalid, no sorting is applied to the model contents and messages are displayed in the order in which they were added into the database.

See also sortKey().

QMailMessageSortKey QMailMessageListModel::sortKey () const

Returns the QMailMessageSortKey used to sort the contents of the model.

See also setSortKey().


Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3