示例#1
0
EXPORT_C TInt CContactItemViewDef::Find(const CContentType &aContentType) const
/** Searches the view definition for any field type contained in the specified 
content type.

@param aContentType Content type containing the field types to search for.
@return The index in the view definition of the first matching field type or 
KErrNotFound. */
	{
	TInt ret=KErrNotFound;
	for(TInt loop=0;loop<aContentType.FieldTypeCount();loop++)
		{
		ret=Find(aContentType.FieldType(loop));
		if (ret!=KErrNotFound)
			break;
		}
	return(ret);
	}
// ---------------------------------------------------------------------------
// CPIMContactFieldInfo::FieldInternalAttributes
// (other items were commented in a header)
// ---------------------------------------------------------------------------
//
void CPIMContactFieldInfo::GetFieldInternalAttributesL(
    const CContentType& aContentType, CArrayFix<TUid>& aArrayOfAttributes) const
{
    JELOG2(EPim);
    TInt fieldCount = aContentType.FieldTypeCount();
    for (TInt i = 0; i < fieldCount; i++)
    {
        TFieldType fieldType = aContentType.FieldType(i);
        TBool isSupported = EFalse;
        for (TInt j = 0; j < KPIMFieldAttributeMapSize && !isSupported; j++)
        {
            // Generate uid from the specified Contacts Model field id
            TUid uid =
                { KPIMFieldAttributeMap[j][1] };

            // Add this attribute to internal attributes array if
            // it is not supported. This covers all unknow attributes
            // that those won't be lost when a database item is modified
            if (fieldType == uid)
            {
                isSupported = ETrue;
            }
        }
        // Check that if field info array knows this Uid
        TInt fieldInfoCount = iFieldsInfo->Count();
        for (TInt j = 0; j < fieldInfoCount && !isSupported; j++)
        {
            const TPIMFieldInfo& fieldInfo = (*iFieldsInfo)[j];
            // Contacts Model field type values are defined as field types
            // So the following mappings is equal to check with the field type
            TUid uid =
                { fieldInfo.iContactsModelField };
            if (fieldType == uid)
            {
                isSupported = ETrue;
            }
        }
        // Not supported, add to internal attributes
        if (!isSupported)
        {
            aArrayOfAttributes.AppendL(fieldType);
        }
    }
}