virtual TKeyResponse OfferKeyEventL  (  const TKeyEvent &  aKeyEvent,  
		TEventCode  aType )
	{
		if (aType==EEventKey && aKeyEvent.iCode==0xF845) {
			TInt idx=ListBox()->CurrentItemIndex();
			if (idx!=-1) {
				TBool selected=EFalse;
				const CArrayFix<TInt> *indexes = ListBox()->SelectionIndexes();
				if (indexes) {
					for (int i=0; i<indexes->Count(); i++) {
						if (indexes->At(i)==idx) {
							selected=ETrue;
							break;
						}
					}
				}
				if (!selected) {
					SelectionListProcessCommandL(EAknCmdMark);
				} else {
					SelectionListProcessCommandL(EAknCmdUnmark);
				}
			}
			return EKeyWasConsumed;
		} else {
			if (aType==EEventKey && aKeyEvent.iCode==KEY_C && FindBox()->TextLength()==0) {
				DeleteItemL();
				return EKeyWasConsumed;
			} else {
				return CAknMarkableListDialog::OfferKeyEventL(aKeyEvent, aType);
			}
		}
	}
예제 #2
0
/**
Persist the items belonging to curent group into group table

@param aGroup referece to a contact group
*/
void CPplGroupsTable::WriteGroupMembersL(const CContactItem& aGroup)
	{
	if (aGroup.Type() != KUidContactGroup)
		{
		return;
		}

	const TContactItemId KGroupId(aGroup.Id() );

	// make sure we clear out any previous, out-of-date data
	TBool lowDiskErr(EFalse);
	DeleteItemL(KGroupId, lowDiskErr);
	if (lowDiskErr)
		{
		User::Leave(KErrDiskFull);
		}

	// build the RSqlStatement
	RSqlStatement stmnt;
	CleanupClosePushL(stmnt);
	stmnt.PrepareL(iDatabase, iInsertStmnt->SqlStringL() );
	const TInt KGroupIdIndex(KFirstIndex); 			// first parameter in query...	
	const TInt KMemberIdIndex(KGroupIdIndex + 1); 	// ...and the second parameter
	
	// copy and sort the member id array so we can see if there are duplicates
	const CContactIdArray* contactIdArray = static_cast<const CContactGroup&>(aGroup).ItemsContained();  //does not take the ownership
	
	const TInt arrayCount = contactIdArray->Count();
	CArrayFixFlat<TContactItemId>* sortedList = new(ELeave) CArrayFixFlat<TContactItemId>(KArrayGranularity);	
	CleanupStack::PushL(sortedList);
    for(TInt loop = 0;loop < arrayCount; ++loop)
    	{
    	sortedList->AppendL((*contactIdArray)[loop]);		
    	}
	TKeyArrayFix key(0,ECmpTInt);
	sortedList->Sort(key);

	// insert the group-member relationships
	const TInt KCountStmntParamIndex(KFirstIndex); // first and only parameter in query
	const TInt listLen(sortedList->Count() );
	TInt lastId(0);
	for (TInt i = 0; i < listLen; ++i)
		{
		TInt itemId((*sortedList)[i]);
		
		//check if a contact item with itemId id really exists in contact database
		RSqlStatement countStmnt;
		CleanupClosePushL(countStmnt);
		countStmnt.PrepareL(iDatabase, iCountContactsStmnt->SqlStringL() );
		User::LeaveIfError(countStmnt.BindInt(KCountStmntParamIndex, itemId) );
		TInt count = 0;
		TInt err = KErrNone;
		if((err = countStmnt.Next() ) == KSqlAtRow)
			{
			count = countStmnt.ColumnInt(iCountContactsStmnt->ParameterIndex(KSqlCount) );
			}
		else
			{
			User::LeaveIfError(err);	
			}	

		if(count == 0) 
			{
			User::Leave(KErrNotFound);	
			}
		CleanupStack::PopAndDestroy(&countStmnt);
			
		// only insert this if we haven't already seen it
		if (itemId != lastId || i == 0)
			{
			User::LeaveIfError(stmnt.BindInt(KGroupIdIndex, KGroupId) );
			User::LeaveIfError(stmnt.BindInt(KMemberIdIndex, itemId) );
			User::LeaveIfError(stmnt.Exec() );
			User::LeaveIfError(stmnt.Reset() );
			}
		lastId = itemId;
		}

	CleanupStack::PopAndDestroy(2, &stmnt); // and sortedList
	}
예제 #3
0
/**
Deletes group informations related to passed contact item from group table

@param aItem Reference to contact item.
@param aLowDiskErrorOccurred out parameter; will be set to ETrue if there was an attempt to delete
		in low disk condition
*/
void CPplGroupsTable::DeleteL(const CContactItem& aItem, TBool& aLowDiskErrorOccurred)
	{
	DeleteItemL(aItem.Id(), aLowDiskErrorOccurred);
	}