|  | Home |

# QMailAccountListModel Class Reference

The QMailAccountListModel class provides access to a list of stored accounts. More...

        #include <QMailAccountListModel>

This class is under development and is subject to change.

Inherits QAbstractListModel.

- List of all members, including inherited members

## Public Types

enum | Roles { NameTextRole, MessageTypeRole, MessageSourcesRole, MessageSinksRole }

## Public Functions

| QMailAccountListModel ( QObject * parent = 0 )
virtual | ~QMailAccountListModel ()
QMailAccountId | idFromIndex ( const QModelIndex & index ) const
QModelIndex | indexFromId ( const QMailAccountId & id ) const
QMailAccountKey | key () const
void | setKey ( const QMailAccountKey & key )
void | setSortKey ( const QMailAccountSortKey & sortKey )
void | setSynchronizeEnabled ( bool val )
QMailAccountSortKey | sortKey () const
bool | synchronizeEnabled () const

## Reimplemented Public Functions

virtual QVariant | data ( const QModelIndex & index, int role = Qt::DisplayRole ) const
virtual int | rowCount ( const QModelIndex & index = QModelIndex() ) const

- 1 public function inherited from QAbstractListModel
- 34 public functions inherited from QAbstractItemModel
- 29 public functions inherited from QObject

### Additional Inherited Members

- 1 property inherited from QObject
- 2 public slots inherited from QAbstractItemModel
- 1 public slot inherited from QObject
- 14 signals inherited from QAbstractItemModel
- 1 signal 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 QMailAccountListModel class provides access to a list of stored accounts.

The QMailAccountListModel presents a list of all the accounts 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 accounts sorted in a particular order.

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

The model listens for changes to the underlying storage system and sychronizes its contents based on the setSynchronizeEnabled() setting.

Accounts can be extracted from the view with the idFromIndex() function and the resultant id can be used to load an account from the store.

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

See also QMailAccount and QSortFilterProxyModel.

## Member Type Documentation

### enum QMailAccountListModel::Roles

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

Constant | Value | Description
--- | --- | ---
`QMailAccountListModel::NameTextRole` | `Qt::UserRole` | The name of the account
`QMailAccountListModel::MessageTypeRole` | ? | The type of the account
`QMailAccountListModel::MessageSourcesRole` | ? | The list of message sources for the account
`QMailAccountListModel::MessageSinksRole` | ? | The list of message sinks for the account

## Member Function Documentation

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

Constructs a QMailAccountListModel with a parent parent. By default, the model will match all accounts in the database, and display them in the order they were submitted. Synchronization defaults to true.

### QMailAccountListModel::~QMailAccountListModel () `[virtual]`

Deletes the QMailMessageListModel object.

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

Reimplemented from QAbstractItemModel::data().

### QMailAccountId QMailAccountListModel::idFromIndex ( const QModelIndex & index ) const

Returns the QMailAccountId of the account represented by the QModelIndex index. If the index is not valid an invalid QMailAccountId is returned.

### QModelIndex QMailAccountListModel::indexFromId ( const QMailAccountId & id ) const

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

### QMailAccountKey QMailAccountListModel::key () const

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

See also setKey().

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

Reimplemented from QAbstractItemModel::rowCount().

### void QMailAccountListModel::setKey ( const QMailAccountKey & key )

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

See also key().

### void QMailAccountListModel::setSortKey ( const QMailAccountSortKey & sortKey )

Sets the QMailAccountSortKey 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 accounts are displayed in the order in which they were added into the database.

See also sortKey().

### void QMailAccountListModel::setSynchronizeEnabled ( bool val )

Sets wheather the model synchronizes its contents based on account changes in the database to val.

See also synchronizeEnabled().

### QMailAccountSortKey QMailAccountListModel::sortKey () const

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

See also setSortKey().

### bool QMailAccountListModel::synchronizeEnabled () const

Returns `true` if the model sychronizes its contents based on account changes in the database, otherwise returns `false`.

See also setSynchronizeEnabled().