当前位置: 首页>>代码示例>>C++>>正文


C++ CContactItemField::TextStorage方法代码示例

本文整理汇总了C++中CContactItemField::TextStorage方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactItemField::TextStorage方法的具体用法?C++ CContactItemField::TextStorage怎么用?C++ CContactItemField::TextStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CContactItemField的用法示例。


在下文中一共展示了CContactItemField::TextStorage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateAndUpdateMultipleContactsL

/** Create Multiple Contact Item with field and Add all contact
 *	Item to Contact database. Update the multiple contact item field value and  
 *	verify field is being updated. 
 *	aValue - field value
 *  @param aStorageType - Storage type of each field
 *	@param aContFieldUid - Uid of Contact field
 *	@param avCardMapUid - Uid of vCard 
 *	@return - void
*/		
void CTestUpdateMultipleContactsStep::CreateAndUpdateMultipleContactsL(TPtrC aValue, TInt aStorageType,TUid aContFieldUid, TUid avCardMap)
    {
    TPtrC value, updateVal, getUpdateValue;
    CContactDatabase *dBase = NULL;
   _LIT(KTestDbName, "c:contactmultiple.cdb");
   	TInt year, month, day,noOfCI;
   	TContactItemId id = 0;
   	RArray <TInt> idArray;
    CleanupClosePushL(idArray);

    //replace existing database name
    dBase = CContactDatabase::ReplaceL(KTestDbName);

    //Get the number of contact item from ini file
    GetIntFromConfig(ConfigSection(), KNoOfContactItem, noOfCI);

    //Get the int value
    GetIntFromConfig(ConfigSection(), KIniYear, year);
    GetIntFromConfig(ConfigSection(), KIniMonth, month);
    GetIntFromConfig(ConfigSection(), KIniDay, day);

    // Create contact item and add field to it
    for(TInt range=0;range<noOfCI;range++)
    	{
        CContactItem* item = CContactCard::NewLC();
        CContactItemField* field = CContactItemField::NewL(aStorageType, aContFieldUid);
        CleanupStack::PushL(field);
        field->SetMapping(avCardMap);
        if(aStorageType==KStorageTypeDateTime)
            {
            TDateTime date(year,(TMonth)month,day,0,0,0,0);
            field->DateTimeStorage()->SetTime(date);
            }
            else
            {
            field->TextStorage()->SetTextL(aValue);
            }
            item->AddFieldL(*field);
            CleanupStack::Pop(field);

        // add contact item to database
        id = dBase->AddNewContactL(*item);
        idArray.Append(id);
        CleanupStack::PopAndDestroy(item);
    	}
    dBase->CloseContactL(id);

    // Get the value from ini file for update
   	GetStringFromConfig(ConfigSection(), KIniUpdatedvalue, updateVal);
    GetIntFromConfig(ConfigSection(), KIniUpdateYear, year);
    GetIntFromConfig(ConfigSection(), KIniUpdateMonth, month);
    GetIntFromConfig(ConfigSection(), KIniUpdateDay, day);
       	
    // update multiple contact item field value
    CContactItem *readItem = NULL;
    for(TInt readContact=0;readContact<noOfCI;readContact++)
    	{
    	readItem = dBase->ReadContactLC(idArray[readContact]);
    	CContactItemFieldSet& ContactFieldSet = readItem->CardFields();
        TInt pos = ContactFieldSet.Find(aContFieldUid, avCardMap);
        if(pos != KErrNotFound)
            {
            if(aStorageType==KStorageTypeDateTime)
                {
                // update the field value
                TDateTime date(year,(TMonth)month,day,0,0,0,0);
   				ContactFieldSet[pos].DateTimeStorage()->SetTime(date);
   				ContactFieldSet.UpdateFieldL(ContactFieldSet[pos],pos);
   				
                // verify the updated field value
   				TInt upadtePos = ContactFieldSet.Find(aContFieldUid, avCardMap);
   				TDateTime result=ContactFieldSet[upadtePos].DateTimeStorage()->Time().DateTime();
   				if((result.Year() == year) && (result.Month() == (TMonth)month) && (result.Day() == day)) 
                    {
                    SetTestStepResult(EPass);	
                    }
                else
                    {
                    SetTestStepResult(EFail);	
                    }
                }
            else
                {
                // Update the field value
                ContactFieldSet[pos].TextStorage()->SetTextL(updateVal);
                ContactFieldSet.UpdateFieldL(ContactFieldSet[pos],pos);
        
                // verify the field is being updated 
                TInt upadtePos = ContactFieldSet.Find(aContFieldUid, avCardMap);
                getUpdateValue.Set(ContactFieldSet[upadtePos].TextStorage()->Text());
    
//.........这里部分代码省略.........
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:101,代码来源:testupdatemultiplecontactsstep.cpp


注:本文中的CContactItemField::TextStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。