Home · All Classes · Grouped Classes · Annotated · Functions

QContactModel Class Reference

The QContactModel class provides access to the Contacts data. More...

    #include <QContactModel>

Inherits QPimModel.

Inherited by ServerContactModel.

Public Types

Public Functions

Static Public Members

Additional Inherited Members


Detailed Description

The QContactModel class provides access to the Contacts data.

User contacts are represented in the contact model as a table, with each row corresponding to a particular contact and each column as on of the fields of the contact. Complete QContact objects can be retrieved using the contact() function which takes either a row, index, or unique identifier.

The contact model is a descendant of QAbstractItemModel, so it is suitable for use with the Qt View classes such as QListView and QTableView, as well as QContactView and any custom views.

The contact model provides functions for sorting and some filtering of items. For filters or sorting that is not provided by the contact model it is recommended that QSortFilterProxyModel is used to wrap the contact model.

A QContactModel instance will also reflect changes made in other instances of QContactModel, both within this application and from other applications. This will result in the modelReset() signal being emitted.

See also QContact, QContactListView, QSortFilterProxyModel, and Pim Library.


Member Type Documentation

enum QContactModel::Field

Enumerates the columns when in table mode and columns used for sorting. Is a subset of data retrievable from a QContact.

ConstantValueDescription
QContactModel::Invalid-1An invalid field
QContactModel::Label0An appropriate text label for the contact
QContactModel::NameTitle1The contact's title, such as Mr or Dr.
QContactModel::FirstName2The first name of the contact
QContactModel::MiddleName3The middle name of the contact
QContactModel::LastName4The last name of the contact
QContactModel::Suffix5The contact's suffix, such as Jr or II.
QContactModel::JobTitle6The contact's job title
QContactModel::Department7The contact's department
QContactModel::Company8The contact's company
QContactModel::BusinessPhone9The business phone number of the contact
QContactModel::BusinessFax10The business fax number of the contact
QContactModel::BusinessMobile11The business mobile number of the contact
QContactModel::BusinessPager28The business pager number of the contact
QContactModel::HomePhone19The home phone number of the contact
QContactModel::HomeFax20The home fax number of the contact
QContactModel::HomeMobile21The home mobile number of the contact
QContactModel::DefaultPhone14The default phone number for the contact
QContactModel::DefaultEmail12The default email address for the contact
QContactModel::Emails13The list of email addresses for the contact
QContactModel::BusinessStreet23The business street address for the contact
QContactModel::BusinessCity24The city for the business address of the contact
QContactModel::BusinessState25The state for the business address of the contact
QContactModel::BusinessZip26The zip code for the business address of the contact
QContactModel::BusinessCountry27The country for the business address of the contact
QContactModel::BusinessWebPage29The business web page address of the contact
QContactModel::Office30The contact's office
QContactModel::Profession31The contact's profession
QContactModel::Assistant32The contact's assistant
QContactModel::Manager33The contact's manager
QContactModel::HomeStreet34The home street address for the contact
QContactModel::HomeCity35The city for the home address of the contact
QContactModel::HomeState36The state for the home address of the contact
QContactModel::HomeZip37The zip code for the home address of the contact
QContactModel::HomeCountry38The country for the home address of the contact
QContactModel::HomeWebPage39The home web page address of the contact
QContactModel::Spouse40The contact's spouse
QContactModel::Gender41The contact's gender
QContactModel::Birthday42The contact's birthday
QContactModel::Anniversary43The contact's anniversary
QContactModel::Nickname44The nickname of the contact
QContactModel::Children45The contact's children
QContactModel::Portrait46The portrait of the contact
QContactModel::Notes47The notes relating to the contact
QContactModel::LastNamePronunciation48The pronunciation of the last name of the contact
QContactModel::FirstNamePronunciation49The pronunciation of the first name of the contact
QContactModel::CompanyPronunciation50The pronunciation of the contact's company
QContactModel::Identifier51The identifier of the contact
QContactModel::Categories52The list of categories the contact belongs to
QContactModel::HomeVOIP54The URI for the contact's home VOIP id
QContactModel::BusinessVOIP55The URI for the contact's business VOIP id

See also localeNameTitles() and localeSuffixes().

enum QContactModel::FilterFlags

These flags describe what kind of contact information to filter contacts on.

ConstantValueDescription
QContactModel::ContainsPhoneNumber0x00100The contact must provide one or more phone numbers.
QContactModel::ContainsEmail0x0200The contact must provide one or more email addresses.
QContactModel::ContainsMailing0x0400The contact must provide one or more mailing addresses.

See also setFilter().

enum QContactModel::QContactModelRole

Extends Qt::ItemDataRole

ConstantValueDescription
QContactModel::LabelRoleQt::UserRoleA short formatted text label of the contacts name.
QContactModel::SubLabelRoleQt::UserRole + 1A short formatted text label with supplementary contact information, like phone number, email address or company.
QContactModel::PortraitRoleQt::UserRole + 2A pixmap of the contacts image, or a default image if none is specifically set.
QContactModel::StatusIconRoleQt::UserRole + 3An icon providing additional information about the contact. For instance marking as a business contact or marking the contact as recently called.


Member Function Documentation

QContactModel::QContactModel ( QObject * parent = 0 )

Constructs contact model with the given parent.

QContactModel::~QContactModel ()   [virtual]

Destroys the contact model.

QUniqueId QContactModel::addContact ( const QContact & contact, const QPimSource & source = QPimSource() )

Adds the contact to the model under the specified storage source. If source is null the function will add the contact to the default storage source.

Returns a valid identifier for the contact if the contact was successfully added. Otherwise returns a null identifier.

Note the current identifier of the specified appointment is ignored.

See also phoneSource(), simSource(), and mirrorToSource().

QUniqueId QContactModel::addRecord ( const QByteArray & bytes, const QPimSource & source, const QString & format = QString() )   [virtual]

Adds the PIM record encoded in bytes to the model under the specified storage source. The format of the record in bytes is given by format. An empty format string will cause the record to be read using the data stream operators for the PIM data type of the model. If the specified source is null the function will add the record to the default storage source.

Returns a valid identifier for the record if the record was successfully added. Otherwise returns a null identifier.

Can only add PIM data that is represented by the model. This means that only contact data can be added using a contact model. Valid formats are "vCard" or an empty string.

Reimplemented from QPimModel.

void QContactModel::clearFilter ()

Clears contact name and type filtering for the model. Does not affect category filtering.

void QContactModel::clearPersonalDetails ()

Clears the personal details of the device owner. Does not remove and contacts from the contact model.

/sa setPersonalDetails()

QContact QContactModel::contact ( const QModelIndex & index ) const

Returns the contact for the row specified by index. The column of index is ignored.

QContact QContactModel::contact ( int row ) const

This is an overloaded member function, provided for convenience.

Return the contact for the given row.

QContact QContactModel::contact ( const QUniqueId & identifier ) const

This is an overloaded member function, provided for convenience.

Returns the contact in the model with the given identifier. The contact does not have to be in the current filter mode for it to be returned.

QVariant QContactModel::contactField ( const QContact & contact, QContactModel::Field field )   [static]

Returns the value for the specified field of the given contact.

See also setContactField().

QVariant QContactModel::data ( const QModelIndex & index, int role ) const   [virtual]

Returns the data stored under the given role for the item referred to by the index.

The row of the index specifies which contact to access and the column of the index is treated as a QContactModel::Field.

Reimplemented from QAbstractItemModel.

See also setData() and contactField().

QIcon QContactModel::fieldIcon ( Field field )   [static]

Returns a icon representing the contact model field.

Returns a null icon if no icon is available.

See also fieldLabel(), fieldIdentifier(), and identifierField().

QString QContactModel::fieldIdentifier ( Field field )   [static]

Returns a non-translated string describing the contact model field.

See also fieldLabel(), fieldIcon(), and identifierField().

QString QContactModel::fieldLabel ( Field field )   [static]

Returns a translated string describing the contact model field.

See also fieldIcon(), fieldIdentifier(), and identifierField().

int QContactModel::filterFlags () const

Returns the filter flags being used by the model.

See also setFilter().

QString QContactModel::filterText () const

Returns the filter text being used by the model.

See also setFilter().

bool QContactModel::hasPersonalDetails () const

Returns true if a contact in the contact model is specified as the personal details of the device owner.

Field QContactModel::identifierField ( const QString & identifier )   [static]

Returns the contact model field for the non-translated field identifier.

See also fieldLabel(), fieldIcon(), and fieldIdentifier().

bool QContactModel::isPersonalDetails ( const QModelIndex & row ) const

Returns true if the contact for the specified row represents the personal details of the device owner.

bool QContactModel::isPersonalDetails ( int row ) const

This is an overloaded member function, provided for convenience.

Returns true if the contact at the given row represents the personal details of the device owner.

bool QContactModel::isPersonalDetails ( const QUniqueId & identifier ) const

This is an overloaded member function, provided for convenience.

Returns true if the contact with specified identifier represents the personal details of the device owner.

bool QContactModel::isSIMCardContact ( const QModelIndex & index ) const

Returns true if the contact at the given index is stored on the SIM card.

bool QContactModel::isSIMCardContact ( const QUniqueId & identifier ) const

This is an overloaded member function, provided for convenience.

Returns true if the contact with the given identifier is on the SIM card.

QList<Field> QContactModel::labelFields ()   [static]

Returns the contact model fields that represent the label for a contact.

QStringList QContactModel::localeNameTitles ()   [static]

Returns known name titles for the current language settings. These are used to assist in parsing and constructing contact name information. Contacts are not restricted to these name titles.

QStringList QContactModel::localeSuffixes ()   [static]

Returns known suffixes for the current language settings. These are used to assist in parsing and constructing contact name information. Contacts are not restricted to these suffixes.

QModelIndexList QContactModel::match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const

Returns a list of indexes for the items where the data matches the specified value. The list that is returned may be empty.

The search starts from the start index and continues until the number of matching data items equals hits or the search reaches the last row

The arguments role and flags are currently ignored.

QContact QContactModel::matchEmailAddress ( const QString & text )

Returns the best match for the email address text. If no contact in the model has an email address matching the given text returns a null contact.

QContact QContactModel::matchPhoneNumber ( const QString & text )

Returns the best match for the phone number text. If no contact in the model has a phone number matching the given text returns a null contact.

bool QContactModel::mirrorAll ( const QPimSource & source, const QPimSource & destination )

Exports the contacts stored in source storage source and imports them into the destination storage source. The contacts are modified by the source and destination storage contexts to account for storage restrictions.

Returns true upon success.

See also mirrorToSource().

bool QContactModel::mirrorToSource ( const QPimSource & destination, const QUniqueId & identifier )

Exports the contact in the model with the specified identifier and imports it into the destination storage source. The contact is modified by the source and destination storage contexts to account for storage restrictions. For instance a contact may be split into multiple contacts when mirrored to the active SIM card and contacts from the SIM card will be merged into contacts in local storage if they have equal name information.

Returns true upon success.

See also mirrorAll().

QContact QContactModel::personalDetails () const

Returns the contact representing the personal details of the device owner.

If no contact is specified as the personal details of the device owner, will return a null contact.

See also setPersonalDetails().

QUniqueId QContactModel::personalID () const

Returns the identifier for the contact representing the personal details of the device owner.

If no contact is specified as the personal details of the device owner, will return a null identifier.

QList<Field> QContactModel::phoneFields ()   [static]

Returns the contact model fields that represent the phone numbers for a contact.

QPimSource QContactModel::phoneSource () const

Returns the default identifier for storage sources relating to the device memory.

QByteArray QContactModel::record ( const QUniqueId & identifier, const QString & format = QString() ) const   [virtual]

Returns the record in the model with the specified identifier encoded in the format specified by the format string. An empty format string will cause the record to be written using the data stream operators for the PIM data type of the model.

Valid formats are "vCard" or an empty string.

Reimplemented from QPimModel.

See also contact().

bool QContactModel::removeContact ( const QContact & contact )

Removes the contact from the model with the same identifier as the specified contact.

Returns true if the contact was successfully removed.

bool QContactModel::removeContact ( const QUniqueId & identifier )

This is an overloaded member function, provided for convenience.

Removes the contact from the model with the specified identifier.

Returns true if the contact was successfully removed.

bool QContactModel::removeList ( const QList<QUniqueId> & identifiers )

Removes the records in the model specified by the list of identifiers.

Returns true if contacts were successfully removed.

bool QContactModel::removeRecord ( const QUniqueId & identifier )   [virtual]

Removes the record from the model with the specified identifier.

Returns true if the record was successfully removed.

Reimplemented from QPimModel.

bool QContactModel::setContactField ( QContact & contact, QContactModel::Field field, const QVariant & value )   [static]

Sets the value for the specified field of the given contact to value.

Returns true if the contact was modified.

See also contactField() and setData().

bool QContactModel::setData ( const QModelIndex & index, const QVariant & value, int role )   [virtual]

Sets the role data for the item at index to value. Returns true if successful.

The contact model only accepts data for the EditRole. The column of the specified index specifies the QContactModel::Field to set and the row of the index specifies which contact to modify.

Reimplemented from QAbstractItemModel.

See also data() and setContactField().

void QContactModel::setFilter ( const QString & text, int flags = 0 )

Sets the model to filter contacts by labels that start with text and contact type information specified flags. By default flags is 0 which means filtering will only occur based on label text.

See also FilterFlags, filterFlags(), and filterText().

void QContactModel::setPersonalDetails ( const QUniqueId & identifier )

Sets the personal details of the device owner to the contact with the given identifier. If there is no contact with the specified identifier in the contact model this will clear the personal details.

See also personalDetails() and clearPersonalDetails().

QPimSource QContactModel::simSource () const

Returns the identifier for storage sources relating to the SIM Card.

void QContactModel::sort ( int column, Qt::SortOrder order = Qt::AscendingOrder )   [virtual]

Sorts the model by column in ascending order

Currently order is ignored but may be implemented at a future date.

Reimplemented from QAbstractItemModel.

bool QContactModel::updateContact ( const QContact & contact )

Updates the contact in the model with the same identifier as the specified contact to equal the specified contact.

Returns true if the contact was successfully updated.

bool QContactModel::updateRecord ( const QUniqueId & id, const QByteArray & bytes, const QString & format = QString() )   [virtual]

Updates the corresponding record in the model to equal the record encoded in bytes. The format of the record in bytes is given by the format string. An empty format string will cause the record to be read using the data stream operators for the PIM data type of the model. If id is not null will set the record identifier to id before attempting to update the record.

Returns true if the record was successfully updated.

Valid formats are "vCalendar" or an empty string.

Reimplemented from QPimModel.

See also updateContact().

bool QContactModel::writeVCard ( const QString & filename )

Write vCards for all visible contacts in the model to the file specified by filename.

Returns true if successful.


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3