uifw/EikStd/coctlsrc/aknitemactionmenu.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 64 85902f042028
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    26 #include <eikpanic.h>
    26 #include <eikpanic.h>
    27 
    27 
    28 #include "akncollectionobserver.h"
    28 #include "akncollectionobserver.h"
    29 #include "aknitemactionmenudata.h"
    29 #include "aknitemactionmenudata.h"
    30 #include "aknitemactionmenuregister.h"
    30 #include "aknitemactionmenuregister.h"
       
    31 #include "akntrace.h"
       
    32 #include "aknmarkingmode.h"
    31 
    33 
    32 /**
    34 /**
    33  * Index for invalid list index.
    35  * Index for invalid list index.
    34  */
    36  */
    35 const TInt KInvalidListIndex( -1 );
    37 const TInt KInvalidListIndex( -1 );
    37 // ---------------------------------------------------------------------------
    39 // ---------------------------------------------------------------------------
    38 // CAknItemActionMenu::NewL
    40 // CAknItemActionMenu::NewL
    39 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    40 //
    42 //
    41 CAknItemActionMenu* CAknItemActionMenu::NewL(
    43 CAknItemActionMenu* CAknItemActionMenu::NewL(
    42         MAknCollection& aCollection )
    44         MAknCollection& aCollection, MObjectProvider* aOwner )
    43     {
    45     {
    44     CAknItemActionMenu* self = CAknItemActionMenu::NewLC( aCollection );
    46     _AKNTRACE_FUNC_ENTER;
       
    47     CAknItemActionMenu* self = CAknItemActionMenu::NewLC( 
       
    48             aCollection, aOwner );
    45     CleanupStack::Pop( self );
    49     CleanupStack::Pop( self );
       
    50     _AKNTRACE_FUNC_EXIT;
    46     return self;
    51     return self;
    47     }
    52     }
    48 
    53 
    49 
    54 
    50 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    51 // CAknItemActionMenu::NewLC
    56 // CAknItemActionMenu::NewLC
    52 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    53 //
    58 //
    54 CAknItemActionMenu* CAknItemActionMenu::NewLC( MAknCollection& aCollection )
    59 CAknItemActionMenu* CAknItemActionMenu::NewLC(
    55     {
    60         MAknCollection& aCollection, MObjectProvider* aOwner )
    56     CAknItemActionMenu* self = new ( ELeave ) CAknItemActionMenu();
    61     {
       
    62     _AKNTRACE_FUNC_ENTER;
       
    63     CAknItemActionMenu* self = new ( ELeave ) CAknItemActionMenu( aOwner );
    57     CleanupStack::PushL( self );
    64     CleanupStack::PushL( self );
    58     self->ConstructL( aCollection );
    65     self->ConstructL( aCollection );
       
    66     _AKNTRACE_FUNC_EXIT;
    59     return self;
    67     return self;
    60     }
    68     }
    61 
    69 
    62 
    70 
    63 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
    64 // CAknItemActionMenu::~CAknItemActionMenu
    72 // CAknItemActionMenu::~CAknItemActionMenu
    65 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    66 //
    74 //
    67 CAknItemActionMenu::~CAknItemActionMenu()
    75 CAknItemActionMenu::~CAknItemActionMenu()
    68     {
    76     {
       
    77     _AKNTRACE_FUNC_ENTER;
    69     AKNTASHOOK_REMOVE();
    78     AKNTASHOOK_REMOVE();
    70     delete iPopupMenu;
    79     delete iPopupMenu;
    71     delete iMenuPane;
    80     delete iMenuPane;
    72     delete iMenuData;
    81     delete iMenuData;
       
    82     delete iMarking;
    73     iStates.Close();
    83     iStates.Close();
       
    84     
       
    85     for ( TInt i = 0; i < iObservers.Count(); ++i )
       
    86         {
       
    87         iObservers[i]->SetItemActionMenu( NULL );
       
    88         }
       
    89 
    74     iObservers.Close();
    90     iObservers.Close();
       
    91     _AKNTRACE_FUNC_EXIT;
    75     }
    92     }
    76 
    93 
    77 
    94 
    78 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
    79 // CAknItemActionMenu::RegisterCollectionL
    96 // CAknItemActionMenu::RegisterCollectionL
    80 // ---------------------------------------------------------------------------
    97 // ---------------------------------------------------------------------------
    81 //
    98 //
    82 EXPORT_C CAknItemActionMenu* CAknItemActionMenu::RegisterCollectionL(
    99 EXPORT_C CAknItemActionMenu* CAknItemActionMenu::RegisterCollectionL(
    83         MAknCollection& aCollection )
   100         MAknCollection& aCollection )
    84     {
   101     {
    85     return AknItemActionMenuRegister::RegisterCollectionL( aCollection );
   102     _AKNTRACE_FUNC_ENTER;
       
   103     _AKNTRACE_FUNC_EXIT;
       
   104     return AknItemActionMenuRegister::RegisterCollectionL(
       
   105             aCollection, NULL );
       
   106     }
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CAknItemActionMenu::RegisterCollectionL
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 EXPORT_C CAknItemActionMenu* CAknItemActionMenu::RegisterCollectionL(
       
   114         MAknCollection& aCollection, MObjectProvider* aMenuBarOwner )
       
   115     {
       
   116     _AKNTRACE_FUNC_ENTER;
       
   117     _AKNTRACE_FUNC_EXIT;
       
   118     return AknItemActionMenuRegister::RegisterCollectionL( 
       
   119             aCollection, aMenuBarOwner );
    86     }
   120     }
    87 
   121 
    88 
   122 
    89 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
    90 // CAknItemActionMenu::RemoveCollection
   124 // CAknItemActionMenu::RemoveCollection
    91 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
    92 //
   126 //
    93 EXPORT_C void CAknItemActionMenu::RemoveCollection(
   127 EXPORT_C void CAknItemActionMenu::RemoveCollection(
    94         MAknCollection& aCollection )
   128         MAknCollection& aCollection )
    95     {
   129     {
       
   130     _AKNTRACE_FUNC_ENTER;
    96     for ( TInt i = 0; i < iStates.Count(); i++ )
   131     for ( TInt i = 0; i < iStates.Count(); i++ )
    97         {
   132         {
    98         MAknCollection* state( iStates[ i ] );
   133         MAknCollection* state( iStates[ i ] );
    99         if ( state == &aCollection )
   134         if ( state == &aCollection )
   100             {
   135             {
   101             iStates.Remove( i );
   136             iStates.Remove( i );
   102             break;
   137             break;
   103             }
   138             }
   104         }
   139         }
   105     UnregisterMenu(); 
   140     UnregisterMenu(); 
       
   141     _AKNTRACE_FUNC_EXIT;
   106     }
   142     }
   107 
   143 
   108 
   144 
   109 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
   110 // CAknItemActionMenu::InitMenuL
   146 // CAknItemActionMenu::InitMenuL
   111 // ---------------------------------------------------------------------------
   147 // ---------------------------------------------------------------------------
   112 //
   148 //
   113 EXPORT_C TBool CAknItemActionMenu::InitMenuL()
   149 EXPORT_C TBool CAknItemActionMenu::InitMenuL()
   114     {
   150     {
       
   151     _AKNTRACE_FUNC_ENTER;
   115     iMenuData->Reset();
   152     iMenuData->Reset();
   116     if ( !iMenuBar )
   153     if ( !iMenuBar )
   117         {
   154         {
   118         AknItemActionMenuRegister::RegisterItemActionMenuL( *this );
   155         AknItemActionMenuRegister::RegisterItemActionMenuL( *this );
   119         }
   156         }
   129     else
   166     else
   130         {
   167         {
   131         return EFalse;
   168         return EFalse;
   132         }
   169         }
   133 
   170 
       
   171     _AKNTRACE_FUNC_EXIT;
   134     return iMenuData->Count();
   172     return iMenuData->Count();
   135     }
   173     }
   136 
   174 
   137 
   175 
   138 // ---------------------------------------------------------------------------
   176 // ---------------------------------------------------------------------------
   141 //
   179 //
   142 EXPORT_C void CAknItemActionMenu::ShowMenuL(
   180 EXPORT_C void CAknItemActionMenu::ShowMenuL(
   143         const TPoint& aPosition,
   181         const TPoint& aPosition,
   144         TUint /*aFlags*/ )
   182         TUint /*aFlags*/ )
   145     {
   183     {
       
   184     _AKNTRACE_FUNC_ENTER;
   146     if ( iMenuData->Count() )
   185     if ( iMenuData->Count() )
   147         {
   186         {
   148         if ( !iPopupMenu )
   187         if ( !iPopupMenu )
   149             {
   188             {
   150             iPopupMenu = CAknStylusPopUpMenu::NewL( this, TPoint() );
   189             iPopupMenu = CAknStylusPopUpMenu::NewL( this, TPoint(), NULL,
       
   190                     CAknStylusPopUpMenu::EConsumeKeyEvents );
   151             }
   191             }
   152         iPopupMenu->Clear();
   192         iPopupMenu->Clear();
   153         iMenuData->AddMenuItemsToStylusPopupMenuL( iPopupMenu );
   193         iMenuData->AddMenuItemsToStylusPopupMenuL( iPopupMenu );
   154         iPopupMenu->SetPosition(
   194         iPopupMenu->SetPosition(
   155                 aPosition,
   195                 aPosition,
   156                 CAknStylusPopUpMenu::EPositionTypeRightBottom );
   196                 CAknStylusPopUpMenu::EPositionTypeRightBottom );
   157         iPopupMenu->ShowMenu();
   197         iPopupMenu->ShowMenu();
   158         }
   198         }
       
   199     _AKNTRACE_FUNC_EXIT;
   159     }
   200     }
   160 
   201 
   161 
   202 
   162 // ---------------------------------------------------------------------------
   203 // ---------------------------------------------------------------------------
   163 // CAknItemActionMenu::CollectionChanged
   204 // CAknItemActionMenu::CollectionChanged
   164 // ---------------------------------------------------------------------------
   205 // ---------------------------------------------------------------------------
   165 //
   206 //
   166 EXPORT_C void CAknItemActionMenu::CollectionChanged(
   207 EXPORT_C void CAknItemActionMenu::CollectionChanged(
   167         MAknCollection& aCollection )
   208         MAknCollection& aCollection )
   168     {
   209     {
       
   210     _AKNTRACE_FUNC_ENTER;
   169     if ( iObservers.Count() && iStates.Find( &aCollection ) != KErrNotFound )
   211     if ( iObservers.Count() && iStates.Find( &aCollection ) != KErrNotFound )
   170         {
   212         {
   171         TBool collectionVisible( aCollection.CollectionState()
   213         TBool collectionVisible( aCollection.CollectionState()
   172                 & MAknCollection::EStateCollectionVisible );
   214                 & MAknCollection::EStateCollectionVisible );
   173         NotifyChangeToActiveObserver( collectionVisible );
   215         NotifyChangeToActiveObserver( collectionVisible );
   174         }
   216         }
       
   217     _AKNTRACE_FUNC_EXIT;
   175     }
   218     }
   176 
   219 
   177 
   220 
   178 // ---------------------------------------------------------------------------
   221 // ---------------------------------------------------------------------------
   179 // CAknItemActionMenu::AddCollectionStateL
   222 // CAknItemActionMenu::AddCollectionStateL
   180 // ---------------------------------------------------------------------------
   223 // ---------------------------------------------------------------------------
   181 //
   224 //
   182 void CAknItemActionMenu::AddCollectionStateL(
   225 void CAknItemActionMenu::AddCollectionStateL(
   183         MAknCollection& aCollection )
   226         MAknCollection& aCollection )
   184     {
   227     {
       
   228     _AKNTRACE_FUNC_ENTER;
   185     if ( iStates.Find( &aCollection ) == KErrNotFound )
   229     if ( iStates.Find( &aCollection ) == KErrNotFound )
   186         {
   230         {
   187         iStates.InsertL( &aCollection, 0 );
   231         iStates.InsertL( &aCollection, 0 );
   188         }
   232         }
       
   233     _AKNTRACE_FUNC_EXIT;
   189     }
   234     }
   190 
   235 
   191 
   236 
   192 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   193 // CAknItemActionMenu::SetMenuBar
   238 // CAknItemActionMenu::SetMenuBar
   195 //
   240 //
   196 void CAknItemActionMenu::SetMenuBar(
   241 void CAknItemActionMenu::SetMenuBar(
   197         MEikMenuObserver* aMenuObserver,
   242         MEikMenuObserver* aMenuObserver,
   198         CEikMenuBar* aMenuBar )
   243         CEikMenuBar* aMenuBar )
   199     {
   244     {
       
   245     _AKNTRACE_FUNC_ENTER;
   200     iMenuBarObserver = aMenuObserver;
   246     iMenuBarObserver = aMenuObserver;
   201     iMenuBar = aMenuBar;
   247     iMenuBar = aMenuBar;
       
   248     _AKNTRACE_FUNC_EXIT;
   202     }
   249     }
   203 
   250 
   204 
   251 
   205 // ---------------------------------------------------------------------------
   252 // ---------------------------------------------------------------------------
   206 // CAknItemActionMenu::CollectionHighlightVisible
   253 // CAknItemActionMenu::CollectionHighlightVisible
   207 // ---------------------------------------------------------------------------
   254 // ---------------------------------------------------------------------------
   208 //
   255 //
   209 TBool CAknItemActionMenu::CollectionHighlightVisible() const
   256 TBool CAknItemActionMenu::CollectionHighlightVisible() const
   210     {
   257     {
       
   258     _AKNTRACE_FUNC_ENTER;
   211     TBool highlightVisible( ETrue );
   259     TBool highlightVisible( ETrue );
   212     for ( TInt i = 0; i < iStates.Count(); i++ )
   260     for ( TInt i = 0; i < iStates.Count(); i++ )
   213         {
   261         {
   214         MAknCollection* state( iStates[ i ] );
   262         MAknCollection* collection( iStates[ i ] );
   215         if ( state->CollectionState() &
   263         TUint state = collection->CollectionState();
   216                 MAknCollection::EStateCollectionVisible )
   264 
   217             {
   265         highlightVisible = state & MAknCollection::EStateHighlightVisible;
   218             highlightVisible = state->CollectionState()
   266         
   219                 & MAknCollection::EStateHighlightVisible;
   267         if ( highlightVisible )
       
   268             {
       
   269             // Highlight can't be visible if the collection is not visible.
       
   270             highlightVisible = state & MAknCollection::EStateCollectionVisible;
   220             break;
   271             break;
   221             }
   272             }
   222         }
   273         }
       
   274     _AKNTRACE_FUNC_EXIT;
   223     return highlightVisible;
   275     return highlightVisible;
   224     }
   276     }
   225 
   277 
   226 
   278 
   227 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   230 //
   282 //
   231 TBool CAknItemActionMenu::CollectionSoftkeyVisible(
   283 TBool CAknItemActionMenu::CollectionSoftkeyVisible(
   232         TBool aVisibleCollection ) const
   284         TBool aVisibleCollection ) const
   233     {
   285     {
       
   286     _AKNTRACE_FUNC_ENTER;
   234     TBool softkeyVisible( ETrue );
   287     TBool softkeyVisible( ETrue );
   235     for ( TInt i = 0; i < iStates.Count(); i++ )
   288     for ( TInt i = 0; i < iStates.Count(); i++ )
   236         {
   289         {
   237         TInt state( iStates[ i ]->CollectionState() );
   290         TInt state( iStates[ i ]->CollectionState() );
   238         if ( !aVisibleCollection
   291         if ( !aVisibleCollection
   249                     state & MAknCollection::EStateHighlightVisible;
   302                     state & MAknCollection::EStateHighlightVisible;
   250                 }
   303                 }
   251             break;
   304             break;
   252             }
   305             }
   253         }
   306         }
       
   307     _AKNTRACE_FUNC_EXIT;
   254     return softkeyVisible;
   308     return softkeyVisible;
   255     }
   309     }
   256 
   310 
   257 
   311 
   258 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   259 // CAknItemActionMenu::MenuData
   313 // CAknItemActionMenu::MenuData
   260 // ---------------------------------------------------------------------------
   314 // ---------------------------------------------------------------------------
   261 //
   315 //
   262 CAknItemActionMenuData& CAknItemActionMenu::MenuData()
   316 CAknItemActionMenuData& CAknItemActionMenu::MenuData()
   263     {
   317     {
       
   318     _AKNTRACE_FUNC_ENTER;
       
   319     _AKNTRACE_FUNC_EXIT;
   264     return *iMenuData;
   320     return *iMenuData;
   265     }
   321     }
   266 
   322 
   267 
   323 
   268 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   270 // ---------------------------------------------------------------------------
   326 // ---------------------------------------------------------------------------
   271 //
   327 //
   272 void CAknItemActionMenu::RegisterCollectionObserverL(
   328 void CAknItemActionMenu::RegisterCollectionObserverL(
   273         MAknCollectionObserver& aObserver )
   329         MAknCollectionObserver& aObserver )
   274     {
   330     {
       
   331     _AKNTRACE_FUNC_ENTER;
   275     if ( iObservers.Find( &aObserver ) == KErrNotFound )
   332     if ( iObservers.Find( &aObserver ) == KErrNotFound )
   276         {
   333         {
   277         iObservers.InsertL( &aObserver, 0 );
   334         iObservers.InsertL( &aObserver, 0 );
   278         aObserver.SetItemActionMenu( this );
   335         aObserver.SetItemActionMenu( this );
   279         }
   336         }
       
   337     _AKNTRACE_FUNC_EXIT;
   280     }
   338     }
   281 
   339 
   282 
   340 
   283 // ---------------------------------------------------------------------------
   341 // ---------------------------------------------------------------------------
   284 // CAknItemActionMenu::RemoveCollectionObserver
   342 // CAknItemActionMenu::RemoveCollectionObserver
   285 // ---------------------------------------------------------------------------
   343 // ---------------------------------------------------------------------------
   286 //
   344 //
   287 void CAknItemActionMenu::RemoveCollectionObserver(
   345 void CAknItemActionMenu::RemoveCollectionObserver(
   288         MAknCollectionObserver& aObserver )
   346         MAknCollectionObserver& aObserver )
   289     {
   347     {
       
   348     _AKNTRACE_FUNC_ENTER;
   290     TInt index( iObservers.Find( &aObserver ) );
   349     TInt index( iObservers.Find( &aObserver ) );
   291     if ( index != KErrNotFound )
   350     if ( index != KErrNotFound )
   292         {
   351         {
   293         iObservers.Remove( index );
   352         iObservers.Remove( index );
   294         UnregisterMenu(); 
   353         UnregisterMenu(); 
   295         }
   354         }
       
   355     _AKNTRACE_FUNC_EXIT;
   296     }
   356     }
   297 
   357 
   298 
   358 
   299 // ---------------------------------------------------------------------------
   359 // ---------------------------------------------------------------------------
   300 // CAknItemActionMenu::CollectionCount
   360 // CAknItemActionMenu::CollectionCount
   301 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   302 //
   362 //
   303 TInt CAknItemActionMenu::CollectionCount() const
   363 TInt CAknItemActionMenu::CollectionCount() const
   304     {
   364     {
       
   365     _AKNTRACE_FUNC_ENTER;
       
   366     _AKNTRACE_FUNC_EXIT;
   305     return iStates.Count();
   367     return iStates.Count();
   306     }
   368     }
   307 
   369 
   308 
   370 
   309 // ---------------------------------------------------------------------------
   371 // ---------------------------------------------------------------------------
       
   372 // CAknItemActionMenu::Owner
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375  MObjectProvider* CAknItemActionMenu::Owner() const
       
   376      {
       
   377     _AKNTRACE_FUNC_ENTER;
       
   378     _AKNTRACE_FUNC_EXIT;
       
   379      return iOwner;
       
   380      }
       
   381 
       
   382 
       
   383 // ---------------------------------------------------------------------------
       
   384 // CAknItemActionMenu::MarkingMode
       
   385 // ---------------------------------------------------------------------------
       
   386 //
       
   387 CAknMarkingMode& CAknItemActionMenu::MarkingMode()
       
   388     {
       
   389     _AKNTRACE_FUNC_ENTER;
       
   390     _AKNTRACE_FUNC_EXIT;
       
   391     return *iMarking;
       
   392     }
       
   393 
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // CAknItemActionMenu::CollectionHasMarkedItems
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 TBool CAknItemActionMenu::CollectionHasMarkedItems()
       
   400     {
       
   401     _AKNTRACE_FUNC_ENTER;
       
   402     TBool markedItems( EFalse );
       
   403     for ( TInt i = 0; i < iStates.Count(); i++ )
       
   404         {
       
   405         TInt state( iStates[ i ]->CollectionState() );
       
   406         if ( state & MAknCollection::EStateCollectionVisible )
       
   407             {
       
   408             if ( state & MAknCollection::EStateMarkedItems )
       
   409                 {
       
   410                 markedItems = ETrue;
       
   411                 }
       
   412             }
       
   413         }
       
   414     _AKNTRACE_FUNC_EXIT;
       
   415     return markedItems;
       
   416     }
       
   417 
       
   418 
       
   419 // ---------------------------------------------------------------------------
       
   420 // CAknItemActionMenu::HideMenu
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CAknItemActionMenu::HideMenu()
       
   424     {
       
   425     if ( iPopupMenu && !iProcessingCommand )
       
   426         {
       
   427         iPopupMenu->HideMenu();
       
   428         }
       
   429     }
       
   430 
       
   431 
       
   432 // ---------------------------------------------------------------------------
   310 // CAknItemActionMenu::CAknItemActionMenu
   433 // CAknItemActionMenu::CAknItemActionMenu
   311 // ---------------------------------------------------------------------------
   434 // ---------------------------------------------------------------------------
   312 //
   435 //
   313 CAknItemActionMenu::CAknItemActionMenu()
   436 CAknItemActionMenu::CAknItemActionMenu( MObjectProvider* aOwner )
   314     : iPopupMenu( NULL ),
   437     : iPopupMenu( NULL ),
   315     iMenuBarObserver( NULL ),
   438     iMenuBarObserver( NULL ),
   316     iMenuBar( NULL ),
   439     iMenuBar( NULL ),
   317     iMenuPane( NULL ),
   440     iMenuPane( NULL ),
   318     iMenuData( NULL )
   441     iMenuData( NULL ),
   319     {
   442     iOwner( aOwner ),
       
   443     iMarking( NULL )
       
   444     {
       
   445     _AKNTRACE_FUNC_ENTER;
   320     AKNTASHOOK_ADD( this, "CAknItemActionMenu" );
   446     AKNTASHOOK_ADD( this, "CAknItemActionMenu" );
       
   447     _AKNTRACE_FUNC_EXIT;
   321     }
   448     }
   322 
   449 
   323 
   450 
   324 // ---------------------------------------------------------------------------
   451 // ---------------------------------------------------------------------------
   325 // CAknItemActionMenu::ConstructL
   452 // CAknItemActionMenu::ConstructL
   326 // ---------------------------------------------------------------------------
   453 // ---------------------------------------------------------------------------
   327 //
   454 //
   328 void CAknItemActionMenu::ConstructL( MAknCollection& aCollection )
   455 void CAknItemActionMenu::ConstructL( MAknCollection& aCollection )
   329     {
   456     {
       
   457     _AKNTRACE_FUNC_ENTER;
   330     AddCollectionStateL( aCollection );
   458     AddCollectionStateL( aCollection );
   331     iMenuData = CAknItemActionMenuData::NewL();
   459     iMenuData = CAknItemActionMenuData::NewL();
       
   460     iMarking = CAknMarkingMode::NewL( *this, iStates );
       
   461     _AKNTRACE_FUNC_EXIT;
   332     }
   462     }
   333 
   463 
   334 
   464 
   335 // ---------------------------------------------------------------------------
   465 // ---------------------------------------------------------------------------
   336 // CAknItemActionMenu::LaunchSubMenuQueryL
   466 // CAknItemActionMenu::LaunchSubMenuQueryL
   337 // ---------------------------------------------------------------------------
   467 // ---------------------------------------------------------------------------
   338 //
   468 //
   339 TInt CAknItemActionMenu::LaunchSubMenuQueryL( const TDesC& aHeading )
   469 TInt CAknItemActionMenu::LaunchSubMenuQueryL( const TDesC& aHeading )
   340     {
   470     {
       
   471     _AKNTRACE_FUNC_ENTER;
   341     TInt selectedIndex( KInvalidListIndex );
   472     TInt selectedIndex( KInvalidListIndex );
   342     if ( iMenuData->Count() )
   473     if ( iMenuData->Count() )
   343         {
   474         {
   344         CAknListQueryDialog* queryDialog
   475         CAknListQueryDialog* queryDialog
   345             = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
   476             = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
   351             {
   482             {
   352             queryDialog->QueryHeading()->SetTextL( aHeading );
   483             queryDialog->QueryHeading()->SetTextL( aHeading );
   353             }
   484             }
   354         queryDialog->RunLD();
   485         queryDialog->RunLD();
   355         }
   486         }
       
   487     _AKNTRACE_FUNC_EXIT;
   356     return ++selectedIndex;
   488     return ++selectedIndex;
   357     }
   489     }
   358 
   490 
   359 
   491 
   360 // ---------------------------------------------------------------------------
   492 // ---------------------------------------------------------------------------
   362 // ---------------------------------------------------------------------------
   494 // ---------------------------------------------------------------------------
   363 //
   495 //
   364 void CAknItemActionMenu::NotifyChangeToActiveObserver(
   496 void CAknItemActionMenu::NotifyChangeToActiveObserver(
   365         TBool aCollectionVisible )
   497         TBool aCollectionVisible )
   366     {
   498     {
       
   499     _AKNTRACE_FUNC_ENTER;
   367     for ( TInt i = 0; i < iObservers.Count(); i++ )
   500     for ( TInt i = 0; i < iObservers.Count(); i++ )
   368         {
   501         {
   369         MAknCollectionObserver* observer( iObservers[ i ] );
   502         MAknCollectionObserver* observer( iObservers[ i ] );
   370         if ( observer->Active() )
   503         if ( observer->Active() )
   371             {
   504             {
   372             observer->CollectionChanged( aCollectionVisible );
   505             observer->CollectionChanged( aCollectionVisible );
   373             break;
   506             break;
   374             }
   507             }
   375         }
   508         }
       
   509     _AKNTRACE_FUNC_EXIT;
   376     }
   510     }
   377 
   511 
   378 
   512 
   379 // ---------------------------------------------------------------------------
   513 // ---------------------------------------------------------------------------
   380 // CAknItemActionMenu::SetEmphasis
   514 // CAknItemActionMenu::SetEmphasis
   382 //
   516 //
   383 void CAknItemActionMenu::SetEmphasis(
   517 void CAknItemActionMenu::SetEmphasis(
   384         CCoeControl* /*aMenuControl*/,
   518         CCoeControl* /*aMenuControl*/,
   385         TBool /*aEmphasis*/ )
   519         TBool /*aEmphasis*/ )
   386     {
   520     {
       
   521     _AKNTRACE_FUNC_ENTER;
       
   522     _AKNTRACE_FUNC_EXIT;
   387     }
   523     }
   388 
   524 
   389 
   525 
   390 // ---------------------------------------------------------------------------
   526 // ---------------------------------------------------------------------------
   391 // CAknItemActionMenu::ProcessCommandL
   527 // CAknItemActionMenu::ProcessCommandL
   392 // ---------------------------------------------------------------------------
   528 // ---------------------------------------------------------------------------
   393 //
   529 //
   394 void CAknItemActionMenu::ProcessCommandL( TInt aCommandId )
   530 void CAknItemActionMenu::ProcessCommandL( TInt aCommandId )
   395     {
   531     {
       
   532     _AKNTRACE_FUNC_ENTER;
   396     MAknCollection* informState ( NULL );
   533     MAknCollection* informState ( NULL );
   397     // Store collection state before sending the command
   534     // Store collection state before sending the command
   398     for ( TInt i = 0; i < iStates.Count(); i++ )
   535     for ( TInt i = 0; i < iStates.Count(); i++ )
   399         {
   536         {
   400         MAknCollection* state( iStates[ i ] );
   537         MAknCollection* state( iStates[ i ] );
   411         TInt cascadeId( iMenuData->MenuItemCascadeId( aCommandId ) );
   548         TInt cascadeId( iMenuData->MenuItemCascadeId( aCommandId ) );
   412         if ( cascadeId && iMenuPane )
   549         if ( cascadeId && iMenuPane )
   413             {
   550             {
   414             TMenuItemTextBuf text = iMenuData->MenuItemText( aCommandId );
   551             TMenuItemTextBuf text = iMenuData->MenuItemText( aCommandId );
   415             iMenuData->Reset();
   552             iMenuData->Reset();
   416             iMenuPane->AddCascadeMenuItemsToActionMenuL(
   553             iMenuPane->AddCascadeMenuItemsToMenuL(
   417                     cascadeId, EFalse, *iMenuData );
   554                     cascadeId, EFalse, ETrue, iMenuData );
   418             aCommandId = LaunchSubMenuQueryL( text );
   555             aCommandId = LaunchSubMenuQueryL( text );
   419             }
   556             }
   420                 
   557                 
   421         if ( aCommandId > 0 && iMenuBarObserver )
   558         if ( aCommandId > 0 && iMenuData->MenuItemCommandId( aCommandId ) 
       
   559                 == EAknCmdMarkingModeMarkOne && iMenuBar )
       
   560             {
       
   561             MarkingMode().MarkCurrentItemL();
       
   562             }
       
   563         else if ( aCommandId > 0 && iMenuBarObserver )
   422             {
   564             {
   423             iProcessingCommand = ETrue; 
   565             iProcessingCommand = ETrue; 
   424             iMenuBarObserver->ProcessCommandL(
   566             iMenuBarObserver->ProcessCommandL(
   425                     iMenuData->MenuItemCommandId( aCommandId ) );
   567                     iMenuData->MenuItemCommandId( aCommandId ) );
   426             iProcessingCommand = EFalse; 
   568             iProcessingCommand = EFalse; 
       
   569             // Try exit marking mode
       
   570             MarkingMode().TryExitMarkingMode();
   427             }
   571             }
   428         }
   572         }
   429     // Inform collection that submenu was closed
   573     // Inform collection that submenu was closed
   430     if ( iStates.Find( informState ) != KErrNotFound ) 
   574     if ( informState && iStates.Find( informState ) != KErrNotFound ) 
   431         {
   575         {
   432         informState->ItemActionMenuClosed();
   576         informState->ItemActionMenuClosed();
   433         }
   577         }
   434     UnregisterMenu(); 
   578     UnregisterMenu(); 
       
   579     _AKNTRACE_FUNC_EXIT;
   435     }
   580     }
   436 
   581 
   437 
   582 
   438 // ---------------------------------------------------------------------------
   583 // ---------------------------------------------------------------------------
   439 // CAknItemActionMenu::UnregisterMenu
   584 // CAknItemActionMenu::UnregisterMenu
   440 // ---------------------------------------------------------------------------
   585 // ---------------------------------------------------------------------------
   441 //
   586 //
   442 void CAknItemActionMenu::UnregisterMenu()
   587 void CAknItemActionMenu::UnregisterMenu()
   443     {
   588     {
       
   589     _AKNTRACE_FUNC_ENTER;
   444     if ( !iProcessingCommand && !iStates.Count() && !iObservers.Count() )
   590     if ( !iProcessingCommand && !iStates.Count() && !iObservers.Count() )
   445         {
   591         {
   446         delete iPopupMenu;
   592         delete iPopupMenu;
   447         iPopupMenu = NULL;
   593         iPopupMenu = NULL;
   448         delete iMenuPane;
   594         delete iMenuPane;
   449         iMenuPane = NULL;
   595         iMenuPane = NULL;
   450         AknItemActionMenuRegister::UnregisterItemActionMenu( *this );
   596         AknItemActionMenuRegister::UnregisterItemActionMenu( *this );
   451         }
   597         }
       
   598     _AKNTRACE_FUNC_EXIT;
   452     }
   599     }
   453 
   600 
   454 // End of File
   601 // End of File
       
   602