--- a/qtmobility/examples/qmlcontacts/qmlcontact.cpp Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/examples/qmlcontacts/qmlcontact.cpp Mon May 03 13:18:40 2010 +0300
@@ -47,7 +47,7 @@
QT_USE_NAMESPACE
QTM_USE_NAMESPACE
-QmlContact::QmlContact(QContact& contact, QObject *parent)
+QmlContact::QmlContact(const QContact& contact, QObject *parent)
: QObject(parent), m_contact(contact)
{
}
@@ -75,50 +75,7 @@
QString QmlContact::name()
{
- QList<QContactDetail> allNames = m_contact.details(QContactName::DefinitionName);
-
- const QLatin1String space(" ");
-
- // synthesise the display label from the name.
- for (int i=0; i < allNames.size(); i++) {
- const QContactName& name = allNames.at(i);
-
- QString result;
- if (!name.value(QContactName::FieldPrefix).trimmed().isEmpty()) {
- result += name.value(QContactName::FieldPrefix);
- }
-
- if (!name.value(QContactName::FieldFirst).trimmed().isEmpty()) {
- if (!result.isEmpty())
- result += space;
- result += name.value(QContactName::FieldFirst);
- }
-
- if (!name.value(QContactName::FieldMiddle).trimmed().isEmpty()) {
- if (!result.isEmpty())
- result += space;
- result += name.value(QContactName::FieldMiddle);
- }
-
- if (!name.value(QContactName::FieldLast).trimmed().isEmpty()) {
- if (!result.isEmpty())
- result += space;
- result += name.value(QContactName::FieldLast);
- }
-
- if (!name.value(QContactName::FieldSuffix).trimmed().isEmpty()) {
- if (!result.isEmpty())
- result += space;
- result += name.value(QContactName::FieldSuffix);
- }
-
- if (!result.isEmpty()) {
- return result;
- }
- }
-
-
- return QString("noName");
+ return m_contact.displayLabel();
}
void QmlContact::setName(QString name)
@@ -190,5 +147,3 @@
}
#include "moc_qmlcontact.cpp"
-
-QML_DEFINE_TYPE(QmlContact, 1, 0, QmlContact, QmlContact)