186 } |
186 } |
187 |
187 |
188 // -------------------------------------------------------------------------- |
188 // -------------------------------------------------------------------------- |
189 // CVPbkCompositeContactView::ApplyInternalCompositePolicyL |
189 // CVPbkCompositeContactView::ApplyInternalCompositePolicyL |
190 // -------------------------------------------------------------------------- |
190 // -------------------------------------------------------------------------- |
191 // |
191 // |
192 void CVPbkCompositeContactView::ApplyInternalCompositePolicyL() |
192 void CVPbkCompositeContactView::ApplyInternalCompositePolicyL() |
193 { |
193 { |
194 if ( !iCompositePolicy || !iCompositePolicy->InternalPolicy() ) |
194 if ( !iCompositePolicy || !iCompositePolicy->InternalPolicy() ) |
195 { |
195 { |
196 MVPbkCompositeContactViewPolicy* newPolicy = |
196 MVPbkCompositeContactViewPolicy* newPolicy = |
197 CVPbkInternalCompositeViewPolicy::NewL( *this, iObservers ); |
197 CVPbkInternalCompositeViewPolicy::NewL( *this, iObservers ); |
198 delete iCompositePolicy; |
198 delete iCompositePolicy; |
199 iCompositePolicy = newPolicy; |
199 iCompositePolicy = newPolicy; |
200 } |
200 } |
201 } |
201 } |
202 |
202 |
203 // -------------------------------------------------------------------------- |
203 // -------------------------------------------------------------------------- |
204 // CVPbkCompositeContactView::Type |
204 // CVPbkCompositeContactView::Type |
205 // Returns view type. |
205 // Returns view type. |
206 // -------------------------------------------------------------------------- |
206 // -------------------------------------------------------------------------- |
207 // |
207 // |
457 (const MVPbkContactBookmark& aContactBookmark) const |
457 (const MVPbkContactBookmark& aContactBookmark) const |
458 { |
458 { |
459 TIdentityRelation<TContactMapping> comparisonOperator( |
459 TIdentityRelation<TContactMapping> comparisonOperator( |
460 &CVPbkCompositeContactView::CompareMappings); |
460 &CVPbkCompositeContactView::CompareMappings); |
461 TInt result = KErrNotFound; |
461 TInt result = KErrNotFound; |
462 |
462 |
463 // Search the bookmark from all the subviews |
463 // Search the bookmark from all the subviews |
464 const TInt subViewCount = iSubViews.Count(); |
464 const TInt subViewCount = iSubViews.Count(); |
465 for (TInt i = 0; i < subViewCount; ++i) |
465 for (TInt i = 0; i < subViewCount; ++i) |
466 { |
466 { |
467 // Check that the view is ready before using it. |
467 // Check that the view is ready before using it. |
468 TInt index(KErrNotFound); |
468 TInt index(KErrNotFound); |
469 if (iSubViews[i]->iState == CSubViewData::EReady) |
469 if (iSubViews[i]->iState == CSubViewData::EReady) |
470 { |
470 { |
471 index = iSubViews[i]->iView->IndexOfBookmarkL(aContactBookmark); |
471 index = iSubViews[i]->iView->IndexOfBookmarkL(aContactBookmark); |
472 } |
472 } |
473 |
473 |
474 if (index != KErrNotFound) |
474 if (index != KErrNotFound) |
475 { |
475 { |
476 // Establish contact mapping for view and contact index |
476 // Establish contact mapping for view and contact index |
477 TContactMapping mapping; |
477 TContactMapping mapping; |
478 mapping.iViewIndex = i; |
478 mapping.iViewIndex = i; |
591 { |
591 { |
592 SendViewErrorEvent( aError, aErrorNotified ); |
592 SendViewErrorEvent( aError, aErrorNotified ); |
593 } |
593 } |
594 |
594 |
595 // -------------------------------------------------------------------------- |
595 // -------------------------------------------------------------------------- |
|
596 // CVPbkCompositeContactView::ContactViewObserverExtension |
|
597 // -------------------------------------------------------------------------- |
|
598 // |
|
599 TAny* CVPbkCompositeContactView::ContactViewObserverExtension( TUid aExtensionUid ) |
|
600 { |
|
601 if( aExtensionUid == KVPbkContactViewObserverExtension2Uid ) |
|
602 { |
|
603 return static_cast<MVPbkContactViewObserverExtension*>( this ); |
|
604 } |
|
605 return NULL; |
|
606 } |
|
607 |
|
608 // -------------------------------------------------------------------------- |
|
609 // CVPbkCompositeContactView::FilteredContactRemovedFromView |
|
610 // -------------------------------------------------------------------------- |
|
611 // |
|
612 void CVPbkCompositeContactView::FilteredContactRemovedFromView( |
|
613 MVPbkContactViewBase& aView ) |
|
614 { |
|
615 const TInt count = iObservers.Count(); |
|
616 |
|
617 for( TInt i = 0; i < count; i++ ) |
|
618 { |
|
619 MVPbkContactViewObserver* observer = iObservers[i]; |
|
620 |
|
621 TAny* extension = observer->ContactViewObserverExtension( |
|
622 KVPbkContactViewObserverExtension2Uid ); |
|
623 |
|
624 if( extension ) |
|
625 { |
|
626 MVPbkContactViewObserverExtension* contactViewExtension = |
|
627 static_cast<MVPbkContactViewObserverExtension*>( extension ); |
|
628 |
|
629 if( contactViewExtension ) |
|
630 { |
|
631 contactViewExtension->FilteredContactRemovedFromView( aView ); |
|
632 } |
|
633 } |
|
634 } |
|
635 } |
|
636 |
|
637 // -------------------------------------------------------------------------- |
596 // CVPbkCompositeContactView::UpdateFilterL |
638 // CVPbkCompositeContactView::UpdateFilterL |
597 // -------------------------------------------------------------------------- |
639 // -------------------------------------------------------------------------- |
598 // |
640 // |
599 void CVPbkCompositeContactView::UpdateFilterL( |
641 void CVPbkCompositeContactView::UpdateFilterL( |
600 const MDesCArray& aFindWords, |
642 const MDesCArray& aFindWords, |
601 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) |
643 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) |
602 { |
644 { |
603 const TInt count = iSubViews.Count(); |
645 const TInt count = iSubViews.Count(); |
604 for( TInt i = 0; i < count; ++i ) |
646 for( TInt i = 0; i < count; ++i ) |
605 { |
647 { |
606 MVPbkContactViewFiltering* filtering = |
648 MVPbkContactViewFiltering* filtering = |
607 iSubViews[i]->iView->ViewFiltering(); |
649 iSubViews[i]->iView->ViewFiltering(); |
608 // Check if the subview supports filtering. |
650 // Check if the subview supports filtering. |
609 if ( filtering ) |
651 if ( filtering ) |
610 { |
652 { |
611 // Filtering supported |
653 // Filtering supported |
682 |
724 |
683 // -------------------------------------------------------------------------- |
725 // -------------------------------------------------------------------------- |
684 // CVPbkCompositeContactView::SendViewErrorEvent |
726 // CVPbkCompositeContactView::SendViewErrorEvent |
685 // -------------------------------------------------------------------------- |
727 // -------------------------------------------------------------------------- |
686 // |
728 // |
687 void CVPbkCompositeContactView::SendViewErrorEvent( TInt aError, |
729 void CVPbkCompositeContactView::SendViewErrorEvent( TInt aError, |
688 TBool aErrorNotified ) |
730 TBool aErrorNotified ) |
689 { |
731 { |
690 SendEventToObservers(*this, iObservers, |
732 SendEventToObservers(*this, iObservers, |
691 &MVPbkContactViewObserver::ContactViewError, aError, aErrorNotified); |
733 &MVPbkContactViewObserver::ContactViewError, aError, aErrorNotified); |
692 } |
734 } |
693 |
735 |
694 // -------------------------------------------------------------------------- |
736 // -------------------------------------------------------------------------- |
695 // CVPbkCompositeContactView::CompareMappings |
737 // CVPbkCompositeContactView::CompareMappings |
696 // -------------------------------------------------------------------------- |
738 // -------------------------------------------------------------------------- |
697 // |
739 // |
698 TBool CVPbkCompositeContactView::CompareMappings |
740 TBool CVPbkCompositeContactView::CompareMappings |
817 |
859 |
818 // -------------------------------------------------------------------------- |
860 // -------------------------------------------------------------------------- |
819 // CVPbkCompositeContactView::HandleContactViewReadyL |
861 // CVPbkCompositeContactView::HandleContactViewReadyL |
820 // -------------------------------------------------------------------------- |
862 // -------------------------------------------------------------------------- |
821 // |
863 // |
822 void CVPbkCompositeContactView::HandleContactViewReadyL( |
864 void CVPbkCompositeContactView::HandleContactViewReadyL( |
823 MVPbkContactViewBase& aView ) |
865 MVPbkContactViewBase& aView ) |
824 { |
866 { |
825 VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( |
867 VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( |
826 "CVPbkCompositeContactView::HandleContactViewReadyL(0x%x)"), this ); |
868 "CVPbkCompositeContactView::HandleContactViewReadyL(0x%x)"), this ); |
827 |
869 |
828 // Find matching subview and set its state to ready |
870 // Find matching subview and set its state to ready |
829 TInt subViewIndex = FindSubViewIndex(aView); |
871 TInt subViewIndex = FindSubViewIndex(aView); |
830 if (subViewIndex != KErrNotFound) |
872 if (subViewIndex != KErrNotFound) |
831 { |
873 { |
832 iSubViews[subViewIndex]->iState = CSubViewData::EReady; |
874 iSubViews[subViewIndex]->iState = CSubViewData::EReady; |
833 } |
875 } |
834 |
876 |
835 // Check that composite's sort order up to date with subviews. |
877 // Check that composite's sort order up to date with subviews. |
836 UpdateSortOrderL(); |
878 UpdateSortOrderL(); |
837 |
879 |
838 // If composite is ready, build view mapping and notify observers |
880 // If composite is ready, build view mapping and notify observers |
839 if ( IsCompositeReady() ) |
881 if ( IsCompositeReady() ) |
840 { |
882 { |
841 VPBK_PROFILE_START(VPbkProfile::ECompositeContactViewMapping); |
883 VPBK_PROFILE_START(VPbkProfile::ECompositeContactViewMapping); |
842 DoBuildContactMappingL(); |
884 DoBuildContactMappingL(); |
843 VPBK_PROFILE_END(VPbkProfile::ECompositeContactViewMapping); |
885 VPBK_PROFILE_END(VPbkProfile::ECompositeContactViewMapping); |
844 SendViewReadyEvent(); |
886 SendViewReadyEvent(); |
845 } |
887 } |
846 } |
888 } |
847 |
889 |
848 // -------------------------------------------------------------------------- |
890 // -------------------------------------------------------------------------- |
849 // CVPbkCompositeContactView::HandleContactViewUnavailableL |
891 // CVPbkCompositeContactView::HandleContactViewUnavailableL |
850 // -------------------------------------------------------------------------- |
892 // -------------------------------------------------------------------------- |
851 // |
893 // |
852 void CVPbkCompositeContactView::HandleContactViewUnavailableL( |
894 void CVPbkCompositeContactView::HandleContactViewUnavailableL( |
853 MVPbkContactViewBase& aView ) |
895 MVPbkContactViewBase& aView ) |
854 { |
896 { |
855 VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( |
897 VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( |
856 "CVPbkCompositeContactView::ContactViewUnavailable(0x%x)"), this ); |
898 "CVPbkCompositeContactView::ContactViewUnavailable(0x%x)"), this ); |
857 |
899 |
858 // Find matching subview and set its state |
900 // Find matching subview and set its state |
859 TInt subViewIndex = FindSubViewIndex(aView); |
901 TInt subViewIndex = FindSubViewIndex(aView); |
860 if (subViewIndex != KErrNotFound) |
902 if (subViewIndex != KErrNotFound) |
861 { |
903 { |
862 iSubViews[subViewIndex]->iState = CSubViewData::EUnavailable; |
904 iSubViews[subViewIndex]->iState = CSubViewData::EUnavailable; |
879 SendViewUnavailableEvent(); |
921 SendViewUnavailableEvent(); |
880 } |
922 } |
881 else |
923 else |
882 { |
924 { |
883 // Composite is still under construction. |
925 // Composite is still under construction. |
884 |
926 |
885 // Dont't send event here because the state of the composite is |
927 // Dont't send event here because the state of the composite is |
886 // not yet known and sending event can cause problems for client |
928 // not yet known and sending event can cause problems for client |
887 // e.g unwanted changes in the UI state. |
929 // e.g unwanted changes in the UI state. |
888 RemoveContactMappingsFromView( aView ); |
930 RemoveContactMappingsFromView( aView ); |
889 } |
931 } |
890 } |
932 } |
891 } |
933 } |
892 |
934 |
893 // -------------------------------------------------------------------------- |
935 // -------------------------------------------------------------------------- |
894 // CVPbkCompositeContactView::CVPbkCompositeContactView |
936 // CVPbkCompositeContactView::CVPbkCompositeContactView |
895 // -------------------------------------------------------------------------- |
937 // -------------------------------------------------------------------------- |
896 // |
938 // |
897 TInt CVPbkCompositeContactView::HandleContactRemoval |
939 TInt CVPbkCompositeContactView::HandleContactRemoval |
898 ( MVPbkContactViewBase& aView, TInt aIndex ) |
940 ( MVPbkContactViewBase& aView, TInt aIndex ) |
899 { |
941 { |
900 TInt index = KErrNotFound; |
942 TInt index = KErrNotFound; |
901 |
943 |
902 // Find correct subview |
944 // Find correct subview |
903 TInt subViewIndex = FindSubViewIndex( aView ); |
945 TInt subViewIndex = FindSubViewIndex( aView ); |
904 if ( subViewIndex != KErrNotFound ) |
946 if ( subViewIndex != KErrNotFound ) |
905 { |
947 { |
906 TIdentityRelation<TContactMapping> comparisonOperator |
948 TIdentityRelation<TContactMapping> comparisonOperator |
934 DoBuildContactMappingL(); |
976 DoBuildContactMappingL(); |
935 } |
977 } |
936 } |
978 } |
937 return index; |
979 return index; |
938 } |
980 } |
939 |
981 |
940 // -------------------------------------------------------------------------- |
982 // -------------------------------------------------------------------------- |
941 // CVPbkCompositeContactView::HandleContactAddition |
983 // CVPbkCompositeContactView::HandleContactAddition |
942 // -------------------------------------------------------------------------- |
984 // -------------------------------------------------------------------------- |
943 // |
985 // |
944 TInt CVPbkCompositeContactView::HandleContactAddition |
986 TInt CVPbkCompositeContactView::HandleContactAddition |
945 (MVPbkContactViewBase& aView, TInt aIndex) |
987 (MVPbkContactViewBase& aView, TInt aIndex) |
946 { |
988 { |
947 TInt index = KErrNotFound; |
989 TInt index = KErrNotFound; |
948 |
990 |
949 // Find correct subview |
991 // Find correct subview |
950 TInt subViewIndex = FindSubViewIndex(aView); |
992 TInt subViewIndex = FindSubViewIndex(aView); |
951 if (subViewIndex != KErrNotFound) |
993 if (subViewIndex != KErrNotFound) |
952 { |
994 { |
953 TRAPD( err, index = DoHandleContactAdditionL |
995 TRAPD( err, index = DoHandleContactAdditionL |
954 ( subViewIndex, aIndex ) ); |
996 ( subViewIndex, aIndex ) ); |
955 if (err != KErrNone) |
997 if (err != KErrNone) |
956 { |
998 { |
957 index = err; |
999 index = err; |
958 } |
1000 } |
959 else |
1001 else |
960 { |
1002 { |
961 // We have to fix the indexes of all the succeeding |
1003 // We have to fix the indexes of all the succeeding |
962 // contacts in the view where the contact addition took place |
1004 // contacts in the view where the contact addition took place |
963 for ( TInt i = index + 1; i < iContactMapping.Count(); ++i ) |
1005 for ( TInt i = index + 1; i < iContactMapping.Count(); ++i ) |
964 { |
1006 { |
1021 // -------------------------------------------------------------------------- |
1063 // -------------------------------------------------------------------------- |
1022 // |
1064 // |
1023 void CVPbkCompositeContactView::UpdateSortOrderL() |
1065 void CVPbkCompositeContactView::UpdateSortOrderL() |
1024 { |
1066 { |
1025 const MVPbkFieldTypeList* sortOrder = NULL; |
1067 const MVPbkFieldTypeList* sortOrder = NULL; |
1026 |
1068 |
1027 // Inspect the sort order of subviews. If all ready subviews have |
1069 // Inspect the sort order of subviews. If all ready subviews have |
1028 // same sort order then update composite's sort order. |
1070 // same sort order then update composite's sort order. |
1029 // This is done because subviews can be shared views whose sort order |
1071 // This is done because subviews can be shared views whose sort order |
1030 // is not changed to client's sort order when a new handle is created. |
1072 // is not changed to client's sort order when a new handle is created. |
1031 TBool subViewsHaveSameOrder = ETrue; |
1073 TBool subViewsHaveSameOrder = ETrue; |
1032 const TInt count = iSubViews.Count(); |
1074 const TInt count = iSubViews.Count(); |
1033 for ( TInt i = 0; i < count && subViewsHaveSameOrder; ++i ) |
1075 for ( TInt i = 0; i < count && subViewsHaveSameOrder; ++i ) |
1034 { |
1076 { |
1035 if ( iSubViews[i]->iState == CSubViewData::EReady ) |
1077 if ( iSubViews[i]->iState == CSubViewData::EReady ) |
1036 { |
1078 { |
1037 const MVPbkFieldTypeList& curViewsOrder = |
1079 const MVPbkFieldTypeList& curViewsOrder = |
1038 iSubViews[i]->iView->SortOrder(); |
1080 iSubViews[i]->iView->SortOrder(); |
1039 if ( sortOrder ) |
1081 if ( sortOrder ) |
1040 { |
1082 { |
1041 subViewsHaveSameOrder = |
1083 subViewsHaveSameOrder = |
1042 VPbkFieldTypeList::IsSame( *sortOrder, curViewsOrder ); |
1084 VPbkFieldTypeList::IsSame( *sortOrder, curViewsOrder ); |
1043 } |
1085 } |
1044 sortOrder = &curViewsOrder; |
1086 sortOrder = &curViewsOrder; |
1045 } |
1087 } |
1046 } |
1088 } |
1047 |
1089 |
1048 if ( subViewsHaveSameOrder && sortOrder && |
1090 if ( subViewsHaveSameOrder && sortOrder && |
1049 !VPbkFieldTypeList::IsSame( *sortOrder, *iSortOrder ) ) |
1091 !VPbkFieldTypeList::IsSame( *sortOrder, *iSortOrder ) ) |
1050 { |
1092 { |
1051 CVPbkSortOrder* newOrder = CVPbkSortOrder::NewL( *sortOrder ); |
1093 CVPbkSortOrder* newOrder = CVPbkSortOrder::NewL( *sortOrder ); |
1052 delete iSortOrder; |
1094 delete iSortOrder; |
1053 iSortOrder = newOrder; |
1095 iSortOrder = newOrder; |
1054 } |
1096 } |
1055 } |
1097 } |
1056 |
1098 |
1057 void CVPbkCompositeContactView::SetViewId(TInt aViewId) |
1099 void CVPbkCompositeContactView::SetViewId(TInt aViewId) |
1058 { |
1100 { |
1059 iViewId = aViewId; |
1101 iViewId = aViewId; |
1060 } |
1102 } |
1061 // -------------------------------------------------------------------------- |
1103 // -------------------------------------------------------------------------- |
1062 // CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy |
1104 // CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy |
1063 // -------------------------------------------------------------------------- |
1105 // -------------------------------------------------------------------------- |
1064 // |
1106 // |
1065 CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy( |
1107 CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy( |
1066 CVPbkCompositeContactView& aCompositeView, |
1108 CVPbkCompositeContactView& aCompositeView, |
1067 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1109 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1068 : iCompositeView( aCompositeView ), |
1110 : iCompositeView( aCompositeView ), |
1069 iObservers( aObservers ) |
1111 iObservers( aObservers ) |
1070 { |
1112 { |
1071 } |
1113 } |
1072 |
1114 |
1073 // -------------------------------------------------------------------------- |
1115 // -------------------------------------------------------------------------- |
1074 // CVPbkExternalCompositeViewPolicy::NewL |
1116 // CVPbkExternalCompositeViewPolicy::NewL |
1075 // -------------------------------------------------------------------------- |
1117 // -------------------------------------------------------------------------- |
1076 // |
1118 // |
1077 CVPbkExternalCompositeViewPolicy* CVPbkExternalCompositeViewPolicy::NewL( |
1119 CVPbkExternalCompositeViewPolicy* CVPbkExternalCompositeViewPolicy::NewL( |
1078 CVPbkCompositeContactView& aCompositeView, |
1120 CVPbkCompositeContactView& aCompositeView, |
1079 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1121 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1080 { |
1122 { |
1081 CVPbkExternalCompositeViewPolicy* self = |
1123 CVPbkExternalCompositeViewPolicy* self = |
1082 new ( ELeave ) CVPbkExternalCompositeViewPolicy( aCompositeView, |
1124 new ( ELeave ) CVPbkExternalCompositeViewPolicy( aCompositeView, |
1083 aObservers ); |
1125 aObservers ); |
1084 return self; |
1126 return self; |
1085 } |
1127 } |
1086 |
1128 |
1087 // -------------------------------------------------------------------------- |
1129 // -------------------------------------------------------------------------- |
1088 // CVPbkExternalCompositeViewPolicy::~CVPbkExternalCompositeViewPolicy |
1130 // CVPbkExternalCompositeViewPolicy::~CVPbkExternalCompositeViewPolicy |
1089 // -------------------------------------------------------------------------- |
1131 // -------------------------------------------------------------------------- |
1090 // |
1132 // |
1091 CVPbkExternalCompositeViewPolicy::~CVPbkExternalCompositeViewPolicy() |
1133 CVPbkExternalCompositeViewPolicy::~CVPbkExternalCompositeViewPolicy() |
1092 { |
1134 { |
1093 iEventArray.ResetAndDestroy(); |
1135 iEventArray.ResetAndDestroy(); |
1094 } |
1136 } |
1095 |
1137 |
1096 // -------------------------------------------------------------------------- |
1138 // -------------------------------------------------------------------------- |
1097 // CVPbkExternalCompositeViewPolicy::HandleViewEventsL |
1139 // CVPbkExternalCompositeViewPolicy::HandleViewEventsL |
1098 // -------------------------------------------------------------------------- |
1140 // -------------------------------------------------------------------------- |
1099 // |
1141 // |
1100 void CVPbkExternalCompositeViewPolicy::HandleViewEventsL( |
1142 void CVPbkExternalCompositeViewPolicy::HandleViewEventsL( |
1101 CVPbkEventArrayItem::TViewEventType aEvent, |
1143 CVPbkEventArrayItem::TViewEventType aEvent, |
1102 MVPbkContactViewBase& /*aSubview*/, |
1144 MVPbkContactViewBase& /*aSubview*/, |
1103 TInt aIndex, const |
1145 TInt aIndex, const |
1104 MVPbkContactLink& aContactLink ) |
1146 MVPbkContactLink& aContactLink ) |
1105 { |
1147 { |
1106 // Append all view events to proper event array. |
1148 // Append all view events to proper event array. |
1107 CVPbkEventArrayItem* item = |
1149 CVPbkEventArrayItem* item = |
1108 CVPbkEventArrayItem::NewLC( aIndex, aContactLink, aEvent ); |
1150 CVPbkEventArrayItem::NewLC( aIndex, aContactLink, aEvent ); |
1109 |
1151 |
1110 iEventArray.AppendL( item ); |
1152 iEventArray.AppendL( item ); |
1111 CleanupStack::Pop(); // item |
1153 CleanupStack::Pop(); // item |
1112 |
1154 |
1113 // Check if the composite is up to date. Note that if the underlying |
1155 // Check if the composite is up to date. Note that if the underlying |
1114 // native store view resides in a separate process or thread, |
1156 // native store view resides in a separate process or thread, |
1115 // this check may "accidentally" pass whilst the native view is still |
1157 // this check may "accidentally" pass whilst the native view is still |
1116 // updating itself. This means that the composite might fall out of sync |
1158 // updating itself. This means that the composite might fall out of sync |
1117 // anytime after this check and it will then mean severe problems to the |
1159 // anytime after this check and it will then mean severe problems to the |
1119 // be zero, as the sync check is implemented in |
1161 // be zero, as the sync check is implemented in |
1120 // CVPbkExternalCompositeViewPolicy::ContactCountL too. |
1162 // CVPbkExternalCompositeViewPolicy::ContactCountL too. |
1121 // The count of zero might be in severe contradiction with the |
1163 // The count of zero might be in severe contradiction with the |
1122 // view events the client just received. |
1164 // view events the client just received. |
1123 // If the native view resides in the same process, there are no risks. |
1165 // If the native view resides in the same process, there are no risks. |
1124 if (iCompositeView.CompositeContactCountL() == |
1166 if (iCompositeView.CompositeContactCountL() == |
1125 iCompositeView.ActualContactCountL() ) |
1167 iCompositeView.ActualContactCountL() ) |
1126 { |
1168 { |
1127 // Composite mapping is valid according to contact counts. Flush |
1169 // Composite mapping is valid according to contact counts. Flush |
1128 // the event cache. |
1170 // the event cache. |
1129 TInt eventCount( iEventArray.Count() ); |
1171 TInt eventCount( iEventArray.Count() ); |
1130 |
1172 |
1131 for( TInt i = 0; i < eventCount; ++i ) |
1173 for( TInt i = 0; i < eventCount; ++i ) |
1132 { |
1174 { |
1133 if ( iEventArray[ i ]->Event() == CVPbkEventArrayItem::ERemoved ) |
1175 if ( iEventArray[ i ]->Event() == CVPbkEventArrayItem::ERemoved ) |
1134 { |
1176 { |
1135 SendEventToObservers( iCompositeView, iObservers, |
1177 SendEventToObservers( iCompositeView, iObservers, |
1136 &MVPbkContactViewObserver::ContactRemovedFromView, |
1178 &MVPbkContactViewObserver::ContactRemovedFromView, |
1137 iEventArray[ i ]->Index(), |
1179 iEventArray[ i ]->Index(), |
1138 *iEventArray[ i ]->Link() ); |
1180 *iEventArray[ i ]->Link() ); |
1139 } |
1181 } |
1140 else |
1182 else |
1141 { |
1183 { |
1142 SendEventToObservers( iCompositeView, iObservers, |
1184 SendEventToObservers( iCompositeView, iObservers, |
1143 &MVPbkContactViewObserver::ContactAddedToView, |
1185 &MVPbkContactViewObserver::ContactAddedToView, |
1144 iEventArray[ i ]->Index(), |
1186 iEventArray[ i ]->Index(), |
1145 *iEventArray[ i ]->Link() ); |
1187 *iEventArray[ i ]->Link() ); |
1146 } |
1188 } |
1147 } |
1189 } |
1148 iEventArray.ResetAndDestroy(); |
1190 iEventArray.ResetAndDestroy(); |
1149 } |
1191 } |
1150 } |
1192 } |
1151 |
1193 |
1152 // -------------------------------------------------------------------------- |
1194 // -------------------------------------------------------------------------- |
1153 // CVPbkExternalCompositeViewPolicy::Reset |
1195 // CVPbkExternalCompositeViewPolicy::Reset |
1154 // -------------------------------------------------------------------------- |
1196 // -------------------------------------------------------------------------- |
1155 // |
1197 // |
1156 void CVPbkExternalCompositeViewPolicy::Reset() |
1198 void CVPbkExternalCompositeViewPolicy::Reset() |
1157 { |
1199 { |
1158 iEventArray.ResetAndDestroy(); |
1200 iEventArray.ResetAndDestroy(); |
1159 } |
1201 } |
1160 |
1202 |
1161 // -------------------------------------------------------------------------- |
1203 // -------------------------------------------------------------------------- |
1162 // CVPbkExternalCompositeViewPolicy::ContactCountL |
1204 // CVPbkExternalCompositeViewPolicy::ContactCountL |
1163 // -------------------------------------------------------------------------- |
1205 // -------------------------------------------------------------------------- |
1164 // |
1206 // |
1165 TInt CVPbkExternalCompositeViewPolicy::ContactCountL() const |
1207 TInt CVPbkExternalCompositeViewPolicy::ContactCountL() const |
1166 { |
1208 { |
1167 TInt compositeCount = iCompositeView.CompositeContactCountL(); |
1209 TInt compositeCount = iCompositeView.CompositeContactCountL(); |
1168 |
1210 |
1169 if ( compositeCount != iCompositeView.ActualContactCountL() ) |
1211 if ( compositeCount != iCompositeView.ActualContactCountL() ) |
1170 { |
1212 { |
1171 // If composite count is different as the contact count in subviews |
1213 // If composite count is different as the contact count in subviews |
1172 // it means that composite hasn't got all view events yet and its |
1214 // it means that composite hasn't got all view events yet and its |
1173 // contact mapping is not in valid state. It's too heavy to build |
1215 // contact mapping is not in valid state. It's too heavy to build |
1179 } |
1221 } |
1180 |
1222 |
1181 // -------------------------------------------------------------------------- |
1223 // -------------------------------------------------------------------------- |
1182 // CVPbkExternalCompositeViewPolicy::InternalPolicy |
1224 // CVPbkExternalCompositeViewPolicy::InternalPolicy |
1183 // -------------------------------------------------------------------------- |
1225 // -------------------------------------------------------------------------- |
1184 // |
1226 // |
1185 TBool CVPbkExternalCompositeViewPolicy::InternalPolicy() const |
1227 TBool CVPbkExternalCompositeViewPolicy::InternalPolicy() const |
1186 { |
1228 { |
1187 return EFalse; |
1229 return EFalse; |
1188 } |
1230 } |
1189 |
1231 |
1190 // -------------------------------------------------------------------------- |
1232 // -------------------------------------------------------------------------- |
1191 // CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy |
1233 // CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy |
1192 // -------------------------------------------------------------------------- |
1234 // -------------------------------------------------------------------------- |
1193 // |
1235 // |
1194 CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy( |
1236 CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy( |
1195 CVPbkCompositeContactView& aCompositeView, |
1237 CVPbkCompositeContactView& aCompositeView, |
1196 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1238 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1197 : iCompositeView( aCompositeView ), |
1239 : iCompositeView( aCompositeView ), |
1198 iObservers( aObservers ) |
1240 iObservers( aObservers ) |
1199 { |
1241 { |
1200 } |
1242 } |
1201 |
1243 |
1202 // -------------------------------------------------------------------------- |
1244 // -------------------------------------------------------------------------- |
1203 // CVPbkInternalCompositeViewPolicy::NewL |
1245 // CVPbkInternalCompositeViewPolicy::NewL |
1204 // -------------------------------------------------------------------------- |
1246 // -------------------------------------------------------------------------- |
1205 // |
1247 // |
1206 CVPbkInternalCompositeViewPolicy* CVPbkInternalCompositeViewPolicy::NewL( |
1248 CVPbkInternalCompositeViewPolicy* CVPbkInternalCompositeViewPolicy::NewL( |
1207 CVPbkCompositeContactView& aCompositeView, |
1249 CVPbkCompositeContactView& aCompositeView, |
1208 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1250 RPointerArray<MVPbkContactViewObserver>& aObservers ) |
1209 { |
1251 { |
1210 CVPbkInternalCompositeViewPolicy* self = |
1252 CVPbkInternalCompositeViewPolicy* self = |
1211 new ( ELeave ) CVPbkInternalCompositeViewPolicy( aCompositeView, |
1253 new ( ELeave ) CVPbkInternalCompositeViewPolicy( aCompositeView, |
1212 aObservers ); |
1254 aObservers ); |
1213 return self; |
1255 return self; |
1214 } |
1256 } |
1215 |
1257 |
1216 // -------------------------------------------------------------------------- |
1258 // -------------------------------------------------------------------------- |
1217 // CVPbkInternalCompositeViewPolicy::HandleViewEventsL |
1259 // CVPbkInternalCompositeViewPolicy::HandleViewEventsL |
1218 // -------------------------------------------------------------------------- |
1260 // -------------------------------------------------------------------------- |
1219 // |
1261 // |
1220 void CVPbkInternalCompositeViewPolicy::HandleViewEventsL( |
1262 void CVPbkInternalCompositeViewPolicy::HandleViewEventsL( |
1221 CVPbkEventArrayItem::TViewEventType aEvent, |
1263 CVPbkEventArrayItem::TViewEventType aEvent, |
1222 MVPbkContactViewBase& /*aSubview*/, |
1264 MVPbkContactViewBase& /*aSubview*/, |
1223 TInt aIndex, const |
1265 TInt aIndex, const |
1224 MVPbkContactLink& aContactLink ) |
1266 MVPbkContactLink& aContactLink ) |
1225 { |
1267 { |
1226 if ( aEvent == CVPbkEventArrayItem::ERemoved ) |
1268 if ( aEvent == CVPbkEventArrayItem::ERemoved ) |
1227 { |
1269 { |
1228 SendEventToObservers( iCompositeView, iObservers, |
1270 SendEventToObservers( iCompositeView, iObservers, |
1229 &MVPbkContactViewObserver::ContactRemovedFromView, |
1271 &MVPbkContactViewObserver::ContactRemovedFromView, |
1230 aIndex, |
1272 aIndex, |
1231 aContactLink ); |
1273 aContactLink ); |
1232 } |
1274 } |
1233 else |
1275 else |
1234 { |
1276 { |
1235 SendEventToObservers( iCompositeView, iObservers, |
1277 SendEventToObservers( iCompositeView, iObservers, |
1236 &MVPbkContactViewObserver::ContactAddedToView, |
1278 &MVPbkContactViewObserver::ContactAddedToView, |
1237 aIndex, |
1279 aIndex, |
1238 aContactLink ); |
1280 aContactLink ); |
1239 } |
1281 } |
1240 } |
1282 } |
1241 |
1283 |
1242 // -------------------------------------------------------------------------- |
1284 // -------------------------------------------------------------------------- |
1243 // CVPbkInternalCompositeViewPolicy::Reset |
1285 // CVPbkInternalCompositeViewPolicy::Reset |
1244 // -------------------------------------------------------------------------- |
1286 // -------------------------------------------------------------------------- |
1245 // |
1287 // |
1246 void CVPbkInternalCompositeViewPolicy::Reset() |
1288 void CVPbkInternalCompositeViewPolicy::Reset() |
1247 { |
1289 { |
1248 // No cached data to reset |
1290 // No cached data to reset |
1249 } |
1291 } |
1250 |
1292 |
1251 // -------------------------------------------------------------------------- |
1293 // -------------------------------------------------------------------------- |
1252 // CVPbkInternalCompositeViewPolicy::ContactCountL |
1294 // CVPbkInternalCompositeViewPolicy::ContactCountL |
1253 // -------------------------------------------------------------------------- |
1295 // -------------------------------------------------------------------------- |
1254 // |
1296 // |
1255 TInt CVPbkInternalCompositeViewPolicy::ContactCountL() const |
1297 TInt CVPbkInternalCompositeViewPolicy::ContactCountL() const |
1256 { |
1298 { |
1257 return iCompositeView.CompositeContactCountL(); |
1299 return iCompositeView.CompositeContactCountL(); |
1258 } |
1300 } |
1259 |
1301 |
1260 // -------------------------------------------------------------------------- |
1302 // -------------------------------------------------------------------------- |
1261 // CVPbkInternalCompositeViewPolicy::InternalPolicy |
1303 // CVPbkInternalCompositeViewPolicy::InternalPolicy |
1262 // -------------------------------------------------------------------------- |
1304 // -------------------------------------------------------------------------- |
1263 // |
1305 // |
1264 TBool CVPbkInternalCompositeViewPolicy::InternalPolicy() const |
1306 TBool CVPbkInternalCompositeViewPolicy::InternalPolicy() const |
1265 { |
1307 { |
1266 return ETrue; |
1308 return ETrue; |
1267 } |
1309 } |
1268 |
1310 |
1269 // End of File |
1311 // End of File |