# class ItemModel

###

Module | akonadi
Namespace | Akonadi
Class | ItemModel
Inherits | QAbstractTableModel

A table model for items.

A self-updating table model that shows all items of a collection.

    QTableView *view = new QTableView( this );

    Akonadi.ItemModel *model = new Akonadi.ItemModel();
    view->setModel( model );

    model->setCollection( Akonadi.Collection.root() );

Author Volker Krause <vkrause@kde.org>

### enums

- Column { Id, RemoteId, MimeType }
- Roles { IdRole, ItemRole, MimeTypeRole, UserRole }

enum details

### methods

- ItemModel (parent)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  parent | QObject | 0

  Creates a new item model.

  parent - The parent object.

- collectionChanged (collection)

  returns Nothing
  SIGNAL ("collectionChanged (const Collection&)")

  Argument | Type | Default
  --- | --- | ---
  collection | Akonadi.Collection |

  This signal is emitted whenever setCollection is called.

- columnCount (parent)

  returns int

  Argument | Type | Default
  --- | --- | ---
  parent | QModelIndex | QModelIndex()

- data (index, role)

  returns QVariant

  Argument | Type | Default
  --- | --- | ---
  index | QModelIndex |
  role | int | Qt.DisplayRole

- dropMimeData (data, action, row, column, parent)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  data | QMimeData |
  action | Qt.DropAction |
  row | int |
  column | int |
  parent | QModelIndex |

- fetchScope ( )

  returns Akonadi.ItemFetchScope

  Returns the item fetch scope.

  Since this returns a reference it can be used to conveniently modify the current scope in-place, i.e. by calling a method on the returned reference without storing it in a local variable. See the ItemFetchScope documentation for an example.

  Returns a reference to the current item fetch scope.

  See also setFetchScope() for replacing the current item fetch scope.

- flags (index)

  returns Qt.ItemFlags

  Argument | Type | Default
  --- | --- | ---
  index | QModelIndex |

- headerData (section, orientation, role)

  returns QVariant

  Argument | Type | Default
  --- | --- | ---
  section | int |
  orientation | Qt.Orientation |
  role | int | Qt.DisplayRole

- indexForItem (item, column)

  returns QModelIndex

  Argument | Type | Default
  --- | --- | ---
  item | Akonadi.Item |
  column | int |

  Returns the model index for the given item, with the given column.

  item - The item to find.

  column - The column for the returned index.

- itemForIndex (index)

  returns Akonadi.Item

  Argument | Type | Default
  --- | --- | ---
  index | QModelIndex |

  Returns the item at the given index.

- mimeData (indexes)

  returns QMimeData

  Argument | Type | Default
  --- | --- | ---
  indexes | QModelIndexList |

- mimeTypes ( )

  returns QStringList

- rowCount (parent)

  returns int

  Argument | Type | Default
  --- | --- | ---
  parent | QModelIndex | QModelIndex()

- session ( )

  returns Akonadi.Session

  Returns the Session object used for all operations by this model.

- setCollection (collection)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  collection | Akonadi.Collection |

  Sets the collection the model should display. If the collection has changed, the model is reset and a new message listing is requested from the Akonadi storage.

  collection - The collection.

- setFetchScope (fetchScope)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  fetchScope | Akonadi.ItemFetchScope |

  Sets the item fetch scope.

  The ItemFetchScope controls how much of an item's data is fetched from the server, e.g. whether to fetch the full item payload or only meta data.

  fetchScope - the new scope for item fetch operations

  See also fetchScope()

### enums - detail

- Column { Id, RemoteId, MimeType }

  Describes the types of the columns in the model.

  | Id | - 0 | - |
  | RemoteId | - | - |
  | MimeType | - | - |

- Roles { IdRole, ItemRole, MimeTypeRole, UserRole }

  Describes the roles of the model.

  | IdRole | - Qt::UserRole+1 | - |
  | ItemRole | - | - |
  | MimeTypeRole | - | - |
  | UserRole | - Qt::UserRole+42 | - |