Exemplo n.º 1
0
void SeasidePerson::setCompanyName(const QString &name)
{
    QContactOrganization companyNameDetail = mContact.detail<QContactOrganization>();
    companyNameDetail.setName(name);
    mContact.saveDetail(&companyNameDetail);
    emit companyNameChanged();
}
Exemplo n.º 2
0
QContactDetail *CntTransformOrganisation::transformItemField(const CContactItemField& field, const QContact &contact)
{
    QContactOrganization *organisation = new QContactOrganization(contact.detail<QContactOrganization>());

	CContactTextField* storage = field.TextStorage();
	QString orgDetail = QString::fromUtf16(storage->Text().Ptr(), storage->Text().Length());

	for (int i = 0; i < field.ContentType().FieldTypeCount(); i++) {
		//Company
		if (field.ContentType().FieldType(i) == KUidContactFieldCompanyName) {
            organisation->setName(orgDetail);
		}
		//Department
		else if (field.ContentType().FieldType(i) == KUidContactFieldDepartmentName) {
		    // Assume only a single department
		    QStringList departments = QStringList(orgDetail);
            organisation->setDepartment(departments);
		}
		//Job title
		else if (field.ContentType().FieldType(i) == KUidContactFieldJobTitle) {
            organisation->setTitle(orgDetail);
		}
	    //Assistant name
	    else if (field.ContentType().FieldType(i) == KUidContactFieldAssistant) {
            organisation->setAssistantName(orgDetail);
	    }
	}

	return organisation;
}
/*!
 * The leaving function that queries the SQL database
 * 
 * \a aSqlQuery An SQL query
 * \return the list of matched contact ids
 */
QList<QContact> CntSymbianSrvConnection::searchContactNamesL(const TDesC& aSqlQuery)
{
    readContactsToBufferL(aSqlQuery, CntSymbianSrvConnection::CntSearchResultList);

    RBufReadStream readStream;
    QList<QContact> contacts;
    TInt id;
    TBuf<256> firstName;
    TBuf<256> lastName;
    TBuf<256> company;

    readStream.Open(*m_buffer);
    while ((id = readStream.ReadInt32L()) != 0) {
        readStream >> firstName;
        readStream >> lastName;
        readStream >> company;

        QContact contact, tempContact;

        QContactName name;
        name.setFirstName(QString::fromUtf16(firstName.Ptr(), firstName.Length()));
        name.setLastName(QString::fromUtf16(lastName.Ptr(), lastName.Length()));
        tempContact.saveDetail(&name);

        QContactOrganization organization;
        organization.setName(QString::fromUtf16(company.Ptr(), company.Length()));
        tempContact.saveDetail(&organization);

        QContactManager::Error error(QContactManager::NoError);
        QString label = m_manager->synthesizedDisplayLabel(tempContact, &error);
        if (error != QContactManager::NoError) {
            continue;
        }
        tempContact.clearDetails();

        m_manager->setContactDisplayLabel(&contact, label);

        QContactId contactId;
        contactId.setLocalId(id);
        contactId.setManagerUri(m_manager->managerUri());
        contact.setId(contactId);

        contacts << contact;
    }

    return contacts;
}