在使用CMsvSession::GetChildIdsL()获取子条目时可以通过CMsvEntryFilter进行过滤和排序,CMsvEntryFilter提供了下面几种过滤方法:
通过Entry的修改时间过滤
void SetLastChangeDate(const TTime& aLastChange);
Description
Sets the last date change for the filter.
This is used to retrieve entries that have changed since a particular date.
通过Entry的MTM过滤
void SetMtm(TUid aMtm);
Description
Sets the MTM UID for the filter.
通过Entry的Service ID过滤
SetService()
void SetService(TMsvId aServiceId);
Description
Sets the service ID for the filter.
未知
SetSortMtm()
void SetSortMtm(TUid aSortMtm);
Description
Sets the sorting by MTM for the filter.
通过Entry的类型过滤
SetType()
void SetType(TUid aType);
Description
Sets the entry type for the filter.
CMsvEntryFilter还提供了SetOrder()方法对过滤的结果进行排序,该方法通指定TMsvSelectionOrdering对象并设置TMsvSorting中的枚举值可以实现不同的排序方法,另外还可以通过TMsvGrouping指定分组方法:
TMsvSorting:
EMsvSortByNone
Don't sort
EMsvSortByDate
Date (earliest-latest)
EMsvSortByDateReverse
Date (latest-earliest)
EMsvSortBySize
Size (smallest-largest)
EMsvSortBySizeReverse
Size (largest-smallest)
EMsvSortByDetails
To/From (A-Z folded)
EMsvSortByDetailsReverse
To/From (Z-A folded)
EMsvSortByDescription
Description (A-Z folded)
EMsvSortByDescriptionReverse
Description (Z-A folded)
EMsvSortById
Sort by message ID.
EMsvSortByIdReverse
Sort in reverse order by message ID.
TMsvGrouping:
KMsvNoGrouping
No grouping
KMsvGroupByType
Group by entry type, in order, services, folders, messages, attachments
KMsvGroupByStandardFolders
Place standard folders first, in the order they were created
KMsvGroupByPriority
Group by message priority, in order, high, medium, then low
KMsvGroupByMtm
Group by MTM, either in the order set by CMsvEntry::SetMtmListL() or by MTM Uid value
示例代码:
//Gets a selection containing the IDs of all the context children.
//If the entry has no children, the selection is empty.
//The calling function is responsible for the deletion of
//the returned CMsvEntrySelection
CMsvEntrySelection* CMsgEngine::ChildrenL( TMsvId aMsvId, TBool aShowInvisible ) const
{
TMsvSelectionOrdering order;
order.SetGroupByType( ETrue );
order.SetSorting( EMsvSortByDate );
order.SetShowInvisibleEntries( aShowInvisible );
CMsvEntrySelection *sel = new(ELeave)CMsvEntrySelection;
CMsvEntryFilter * filter = CMsvEntryFilter::NewLC();
filter->SetOrder( order );
iSession->GetChildIdsL( aMsvId, *filter, *sel );
CleanupStack::PopAndDestroy( filter );
return sel;
}
Symbian OS中的消息存储与常用操作
http://blog.youkuaiyun.com/beover1984/archive/2006/01/05/571317.aspx