diff -r 000000000000 -r e686773b3f54 phonebookengines/contactsmodel/cntview/ConcView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookengines/contactsmodel/cntview/ConcView.cpp Tue Feb 02 10:12:17 2010 +0200 @@ -0,0 +1,376 @@ +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include "CNTSTD.H" + +//#define CNTVIEW_API_PROFILING + + +// +// CContactConcatenatedView. +// + +CContactConcatenatedView::~CContactConcatenatedView() + { + CloseComponentViews(); + } + +CContactConcatenatedView::CContactConcatenatedView(const CContactDatabase& aDb) : CContactViewBase(aDb) + { + } + +EXPORT_C CContactConcatenatedView* CContactConcatenatedView::NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,RPointerArray& aComponentViews) +/** Allocates and constructs a new CContactConcatenatedView object, + +@param aObserver An observer that receives notifications when this view is +ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady +event when the view is ready. An attempt to use the view before this notification +causes a panic. +@param aDb The database that contains the contact items. +@param aComponentViews An array of pointers to the component views to append +to this view. The concatenated view creates its own copy of this array and +sets itself to be the observer of each of the component views, unless an error +occurs, in which case the function leaves. +@return The newly constructed concatenated view object. */ + { +#ifdef CNTVIEW_API_PROFILING + RDebug::Print(_L("[CNTMODEL] CContactConcatenatedView::NewL()\n")); +#endif + CContactConcatenatedView* self=new(ELeave) CContactConcatenatedView(aDb); + CleanupStack::PushL(self); + self->ConstructL(aObserver,aComponentViews); + CleanupStack::Pop(); // self. + return self; + } + +/* + * This is a reserved virtual exported function that is used for BC proofing + * against present and future additions of new exported virtual functions. + @return Any return values of the helper functions called from this function or NULL. + */ +TAny* CContactConcatenatedView::CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams) + { + return CContactViewBase::CContactViewBase_Reserved_1(aFunction,aParams); + } +void CContactConcatenatedView::ConstructL(MContactViewObserver& aObserver,RPointerArray& aComponentViews) + { + CContactViewBase::ConstructL(); + OpenL(aObserver); + CopyComponentViewsL(aComponentViews); + OpenComponentViewsL(); + } + +void CContactConcatenatedView::CopyComponentViewsL(RPointerArray& aComponentViews) + { + const TInt numComponentViews=aComponentViews.Count(); + for (TInt ii=0;ii(ComponentViewsEqual)); + __ASSERT_DEBUG(index!=KErrNotFound,Panic(ECntPanicComponentViewNotFound)); + return index; + } + +TContactItemId CContactConcatenatedView::AtL(TInt aIndex) const +/** Gets the contact item ID at the specified index into the concatenated view. + +@param aIndex Index into the concatenated view. +@leave KErrNotReady The view is not ready for use. +@leave KErrNotFound The index is out of bounds. It must be less than the +total number of items in all component views. +@return The contact item ID. +*/ + { + if (iState != EReady) + { + User::Leave(KErrNotReady); + } + TInt count=0; + const TInt numComponentViews=iComponentView.Count(); + for (TInt ii=0;ii