--- a/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListEmptyState.cpp Thu Jul 15 18:22:55 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListEmptyState.cpp Thu Aug 19 09:41:07 2010 +0300
@@ -41,6 +41,10 @@
// Debugging headers
#include <Pbk2Debug.h>
+#include <aknnavi.h>
+#include <aknnavide.h>
+#include <aknnavilabel.h>
+
/// Unnamed namespace for local definitions
namespace {
@@ -124,12 +128,35 @@
//
void CPbk2NamesListEmptyState::ActivateStateL()
{
- AllowCommandsToShowThemselves( ETrue );
-
- // hide findbox since there is no contact
+ AllowCommandsToShowThemselves( ETrue );
+ CPbk2NamesListControl& namesListControl =
+ reinterpret_cast<CPbk2NamesListControl&>(CoeControl());
+ if( namesListControl.GetMarkingMode() )
+ {
+ // If NamesListEmptyState and Marking mode are both active,
+ // the Marking mode should be canceled.
+ iListBox.SetMarkingMode(EFalse);
+ CEikonEnv* eikonEnv = CEikonEnv::Static();
+ if ( eikonEnv && eikonEnv->AppUiFactory() )
+ {
+ CEikStatusPane* statusPane = eikonEnv->AppUiFactory()->StatusPane();
+ if ( statusPane )
+ {
+
+ CAknNavigationControlContainer* naviPane =
+ (CAknNavigationControlContainer *)statusPane->ControlL(
+ TUid::Uid(EEikStatusPaneUidNavi));
+ CAknNavigationDecorator* decorator = naviPane->Top();
+ naviPane->Pop( decorator );
+ naviPane->DrawDeferred();
+ }
+ }
+ }
+
+ // hide findbox since there is no contact
if ( iFindBox && iFindBox->IsVisible() )
{
- iFindBox->MakeVisible( EFalse );
+ iFindBox->MakeVisible( EFalse );
}
}
@@ -140,8 +167,8 @@
//
void CPbk2NamesListEmptyState::DeactivateState()
{
- AllowCommandsToShowThemselves( EFalse );
-
+ AllowCommandsToShowThemselves( EFalse );
+
if ( iFindBox && !iFindBox->IsFocused() )
{
iFindBox->SetFocus( ETrue );
@@ -297,7 +324,7 @@
//
void CPbk2NamesListEmptyState::HandleListboxEventL
(TInt aEvent, TInt aListboxIndex,
- TBool /*aMantainFocus*/)
+ TBool /*aMantainFocus*/)
{
iListBox.HandleEventL( aEvent, aListboxIndex );
iParent.DrawDeferred();
@@ -349,9 +376,9 @@
// The listbox can also have command items.
TInt result = iListBox.NumberOfItems() - CommandItemCount();
if ( result < 0 )
- {
- result = KNumberOfContacts; // No contacts
- }
+ {
+ result = KNumberOfContacts; // No contacts
+ }
return result;
}
@@ -491,53 +518,53 @@
MVPbkContactLinkArray*
CPbk2NamesListEmptyState::SelectedContactsOrFocusedContactL() const
{
- CVPbkContactLinkArray* array = NULL;
- // my card is showing on empty list, check if the wanted contact is it
- TInt currentItem = iListBox.CurrentItemIndex();
- // if focused index is command item
- if( currentItem < CommandItemCount() )
- {
- // check if the command is my card ( this search is copied from CommandItemAt - function to avoid const cast)
- // Some of the commands might be disabled. Skip those.
- TInt enabledCount = 0;
- TInt indexOfResult = KErrNotFound;
- for ( TInt n = 0; n < iCommandItems.Count() && indexOfResult == KErrNotFound; ++n )
- {
- if ( iCommandItems[ n ]->IsEnabled() )
- {
- enabledCount++;
- if ( enabledCount-1 == currentItem )
- {
- indexOfResult = n;
- }
- }
- }
- MPbk2UiControlCmdItem* item = iCommandItems[ indexOfResult ];
- // check if the command item was a my card
- if( item->CommandId() == EPbk2CmdOpenMyCard )
- {
- // get extension point and my card link
- TAny* object = item->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, add it to the array
- if( link )
- {
- array = CVPbkContactLinkArray::NewLC();
- array->AppendL( link->CloneLC() );
- CleanupStack::Pop( 2 ); // array, link
- }
- }
- }
- }
- }
- return array;
+ CVPbkContactLinkArray* array = NULL;
+ // my card is showing on empty list, check if the wanted contact is it
+ TInt currentItem = iListBox.CurrentItemIndex();
+ // if focused index is command item
+ if( currentItem < CommandItemCount() )
+ {
+ // check if the command is my card ( this search is copied from CommandItemAt - function to avoid const cast)
+ // Some of the commands might be disabled. Skip those.
+ TInt enabledCount = 0;
+ TInt indexOfResult = KErrNotFound;
+ for ( TInt n = 0; n < iCommandItems.Count() && indexOfResult == KErrNotFound; ++n )
+ {
+ if ( iCommandItems[ n ]->IsEnabled() )
+ {
+ enabledCount++;
+ if ( enabledCount-1 == currentItem )
+ {
+ indexOfResult = n;
+ }
+ }
+ }
+ MPbk2UiControlCmdItem* item = iCommandItems[ indexOfResult ];
+ // check if the command item was a my card
+ if( item->CommandId() == EPbk2CmdOpenMyCard )
+ {
+ // get extension point and my card link
+ TAny* object = item->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, add it to the array
+ if( link )
+ {
+ array = CVPbkContactLinkArray::NewLC();
+ array->AppendL( link->CloneLC() );
+ CleanupStack::Pop( 2 ); // array, link
+ }
+ }
+ }
+ }
+ }
+ return array;
}
// --------------------------------------------------------------------------
@@ -607,17 +634,17 @@
// --------------------------------------------------------------------------
//
TInt CPbk2NamesListEmptyState::CommandItemCount() const
- {
+ {
// Some of the commands might be disabled. Don't count those.
- TInt enabledCommandCount = 0;
- for ( TInt n = 0; n < iCommandItems.Count(); ++n )
- {
- if ( iCommandItems[ n ]->IsEnabled() )
- {
- enabledCommandCount++;
- }
- }
- return enabledCommandCount;
+ TInt enabledCommandCount = 0;
+ for ( TInt n = 0; n < iCommandItems.Count(); ++n )
+ {
+ if ( iCommandItems[ n ]->IsEnabled() )
+ {
+ enabledCommandCount++;
+ }
+ }
+ return enabledCommandCount;
}
// --------------------------------------------------------------------------
@@ -626,24 +653,24 @@
//
const MPbk2UiControlCmdItem&
CPbk2NamesListEmptyState::CommandItemAt( TInt aIndex ) const
- {
+ {
// Some of the commands might be disabled. Skip those.
- TInt enabledCount = 0;
- TInt indexOfResult = KErrNotFound;
- for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n )
-
- {
- if ( iCommandItems[ n ]->IsEnabled() )
- {
- enabledCount++;
- if ( enabledCount-1 == aIndex )
- {
- indexOfResult = n;
- }
- }
- }
- return *iCommandItems[ indexOfResult ];
- }
+ TInt enabledCount = 0;
+ TInt indexOfResult = KErrNotFound;
+ for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n )
+
+ {
+ if ( iCommandItems[ n ]->IsEnabled() )
+ {
+ enabledCount++;
+ if ( enabledCount-1 == aIndex )
+ {
+ indexOfResult = n;
+ }
+ }
+ }
+ return *iCommandItems[ indexOfResult ];
+ }
// --------------------------------------------------------------------------
// CPbk2NamesListEmptyState::FocusedCommandItem
@@ -651,9 +678,9 @@
//
const MPbk2UiControlCmdItem*
CPbk2NamesListEmptyState::FocusedCommandItem() const
- {
- const MPbk2UiControlCmdItem* cmdItem = NULL;
- // Is the focus on a command item:
+ {
+ const MPbk2UiControlCmdItem* cmdItem = NULL;
+ // Is the focus on a command item:
TInt focusListIndex = iListBox.CurrentItemIndex();
const TInt commandItemCount = CommandItemCount();
if ( focusListIndex != KErrNotFound && focusListIndex < commandItemCount )
@@ -661,7 +688,7 @@
// Yes it's a command item.
cmdItem = &CommandItemAt(focusListIndex);
}
- return cmdItem;
+ return cmdItem;
}
// --------------------------------------------------------------------------
@@ -669,7 +696,7 @@
// --------------------------------------------------------------------------
//
void CPbk2NamesListEmptyState::DeleteCommandItemL( TInt /*aIndex*/ )
- {
+ {
// ownership & management of iCommandItems is wasted in names list
// control. Do nothing here
}
@@ -682,7 +709,7 @@
{
// ownership & management of iCommandItems is wasted in names list
// control. Do nothing here
- }
+ }
// --------------------------------------------------------------------------
// CPbk2NamesListEmptyState::DynInitMenuPaneL
@@ -698,13 +725,9 @@
TInt pos; // Stores the position of the searched menu item.
// This position is not needed or used anywhere
- if (aMenuPane->MenuItemExists(EAknUnmarkAll, pos))
+ if ( aMenuPane->MenuItemExists ( EAknCmdMarkingModeEnter, pos ) )
{
- aMenuPane->SetItemDimmed(EAknUnmarkAll, ETrue);
- }
- if (aMenuPane->MenuItemExists(EAknMarkAll, pos))
- {
- aMenuPane->SetItemDimmed(EAknMarkAll, ETrue);
+ aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue );
}
}
@@ -944,9 +967,9 @@
// ownership not transferred
iListBox.SetListCommands( &iCommandItems );
SubscribeCmdItemsVisibility();
- UpdateCommandEnabled( EPbk2CmdRcl, ETrue );
+ UpdateCommandEnabled( EPbk2CmdRcl, ETrue );
UpdateCommandEnabled( EPbk2CmdAddFavourites, EFalse );
- //MyCard is stored separately and may also contain data
+ //MyCard is stored separately and may also contain data
UpdateCommandEnabled( EPbk2CmdOpenMyCard, ETrue );
}
else
@@ -962,9 +985,20 @@
void CPbk2NamesListEmptyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible )
{
TInt cmdItemIndex = FindCommand(aCmdItemId);
- TRAP_IGNORE( HandleCommandEventL(
+ TRAP_IGNORE(
+ // If command item is changed to be visible, set its hidden selection to ETrue.
+ if( aVisible )
+ {
+ TInt enableCmdCount = EnabledCommandCount();
+ TListItemProperties prop( iListBox.ItemDrawer()->Properties(enableCmdCount) );
+ prop.SetHiddenSelection(aVisible);
+ iListBox.ItemDrawer()->SetPropertiesL(enableCmdCount-1, prop);
+ }
+
+ HandleCommandEventL(
(aVisible ? EItemAdded : EItemRemoved),
- cmdItemIndex) );
+ cmdItemIndex);
+ );
}
// --------------------------------------------------------------------------
@@ -1049,4 +1083,21 @@
}
}
+// --------------------------------------------------------------------------
+// CPbk2NamesListEmptyState::EnabledCommandCount
+// --------------------------------------------------------------------------
+//
+TInt CPbk2NamesListEmptyState::EnabledCommandCount() const
+ {
+ TInt result = 0;
+ for ( TInt i = 0; i < iCommandItems.Count(); ++i )
+ {
+ if(iCommandItems[i]->IsEnabled())
+ {
+ result++;
+ }
+ }
+ return result;
+ }
+
// End of File