phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkCompositeContactView.h
branchRCL_3
changeset 6 e8e3147d53eb
parent 0 e686773b3f54
equal deleted inserted replaced
5:81f8547efd4f 6:e8e3147d53eb
    38 /**
    38 /**
    39  * Virtual Phonebook abstract composite contact view.
    39  * Virtual Phonebook abstract composite contact view.
    40  * Composite contact views can be used to compose a view from
    40  * Composite contact views can be used to compose a view from
    41  * multiple sub views.
    41  * multiple sub views.
    42  */
    42  */
    43 NONSHARABLE_CLASS(CVPbkCompositeContactView) : 
    43 NONSHARABLE_CLASS(CVPbkCompositeContactView) :
    44         public CBase,
    44         public CBase,
    45         public MVPbkContactViewBase,
    45         public MVPbkContactViewBase,
    46         public MVPbkContactViewObserver,
    46         public MVPbkContactViewObserver,
       
    47         public MVPbkContactViewObserverExtension,
    47         protected MVPbkContactViewFiltering,
    48         protected MVPbkContactViewFiltering,
    48         public MVPbkContactViewBaseChildAccessExtension
    49         public MVPbkContactViewBaseChildAccessExtension
    49 	{
    50 	{
    50     public: // Constructors and destructor
    51     public: // Constructors and destructor
    51         /**
    52         /**
    63          * @param aSubView Subview to add to this composite view.
    64          * @param aSubView Subview to add to this composite view.
    64          * @param aViewId ViewId of added subview
    65          * @param aViewId ViewId of added subview
    65          */
    66          */
    66         void AddSubViewL(
    67         void AddSubViewL(
    67                 MVPbkContactViewBase* aSubView, TInt  aViewId = KVPbkDefaultViewId);
    68                 MVPbkContactViewBase* aSubView, TInt  aViewId = KVPbkDefaultViewId);
    68         
    69 
    69         /**
    70         /**
    70          * ActualContactCountL returns the number of contact's in subviews.
    71          * ActualContactCountL returns the number of contact's in subviews.
    71          * It might be that all subview events haven't
    72          * It might be that all subview events haven't
    72          * arrived yet to this composite so ActualContactCountL is not always
    73          * arrived yet to this composite so ActualContactCountL is not always
    73          * same as CompositeContactCountL
    74          * same as CompositeContactCountL
    74          *
    75          *
    75          * @return the contact count calculated from subviews.
    76          * @return the contact count calculated from subviews.
    76          */
    77          */
    77         TInt ActualContactCountL() const;
    78         TInt ActualContactCountL() const;
    78         
    79 
    79         /**
    80         /**
    80          * @return The number of contacts in iContactMapping
    81          * @return The number of contacts in iContactMapping
    81          */
    82          */
    82         inline TInt CompositeContactCountL() const;
    83         inline TInt CompositeContactCountL() const;
    83         
    84 
    84         /**
    85         /**
    85          * If the parent of this view is also a composite view
    86          * If the parent of this view is also a composite view
    86          * it calls this to configure this view as an internal view
    87          * it calls this to configure this view as an internal view
    87          * that has no external observers.
    88          * that has no external observers.
    88          */
    89          */
    89         void ApplyInternalCompositePolicyL();
    90         void ApplyInternalCompositePolicyL();
    90         
    91 
    91         void SetViewId(TInt aViewId);
    92         void SetViewId(TInt aViewId);
    92         
    93 
    93     private: // Abstract interface for composite implementations
    94     private: // Abstract interface for composite implementations
    94         /**
    95         /**
    95          * Builds view mapping.
    96          * Builds view mapping.
    96          */
    97          */
    97         virtual void DoBuildContactMappingL() = 0;
    98         virtual void DoBuildContactMappingL() = 0;
   131         MVPbkContactBookmark* CreateBookmarkLC(
   132         MVPbkContactBookmark* CreateBookmarkLC(
   132                 TInt aIndex ) const;
   133                 TInt aIndex ) const;
   133         TInt IndexOfBookmarkL(
   134         TInt IndexOfBookmarkL(
   134                 const MVPbkContactBookmark& aContactBookmark ) const;
   135                 const MVPbkContactBookmark& aContactBookmark ) const;
   135         MVPbkContactViewFiltering* ViewFiltering();
   136         MVPbkContactViewFiltering* ViewFiltering();
   136         TAny* ContactViewBaseExtension(TUid aExtensionUid); 
   137         TAny* ContactViewBaseExtension(TUid aExtensionUid);
   137             
   138 
   138     private: // From MVPbkContactViewObserver
   139     private: // From MVPbkContactViewObserver
   139         void ContactViewReady(
   140         void ContactViewReady(
   140                 MVPbkContactViewBase& aView );
   141                 MVPbkContactViewBase& aView );
   141         void ContactViewUnavailable(
   142         void ContactViewUnavailable(
   142                 MVPbkContactViewBase& aView );
   143                 MVPbkContactViewBase& aView );
   150                 const MVPbkContactLink& aContactLink );
   151                 const MVPbkContactLink& aContactLink );
   151         void ContactViewError(
   152         void ContactViewError(
   152                 MVPbkContactViewBase& aView,
   153                 MVPbkContactViewBase& aView,
   153                 TInt aError,
   154                 TInt aError,
   154                 TBool aErrorNotified);
   155                 TBool aErrorNotified);
       
   156         TAny* ContactViewObserverExtension( TUid aExtensionUid );
       
   157 
       
   158     private: // From MVPbkContactViewObserverExtension
       
   159         void FilteredContactRemovedFromView(
       
   160 			 	MVPbkContactViewBase& aView );
   155 
   161 
   156     private: // From MVPbkContactViewFiltering
   162     private: // From MVPbkContactViewFiltering
   157         /// Composite implementations must implement this
   163         /// Composite implementations must implement this
   158         virtual MVPbkContactViewBase* CreateFilteredViewLC(
   164         virtual MVPbkContactViewBase* CreateFilteredViewLC(
   159             MVPbkContactViewObserver& aObserver,
   165             MVPbkContactViewObserver& aObserver,
   160             const MDesCArray& aFindWords,
   166             const MDesCArray& aFindWords,
   161             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) = 0;
   167             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) = 0;
   162         void UpdateFilterL( 
   168         void UpdateFilterL(
   163             const MDesCArray& aFindWords,
   169             const MDesCArray& aFindWords,
   164             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
   170             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
   165 
   171 
   166     private: // From MVPbkContactViewBaseChildAccessExtension
   172     private: // From MVPbkContactViewBaseChildAccessExtension
   167         TInt ChildViewCount() const;
   173         TInt ChildViewCount() const;
   169         MVPbkContactViewBase* GetChildViewById(TInt aId);
   175         MVPbkContactViewBase* GetChildViewById(TInt aId);
   170         TInt GetViewId();
   176         TInt GetViewId();
   171 
   177 
   172     protected: // Types
   178     protected: // Types
   173         class CSubViewData;
   179         class CSubViewData;
   174                 
   180 
   175         /**
   181         /**
   176          * Contact mapping structure. Mapping supports 128 subviews
   182          * Contact mapping structure. Mapping supports 128 subviews
   177          * and over 8 million contacts per sub view.
   183          * and over 8 million contacts per sub view.
   178          */
   184          */
   179         struct TContactMapping
   185         struct TContactMapping
   180             {
   186             {
   181             /// Own: View index
   187             /// Own: View index
   182             TInt iViewIndex: 8;
   188             TInt iViewIndex: 8;
   183             /// Own: Contact index
   189             /// Own: Contact index
   184             TInt iContactIndex: 24;
   190             TInt iContactIndex: 24;
   185             };                          
   191             };
   186 
   192 
   187     protected: // Implementation
   193     protected: // Implementation
   188         CVPbkCompositeContactView();
   194         CVPbkCompositeContactView();
   189         void BaseConstructL(
   195         void BaseConstructL(
   190                 const MVPbkFieldTypeList& aSortOrder );
   196                 const MVPbkFieldTypeList& aSortOrder );
   192                 const TContactMapping& aLhs,
   198                 const TContactMapping& aLhs,
   193                 const TContactMapping& aRhs );
   199                 const TContactMapping& aRhs );
   194         TBool IsCompositeReady() const;
   200         TBool IsCompositeReady() const;
   195         /// Returns the composite's view policy.
   201         /// Returns the composite's view policy.
   196         MVPbkCompositeContactViewPolicy& CompositePolicy() const;
   202         MVPbkCompositeContactViewPolicy& CompositePolicy() const;
   197         
   203 
   198     private: // Implementation
   204     private: // Implementation
   199         TInt FindSubViewIndex(MVPbkContactViewBase& aView) const;
   205         TInt FindSubViewIndex(MVPbkContactViewBase& aView) const;
   200         TBool AllSubViewsKnown() const;
   206         TBool AllSubViewsKnown() const;
   201         TBool AnySubViewReady() const;
   207         TBool AnySubViewReady() const;
   202         void ResetContactMapping();
   208         void ResetContactMapping();
   215                 TInt aError );
   221                 TInt aError );
   216         void SendViewReadyEvent();
   222         void SendViewReadyEvent();
   217         void SendViewUnavailableEvent();
   223         void SendViewUnavailableEvent();
   218         void SendViewErrorEvent( TInt aError, TBool aErrorNotified );
   224         void SendViewErrorEvent( TInt aError, TBool aErrorNotified );
   219         void UpdateSortOrderL();
   225         void UpdateSortOrderL();
   220             
   226 
   221     protected: // Data
   227     protected: // Data
   222         /// Own: Array of subviews
   228         /// Own: Array of subviews
   223         RPointerArray<CSubViewData> iSubViews;
   229         RPointerArray<CSubViewData> iSubViews;
   224         /// Own: Array of contact mappings
   230         /// Own: Array of contact mappings
   225         RArray<TContactMapping> iContactMapping;
   231         RArray<TContactMapping> iContactMapping;
   264          * Constructor.
   270          * Constructor.
   265          *
   271          *
   266          * @param aState    View state.
   272          * @param aState    View state.
   267          */
   273          */
   268         CSubViewData(TViewState aState) : iState( aState ) {}
   274         CSubViewData(TViewState aState) : iState( aState ) {}
   269             
   275 
   270         /**
   276         /**
   271          * Destructor.
   277          * Destructor.
   272          */
   278          */
   273         ~CSubViewData();
   279         ~CSubViewData();
   274 
   280 
   286     };
   292     };
   287 
   293 
   288 /**
   294 /**
   289  * Internal interface for different behavior of exterior and interior
   295  * Internal interface for different behavior of exterior and interior
   290  * composite views.
   296  * composite views.
   291  */ 
   297  */
   292 NONSHARABLE_CLASS(MVPbkCompositeContactViewPolicy)
   298 NONSHARABLE_CLASS(MVPbkCompositeContactViewPolicy)
   293     {
   299     {
   294     public: 
   300     public:
   295         /**
   301         /**
   296          * Destructor
   302          * Destructor
   297          */
   303          */
   298         virtual ~MVPbkCompositeContactViewPolicy() {}
   304         virtual ~MVPbkCompositeContactViewPolicy() {}
   299         
   305 
   300         /**
   306         /**
   301          * Handles contact added & removed events.
   307          * Handles contact added & removed events.
   302          */
   308          */
   303         virtual void HandleViewEventsL( 
   309         virtual void HandleViewEventsL(
   304             CVPbkEventArrayItem::TViewEventType aEvent,
   310             CVPbkEventArrayItem::TViewEventType aEvent,
   305             MVPbkContactViewBase& aSubview,
   311             MVPbkContactViewBase& aSubview,
   306             TInt aIndex, const 
   312             TInt aIndex, const
   307             MVPbkContactLink& aContactLink ) = 0;
   313             MVPbkContactLink& aContactLink ) = 0;
   308         
   314 
   309         /** 
   315         /**
   310          * Reset policy if it has cached data.
   316          * Reset policy if it has cached data.
   311          */
   317          */
   312         virtual void Reset() = 0;
   318         virtual void Reset() = 0;
   313         
   319 
   314         /**
   320         /**
   315          * Returns the contact count in composite or 0 if
   321          * Returns the contact count in composite or 0 if
   316          * composite is not up to date with leaf views.
   322          * composite is not up to date with leaf views.
   317          * @param aCompositeCount The count according to composite view.
   323          * @param aCompositeCount The count according to composite view.
   318          * @return aCompositeCount or 0.
   324          * @return aCompositeCount or 0.
   319          */
   325          */
   320         virtual TInt ContactCountL() const = 0;
   326         virtual TInt ContactCountL() const = 0;
   321         
   327 
   322         /**
   328         /**
   323          * Returns ETrue if this is an internal composite policy
   329          * Returns ETrue if this is an internal composite policy
   324          * @return ETrue if this is an internal composite policy
   330          * @return ETrue if this is an internal composite policy
   325          */ 
   331          */
   326         virtual TBool InternalPolicy() const = 0;
   332         virtual TBool InternalPolicy() const = 0;
   327     };
   333     };
   328 
   334 
   329 /**
   335 /**
   330  * An implementation for exterior composite view
   336  * An implementation for exterior composite view
   336     public: // Construction and destruction
   342     public: // Construction and destruction
   337         static CVPbkExternalCompositeViewPolicy* NewL(
   343         static CVPbkExternalCompositeViewPolicy* NewL(
   338                 CVPbkCompositeContactView& aCompositeView,
   344                 CVPbkCompositeContactView& aCompositeView,
   339                 RPointerArray<MVPbkContactViewObserver>& aObservers );
   345                 RPointerArray<MVPbkContactViewObserver>& aObservers );
   340         ~CVPbkExternalCompositeViewPolicy();
   346         ~CVPbkExternalCompositeViewPolicy();
   341         
   347 
   342     private: // From MVPbkCompositeContactViewPolicy
   348     private: // From MVPbkCompositeContactViewPolicy
   343         void HandleViewEventsL( 
   349         void HandleViewEventsL(
   344             CVPbkEventArrayItem::TViewEventType aEvent,
   350             CVPbkEventArrayItem::TViewEventType aEvent,
   345             MVPbkContactViewBase& aSubview,
   351             MVPbkContactViewBase& aSubview,
   346             TInt aIndex, const 
   352             TInt aIndex, const
   347             MVPbkContactLink& aContactLink );
   353             MVPbkContactLink& aContactLink );
   348         void Reset();
   354         void Reset();
   349         TInt ContactCountL() const;
   355         TInt ContactCountL() const;
   350         TBool InternalPolicy() const;
   356         TBool InternalPolicy() const;
   351     
   357 
   352     private: // Implementation
   358     private: // Implementation
   353         CVPbkExternalCompositeViewPolicy(
   359         CVPbkExternalCompositeViewPolicy(
   354             CVPbkCompositeContactView& aCompositeView,
   360             CVPbkCompositeContactView& aCompositeView,
   355             RPointerArray<MVPbkContactViewObserver>& aObservers );
   361             RPointerArray<MVPbkContactViewObserver>& aObservers );
   356         
   362 
   357     private: // Data
   363     private: // Data
   358         /// Ref: The parent of this policy
   364         /// Ref: The parent of this policy
   359         CVPbkCompositeContactView& iCompositeView;
   365         CVPbkCompositeContactView& iCompositeView;
   360         /// Ref: Array of observers
   366         /// Ref: Array of observers
   361         RPointerArray<MVPbkContactViewObserver>& iObservers;
   367         RPointerArray<MVPbkContactViewObserver>& iObservers;
   372     {
   378     {
   373     public: // Construction and destruction
   379     public: // Construction and destruction
   374         static CVPbkInternalCompositeViewPolicy* NewL(
   380         static CVPbkInternalCompositeViewPolicy* NewL(
   375                 CVPbkCompositeContactView& aCompositeView,
   381                 CVPbkCompositeContactView& aCompositeView,
   376                 RPointerArray<MVPbkContactViewObserver>& aObservers );
   382                 RPointerArray<MVPbkContactViewObserver>& aObservers );
   377         
   383 
   378     private: // From MVPbkCompositeContactViewPolicy
   384     private: // From MVPbkCompositeContactViewPolicy
   379         void HandleViewEventsL( 
   385         void HandleViewEventsL(
   380             CVPbkEventArrayItem::TViewEventType aEvent,
   386             CVPbkEventArrayItem::TViewEventType aEvent,
   381             MVPbkContactViewBase& aSubview,
   387             MVPbkContactViewBase& aSubview,
   382             TInt aIndex, const 
   388             TInt aIndex, const
   383             MVPbkContactLink& aContactLink );
   389             MVPbkContactLink& aContactLink );
   384         void Reset();
   390         void Reset();
   385         TInt ContactCountL() const;
   391         TInt ContactCountL() const;
   386         TBool InternalPolicy() const;
   392         TBool InternalPolicy() const;
   387     
   393 
   388     private: // Implementation
   394     private: // Implementation
   389         CVPbkInternalCompositeViewPolicy(
   395         CVPbkInternalCompositeViewPolicy(
   390             CVPbkCompositeContactView& aCompositeView,
   396             CVPbkCompositeContactView& aCompositeView,
   391             RPointerArray<MVPbkContactViewObserver>& aObservers );
   397             RPointerArray<MVPbkContactViewObserver>& aObservers );
   392         
   398 
   393     private: // Data
   399     private: // Data
   394         /// Ref: The parent of this policy
   400         /// Ref: The parent of this policy
   395         CVPbkCompositeContactView& iCompositeView;
   401         CVPbkCompositeContactView& iCompositeView;
   396         /// Ref: Array of observers
   402         /// Ref: Array of observers
   397         RPointerArray<MVPbkContactViewObserver>& iObservers;
   403         RPointerArray<MVPbkContactViewObserver>& iObservers;