|  | Home |

# QMailMessageModelBase Class Reference

The QMailMessageModelBase class provides an interface to a model containing messages. More...

        #include <QMailMessageModelBase>

This class is under development and is subject to change.

Inherits QAbstractItemModel.

Inherited by QMailMessageListModel and QMailMessageThreadedModel.

- List of all members, including inherited members

## Public Types

enum | Roles { MessageAddressTextRole, MessageSubjectTextRole, MessageFilterTextRole, MessageTimeStampTextRole, ..., MessageIdRole }

## Public Functions

| QMailMessageModelBase ( QObject * parent = 0 )
QMailMessageId | idFromIndex ( const QModelIndex & index ) const
bool | ignoreMailStoreUpdates () const
QModelIndex | indexFromId ( const QMailMessageId & id ) const
bool | isEmpty () const
QMailMessageKey | key () const
void | setIgnoreMailStoreUpdates ( bool ignore )
void | setKey ( const QMailMessageKey & key )
void | setSortKey ( const QMailMessageSortKey & sortKey )
QMailMessageSortKey | sortKey () const

## Reimplemented Public Functions

virtual int | columnCount ( const QModelIndex & index = QModelIndex() ) const
virtual QVariant | data ( const QModelIndex & index, int role = Qt::DisplayRole ) const
virtual int | rowCount ( const QModelIndex & index = QModelIndex() ) const
virtual bool | setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )

- 34 public functions inherited from QAbstractItemModel
- 29 public functions inherited from QObject

## Signals

void | modelChanged ()

- 14 signals inherited from QAbstractItemModel
- 1 signal inherited from QObject

### Additional Inherited Members

- 1 property inherited from QObject
- 2 public slots inherited from QAbstractItemModel
- 1 public slot inherited from QObject
- 1 public type inherited from QObject
- 4 static public members inherited from QObject
- 14 protected functions inherited from QAbstractItemModel
- 7 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

The QMailMessageModelBase class provides an interface to a model containing messages.

The QMailMessageModelBase presents a model 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 QMailMessageModelBase is a descendant of QAbstractListModel, so it is suitable for use with the Qt View classes such as QListView and QTreeView to visually present groups 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 QMailMessageModelBase 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 QMailMessageModelBase::Roles

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

Constant | Value | Description
--- | --- | ---
`QMailMessageModelBase::MessageAddressTextRole` | `Qt::UserRole` | The 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.
`QMailMessageModelBase::MessageSubjectTextRole` | ? | The subject of a message. For-non email messages this may represent the body text of a message.
`QMailMessageModelBase::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.
`QMailMessageModelBase::MessageTimeStampTextRole` | ? | The timestamp of a message. "Received" or "Sent" is prepended to the timestamp string depending on the message direction.
`QMailMessageModelBase::MessageSizeTextRole` | ? | The size of a message, formatted as text.
`QMailMessageModelBase::MessageTypeIconRole` | ? | A string that can be passed to QIcon representing the type of the message.
`QMailMessageModelBase::MessageStatusIconRole` | ? | A string that can be passed to QIcon representing the status of the message. e.g Read, Unread, Downloaded
`QMailMessageModelBase::MessageDirectionIconRole` | ? | A string that can be passed to QIcon representing the incoming or outgoing direction of a message.
`QMailMessageModelBase::MessagePresenceIconRole` | ? | A string that can be passed to QIcon representing the presence status of the contact associated with the MessageAddressTextRole.
`QMailMessageModelBase::MessageBodyTextRole` | ? | The body of a message represented as text.
`QMailMessageModelBase::MessageIdRole` | ? | The QMailMessageId value identifying the message.

## Member Function Documentation

### QMailMessageModelBase::QMailMessageModelBase ( QObject * parent = 0 )

Constructs a QMailMessageModelBase with the parent parent.

### int QMailMessageModelBase::columnCount ( const QModelIndex & index = QModelIndex() ) const `[virtual]`

Reimplemented from QAbstractItemModel::columnCount().

### QVariant QMailMessageModelBase::data ( const QModelIndex & index, int role = Qt::DisplayRole ) const `[virtual]`

Reimplemented from QAbstractItemModel::data().

See also setData().

### QMailMessageId QMailMessageModelBase::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 QMailMessageModelBase::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 QMailMessageModelBase::indexFromId ( const QMailMessageId & id ) const

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

### bool QMailMessageModelBase::isEmpty () const

Returns true if the model contains no messages.

### QMailMessageKey QMailMessageModelBase::key () const

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

See also setKey().

### void QMailMessageModelBase::modelChanged () `[signal]`

Signal that is emitted when the content or ordering of the model is reset.

### int QMailMessageModelBase::rowCount ( const QModelIndex & index = QModelIndex() ) const `[virtual]`

Reimplemented from QAbstractItemModel::rowCount().

### bool QMailMessageModelBase::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) `[virtual]`

Reimplemented from QAbstractItemModel::setData().

See also data().

### void QMailMessageModelBase::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 QMailMessageModelBase::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() and modelChanged().

### void QMailMessageModelBase::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() and modelChanged().

### QMailMessageSortKey QMailMessageModelBase::sortKey () const

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

See also setSortKey().