--- a/phonebookui/Phonebook2/NamesListExtension/src/NamesListExView.cpp Thu Jul 15 18:22:55 2010 +0300
+++ b/phonebookui/Phonebook2/NamesListExtension/src/NamesListExView.cpp Thu Aug 19 09:41:07 2010 +0300
@@ -62,6 +62,7 @@
#include <pbk2mapcommands.hrh>
#include "Pbk2InternalCommands.hrh"
#include "CPbk2ContactViewListBox.h"
+#include <pbk2doublelistboxcmditemextension.h>
#include "CVPbkContactManager.h"
#include "MVPbkContactStoreList.h"
@@ -111,6 +112,7 @@
#include <CPbk2StoreConfiguration.h>
#include <VPbkContactStoreUris.h>
#include <TVPbkContactStoreUriPtr.h>
+#include <Pbk2InternalUID.h>
/// Unnamed namespace for local definitions
namespace {
@@ -201,7 +203,8 @@
iCtrlVisibleStateBeforeLosingForground( ETrue ),
iFirstTimeActivated( ETrue ),
iContentProvider( aStatusProvider ),
- iCCAConnection( aCCAConnection )
+ iCCAConnection( aCCAConnection ),
+ iMarkingModeOn( EFalse )
{
}
@@ -416,9 +419,9 @@
}
if ( EPbk2CmdOpenCca == aCommandId )
- {
+ {
iControl->SetOpeningCca( ETrue );
- }
+ }
// Set focus, keep current focus on the area of the client screen
// when scoll to the bottom of Names list view.
@@ -563,7 +566,7 @@
// The application is set here to background if application exit occurs
PBK2_PROFILE_START
( Pbk2Profile::ENamesListViewDoActivateNotifyViewActivatation );
-
+
// The application is set here to background if application exit occurs
// When the device is powered on, Phonebook will start up automatically and
// hide itself in the background. At the first time of names list view activation,
@@ -595,9 +598,12 @@
PBK2_PROFILE_END(Pbk2Profile::ENamesListViewDoActivateL);
+ // It will return the listbox by calling iControl->ComponentControl(0),
+ // which is defined in CPbk2NamesListControl::ComponentControl(TInt aIndex).
CCoeControl* ctrl=iControl->ComponentControl(0);
CEikListBox* listbox=static_cast <CEikListBox*> (ctrl);
listbox->SetListBoxObserver( this );
+ listbox->SetMarkingModeObserver( this );
// iCtrlVisibleStateBeforeLosingForground records the names list control states before
// losing foreground during a command execution. Set the iCtrlVisibleStateBeforeLosingForground
@@ -620,17 +626,17 @@
// Check if there is need to create MyCard
if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) &&
( !iMyCard && IsPhoneMemoryUsedL() ) )
- {
- // Get the phoneStore for MyCard
- MVPbkContactStore* phoneStore = iContactManager->ContactStoresL()
- .Find(VPbkContactStoreUris::DefaultCntDbUri() );
-
- if( phoneStore )
- {
- // Create MyCard if not already exist and the phone memory selected
- iMyCard = CPbk2MyCard::NewL( *phoneStore );
- }
- }
+ {
+ // Get the phoneStore for MyCard
+ MVPbkContactStore* phoneStore = iContactManager->ContactStoresL()
+ .Find(VPbkContactStoreUris::DefaultCntDbUri() );
+
+ if( phoneStore )
+ {
+ // Create MyCard if not already exist and the phone memory selected
+ iMyCard = CPbk2MyCard::NewL( *phoneStore );
+ }
+ }
// Add the MyCard item to the top of the list
if( iMyCard && IsPhoneMemoryUsedL() )
@@ -652,13 +658,13 @@
// promotion item disabled until we can support command items at the bottom of the list
// if ( IsRclOnL() )
if( 0 )
- {
+ {
CPbk2CmdItemRemoteContactLookup* rclCmd = CPbk2CmdItemRemoteContactLookup::NewLC();
// Add the command item to the bottom of the command list
iControl->AddCommandItemL( rclCmd, commandCount ); // ownership transferred
CleanupStack::Pop( rclCmd );
commandCount++;
- }
+ }
}
// --------------------------------------------------------------------------
@@ -698,17 +704,17 @@
// --------------------------------------------------------------------------
//
CPbk2MyCard* CPbk2NamesListExView::MyCard() const
- {
- TBool phoneMemory = EFalse;
-
- TRAP_IGNORE( phoneMemory = IsPhoneMemoryUsedL() );
-
- if( phoneMemory )
- {
- return iMyCard;
- }
-
- return NULL;
+ {
+ TBool phoneMemory = EFalse;
+
+ TRAP_IGNORE( phoneMemory = IsPhoneMemoryUsedL() );
+
+ if( phoneMemory )
+ {
+ return iMyCard;
+ }
+
+ return NULL;
}
// --------------------------------------------------------------------------
@@ -758,6 +764,15 @@
if (iContainer)
{
CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
+ if( iMarkingModeOn )
+ {
+ // It will return the listbox by calling
+ // iControl->ComponentControl(0), which is defined
+ // in CPbk2NamesListControl::ComponentControl(TInt aIndex).
+ CCoeControl* ctrl=iControl->ComponentControl(0);
+ CEikListBox* listbox=static_cast <CEikListBox*> (ctrl);
+ listbox->SetMarkingMode(EFalse);
+ }
// Store current state, safe to ignore. There's no real harm,
// if theres no stored state when activating this view again
TRAP_IGNORE(StoreStateL());
@@ -790,17 +805,35 @@
//there.
switch (aResourceId)
{
+ case R_AVKON_MENUPANE_MARK_MULTIPLE:
+ {
+ TInt pos;
+ if ( aMenuPane->MenuItemExists( EAknCmdMarkingModeEnter, pos ) &&
+ iControl->NumberOfContacts() <= 0 )
+ {
+ aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue );
+ }
+ break;
+ }
case R_PHONEBOOK2_NAMESLIST_SEND_URL_MENU:
{
DimItem( aMenuPane, EPbk2CmdGoToURL );
+ if ( iControl->ContactsMarked() && iMarkingModeOn )
+ {
+ aMenuPane->SetItemDimmed( EPbk2CmdSend, EFalse );
+ }
break;
}
- case R_PHONEBOOK2_NAMELIST_CREATE_MESSAGE_MENU:
+ case R_PHONEBOOK2_NAMESLIST_COPY_MENU:
{
TInt pos;
- if ( aMenuPane->MenuItemExists( EPbk2CmdWriteNoQuery, pos ) )
+ if ( aMenuPane->MenuItemExists( EPbk2CmdCopy, pos ) && iMarkingModeOn
+ && iControl->NumberOfContacts() > 0 )
{
- aMenuPane->SetItemSpecific( EPbk2CmdWriteNoQuery, !iControl->ContactsMarked() );
+ // Show Copy item both in pop up menu and Options
+ // when Marking mode is active.
+ aMenuPane->SetItemSpecific( EPbk2CmdCopy, ETrue );
+ aMenuPane->SetItemDimmed( EPbk2CmdCopy, EFalse );
}
break;
}
@@ -900,14 +933,44 @@
}
case EKeyBackspace:
{
- if ( (itemSpecEnabled && (iControl->NumberOfContacts() > 0))
- || iControl->ContactsMarked() )
+ if ( itemSpecEnabled && ( iControl->FindTextL() == KNullDesC ) )
{
- if (iControl->FindTextL() == KNullDesC)
+ TBool contactsMarked( iControl->ContactsMarked() );
+
+ MPbk2UiControlCmdItem* cmdItem = const_cast<MPbk2UiControlCmdItem*> ( iControl->FocusedCommandItem() );
+
+ TBool onMyCard = cmdItem && ( EPbk2CmdOpenMyCard == cmdItem->CommandId() );
+
+ if ( !contactsMarked && onMyCard )
{
+ //Check to see whether the current focus is on MyCard or not
+ //When none of the contacts are marked and with focus on MyCard,
+ // pressing BackSpace/Del key leads to deletion of MyCard
+
+ // get extension point and my card link
+ TAny* object = cmdItem->ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) );
+ if( object )
+ {
+ MPbk2DoubleListboxCmdItemExtension* extension =
+ static_cast<MPbk2DoubleListboxCmdItemExtension*>( object );
+ // if extension exists
+ if( extension )
+ {
+ const MVPbkContactLink* link = extension->Link();
+ // if link exists, then MyCard has been Assigned
+ if( link )
+ {
+ HandleCommandL( EPbk2CmdDeleteMyCard );
+ result = ETrue;
+ }
+ }
+ }
+ }
+ else if( ( contactsMarked ) || (iControl->NumberOfContacts() > 0) )
+ {
HandleCommandL(EPbk2CmdDeleteMe);
result = ETrue;
- }
+ }
}
break;
}
@@ -916,18 +979,12 @@
case EKeyOK:
{
if ( !ShiftDown(aKeyEvent) ) // pure OK key
- {
- if ( iControl->ContactsMarked() && itemSpecEnabled )
- {
- iView.LaunchPopupMenuL(
- R_PHONEBOOK2_NAMESLIST_CONTEXT_MENUBAR_ITEMS_MARKED);
- result = ETrue;
- }
- else if ( iControl->NumberOfContacts() == 0 )
- {
- result = ETrue;
- }
- }
+ {
+ if ( iControl->ContactsMarked() && itemSpecEnabled )
+ {
+ result = EFalse;
+ }
+ }
break;
}
default:
@@ -958,11 +1015,11 @@
switch ( aEventType )
{
case EEventItemSingleClicked:
- {
+ {
ShowContextMenuL();
break;
}
-#if 0
+#if 0
case EEventEmptyAreaClicked: //An empty area of non-empty listbox was clicked
case EEventEmptyListClicked: //An empty listbox was clicked
{
@@ -995,11 +1052,6 @@
// Select key is mapped to "Open Contact" command
HandleCommandL(EPbk2CmdOpenCca);
}
- else if (iControl->ContactsMarked())
- {
- iView.LaunchPopupMenuL(
- R_PHONEBOOK2_NAMESLIST_CONTEXT_MENUBAR_ITEMS_MARKED);
- }
break;
}
default:
@@ -1082,13 +1134,7 @@
{
if ( iPointerEventInspector->FocusedItemPointed() )
{
- if ( iControl->ContactsMarked() )
- {
- // Display marked items context menu
- iView.LaunchPopupMenuL
- ( R_PHONEBOOK2_NAMESLIST_CONTEXT_MENUBAR_ITEMS_MARKED );
- }
- else
+ if ( !iControl->ContactsMarked() )
{
// cancel the long tap animation with pointer up event
TPointerEvent event;
@@ -1131,9 +1177,9 @@
{
MTouchFeedback* feedback = MTouchFeedback::Instance();
if ( feedback )
- {
- feedback->InstantFeedback( ETouchFeedbackBasic );
- }
+ {
+ feedback->InstantFeedback( ETouchFeedbackBasic );
+ }
HandleCommandL( EPbk2CmdCreateNew );
}
}
@@ -1243,22 +1289,22 @@
Reset();
if( iMyCard )
- {
- return;
- }
+ {
+ return;
+ }
if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) )
- {
- // Get the phoneStore for MyCard
- TRAP_IGNORE( phoneStore = iContactManager->ContactStoresL().
- Find( VPbkContactStoreUris::DefaultCntDbUri() ) );
- }
+ {
+ // Get the phoneStore for MyCard
+ TRAP_IGNORE( phoneStore = iContactManager->ContactStoresL().
+ Find( VPbkContactStoreUris::DefaultCntDbUri() ) );
+ }
if( !phoneStore )
- {
+ {
TRAP_IGNORE( iContactManager->LoadContactStoreL(
VPbkContactStoreUris::DefaultCntDbUri() ) );
- }
+ }
}
// --------------------------------------------------------------------------
@@ -1515,13 +1561,51 @@
}
}
+// -----------------------------------------------------------------------------
+// CPbk2NamesListExView::MarkingModeStatusChanged
+// -----------------------------------------------------------------------------
+//
+void CPbk2NamesListExView::MarkingModeStatusChanged( TBool aActivated )
+ {
+ iMarkingModeOn = aActivated;
+
+ // It will return the control findbox by calling
+ // iControl->ComponentControl(1), which is defined
+ // in CPbk2NamesListControl::ComponentControl(TInt aIndex).
+ if ( !iMarkingModeOn && iControl->ComponentControl(1)->IsVisible() )
+ {
+ // Clear the text of the FindBox, when canceling from Marking mode.
+ TRAP_IGNORE( iControl->ResetFindL() );
+ }
+ iControl->SetMarkingMode( aActivated );
+
+ // It will return the control listbox by calling
+ // iControl->ComponentControl(0), which is defined
+ // in CPbk2NamesListControl::ComponentControl(TInt aIndex).
+ CPbk2ContactViewListBox* listbox =
+ static_cast<CPbk2ContactViewListBox*>(iControl->ComponentControl(0));
+ listbox->SetMarkingModeState( aActivated );
+ }
+
+// -----------------------------------------------------------------------------
+// CPbk2NamesListExView::ExitMarkingMode
+// Called by avkon, if the return value is ETrue,
+// the Marking mode will be canceled after any operation,
+// otherwise the Marking mode keep active.
+// -----------------------------------------------------------------------------
+//
+TBool CPbk2NamesListExView::ExitMarkingMode() const
+ {
+ return EFalse;
+ }
+
//---------------------------------------------------------------------------
// CPbk2NamesListExView::CreateControlsL
// --------------------------------------------------------------------------
//
inline void CPbk2NamesListExView::CreateControlsL()
{
-
+
if (!iContainer)
{
PBK2_PROFILE_START(Pbk2Profile::ENamesListViewCreateControls);
@@ -1628,9 +1712,6 @@
{
// Set middle softkey as Context Icon
iView.Cba()->SetCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_EXIT_CONTEXT );
- // Change context menu when marked items
- iView.MenuBar()->SetContextMenuTitleResourceId
- ( R_PHONEBOOK2_NAMESLIST_CONTEXT_MENUBAR_ITEMS_MARKED );
}
else // not listContainsContacts && not contactsMarked
{
@@ -1856,25 +1937,25 @@
// --------------------------------------------------------------------------
//
TBool CPbk2NamesListExView::IsPhoneMemoryUsedL() const
- {
- CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL();
-
- // Get current configuration
- CPbk2StoreConfiguration& storeConfig = appServices->StoreConfiguration();
-
- CVPbkContactStoreUriArray* uriArray = storeConfig.CurrentConfigurationL();
-
- TVPbkContactStoreUriPtr contactUri( VPbkContactStoreUris::DefaultCntDbUri() );
-
- // Check is phone memory included
- TBool phoneMemory = uriArray->IsIncluded( contactUri );
-
- delete uriArray;
- Release( appServices );
-
- return phoneMemory;
- }
-
+ {
+ CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL();
+
+ // Get current configuration
+ CPbk2StoreConfiguration& storeConfig = appServices->StoreConfiguration();
+
+ CVPbkContactStoreUriArray* uriArray = storeConfig.CurrentConfigurationL();
+
+ TVPbkContactStoreUriPtr contactUri( VPbkContactStoreUris::DefaultCntDbUri() );
+
+ // Check is phone memory included
+ TBool phoneMemory = uriArray->IsIncluded( contactUri );
+
+ delete uriArray;
+ Release( appServices );
+
+ return phoneMemory;
+ }
+
// --------------------------------------------------------------------------
// CPbk2NamesListExView::HandleGainingForeground
// --------------------------------------------------------------------------