69 /// Unnamed namespace for local definitions |
69 /// Unnamed namespace for local definitions |
70 namespace { |
70 namespace { |
71 |
71 |
72 const TInt KPbk2MSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition ); |
72 const TInt KPbk2MSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition ); |
73 const TInt KFirstElement = 0; |
73 const TInt KFirstElement = 0; |
|
74 const TInt KDefaultMinSelection = 1; |
74 |
75 |
75 enum TPanicCode |
76 enum TPanicCode |
76 { |
77 { |
77 EPanicInvalidResourceData = 1, |
78 EPanicInvalidResourceData = 1, |
78 EPanicPostCond_PreLayoutDynInitL, |
79 EPanicPostCond_PreLayoutDynInitL, |
98 iMarkedEntries( NULL ), |
99 iMarkedEntries( NULL ), |
99 iNamesListView( NULL ), |
100 iNamesListView( NULL ), |
100 iGroupsListView( NULL ), |
101 iGroupsListView( NULL ), |
101 iCbaId( 0 ), |
102 iCbaId( 0 ), |
102 iNaviPaneId( 0 ), |
103 iNaviPaneId( 0 ), |
103 iExitCallback( NULL ) |
104 iExitCallback( NULL ), |
|
105 iMinSelection( KDefaultMinSelection ) |
104 { |
106 { |
105 } |
107 } |
106 |
108 |
107 // -------------------------------------------------------------------------- |
109 // -------------------------------------------------------------------------- |
108 // CPbk2FetchDlg::TParams::TCleanupItem |
110 // CPbk2FetchDlg::TParams::TCleanupItem |
490 { |
492 { |
491 const MVPbkBaseContact* focusedContact = |
493 const MVPbkBaseContact* focusedContact = |
492 iPages->FocusedContactL(); |
494 iPages->FocusedContactL(); |
493 if ( focusedContact ) |
495 if ( focusedContact ) |
494 { |
496 { |
|
497 if ( !( iParams.iFlags & EFetchMultiple ) ) |
|
498 { |
|
499 delete iFocusedContactLink; |
|
500 iFocusedContactLink = NULL; |
|
501 iFocusedContactLink = focusedContact->CreateLinkLC(); |
|
502 CleanupStack::Pop(); // iFocusedContactLink |
|
503 } |
495 MVPbkContactLink* link = focusedContact->CreateLinkLC(); |
504 MVPbkContactLink* link = focusedContact->CreateLinkLC(); |
496 SelectContactL( *link, selectContact ); |
505 SelectContactL( *link, selectContact ); |
497 CleanupStack::PopAndDestroy(); // link |
506 CleanupStack::PopAndDestroy(); // link |
498 result = EKeyWasConsumed; |
507 result = EKeyWasConsumed; |
499 } |
508 } |
819 // -------------------------------------------------------------------------- |
828 // -------------------------------------------------------------------------- |
820 // |
829 // |
821 void CPbk2FetchDlg::ContactSelected |
830 void CPbk2FetchDlg::ContactSelected |
822 ( const MVPbkContactLink& aLink, TBool aSelected ) |
831 ( const MVPbkContactLink& aLink, TBool aSelected ) |
823 { |
832 { |
824 if ( aSelected && iFocusedContactLink && |
833 if ( aSelected && iFocusedContactLink && iFocusedContactLink->IsSame( aLink ) ) |
825 iFocusedContactLink->IsSame( aLink ) ) |
|
826 { |
834 { |
827 // Deleting focused contact link that next time single fetch |
835 // Deleting focused contact link that next time single fetch |
828 // also fetches the contact. |
836 // also fetches the contact. |
829 delete iFocusedContactLink; |
837 delete iFocusedContactLink; |
830 iFocusedContactLink = NULL; |
838 iFocusedContactLink = NULL; |
918 // CPbk2FetchDlg::UpdateCbasL |
930 // CPbk2FetchDlg::UpdateCbasL |
919 // -------------------------------------------------------------------------- |
931 // -------------------------------------------------------------------------- |
920 // |
932 // |
921 void CPbk2FetchDlg::UpdateCbasL() |
933 void CPbk2FetchDlg::UpdateCbasL() |
922 { |
934 { |
923 if (iResults && iPages && iPages->CurrentPage().DlgPageReady() && |
935 if ( iResults && iPages && iPages->CurrentPage().DlgPageReady() && |
924 !iPages->CurrentPage().DlgPageEmpty() ) |
936 !iPages->CurrentPage().DlgPageEmpty() ) |
925 { |
937 { |
926 // Use user defined CBA parameter if exist |
938 // Use user defined CBA parameter if exist |
927 if ( iParams.iCbaId ) |
939 if ( iParams.iCbaId ) |
928 { |
940 { |
937 else if ( iParams.iFlags & EFetchSingle ) |
949 else if ( iParams.iFlags & EFetchSingle ) |
938 { |
950 { |
939 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OK_BACK_OK ); |
951 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OK_BACK_OK ); |
940 } |
952 } |
941 |
953 |
|
954 if ( iParams.iFlags & EFetchMultiple ) |
|
955 { |
|
956 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
957 if ( iResults->Count() < iParams.iMinSelection ) |
|
958 { |
|
959 cba.MakeCommandVisibleByPosition |
|
960 ( CEikButtonGroupContainer::ELeftSoftkeyPosition, EFalse ); |
|
961 } |
|
962 else |
|
963 { |
|
964 cba.MakeCommandVisibleByPosition |
|
965 ( CEikButtonGroupContainer::ELeftSoftkeyPosition, ETrue ); |
|
966 } |
|
967 } |
|
968 |
942 MVPbkContactLink* link = NULL; |
969 MVPbkContactLink* link = NULL; |
943 TBool contactSelected = EFalse; |
970 TBool contactSelected = EFalse; |
944 //Used the TRAPD to catch the exception when the contact can't be found in DB. |
971 //Used the TRAPD to catch the exception when the contact can't be found in DB. |
945 TRAPD( err, |
972 TRAPD( err, |
946 {link=iPages->CurrentPage().Control().FocusedContactL()->CreateLinkLC();CleanupStack::Pop();}); |
973 {link=iPages->CurrentPage().Control().FocusedContactL()->CreateLinkLC();CleanupStack::Pop();}); |
1083 |
1110 |
1084 if ( ret && aButtonId != EEikBidCancel ) |
1111 if ( ret && aButtonId != EEikBidCancel ) |
1085 { |
1112 { |
1086 // Focused contact must be returned if no contacts yet selected, |
1113 // Focused contact must be returned if no contacts yet selected, |
1087 // and the focused contact selection is not already on its way |
1114 // and the focused contact selection is not already on its way |
1088 if ( FetchDlgSelection().Count() == 0 ) |
1115 if ( FetchDlgSelection().Count() == 0 && !( iParams.iFlags & EFetchMultiple ) ) |
1089 { |
1116 { |
1090 const MVPbkBaseContact* focusedContact = |
1117 const MVPbkBaseContact* focusedContact = iPages->FocusedContactL(); |
1091 iPages->FocusedContactL(); |
|
1092 if ( focusedContact ) |
1118 if ( focusedContact ) |
1093 { |
1119 { |
1094 delete iFocusedContactLink; |
1120 delete iFocusedContactLink; |
1095 iFocusedContactLink = NULL; |
1121 iFocusedContactLink = NULL; |
1096 iFocusedContactLink = focusedContact->CreateLinkLC(); |
1122 iFocusedContactLink = focusedContact->CreateLinkLC(); |
1097 CleanupStack::Pop(); // iFocusedContactLink |
1123 CleanupStack::Pop(); // iFocusedContactLink |
1098 |
|
1099 if ( iParams.iFlags & EFetchSingle ) |
1124 if ( iParams.iFlags & EFetchSingle ) |
1100 { |
1125 { |
1101 // Clean result if this is single fetch. |
1126 // Clean result if this is single fetch. |
1102 iResults->ResetAndDestroy(); |
1127 iResults->ResetAndDestroy(); |
1103 } |
1128 } |
1104 |
|
1105 SelectContactL( *iFocusedContactLink, ETrue ); |
1129 SelectContactL( *iFocusedContactLink, ETrue ); |
1106 } |
1130 } |
1107 |
1131 |
1108 // Not ok to to exit, since contact selection is asynchronous |
1132 // Not ok to to exit, since contact selection is asynchronous |
1109 ret = EFalse; |
1133 ret = EFalse; |