QString CntSymbianSimEngine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const { Q_UNUSED(error); QContactName name = contact.detail(QContactName::DefinitionName); if(!name.customLabel().isEmpty()) { return name.customLabel(); } else { return QString(""); } }
/* Synthesise the display label of a contact */ QString QContactMaemo5Engine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const { QString label; // Try to get the display name from the OSSO-ABook Contact label = d->m_abook->getDisplayName(contact); // Synthesise the display label for not saved contacts // A. FirstName + LastName if (label.isEmpty()){ QContactName name = contact.detail(QContactName::DefinitionName); QStringList nameList; nameList << name.firstName(); if (name.lastName().count()){ nameList << name.lastName(); } label = nameList.join(QString(' ')); } // B. Email if (label.isEmpty()){ QContactEmailAddress email = contact.detail(QContactEmailAddress::DefinitionName); label = email.emailAddress(); } // if (label.isEmpty()){ *error = QContactManager::UnspecifiedError; return QString("No name"); } *error = QContactManager::NoError; return label; }
void MainWindow::on_pushButton_3_clicked() { // qDebug() << "The default manager for the platform is:" << cm.managerName(); // qDebug() << "It" << (cm.isRelationshipTypeSupported(QContactRelationship::HasAssistant) ? "supports" : "does not support") << "assistant relationships."; // qDebug() << "It" << (cm.supportedContactTypes().contains(QContactType::TypeGroup) ? "supports" : "does not support") << "groups."; // qDebug() << "It" << (cm.hasFeature(QContactManager::MutableDefinitions) ? "supports" : "does not support") << "mutable detail definitions."; QList<QContactLocalId> contactIds = cm.contactIds(); QContact a = cm.contact(contactIds.first()); qDebug() << "Viewing the details of" << a.displayLabel(); QList<QContactDetail> allDetails = a.details(); for (int i = 0; i < allDetails.size(); i++) { QContactDetail detail = allDetails.at(i); QContactDetailDefinition currentDefinition = cm.detailDefinition(detail.definitionName()); QMap<QString, QContactDetailFieldDefinition> fields = currentDefinition.fields(); qDebug("\tDetail #%d (%s):", i, detail.definitionName().toAscii().constData()); foreach (const QString& fieldKey, fields.keys()) { qDebug() << "\t\t" << fieldKey << "(" << fields.value(fieldKey).dataType() << ") =" << detail.value(fieldKey); } qDebug(); } QContact b; QContactDetail de; foreach (const QContactLocalId& ids, contactIds ) { b = cm.contact(ids); de = b.detail("PhoneNumber"); bool s = de.hasValue("PhoneNumber"); qDebug()<< " has Value PhoneNumber key"<<s<<"|"<<de.value("PhoneNumber"); QString show; show = b.displayLabel(); show.append("\t"); show.append(de.value("PhoneNumber")); ui->listWidget_2->addItem(show); }
/*! * Generate the display label * \a contact to read the data from . * \a detailList contains the details to be read from the contact * \return synthesised display label */ QString CntDisplayLabel::generateDisplayLabel( const QContact &contact, const QList<QList<QPair<QLatin1String, QLatin1String> > > detailList) const { // Default to empty display label. It is up to the client to create a // localised presentation of a contact without a name. QString displayLabel(""); //loop through the details and create display label for(int i = 0; i < detailList.count() && displayLabel.isEmpty(); i++ ) { QList<QPair<QLatin1String, QLatin1String> > detailPairList = detailList.at(i); QContactDetail contactDetail; for(int j = 0; j < detailPairList.count(); j++) { contactDetail = contact.detail(detailPairList.at(j).first); if(displayLabel.isEmpty()){ //read the value and set it as display label displayLabel = contactDetail.value(detailPairList.at(j).second); } else{ //read the value and append it to the display label QString label = contactDetail.value(detailPairList.at(j).second); if(!label.isEmpty()) { #ifdef SYMBIAN_BACKEND_USE_SQLITE // Inlcude a comma if needed in the display label if (m_nameOrder == CntOrderLastCommaFirst) displayLabel.append(comma()); #endif displayLabel.append(delimiter()); displayLabel.append(label); } } } } return displayLabel; }