|
Nokia N97 SDK Example Applications Guide |
#include <ccontcontainer.h>
Inheritance diagram for CContContainer:

Definition at line 39 of file ccontcontainer.h.
Public Member Functions |
|
| void | ConstructL (const TRect &aRect) |
| virtual | ~CContContainer () |
| CContContainer () | |
| void | AddNewContactDlgL () |
| void | EditContactDlgL () |
| void | DeleteContactDlgL () |
| void | AddContactToGrpL () |
| void | GetSelectedContactL () |
| void | CreateContactTemplateL () |
| void | CreateContactGroupL () |
| void | DeleteContactGroupL () |
| void | ShowContactsL () |
| void | ShowContactGroupsL () |
| TBool | IsContactsOnListBox () |
| TBool | IfContactDbSelected () |
| TBool | CanAddContactToGroupL () |
| void | OpenDefaultDatabaseL () |
| void | UpdateContactDbName (TDesC &aDbName) |
Private Member Functions |
|
| void | SizeChanged () |
| TInt | CountComponentControls () const |
| CCoeControl * | ComponentControl (TInt aIndex) const |
| void | Draw (const TRect &aRect) const |
| void | HandleControlEventL (CCoeControl *aControl, TCoeEvent aEventType) |
| TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
| void | HandleListBoxEventL (CEikListBox *aListBox, TListBoxEvent aEventType) |
| void | UpdateListBoxL () |
| void | ReadContactsFromDbL () |
| void | ReadContactGroupsFromDbL () |
| TBool | ShowDeleteConfirmationQueryL (const TInt aTextResourceId) |
| TBool | OpenTextBoxQueryL (const TInt aTextResourceId, TPtr aTextData, TInt aTextLength=KMaxTextLength) |
| void | ShowInformationNoteNoDbL () |
Private Attributes |
|
| CContactDatabase * | iContactDb |
| CEikTextListBox * | iListBox |
| CDesCArray * | iContactArray |
| CDesCArray * | iContactGroupArray |
| TBuf< KMaxDatabasePathAndNameLength > | iDbName |
| TContactItemId | iSelectedItemId |
|
|
Destructor. Destructor is always virtual Definition at line 87 of file ccontcontainer.cpp. References iContactArray, iContactDb, iContactGroupArray, and iListBox. 00088 { 00089 if ( iListBox ) 00090 { 00091 delete iListBox; 00092 } 00093 00094 if ( iContactDb ) 00095 { 00096 iContactDb->CloseTables(); 00097 delete iContactDb; 00098 } 00099 00100 if ( iContactArray ) 00101 { 00102 delete iContactArray; 00103 } 00104 00105 if ( iContactGroupArray ) 00106 { 00107 delete iContactGroupArray; 00108 } 00109 }
|
|
|
Constructor Definition at line 45 of file ccontcontainer.cpp. References iContactDb, and iSelectedItemId. 00046 { 00047 iContactDb = NULL; 00048 iSelectedItemId = -1; 00049 }
|
|
|
Default constructor Definition at line 56 of file ccontcontainer.cpp. References iContactArray, iContactGroupArray, iListBox, and SizeChanged(). Referenced by CContAppUi::ConstructL(). 00057 { 00058 CreateWindowL(); 00059 00060 iContactArray = new (ELeave) CDesCArrayFlat( KArraySize ); 00061 iContactGroupArray = new (ELeave) CDesCArrayFlat( KArraySize ); 00062 00063 // Create Listbox 00064 iListBox = new (ELeave) CAknSingleStyleListBox; 00065 00066 if ( iListBox ) 00067 { 00068 iListBox->ConstructL( NULL, EAknListBoxSelectionList ); 00069 iListBox->Model()->SetItemTextArray( iContactArray ); 00070 iListBox->CreateScrollBarFrameL(); 00071 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); 00072 iListBox->SetListBoxObserver( this ); 00073 iListBox->HandleItemAdditionL(); 00074 } 00075 SizeChanged(); 00076 00077 SetRect( aRect ); 00078 00079 ActivateL(); 00080 }
|
|
|
AddNewContactDlgL The method adds new contact Definition at line 620 of file ccontcontainer.cpp. References iContactDb, iDbName, IfContactDbSelected(), IsContactsOnListBox(), ReadContactsFromDbL(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00621 { 00622 00623 if ( !IfContactDbSelected() ) 00624 { 00625 ShowInformationNoteNoDbL(); 00626 return; 00627 } 00628 00629 if ( !IsContactsOnListBox() ) 00630 { 00631 return; 00632 } 00633 00634 CPbkContactEngine* pbkContactEng = CPbkContactEngine::NewL( &iCoeEnv->FsSession()); 00635 // Put object to the stack 00636 CleanupStack::PushL( pbkContactEng ); 00637 00638 // load the contacts dialog resources 00639 CCoeEnv *env = CEikonEnv::Static(); 00640 RPbkViewResourceFile pbkRes( *env ); 00641 pbkRes.OpenL(); 00642 00643 //create a new empty contact 00644 // The caller takes ownership of this object. 00645 // so push it onto the CleanupStack 00646 CPbkContactItem* aContactItem = pbkContactEng->CreateEmptyContactL(); 00647 CleanupStack::PushL( aContactItem ); 00648 00649 // launch the contact dialog 00650 CPbkContactEditorDlg* pbkContactDlg = 00651 CPbkContactEditorDlg::NewL( *pbkContactEng, 00652 *aContactItem, 00653 ETrue, -1, 00654 ETrue ); 00655 00656 CleanupStack::PushL( pbkContactDlg ); 00657 00658 pbkContactDlg->SetMopParent( iAvkonAppUi ); 00659 00660 TInt res( KErrNone ); 00661 00662 // Show contact dialog 00663 TRAPD( err, res = pbkContactDlg->ExecuteLD() ); 00664 00665 pbkRes.Close(); 00666 00667 CleanupStack::Pop( pbkContactDlg ); 00668 CleanupStack::PopAndDestroy( 2 ); //aContactItem, pbkContactEng 00669 00670 // Update internal database connection 00671 iContactDb->CloseTables(); 00672 delete iContactDb; 00673 iContactDb = CContactDatabase::OpenL( iDbName ); 00674 00675 // Update iContactArray and iContactGroupArray 00676 ReadContactsFromDbL(); 00677 // Update display 00678 UpdateListBoxL(); 00679 }
|
|
|
EditContactDlgL The method edits contact Definition at line 467 of file ccontcontainer.cpp. References iContactArray, iContactDb, IfContactDbSelected(), iListBox, IsContactsOnListBox(), ReadContactsFromDbL(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(), and HandleListBoxEventL(). 00468 { 00469 if ( !IfContactDbSelected() ) 00470 { 00471 ShowInformationNoteNoDbL(); 00472 return; 00473 } 00474 00475 // Check if contacts list on the list box 00476 if ( !IsContactsOnListBox() ) 00477 { 00478 return; 00479 } 00480 00481 // The caller does not take ownership of this object. 00482 // so do not push it onto the CleanupStack. 00483 const CContactIdArray* contacts = iContactDb->SortedItemsL(); 00484 00485 TInt currentItemIndex( iListBox->CurrentItemIndex() ); 00486 TInt count( iContactArray->Count() ); 00487 if ( currentItemIndex < 0 || currentItemIndex >= count ) 00488 { 00489 HBufC* textResource = StringLoader::LoadLC( R_CONTACTS_NO_CONTACT_SELECTED ); 00490 CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote; 00491 informationNote->ExecuteLD( textResource->Des() ); 00492 CleanupStack::PopAndDestroy( textResource ); 00493 return; 00494 } 00495 00496 TContactItemId itemId( ((*contacts)[currentItemIndex]) ); 00497 00498 CPbkContactEngine* pbkContactEng = CPbkContactEngine::NewL( &iCoeEnv->FsSession()); 00499 CleanupStack::PushL( pbkContactEng ); 00500 // load the contacts dialog resources 00501 CCoeEnv *env = CEikonEnv::Static(); 00502 RPbkViewResourceFile pbkRes( *env ); 00503 pbkRes.OpenL(); 00504 00505 CPbkContactItem* aContactItem = pbkContactEng->OpenContactL( itemId ); 00506 CleanupStack::PushL( aContactItem ); 00507 00508 // Open the contacts dialog 00509 // third parameter: set to true if aContactItem is a 00510 // new contact (not yet in the database) 00511 // fourth parameter index of field to focus initially 00512 // fifth paramter if true sets the contact initially as "edited". 00513 CPbkContactEditorDlg* pbkContactDlg = 00514 CPbkContactEditorDlg::NewL( *pbkContactEng, 00515 *aContactItem, 00516 EFalse, -1, 00517 EFalse ); 00518 00519 CleanupStack::PushL( pbkContactDlg ); 00520 pbkContactDlg->SetMopParent( iAvkonAppUi ); 00521 00522 TInt res( KErrNone ); 00523 TRAPD( err, res = pbkContactDlg->ExecuteLD() ); 00524 00525 pbkRes.Close(); 00526 pbkContactEng->CloseContactL( aContactItem->Id() ); 00527 00528 CleanupStack::Pop( pbkContactDlg ); 00529 CleanupStack::PopAndDestroy( 2 ); //aContactItem, pbkContactEng 00530 00531 // Update iContactArray and iContactGroupArray 00532 ReadContactsFromDbL(); 00533 UpdateListBoxL(); 00534 }
|
|
|
DeleteContactDlgL The method deletes contact Definition at line 686 of file ccontcontainer.cpp. References iContactArray, iContactDb, iDbName, IfContactDbSelected(), iListBox, IsContactsOnListBox(), ReadContactsFromDbL(), ShowDeleteConfirmationQueryL(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00687 { 00688 00689 if ( !IfContactDbSelected() ) 00690 { 00691 ShowInformationNoteNoDbL(); 00692 return; 00693 } 00694 00695 if ( !IsContactsOnListBox() ) 00696 { 00697 return; 00698 } 00699 00700 // The caller does not take ownership of this object. 00701 // so do not push it onto the CleanupStack 00702 00703 TInt currentItemIndex( iListBox->CurrentItemIndex() ); 00704 TInt count( iContactArray->Count() ); 00705 if (currentItemIndex < 0 || currentItemIndex >= count ) 00706 { 00707 HBufC* textResource = StringLoader::LoadLC( R_CONTACTS_NO_CONTACT_SELECTED ); 00708 CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote; 00709 informationNote->ExecuteLD( textResource->Des() ); 00710 CleanupStack::PopAndDestroy( textResource ); 00711 return; 00712 } 00713 00714 // Ask about deletion 00715 if ( !ShowDeleteConfirmationQueryL( R_CONTACTS_DELETE_CONTACT_MESSAGE ) ) 00716 { 00717 return; 00718 } 00719 00720 // Sets the type of contact items to be included in 00721 // sorted views of the database 00722 iContactDb->SetDbViewContactType( KUidContactCard ); 00723 00724 const CContactIdArray* contacts = iContactDb->SortedItemsL(); 00725 TContactItemId itemId( ( (*contacts)[currentItemIndex] ) ); 00726 00727 CPbkContactEngine* pbkContactEng = CPbkContactEngine::NewL( &iCoeEnv->FsSession()); 00728 CleanupStack::PushL( pbkContactEng ); 00729 pbkContactEng->DeleteContactL( itemId ); 00730 CleanupStack::PopAndDestroy( pbkContactEng ); 00731 00732 iContactDb->CloseTables(); 00733 delete iContactDb; 00734 iContactDb = NULL; 00735 iContactDb = CContactDatabase::OpenL( iDbName ); 00736 00737 // Update iContactArray and iContactGroupArray 00738 ReadContactsFromDbL(); 00739 UpdateListBoxL(); 00740 }
|
|
|
AddContactToGrpL The method adds contact to selected contact group Definition at line 577 of file ccontcontainer.cpp. References iContactDb, iContactGroupArray, IfContactDbSelected(), iListBox, iSelectedItemId, and ShowInformationNoteNoDbL(). Referenced by CContAppUi::HandleCommandL(). 00578 { 00579 if ( !IfContactDbSelected() ) 00580 { 00581 ShowInformationNoteNoDbL(); 00582 return; 00583 } 00584 00585 if ( iSelectedItemId == -1 ) 00586 { 00587 return; 00588 } 00589 00590 TInt currentItemIndex( iListBox->CurrentItemIndex() ); 00591 TInt count( iContactGroupArray->Count() ); 00592 if ( currentItemIndex < 0 || currentItemIndex >= count ) 00593 { 00594 return; 00595 } 00596 00597 // The caller takes ownership of the returned object. 00598 // groupIdList is NULL if there are no groups in the database. 00599 CContactIdArray* groupIdList = iContactDb->GetGroupIdListL(); 00600 if ( !groupIdList ) 00601 { 00602 return; 00603 } 00604 00605 CleanupStack::PushL( groupIdList ); 00606 00607 TContactItemId groupItemId = ((*groupIdList)[currentItemIndex]); 00608 iContactDb->AddContactToGroupL( iSelectedItemId , groupItemId ); 00609 00610 iSelectedItemId = -1; 00611 00612 CleanupStack::PopAndDestroy( groupIdList ); 00613 }
|
|
|
GetSelectedContactL The method stores selected contact and open group list to the listbox Definition at line 542 of file ccontcontainer.cpp. References iContactArray, iContactDb, IfContactDbSelected(), iListBox, IsContactsOnListBox(), iSelectedItemId, ShowContactGroupsL(), and ShowInformationNoteNoDbL(). Referenced by CContAppUi::HandleCommandL(). 00543 { 00544 if ( !IfContactDbSelected() ) 00545 { 00546 ShowInformationNoteNoDbL(); 00547 return; 00548 } 00549 00550 if ( !IsContactsOnListBox() ) 00551 { 00552 return; 00553 } 00554 00555 iContactDb->SetDbViewContactType( KUidContactCard ); 00556 // The caller does not take ownership of this object. 00557 // so do not push it onto the CleanupStack 00558 const CContactIdArray* contacts = iContactDb->SortedItemsL(); 00559 00560 TInt currentItemIndex( iListBox->CurrentItemIndex() ); 00561 TInt count( iContactArray->Count() ); 00562 if ( currentItemIndex < 0 || currentItemIndex >= count ) 00563 { 00564 return; 00565 } 00566 00567 iSelectedItemId = ((*contacts)[currentItemIndex]); 00568 00569 ShowContactGroupsL(); 00570 }
|
|
|
CreateContactTemplateL The method creates new contact template Definition at line 748 of file ccontcontainer.cpp. References iContactDb, IfContactDbSelected(), OpenTextBoxQueryL(), ReadContactsFromDbL(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00749 { 00750 00751 if ( !IfContactDbSelected() ) 00752 { 00753 ShowInformationNoteNoDbL(); 00754 return; 00755 } 00756 00757 HBufC* templateName = HBufC::NewLC( KMaxTemplateNameLength ); 00758 TPtr ptr( templateName->Des() ); 00759 if( !OpenTextBoxQueryL( R_CONTACTS_CREATE_TEMPLATE_MESSAGE, 00760 ptr, 00761 KMaxTextLength ) ) 00762 { 00763 CleanupStack::PopAndDestroy( 1 ); // templateName 00764 return; 00765 } 00766 00767 // The caller takes ownership of this object. 00768 // so push it onto the CleanupStack 00769 CContactItem* contactTemplate = 00770 iContactDb->CreateContactCardTemplateL( templateName->Des() ); 00771 CleanupStack::PushL( contactTemplate ); 00772 CContactItemField* givenNameField = 00773 CContactItemField::NewLC( KStorageTypeText, 00774 KUidContactFieldGivenName ); 00775 CContactItemField* familyNameField = 00776 CContactItemField::NewLC(KStorageTypeText, 00777 KUidContactFieldFamilyName ); 00778 CContactItemField* phoneNumberField = 00779 CContactItemField::NewLC(KStorageTypeText, 00780 KUidContactFieldPhoneNumber ); 00781 00782 // Add data to fields 00783 givenNameField->TextStorage()->SetTextL( KFirstName ); 00784 givenNameField->SetMapping( KUidContactFieldVCardMapUnusedN ); 00785 familyNameField->TextStorage()->SetTextL( KLastName ); 00786 familyNameField->SetMapping( KUidContactFieldVCardMapUnusedN ); 00787 phoneNumberField->TextStorage()->SetTextL( KPhoneNumber ); 00788 phoneNumberField->SetMapping( KUidContactFieldVCardMapTEL ); 00789 00790 // Add fields to a contact template 00791 contactTemplate->AddFieldL( *givenNameField ); 00792 contactTemplate->AddFieldL( *familyNameField ); 00793 contactTemplate->AddFieldL( *phoneNumberField ); 00794 00795 // Item takes the ownership of fields 00796 CleanupStack::Pop( 3 ); // givenNameField, familyNameField, phoneNumberField 00797 CleanupStack::PopAndDestroy( 2 );// templateName, contactTemplate 00798 00799 // Update iContactArray and iContactGroupArray 00800 ReadContactsFromDbL(); 00801 UpdateListBoxL(); 00802 }
|
|
|
CreateContactGroupL The method Creates new contact group Definition at line 809 of file ccontcontainer.cpp. References iContactDb, iDbName, IfContactDbSelected(), IsContactsOnListBox(), OpenTextBoxQueryL(), ReadContactsFromDbL(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00810 { 00811 00812 if ( !IfContactDbSelected() ) 00813 { 00814 ShowInformationNoteNoDbL(); 00815 return; 00816 } 00817 00818 if ( IsContactsOnListBox() ) 00819 { 00820 return; 00821 } 00822 00823 CPbkContactEngine* pbkContactEng = CPbkContactEngine::NewL( &iCoeEnv->FsSession()); 00824 CleanupStack::PushL( pbkContactEng ); 00825 00826 // Open dialog 00827 HBufC* groupName = HBufC::NewLC( KMaxGroupNameLength ); 00828 TPtr ptr( groupName->Des() ); 00829 if ( OpenTextBoxQueryL( R_CONTACTS_CREATE_GROUP_MESSAGE, 00830 ptr, 00831 KMaxTextLength ) ) 00832 { 00833 //Create contactGroup 00834 CContactGroup* contactGroup = 00835 pbkContactEng->CreateContactGroupL( groupName->Des() ); 00836 delete contactGroup; 00837 } 00838 00839 CleanupStack::PopAndDestroy( 2 ); // pbkContactEng, groupName 00840 00841 iContactDb->CloseTables(); 00842 delete iContactDb; 00843 iContactDb = NULL; 00844 iContactDb = CContactDatabase::OpenL( iDbName ); 00845 00846 // Update iContactArray and iContactGroupArray 00847 ReadContactsFromDbL(); 00848 UpdateListBoxL(); 00849 }
|
|
|
DeleteContactGroupL The method deletes contact group Definition at line 856 of file ccontcontainer.cpp. References iContactDb, iContactGroupArray, iDbName, IfContactDbSelected(), iListBox, IsContactsOnListBox(), ReadContactsFromDbL(), ShowDeleteConfirmationQueryL(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00857 { 00858 00859 if ( !IfContactDbSelected() ) 00860 { 00861 ShowInformationNoteNoDbL(); 00862 return; 00863 } 00864 00865 if ( IsContactsOnListBox() ) 00866 { 00867 return; 00868 } 00869 00870 TInt currentItemIndex( iListBox->CurrentItemIndex() ); 00871 TInt count( iContactGroupArray->Count() ); 00872 if ( currentItemIndex < 0 || currentItemIndex >= count ) 00873 { 00874 return; 00875 } 00876 00877 // The caller takes ownership of the returned object. 00878 // groupIdList is NULL if there are no groups in the database. 00879 CContactIdArray* groupIdList = iContactDb->GetGroupIdListL(); 00880 if ( !groupIdList ) 00881 { 00882 return; 00883 } 00884 00885 CleanupStack::PushL( groupIdList ); 00886 00887 CPbkContactEngine* pbkContactEng = CPbkContactEngine::NewL( &iCoeEnv->FsSession()); 00888 CleanupStack::PushL(pbkContactEng); 00889 00890 TContactItemId itemId = ((*groupIdList)[currentItemIndex]); 00891 00892 // Ask about deletion 00893 if (ShowDeleteConfirmationQueryL( R_CONTACTS_DELETE_GROUP_MESSAGE ) ) 00894 { 00895 pbkContactEng->DeleteContactGroupL( itemId ); 00896 } 00897 00898 CleanupStack::PopAndDestroy( 2 ); //pbkContactEng , groupIdList 00899 00900 iContactDb->CloseTables(); 00901 delete iContactDb; 00902 iContactDb = NULL; 00903 iContactDb = CContactDatabase::OpenL( iDbName ); 00904 00905 // Update iContactArray and iContactGroupArray 00906 ReadContactsFromDbL(); 00907 UpdateListBoxL(); 00908 }
|
|
|
ShowContactsL The method shows contacts in the listbox Definition at line 264 of file ccontcontainer.cpp. References iContactArray, IfContactDbSelected(), iListBox, IsContactsOnListBox(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00265 { 00266 00267 if ( !IfContactDbSelected() ) 00268 { 00269 ShowInformationNoteNoDbL(); 00270 return; 00271 } 00272 00273 if ( IsContactsOnListBox() ) 00274 { 00275 return; 00276 } 00277 00278 iListBox->Model()->SetItemTextArray( iContactArray ); 00279 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); 00280 UpdateListBoxL(); 00281 }
|
|
|
ShowContactGroupsL The method shows contact groups in the listbox Definition at line 288 of file ccontcontainer.cpp. References iContactGroupArray, IfContactDbSelected(), iListBox, IsContactsOnListBox(), ShowInformationNoteNoDbL(), and UpdateListBoxL(). Referenced by GetSelectedContactL(), and CContAppUi::HandleCommandL(). 00289 { 00290 00291 if ( !IfContactDbSelected() ) 00292 { 00293 ShowInformationNoteNoDbL(); 00294 return; 00295 } 00296 00297 if ( !IsContactsOnListBox() ) 00298 { 00299 return; 00300 } 00301 00302 iListBox->Model()->SetItemTextArray( iContactGroupArray ); 00303 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); 00304 UpdateListBoxL(); 00305 }
|
|
|
IsContactsOnListBox The method returns true if contacs are in the listbox
Definition at line 248 of file ccontcontainer.cpp. References iContactArray, and iListBox. Referenced by AddNewContactDlgL(), CreateContactGroupL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), GetSelectedContactL(), ShowContactGroupsL(), and ShowContactsL(). 00249 { 00250 CDesCArray* itemArray = (CDesCArray*) iListBox->Model()->ItemTextArray(); 00251 00252 if ( iContactArray == itemArray ) 00253 { 00254 return ETrue; 00255 } 00256 00257 return EFalse; 00258 }
|
|
|
IfContactDbSelected The method returns true if contacs are opened.
Definition at line 329 of file ccontcontainer.cpp. References iContactDb. Referenced by AddContactToGrpL(), AddNewContactDlgL(), CanAddContactToGroupL(), CreateContactGroupL(), CreateContactTemplateL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), GetSelectedContactL(), CContAppUi::HandleCommandL(), ReadContactGroupsFromDbL(), ReadContactsFromDbL(), ShowContactGroupsL(), and ShowContactsL(). 00330 { 00331 00332 if ( iContactDb ) 00333 { 00334 return ETrue; 00335 } 00336 00337 return EFalse; 00338 }
|
|
|
CanAddContactToGroupL The method returns ETrue is contact database has been opened and contains at least one contact item
Definition at line 346 of file ccontcontainer.cpp. References iContactArray, IfContactDbSelected(), and ShowInformationNoteNoDbL(). Referenced by CContAppUi::HandleCommandL(). 00347 { 00348 if ( !IfContactDbSelected() ) 00349 { 00350 ShowInformationNoteNoDbL(); 00351 return EFalse; 00352 } 00353 00354 if ( !iContactArray->Count() ) 00355 { 00356 HBufC* textResource = StringLoader::LoadLC( R_CONTACTS_NO_CONTACT_SELECTED ); 00357 CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote; 00358 informationNote->ExecuteLD( textResource->Des() ); 00359 CleanupStack::PopAndDestroy( textResource ); 00360 return EFalse; 00361 } 00362 00363 return ETrue; 00364 }
|
|
|
OpenDefaultDatabaseL The method opens default contact database Definition at line 372 of file ccontcontainer.cpp. References iContactDb, iDbName, ReadContactsFromDbL(), UpdateContactDbName(), and UpdateListBoxL(). Referenced by CContAppUi::HandleCommandL(). 00373 { 00374 // Read name of the default database 00375 _LIT( KOrgContactFile,"" ); 00376 TBuf<KMaxDatabasePathAndNameLength> orgContactFile( KOrgContactFile ); 00377 CContactDatabase::GetDefaultNameL( orgContactFile ); 00378 orgContactFile.LowerCase(); 00379 00380 if ( iContactDb ) 00381 { 00382 if ( !iDbName.Compare( orgContactFile ) ) 00383 { 00384 return; 00385 } 00386 iContactDb->CloseTables(); 00387 delete iContactDb; 00388 iContactDb = NULL; 00389 } 00390 00391 TRAPD(err, iContactDb = CContactDatabase::OpenL( orgContactFile );); 00392 // Check if database already exist 00393 if ( err == KErrNotFound ) 00394 { 00395 00396 HBufC* text = StringLoader::LoadLC( R_CONTACTS_DB_NOT_FOUND ); 00397 CAknInformationNote* informationNote = new (ELeave) CAknInformationNote; 00398 informationNote->ExecuteLD( *text ); 00399 CleanupStack::PopAndDestroy( text ); 00400 iContactDb = NULL; 00401 ReadContactsFromDbL();// Update iContactArray and iContactGroupArray 00402 00403 TBuf<15> noContactFile( KNullDesC ); 00404 UpdateContactDbName( noContactFile ); 00405 00406 UpdateListBoxL(); 00407 } 00408 else 00409 { 00410 // Update iContactArray and iContactGroupArray 00411 ReadContactsFromDbL(); 00412 UpdateContactDbName( orgContactFile ); 00413 UpdateListBoxL(); 00414 } 00415 }
|
|
|
OpenContactDatabase The method stores name of the contact database complete path to the variable iDbName
Definition at line 223 of file ccontcontainer.cpp. References iDbName. Referenced by OpenDefaultDatabaseL(). 00224 { 00225 iDbName = aDbName; 00226 }
|
|
|
From CoeControl,SizeChanged Called by framework when the view size is changed Definition at line 116 of file ccontcontainer.cpp. References iListBox. Referenced by ConstructL(), and UpdateListBoxL(). 00117 { 00118 // We want the list box to begin from top of the main pane 00119 // and fill at least its minimum size. 00120 TPoint coordListBox; 00121 AknLayoutUtils::LayoutMetricsPosition(AknLayoutUtils::EMainPane, coordListBox); 00122 iListBox->SetExtent( coordListBox, iListBox->MinimumSize() ); 00123 }
|
|
|
From CoeControl,CountComponentControls
Definition at line 131 of file ccontcontainer.cpp.
|
|
|
From CCoeControl,ComponentControl
Definition at line 140 of file ccontcontainer.cpp. References iListBox. 00141 { 00142 switch ( aIndex ) 00143 { 00144 case 0: 00145 if ( iListBox ) 00146 { 00147 return iListBox; 00148 } 00149 00150 default: 00151 return NULL; 00152 } 00153 }
|
|
|
From CCoeControl,Draw
Definition at line 159 of file ccontcontainer.cpp. 00160 { 00161 CWindowGc& gc = SystemGc(); 00162 gc.SetPenStyle( CGraphicsContext::ENullPen ); 00163 gc.SetBrushColor( KRgbWhite ); 00164 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 00165 gc.DrawRect( aRect ); 00166 }
|
|
||||||||||||
|
From CCoeControl event handling section e.g Listbox events
Definition at line 213 of file ccontcontainer.cpp.
|
|
||||||||||||
|
From CCoeControl event handling section e.g Listbox events
Definition at line 173 of file ccontcontainer.cpp. References iListBox. 00175 { 00176 if ( aType != EEventKey ) 00177 { 00178 return EKeyWasNotConsumed; 00179 } 00180 00181 if ( iListBox ) 00182 { 00183 return iListBox->OfferKeyEventL( aKeyEvent, aType ); 00184 } 00185 00186 return EKeyWasNotConsumed; 00187 00188 }
|
|
||||||||||||
|
From MEikListBoxObserver,HandleListBoxEventL. Handles listbox events.
Definition at line 195 of file ccontcontainer.cpp. References EditContactDlgL(). 00197 { 00198 switch( aEventType ) 00199 { 00200 case EEventEnterKeyPressed: // Flow through 00201 case EEventItemClicked: 00202 EditContactDlgL(); 00203 break; 00204 default: 00205 break; 00206 } 00207 }
|
|
|
UpdateListBoxL The method updates listbox Definition at line 233 of file ccontcontainer.cpp. References iListBox, and SizeChanged(). Referenced by AddNewContactDlgL(), CreateContactGroupL(), CreateContactTemplateL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), OpenDefaultDatabaseL(), ShowContactGroupsL(), and ShowContactsL(). 00234 { 00235 iListBox->HandleItemAdditionL(); 00236 iListBox->SetCurrentItemIndexAndDraw( 0 ); 00237 SizeChanged(); 00238 DrawNow(); 00239 }
|
|
|
ReadContactsFromDbL The method reads contacts from contact database Definition at line 918 of file ccontcontainer.cpp. References iContactArray, iContactDb, IfContactDbSelected(), and ReadContactGroupsFromDbL(). Referenced by AddNewContactDlgL(), CreateContactGroupL(), CreateContactTemplateL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), and OpenDefaultDatabaseL(). 00919 { 00920 ReadContactGroupsFromDbL(); 00921 00922 // Delete old contact from listbox 00923 TInt count( iContactArray->Count() ); 00924 if ( count ) 00925 { 00926 // Clear array. Start to index 0 00927 iContactArray->Delete( 0, count ); 00928 } 00929 00930 if ( !IfContactDbSelected() ) 00931 { 00932 return; 00933 } 00934 00935 iContactDb->SetDbViewContactType( KUidContactCard ); 00936 00937 TFieldType aFieldType1( KUidContactFieldFamilyName ); 00938 TFieldType aFieldType2( KUidContactFieldGivenName ); 00939 CContactDatabase::TSortPref sortPref1( aFieldType1 ); 00940 CContactDatabase::TSortPref sortPref2( aFieldType2 ); 00941 00942 // Sort contacts by Family and Given Name 00943 CArrayFixFlat<CContactDatabase::TSortPref>* aSortOrder = 00944 new (ELeave) CArrayFixFlat<CContactDatabase::TSortPref>(2); 00945 00946 CleanupStack::PushL( aSortOrder ); 00947 aSortOrder->AppendL( sortPref1 ); 00948 aSortOrder->AppendL( sortPref2 ); 00949 00950 // The database takes ownership of the sort order array passed in 00951 iContactDb->SortL( aSortOrder ); 00952 00953 // The caller does not take ownership of this object. 00954 // so do not push it onto the CleanupStack 00955 const CContactIdArray* contacts = iContactDb->SortedItemsL(); 00956 00957 // Go through each contact item and 00958 // make items for listbox 00959 const TInt nc( contacts->Count() ); 00960 00961 for ( TInt i( nc-1 ); i >= 0; i-- ) //For each ContactId 00962 { 00963 CContactItem* contact = NULL; 00964 // The caller takes ownership of the returned object. 00965 // So push it onto the CleanupStack 00966 contact = iContactDb->OpenContactL( (*contacts)[i] ); 00967 CleanupStack::PushL( contact ); 00968 00969 CContactItemFieldSet& fieldSet = contact->CardFields(); 00970 00971 HBufC* firstNameBuf = NULL; 00972 HBufC* lastNameBuf = NULL; 00973 00974 // Get first name 00975 TInt findpos( fieldSet.Find( KUidContactFieldGivenName ) ); 00976 00977 // Check that the first name field is actually there. 00978 if ( (findpos > -1) || (findpos >= fieldSet.Count()) ) 00979 { 00980 CContactItemField& firstNameField = fieldSet[findpos]; 00981 CContactTextField* firstName = firstNameField.TextStorage(); 00982 firstNameBuf = firstName->Text().AllocLC(); 00983 } 00984 00985 // Get last name 00986 findpos = fieldSet.Find( KUidContactFieldFamilyName ); 00987 00988 // Check that the last name field is actually there. 00989 if ( (findpos > -1) || (findpos >= fieldSet.Count()) ) 00990 { 00991 CContactItemField& lastNameField = fieldSet[ findpos ]; 00992 CContactTextField* lastName = lastNameField.TextStorage(); 00993 lastNameBuf = lastName->Text().AllocLC(); 00994 } 00995 00996 TInt len( 0 ); 00997 00998 if ( firstNameBuf ) 00999 { 01000 len+=firstNameBuf->Length(); 01001 } 01002 01003 if ( lastNameBuf ) 01004 { 01005 len+=lastNameBuf->Length(); 01006 } 01007 01008 // Create new buffer and add space for formatters 01009 HBufC* combinedDes = HBufC::NewLC( len + KFormattersSpace ); 01010 if ( ( firstNameBuf ) && ( lastNameBuf ) ) 01011 { 01012 combinedDes->Des().Format( KListItemFormatter, 01013 lastNameBuf, 01014 firstNameBuf ); 01015 } 01016 else 01017 { 01018 if ( firstNameBuf ) 01019 { 01020 combinedDes->Des().Format( KListOItemFormatter, firstNameBuf ); 01021 } 01022 else if ( lastNameBuf ) 01023 { 01024 combinedDes->Des().Format( KListOItemFormatter, lastNameBuf ); 01025 } 01026 } 01027 01028 // Insert a contacts name into the array at the specified position. 01029 // If the specified position is the same as the current number of 01030 // descriptor elements in the array, this has the effect of 01031 // appending the element. 01032 iContactArray->InsertL( 0, *combinedDes ); 01033 01034 CleanupStack::PopAndDestroy( combinedDes ); 01035 01036 if ( lastNameBuf ) 01037 { 01038 CleanupStack::PopAndDestroy( lastNameBuf ); 01039 } 01040 01041 if ( firstNameBuf ) 01042 { 01043 CleanupStack::PopAndDestroy( firstNameBuf ); 01044 } 01045 01046 iContactDb->CloseContactL( contact->Id() ); 01047 CleanupStack::PopAndDestroy( contact ); 01048 01049 } 01050 01051 CleanupStack::Pop( aSortOrder ); 01052 }
|
|
|
ReadContactGroupsFromDbL The method reads contact groups from contact database Definition at line 1061 of file ccontcontainer.cpp. References iContactDb, iContactGroupArray, and IfContactDbSelected(). Referenced by ReadContactsFromDbL(). 01062 { 01063 TInt count( iContactGroupArray->Count() ); 01064 if ( count ) 01065 { 01066 // Clear array. Start to index 0 01067 iContactGroupArray->Delete( 0, count ); 01068 } 01069 if ( !IfContactDbSelected() ) 01070 { 01071 return; 01072 } 01073 01074 //The caller takes ownership of the returned object. 01075 // groupIdList is NULL if there are no groups in the database. 01076 CContactIdArray* groupIdList = iContactDb->GetGroupIdListL(); 01077 if( !groupIdList ) 01078 { 01079 return; 01080 } 01081 01082 CleanupStack::PushL( groupIdList ); 01083 01084 CContactGroup* contactGroup = NULL; 01085 const TInt nc( groupIdList->Count() ); 01086 for ( TInt i( nc-1 ); i >= 0; i-- ) //For each Contact Group Id 01087 { 01088 CContactItem* contact=NULL; 01089 01090 // The caller takes ownership of the returned object. 01091 // So push it onto the CleanupStack 01092 contact = iContactDb->OpenContactL( ((*groupIdList)[i]) ); 01093 CleanupStack::PushL( contact ); 01094 01095 contactGroup = (CContactGroup*) contact; 01096 TInt len( contactGroup->GetGroupLabelL().Length() ); 01097 HBufC* groupLabelBuf = HBufC::NewLC( len + KFormattersSpace ); 01098 HBufC* combinedDes = HBufC::NewLC( len + KFormattersSpace ); 01099 01100 *groupLabelBuf = contactGroup->GetGroupLabelL(); 01101 combinedDes->Des().Format( KListOItemFormatter, groupLabelBuf ); 01102 01103 // Insert a group name into the array at the specified position. 01104 // If the specified position is the same as the current number of 01105 // descriptor elements in the array, this has the effect of 01106 // appending the element. 01107 iContactGroupArray->InsertL( 0, *combinedDes ); 01108 01109 CleanupStack::PopAndDestroy( combinedDes ); 01110 CleanupStack::PopAndDestroy( groupLabelBuf ); 01111 01112 iContactDb->CloseContactL( contact->Id() ); 01113 CleanupStack::PopAndDestroy( contact ); 01114 } 01115 01116 CleanupStack::PopAndDestroy( groupIdList ); 01117 }
|
|
|
ShowDeleteConfirmationQueryL The method shows confirmation query display
Definition at line 422 of file ccontcontainer.cpp. Referenced by DeleteContactDlgL(), and DeleteContactGroupL(). 00423 { 00424 HBufC* prompt = StringLoader::LoadLC( aTextResourceId ); 00425 00426 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); 00427 00428 dlg->SetPromptL( *prompt ); 00429 TInt retCode( dlg->ExecuteLD( R_CONTACTS_CONFIRMATION_QUERY ) ); 00430 00431 CleanupStack::PopAndDestroy(); //prompt 00432 return retCode; 00433 }
|
|
||||||||||||||||
|
OpenTextBoxQueryL The method shows text query display
Definition at line 440 of file ccontcontainer.cpp. Referenced by CreateContactGroupL(), and CreateContactTemplateL(). 00443 { 00444 HBufC* prompt = StringLoader::LoadLC( aTextResourceId ); 00445 // aTextData is smaller than 40 so this does not crash 00446 TBuf<KMaxTextBoxQueryLength> text = aTextData; 00447 00448 CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog( text, 00449 CAknQueryDialog::ENoTone ); 00450 00451 CleanupStack::PushL( dlg ); 00452 dlg->SetPromptL( *prompt ); 00453 dlg->SetMaxLength( aTextLength ); 00454 00455 TBool answer( dlg->ExecuteLD( R_CONTACTS_TEXTBOX_QUERY ) ); 00456 CleanupStack::Pop( dlg ); 00457 CleanupStack::PopAndDestroy( prompt ); 00458 aTextData = text; 00459 return answer; 00460 }
|
|
|
ShowInformationNoteNoDbL The method shows no contact database selected information note Definition at line 315 of file ccontcontainer.cpp. Referenced by AddContactToGrpL(), AddNewContactDlgL(), CanAddContactToGroupL(), CreateContactGroupL(), CreateContactTemplateL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), GetSelectedContactL(), ShowContactGroupsL(), and ShowContactsL(). 00316 { 00317 HBufC* textResource = StringLoader::LoadLC( R_CONTACTS_NO_DB_SELECTED ); 00318 CAknInformationNote* informationNote = new( ELeave ) CAknInformationNote; 00319 informationNote->ExecuteLD( textResource->Des() ); 00320 CleanupStack::PopAndDestroy( textResource ); 00321 00322 }
|
|
|
iContactDb the contact database Owned by CContContainer object Definition at line 267 of file ccontcontainer.h. Referenced by AddContactToGrpL(), AddNewContactDlgL(), CContContainer(), CreateContactGroupL(), CreateContactTemplateL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), GetSelectedContactL(), IfContactDbSelected(), OpenDefaultDatabaseL(), ReadContactGroupsFromDbL(), ReadContactsFromDbL(), and ~CContContainer(). |
|
|
iListBox the listbox Owned by CContContainer object, instantiated in ConstructL, deleted in destructor Definition at line 274 of file ccontcontainer.h. Referenced by AddContactToGrpL(), ComponentControl(), ConstructL(), DeleteContactDlgL(), DeleteContactGroupL(), EditContactDlgL(), GetSelectedContactL(), IsContactsOnListBox(), OfferKeyEventL(), ShowContactGroupsL(), ShowContactsL(), SizeChanged(), UpdateListBoxL(), and ~CContContainer(). |
|
|
iContactArray the array of the contacts Owned by CContContainer object, instantiated in ConstructL, deleted in destructor Definition at line 281 of file ccontcontainer.h. Referenced by CanAddContactToGroupL(), ConstructL(), DeleteContactDlgL(), EditContactDlgL(), GetSelectedContactL(), IsContactsOnListBox(), ReadContactsFromDbL(), ShowContactsL(), and ~CContContainer(). |
|
|
iContactGroupArray the array of the contacts Owned by CContContainer object, instantiated in ConstructL, deleted in destructor Definition at line 288 of file ccontcontainer.h. Referenced by AddContactToGrpL(), ConstructL(), DeleteContactGroupL(), ReadContactGroupsFromDbL(), ShowContactGroupsL(), and ~CContContainer(). |
|
|
iDbName the name of the contact database variable contains path and name Definition at line 294 of file ccontcontainer.h. Referenced by AddNewContactDlgL(), CreateContactGroupL(), DeleteContactDlgL(), DeleteContactGroupL(), OpenDefaultDatabaseL(), and UpdateContactDbName(). |
|
|
iSelectedItemId the id of the selected item Definition at line 299 of file ccontcontainer.h. Referenced by AddContactToGrpL(), CContContainer(), and GetSelectedContactL(). |
|
© Nokia 2009 |