menufw/menufwui/matrixmenu/src/mmappui.cpp
branchRCL_3
changeset 19 79311d856354
parent 17 b8fae6b8a148
child 23 7be2816dbabd
equal deleted inserted replaced
18:d05a55b217df 19:79311d856354
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Application UI class
    14 * Description:  Application UI class
    15 *  Version     : %version: MM_176.1.28.1.67 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: MM_176.1.28.1.69 % << Don't touch! Updated by Synergy at check-out.
    16 *  Version     : %version: MM_176.1.28.1.67 % << Don't touch! Updated by Synergy at check-out.
    16 *  Version     : %version: MM_176.1.28.1.69 % << Don't touch! Updated by Synergy at check-out.
    17 *
    17 *
    18 */
    18 */
    19 
    19 
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 #include <e32cmn.h>
    21 #include <e32cmn.h>
    91 
    91 
    92     //set matrix to be system app
    92     //set matrix to be system app
    93     iEikonEnv->SetSystem( ETrue );
    93     iEikonEnv->SetSystem( ETrue );
    94 
    94 
    95     TInt appUiFlags = AknLayoutUtils::PenEnabled() ?
    95     TInt appUiFlags = AknLayoutUtils::PenEnabled() ?
    96     	EAknEnableSkin | EAknSingleClickCompatible :
    96       EAknEnableSkin | EAknSingleClickCompatible :
    97         EAknEnableSkin | EAknEnableMSK;
    97         EAknEnableSkin | EAknEnableMSK;
    98     BaseConstructL( appUiFlags );
    98     BaseConstructL( appUiFlags );
    99     //hide Menu from TS at startup
    99     //hide Menu from TS at startup
   100     HideApplicationFromFSW( ETrue );
   100     HideApplicationFromFSW( ETrue );
   101     isHiddenFromFS = ETrue;
   101     isHiddenFromFS = ETrue;
   211         // Do not call StartLayoutSwitchFullScreen(),
   211         // Do not call StartLayoutSwitchFullScreen(),
   212         // layout switch effect is started automatically
   212         // layout switch effect is started automatically
   213         iIsKastorEffectStarted = ETrue;
   213         iIsKastorEffectStarted = ETrue;
   214         TInt lastItemIndex = iCurrentContainer->NumberOfItems() - 1;
   214         TInt lastItemIndex = iCurrentContainer->NumberOfItems() - 1;
   215 
   215 
   216         if ( lastItemIndex >= 0 && iCurrentContainer->ItemIsFullyVisible( lastItemIndex ) &&
   216         if ( lastItemIndex >= 0 && iCurrentContainer->ItemIsFullyVisible( lastItemIndex )
   217         		!iCurrentContainer->IsHighlightVisible() )
   217                 && !iCurrentContainer->IsHighlightVisible() )
   218         	{
   218             {
   219         	iCurrentContainer->SetManualHighlightL( lastItemIndex, EFalse );
   219             iCurrentContainer->SetManualHighlightL( lastItemIndex, EFalse );
   220         	}
   220             }
       
   221 /*        else if( !iCurrentContainer->IsHighlightVisible()
       
   222                 && iCurrentContainer->Widget()->TopItemIndex() > -1)
       
   223             {
       
   224             iCurrentContainer->SetManualHighlightL(
       
   225                     iCurrentContainer->Widget()->TopItemIndex(), EFalse );
       
   226             } */
   221 
   227 
   222         iCurrentContainer->SetRect( ClientRect() );
   228         iCurrentContainer->SetRect( ClientRect() );
   223         iDummyContainer->SetRect( ClientRect() );
   229         iDummyContainer->SetRect( ClientRect() );
   224 
   230 
   225         THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap );
   231         THashMapIter< TInt, CMmWidgetContainer* > iterator( iContainerMap );
   299         {
   305         {
   300         CAknAppUi::ProcessCommandL( aCommand );
   306         CAknAppUi::ProcessCommandL( aCommand );
   301         }
   307         }
   302 
   308 
   303     if ( iCurrentContainer )
   309     if ( iCurrentContainer )
   304     	{
   310       {
   305     	iCurrentContainer->EndLongTapL();
   311       iCurrentContainer->EndLongTapL();
   306     	}
   312       }
   307     }
   313     }
   308 
   314 
   309 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   310 //
   316 //
   311 // ---------------------------------------------------------------------------
   317 // ---------------------------------------------------------------------------
   320     // Handle empty message sends by AVKON after app key press or switch
   326     // Handle empty message sends by AVKON after app key press or switch
   321     // to Menu via task swapper.
   327     // to Menu via task swapper.
   322     if( !aParams.Compare( KNullDesC8 ) )
   328     if( !aParams.Compare( KNullDesC8 ) )
   323         {
   329         {
   324         if ( !iAppkeyHandler->IsActive() )
   330         if ( !iAppkeyHandler->IsActive() )
   325         	{
   331             {
   326             //make dummy container visible when returning
   332             //make dummy container visible when returning
   327             //to menu by AppKey
   333             //to menu by AppKey
   328         	iDummyContainer->MakeVisible( ETrue );
   334             iDummyContainer->MakeVisible( ETrue );
   329             RefreshUiPanesL( ETrue );
   335             RefreshUiPanesL( ETrue );
   330             iCurrentContainer->MakeVisible( EFalse );
   336             iCurrentContainer->MakeVisible( EFalse );
   331             iDummyContainer->DrawNow();
   337             iDummyContainer->DrawNow();
   332             CleanupForExitL( EExitKeyApplication );
   338             CleanupForExitL( EExitKeyApplication );
   333 			User::LeaveIfError( iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(
   339             User::LeaveIfError( iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(
   334 						CEikonEnv::Static()->RootWin().Identifier(), 0 ) );
   340             CEikonEnv::Static()->RootWin().Identifier(), 0 ) );
   335 			iAppkeyHandler->StartL();
   341             iAppkeyHandler->StartL();
   336         	}
   342             }
   337         }
   343         }
   338 
   344 
   339     // first refresh model, show afterwords
   345     // first refresh model, show afterwords
   340     if ( aParams.Length() )
   346     if ( aParams.Length() )
   341         {
   347         {
   625 // ---------------------------------------------------------------------------
   631 // ---------------------------------------------------------------------------
   626 //
   632 //
   627 // ---------------------------------------------------------------------------
   633 // ---------------------------------------------------------------------------
   628 //
   634 //
   629 TInt CMmAppUi::GetKastorEffectL( CHnItemModel* aItemModel )
   635 TInt CMmAppUi::GetKastorEffectL( CHnItemModel* aItemModel )
   630 	{
   636   {
   631 	TInt effect( AknTransEffect::ENone );
   637   TInt effect( AknTransEffect::ENone );
   632     if ((IsEditMode() || iEditModeStatus == ETransitionFromEditMode)
   638     if ((IsEditMode() || iEditModeStatus == ETransitionFromEditMode)
   633             && !AknLayoutUtils::PenEnabled())
   639             && !AknLayoutUtils::PenEnabled())
   634         {
   640         {
   635         return effect;
   641         return effect;
   636         }
   642         }
   637 	switch( aItemModel->GetItemType() )
   643   switch( aItemModel->GetItemType() )
   638 		{
   644     {
   639 		case EItemTypeApplication:
   645     case EItemTypeApplication:
   640 			{
   646       {
   641 			if( !IsEditMode() && !aItemModel->IsDrmExpired() )
   647       if( !IsEditMode() && !aItemModel->IsDrmExpired() )
   642 				{
   648         {
   643 				if( aItemModel->IsRunning() )
   649         if( aItemModel->IsRunning() )
   644 					{
   650           {
   645 					effect = AknTransEffect::EApplicationStartSwitchRect;
   651           effect = AknTransEffect::EApplicationStartSwitchRect;
   646 					}
   652           }
   647 				else
   653         else
   648 					{
   654           {
   649 					effect = AknTransEffect::EApplicationStartRect;
   655           effect = AknTransEffect::EApplicationStartRect;
   650 					}
   656           }
   651 				}
   657         }
   652 			break;
   658       break;
   653 			}
   659       }
   654 		case EItemTypeSuite:
   660     case EItemTypeSuite:
   655 			{
   661       {
   656 			if( !IsEditMode() )
   662       if( !IsEditMode() )
   657 				{
   663         {
   658 				effect = EMenuOpenFolderEffect;
   664         effect = EMenuOpenFolderEffect;
   659 				iIsKastorEffectStarted = ETrue;
   665         iIsKastorEffectStarted = ETrue;
   660 				}
   666         }
   661 			break;
   667       break;
   662 			}
   668       }
   663 		case EItemTypeParentFolder:
   669     case EItemTypeParentFolder:
   664 		    {
   670         {
   665             effect = EMenuCloseFolderEffect;
   671             effect = EMenuCloseFolderEffect;
   666             iIsKastorEffectStarted = ETrue;
   672             iIsKastorEffectStarted = ETrue;
   667 		    break;
   673         break;
   668 		    }
   674         }
   669 		case EItemTypeFolder:
   675     case EItemTypeFolder:
   670 			{
   676       {
   671 			if (!(IsEditMode() && aItemModel->IsDeleteLocked()))
   677       if (!(IsEditMode() && aItemModel->IsDeleteLocked()))
   672                 {
   678                 {
   673                 effect = EMenuOpenFolderEffect;
   679                 effect = EMenuOpenFolderEffect;
   674                 iIsKastorEffectStarted = ETrue;
   680                 iIsKastorEffectStarted = ETrue;
   675                 }
   681                 }
   676 			break;
   682       break;
   677 			}
   683       }
   678 		case EItemTypeUnknown:
   684     case EItemTypeUnknown:
   679 		default:
   685     default:
   680 			{
   686       {
   681 			effect = AknTransEffect::ENone;
   687       effect = AknTransEffect::ENone;
   682 			break;
   688       break;
   683 			}
   689       }
   684 		}
   690     }
   685     return effect;
   691     return effect;
   686     }
   692     }
   687 
   693 
   688 // ---------------------------------------------------------------------------
   694 // ---------------------------------------------------------------------------
   689 //
   695 //
   959             aKeyEvent.iScanCode == EStdKeyDevice3 ) &&
   965             aKeyEvent.iScanCode == EStdKeyDevice3 ) &&
   960             aType == EEventKeyDown &&
   966             aType == EEventKeyDown &&
   961             IsEditMode() && !Layout_Meta_Data::IsPenEnabled() )
   967             IsEditMode() && !Layout_Meta_Data::IsPenEnabled() )
   962         {
   968         {
   963         DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - enter in edit mode"));
   969         DEBUG(("_Mm_:CMmAppUi::HandleKeyPressedL - enter in edit mode"));
   964 		HandleCommandL( EAknSoftkeyOk );
   970         HandleCommandL( EAknSoftkeyOk );
   965         resp = EKeyWasConsumed;
   971         resp = EKeyWasConsumed;
   966         }
   972         }
   967 
   973 
   968     // handle the key exactly as container does (the same conditions)
   974     // handle the key exactly as container does (the same conditions)
   969     if ( ( aKeyEvent.iRepeats > 0 && aType == EEventKey ) ||
   975     if ( ( aKeyEvent.iRepeats > 0 && aType == EEventKey ) ||
  1068 // -----------------------------------------------------------------------------
  1074 // -----------------------------------------------------------------------------
  1069 //
  1075 //
  1070 void CMmAppUi::HandleDragStopL( TInt aModelItemIndex )
  1076 void CMmAppUi::HandleDragStopL( TInt aModelItemIndex )
  1071     {
  1077     {
  1072     MMPERF(("CMmAppUi::HandleDragStopL - START"));
  1078     MMPERF(("CMmAppUi::HandleDragStopL - START"));
  1073     if ( IsEditMode() )
  1079     if( IsEditMode() )
  1074         {
  1080         {
  1075         TInt itemId = iCurrentSuiteModel->IdByIndex( aModelItemIndex );
  1081         TInt itemId = iCurrentSuiteModel->IdByIndex( aModelItemIndex );
  1076         TMcsItemType typeCurr =
  1082         TMcsItemType typeCurr =
  1077             iCurrentSuiteModel->GetItemType( aModelItemIndex );
  1083             iCurrentSuiteModel->GetItemType( aModelItemIndex );
  1078         TBool isOverFolder = ( AknLayoutUtils::PenEnabled() &&
  1084         TBool isOverFolder = ( AknLayoutUtils::PenEnabled() &&
  1079             ( typeCurr == EItemTypeParentFolder || typeCurr == EItemTypeFolder ) );
  1085             ( typeCurr == EItemTypeParentFolder || typeCurr == EItemTypeFolder ) );
  1080         TBool isDeleteLocked = (itemId != KErrNotFound) ?
  1086         TBool isDeleteLocked = (itemId != KErrNotFound)
  1081                     iCurrentSuiteModel->GetItemModel( itemId )->IsDeleteLocked():
  1087                                 ? iCurrentSuiteModel->GetItemModel( itemId )->IsDeleteLocked()
  1082                     EFalse;
  1088                                 : EFalse;
  1083 
  1089 
  1084         TBuf8< KMaxLength > beforeCustomId;
  1090         TBuf8<KMaxLength> beforeCustomId;
  1085         beforeCustomId.Num( KErrNotFound );
  1091         beforeCustomId.Num( KErrNotFound );
  1086         if ( aModelItemIndex + 1 < iCurrentContainer->NumberOfItems() )
  1092         if( aModelItemIndex + 1 < iCurrentContainer->NumberOfItems() )
  1087             {
  1093             {
  1088             beforeCustomId.Num( iCurrentSuiteModel->GetItemModel(
  1094             beforeCustomId.Num( iCurrentSuiteModel->GetItemModel(
  1089                     iCurrentSuiteModel->IdByIndex( aModelItemIndex + 1 ) )->CustomId() );
  1095                     iCurrentSuiteModel->IdByIndex( aModelItemIndex + 1 ) )->CustomId() );
  1090             }
  1096             }
  1091 
  1097 
  1092         TBuf8< KMaxLength > draggedCustomId;
  1098         TBuf8<KMaxLength> draggedCustomId;
  1093         draggedCustomId.Num( KErrNotFound );
  1099         draggedCustomId.Num( KErrNotFound );
  1094         CHnItemModel* draggedModel = iCurrentSuiteModel->GetItemModel( iIdDragged );
  1100         CHnItemModel* draggedModel = iCurrentSuiteModel->GetItemModel( iIdDragged );
  1095         if (draggedModel)
  1101         if( draggedModel )
  1096             {
  1102             {
  1097             draggedCustomId.Num( iCurrentSuiteModel->GetItemModel( iIdDragged )->CustomId() );
  1103             draggedCustomId.Num( iCurrentSuiteModel->GetItemModel( iIdDragged )->CustomId() );
  1098             }
  1104             }
  1099 
  1105 
  1100         CLiwGenericParamList* eventParameters = CLiwGenericParamList::NewL();
  1106         CLiwGenericParamList* eventParameters = CLiwGenericParamList::NewL();
  1114         tempKeys->AddSubKeyL( baseKey );
  1120         tempKeys->AddSubKeyL( baseKey );
  1115 
  1121 
  1116         tempKeys->ToGenericParamListL( *eventParameters );
  1122         tempKeys->ToGenericParamListL( *eventParameters );
  1117         CleanupStack::PopAndDestroy( tempKeys );
  1123         CleanupStack::PopAndDestroy( tempKeys );
  1118 
  1124 
  1119         if ( iIdDragged != itemId
  1125         TBool allowMoveInto = iCurrentContainer->AllowMove();
  1120                 && isOverFolder && !isDeleteLocked)
  1126 
       
  1127         if( iIdDragged != itemId && isOverFolder && !isDeleteLocked
       
  1128                 && allowMoveInto )
  1121             {
  1129             {
  1122             iCurrentSuiteModel->RemoveItemL( iIdDragged );
  1130             iCurrentSuiteModel->RemoveItemL( iIdDragged );
  1123             if ( iItemDragged < aModelItemIndex )
  1131             if( iItemDragged < aModelItemIndex )
  1124                 {
  1132                 {
  1125                 // indices of all items after iItemDragged have been
  1133                 // indices of all items after iItemDragged have been
  1126                 // decreased when the dragged item got removed from the
  1134                 // decreased when the dragged item got removed from the
  1127                 // current suite; prevent highlighted item change
  1135                 // current suite; prevent highlighted item change
  1128                 iCurrentSuiteModel->SetSuiteHighlightL( aModelItemIndex - 1 );
  1136                 iCurrentSuiteModel->SetSuiteHighlightL( aModelItemIndex - 1 );
  1134             iCurrentContainer->CancelDragL( EFalse );
  1142             iCurrentContainer->CancelDragL( EFalse );
  1135 
  1143 
  1136             iHNInterface->TriggerHnEventL( KKeyIdMoveInto, itemId, eventParameters );
  1144             iHNInterface->TriggerHnEventL( KKeyIdMoveInto, itemId, eventParameters );
  1137             iMakeHightlightedItemFullyVisible = ETrue;
  1145             iMakeHightlightedItemFullyVisible = ETrue;
  1138             }
  1146             }
  1139         else if ( iIdDragged == itemId )
  1147         else if( iIdDragged == itemId )
  1140             {
  1148             {
  1141             iCurrentContainer->CancelDragL( ETrue );
  1149             iCurrentContainer->CancelDragL( ETrue );
  1142             TBool result = iHNInterface->TriggerHnEventL( KKeyIdMove, itemId, eventParameters );
  1150             iCurrentContainer->SetTriggerMoveItemL( itemId, eventParameters );
  1143             // fix for: edit->move, then LSK->Up->LSK->LSK FAST... (short options show up)
  1151             // fix for: edit->move, then LSK->Up->LSK->LSK FAST... (short options show up)
  1144             if ( result != KErrNone && !AknLayoutUtils::PenEnabled() )
  1152             if( !AknLayoutUtils::PenEnabled() )
  1145 				{
       
  1146 				CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC();
       
  1147 				TLiwGenericParam command(KHnRequest, TLiwVariant( KEvaluateMdModel));
       
  1148 				paramList->AppendL(command);
       
  1149 				HandleRequestL(*paramList);
       
  1150 				CleanupStack::PopAndDestroy(paramList);
       
  1151 				}
       
  1152             }
       
  1153         else
       
  1154             {
       
  1155             iCurrentContainer->CancelDragL( ETrue );
       
  1156             if (!AknLayoutUtils::PenEnabled())
       
  1157                 {
  1153                 {
  1158                 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC();
  1154                 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC();
  1159                 TLiwGenericParam command(KHnRequest, TLiwVariant( KEvaluateMdModel));
  1155                 TLiwGenericParam command(KHnRequest, TLiwVariant( KEvaluateMdModel));
  1160                 paramList->AppendL(command);
  1156                 paramList->AppendL( command );
  1161                 HandleRequestL(*paramList);
  1157                 HandleRequestL( *paramList );
  1162                 CleanupStack::PopAndDestroy(paramList);
  1158                 CleanupStack::PopAndDestroy( paramList );
       
  1159                 }
       
  1160             }
       
  1161         else
       
  1162             {
       
  1163             iCurrentContainer->CancelDragL( ETrue );
       
  1164             if( !AknLayoutUtils::PenEnabled() )
       
  1165                 {
       
  1166                 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC();
       
  1167                 TLiwGenericParam command(KHnRequest, TLiwVariant( KEvaluateMdModel));
       
  1168                 paramList->AppendL( command );
       
  1169                 HandleRequestL( *paramList );
       
  1170                 CleanupStack::PopAndDestroy( paramList );
  1163                 }
  1171                 }
  1164             }
  1172             }
  1165 
  1173 
  1166         CleanupStack::PopAndDestroy( eventParameters );
  1174         CleanupStack::PopAndDestroy( eventParameters );
  1167         }
  1175         }
  1211         {
  1219         {
  1212         DEBUG(("\t_Mm_:CMmAppUi::HandleListBoxEventL EEventItemSingleClicked"));
  1220         DEBUG(("\t_Mm_:CMmAppUi::HandleListBoxEventL EEventItemSingleClicked"));
  1213         HandleHighlightItemSingleClickedL(  iCurrentContainer->Widget()->CurrentItemIndex() );
  1221         HandleHighlightItemSingleClickedL(  iCurrentContainer->Widget()->CurrentItemIndex() );
  1214         }
  1222         }
  1215     else if ( aEventType == MEikListBoxObserver::EEventPanningStarted )
  1223     else if ( aEventType == MEikListBoxObserver::EEventPanningStarted )
  1216     	{
  1224       {
  1217     	iKeyClickLocked = ETrue;
  1225       iKeyClickLocked = ETrue;
  1218     	}
  1226       }
  1219 
  1227 
  1220     DEBUG(("_Mm_:CMmAppUi::HandleListBoxEventL OUT"));
  1228     DEBUG(("_Mm_:CMmAppUi::HandleListBoxEventL OUT"));
  1221     }
  1229     }
  1222 
  1230 
  1223 // ---------------------------------------------------------------------------
  1231 // ---------------------------------------------------------------------------
  1224 //
  1232 //
  1225 // ---------------------------------------------------------------------------
  1233 // ---------------------------------------------------------------------------
  1226 //
  1234 //
  1227 void CMmAppUi::HandleLongTapEventL( const TPoint& aPenEventLocation )
  1235 void CMmAppUi::HandleLongTapEventL( const TPoint& aPenEventLocation )
  1228 	{
  1236   {
  1229     TBool popupMenuDisplayed(EFalse);
  1237     TBool popupMenuDisplayed(EFalse);
  1230 	if (iPopupMenu)
  1238   if (iPopupMenu)
  1231     	{
  1239       {
  1232     	delete iPopupMenu;
  1240       delete iPopupMenu;
  1233     	iPopupMenu = NULL;
  1241       iPopupMenu = NULL;
  1234     	}
  1242       }
  1235     iPopupMenu = CAknStylusPopUpMenu::NewL(this,aPenEventLocation);
  1243     iPopupMenu = CAknStylusPopUpMenu::NewL(this,aPenEventLocation);
  1236 
  1244 
  1237     if ( AknLayoutUtils::LayoutMirrored() )
  1245     if ( AknLayoutUtils::LayoutMirrored() )
  1238         {
  1246         {
  1239         iPopupMenu->SetPosition( aPenEventLocation,
  1247         iPopupMenu->SetPosition( aPenEventLocation,
  1244         iPopupMenu->SetPosition( aPenEventLocation,
  1252         iPopupMenu->SetPosition( aPenEventLocation,
  1245                 CAknStylusPopUpMenu::EPositionTypeLeftBottom );
  1253                 CAknStylusPopUpMenu::EPositionTypeLeftBottom );
  1246         }
  1254         }
  1247 
  1255 
  1248     if( iCurrentSuiteModel == iHNInterface->GetLastSuiteModelL()
  1256     if( iCurrentSuiteModel == iHNInterface->GetLastSuiteModelL()
  1249     		&& iCurrentContainer->IsHighlightVisible()
  1257         && iCurrentContainer->IsHighlightVisible()
  1250     		&& iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1 )
  1258         && iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1 )
  1251     	{
  1259       {
  1252 		MMPERF(("CMmAppUi::DynInitMenuPaneL - START"));
  1260     MMPERF(("CMmAppUi::DynInitMenuPaneL - START"));
  1253 		//fill the main menu structure, look for cascade menus
  1261     //fill the main menu structure, look for cascade menus
  1254 		//reset the helper hash map
  1262     //reset the helper hash map
  1255 		iCascadeMenuMap.Close();
  1263     iCascadeMenuMap.Close();
  1256 
  1264 
  1257 		MHnMenuItemModelIterator* menuIterator =
  1265     MHnMenuItemModelIterator* menuIterator =
  1258 			iCurrentSuiteModel->GetMenuStructureL(
  1266       iCurrentSuiteModel->GetMenuStructureL(
  1259 				iCurrentSuiteModel->IdByIndex(
  1267         iCurrentSuiteModel->IdByIndex(
  1260 						iCurrentContainer->GetHighlight() ) );
  1268             iCurrentContainer->GetHighlight() ) );
  1261 
  1269 
  1262 		// check if there is a menu structure available
  1270     // check if there is a menu structure available
  1263 		// for the specified item
  1271     // for the specified item
  1264 		if ( menuIterator )
  1272     if ( menuIterator )
  1265 			{
  1273       {
  1266 			//create item sorting helper objects
  1274       //create item sorting helper objects
  1267 			RArray<TInt> positionArray;
  1275       RArray<TInt> positionArray;
  1268 			CleanupClosePushL( positionArray );
  1276       CleanupClosePushL( positionArray );
  1269 			RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap;
  1277       RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap;
  1270 			CleanupClosePushL( menuItemMap );
  1278       CleanupClosePushL( menuItemMap );
  1271 
  1279 
  1272             while ( menuIterator->HasNextSpecific() )
  1280             while ( menuIterator->HasNextSpecific() )
  1273                 {
  1281                 {
  1274                 CHnMenuItemModel* childItem = menuIterator->GetNextSpecific();
  1282                 CHnMenuItemModel* childItem = menuIterator->GetNextSpecific();
  1275 				CEikMenuPaneItem::SData childData;
  1283         CEikMenuPaneItem::SData childData;
  1276 				childData.iCommandId = childItem->Command();
  1284         childData.iCommandId = childItem->Command();
  1277 				childData.iText = childItem->NameL().
  1285         childData.iText = childItem->NameL().
  1278 					Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1286           Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1279 				childData.iFlags = 0;
  1287         childData.iFlags = 0;
  1280 				childData.iCascadeId = 0;
  1288         childData.iCascadeId = 0;
  1281 
  1289 
  1282 				positionArray.AppendL( childItem->Position() );
  1290         positionArray.AppendL( childItem->Position() );
  1283 				menuItemMap.InsertL( childItem->Position(), childData );
  1291         menuItemMap.InsertL( childItem->Position(), childData );
  1284                 }
  1292                 }
  1285 
  1293 
  1286 			positionArray.Sort();
  1294       positionArray.Sort();
  1287 
  1295 
  1288 			//add items in correct order
  1296       //add items in correct order
  1289 			for ( TInt i = 0; i < positionArray.Count(); ++i )
  1297       for ( TInt i = 0; i < positionArray.Count(); ++i )
  1290 				{
  1298         {
  1291 				iPopupMenu->
  1299         iPopupMenu->
  1292 					AddMenuItemL(
  1300           AddMenuItemL(
  1293 						menuItemMap.FindL( positionArray[i] ).iText,
  1301             menuItemMap.FindL( positionArray[i] ).iText,
  1294 						menuItemMap.FindL( positionArray[i] ).iCommandId );
  1302             menuItemMap.FindL( positionArray[i] ).iCommandId );
  1295 				}
  1303         }
  1296 
  1304 
  1297 			if (positionArray.Count()>0)
  1305       if (positionArray.Count()>0)
  1298 				{
  1306         {
  1299 				iPopupMenu->ShowMenu();
  1307         iPopupMenu->ShowMenu();
  1300 				popupMenuDisplayed = ETrue;
  1308         popupMenuDisplayed = ETrue;
  1301 				}
  1309         }
  1302 			CleanupStack::PopAndDestroy( &menuItemMap );
  1310       CleanupStack::PopAndDestroy( &menuItemMap );
  1303 			CleanupStack::PopAndDestroy( &positionArray );
  1311       CleanupStack::PopAndDestroy( &positionArray );
  1304 			}
  1312       }
  1305 		MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP"));
  1313     MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP"));
  1306 		}
  1314     }
  1307 
  1315 
  1308 	if ( !popupMenuDisplayed && iCurrentContainer )
  1316   if ( !popupMenuDisplayed && iCurrentContainer )
  1309 		{
  1317     {
  1310 		iCurrentContainer->EndLongTapL( ETrue );
  1318     iCurrentContainer->EndLongTapL( ETrue );
  1311 		HandleHighlightItemSingleClickedL(
  1319     HandleHighlightItemSingleClickedL(
  1312 				iCurrentContainer->Widget()->CurrentItemIndex() );
  1320         iCurrentContainer->Widget()->CurrentItemIndex() );
  1313 		}
  1321     }
  1314     }
  1322     }
  1315 
  1323 
  1316 // ---------------------------------------------------------------------------
  1324 // ---------------------------------------------------------------------------
  1317 //
  1325 //
  1318 // ---------------------------------------------------------------------------
  1326 // ---------------------------------------------------------------------------
  1319 //
  1327 //
  1320 void CMmAppUi::HandleHighlightItemDoubleClickedL( TInt aIndex )
  1328 void CMmAppUi::HandleHighlightItemDoubleClickedL( TInt aIndex )
  1321     {
  1329     {
  1322     if ( iKeyClickLocked )
  1330     if ( iKeyClickLocked )
  1323     	return;
  1331       return;
  1324 
  1332 
  1325     if ( iCurrentSuiteModel->WidgetType() == EListWidget
  1333     if ( iCurrentSuiteModel->WidgetType() == EListWidget
  1326         && iCurrentContainer->GetPreviousHighlight() == aIndex )
  1334         && iCurrentContainer->GetPreviousHighlight() == aIndex )
  1327         {
  1335         {
  1328         ForwardEventToHNL( KKeyIdSelect, aIndex );
  1336         ForwardEventToHNL( KKeyIdSelect, aIndex );
  1437         RemoveFromStack( iCurrentContainer );
  1445         RemoveFromStack( iCurrentContainer );
  1438         iDummyContainer->MakeVisible( ETrue );
  1446         iDummyContainer->MakeVisible( ETrue );
  1439         RefreshCbaL();
  1447         RefreshCbaL();
  1440         iGarbage.ResetAndDestroy();
  1448         iGarbage.ResetAndDestroy();
  1441         ResetContainerMap();
  1449         ResetContainerMap();
  1442 	    iCurrentSuiteModel = NULL;
  1450       iCurrentSuiteModel = NULL;
  1443 	    iCurrentContainer = NULL;
  1451       iCurrentContainer = NULL;
  1444 	    }
  1452       }
  1445 
  1453 
  1446     TRAPD( err, iHNInterface->LoadSuitesFromUriL( aMessage ) );
  1454     TRAPD( err, iHNInterface->LoadSuitesFromUriL( aMessage ) );
  1447 
  1455 
  1448     if ( err && iCurrentContainer && ( aMessage.Find( KSetFocusWithPref ) == KErrNotFound ) )
  1456     if ( err && iCurrentContainer && ( aMessage.Find( KSetFocusWithPref ) == KErrNotFound ) )
  1449         {
  1457         {
  1474                 TBool ignoreItemSpecific( EFalse );
  1482                 TBool ignoreItemSpecific( EFalse );
  1475                 if ( iCurrentSuiteModel )
  1483                 if ( iCurrentSuiteModel )
  1476                     {
  1484                     {
  1477                     TInt itemId( KErrNotFound );
  1485                     TInt itemId( KErrNotFound );
  1478                     TBool suiteModelHasItems = iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1;
  1486                     TBool suiteModelHasItems = iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1;
  1479 					TBool highlightVisible = iCurrentContainer->IsHighlightVisible();
  1487           TBool highlightVisible = iCurrentContainer->IsHighlightVisible();
  1480 					if ( !highlightVisible && suiteModelHasItems )
  1488           if ( !highlightVisible && suiteModelHasItems )
  1481 						{
  1489             {
  1482 //						if there is no highlight, but there are items, show menuitems for logically
  1490 //						if there is no highlight, but there are items, show menuitems for logically
  1483 //						current suite highlight fetched from suite model.
  1491 //						current suite highlight fetched from suite model.
  1484 						TInt suiteHighlight = iCurrentSuiteModel->GetSuiteHighlight();
  1492             TInt suiteHighlight = iCurrentSuiteModel->GetSuiteHighlight();
  1485 						ASSERT( suiteHighlight != KErrNotFound );
  1493             ASSERT( suiteHighlight != KErrNotFound );
  1486 						itemId = iCurrentSuiteModel->IdByIndex( suiteHighlight );
  1494             itemId = iCurrentSuiteModel->IdByIndex( suiteHighlight );
  1487 						ignoreItemSpecific = ETrue;
  1495             ignoreItemSpecific = ETrue;
  1488 						}
  1496             }
  1489 					else
  1497           else
  1490 						{
  1498             {
  1491 	                    TBool idByContainer = highlightVisible && suiteModelHasItems;
  1499                       TBool idByContainer = highlightVisible && suiteModelHasItems;
  1492 	                    itemId = idByContainer ?
  1500                       itemId = idByContainer ?
  1493 	                        iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) :
  1501                           iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) :
  1494 	                        iCurrentSuiteModel->IdByIndex( KErrNotFound );
  1502                           iCurrentSuiteModel->IdByIndex( KErrNotFound );
  1495 						}
  1503             }
  1496                     menuIterator = iCurrentSuiteModel->GetMenuStructureL( itemId );
  1504                     menuIterator = iCurrentSuiteModel->GetMenuStructureL( itemId );
  1497                 }
  1505                 }
  1498 
  1506 
  1499                 // check if there is a menu structure available
  1507                 // check if there is a menu structure available
  1500                 // for the specified item
  1508                 // for the specified item
  1522                     //get custom menu items and their positions
  1530                     //get custom menu items and their positions
  1523                     while ( menuIterator->HasNext() )
  1531                     while ( menuIterator->HasNext() )
  1524                         {
  1532                         {
  1525                         CHnMenuItemModel* menuItem = menuIterator->GetNext();
  1533                         CHnMenuItemModel* menuItem = menuIterator->GetNext();
  1526                         if ( (menuItem->MenuItemType() == CHnMenuItemModel::EItemApplication) || !ignoreItemSpecific )
  1534                         if ( (menuItem->MenuItemType() == CHnMenuItemModel::EItemApplication) || !ignoreItemSpecific )
  1527                         	{
  1535                           {
  1528                         	CEikMenuPaneItem::SData menuData;
  1536                           CEikMenuPaneItem::SData menuData;
  1529 							menuData.iCommandId = menuItem->Command();
  1537               menuData.iCommandId = menuItem->Command();
  1530 							menuData.iText = menuItem->NameL().
  1538               menuData.iText = menuItem->NameL().
  1531 								Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1539                 Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1532 							menuData.iFlags = 0;
  1540               menuData.iFlags = 0;
  1533 
  1541 
  1534 							//check for children
  1542               //check for children
  1535 							MHnMenuItemModelIterator* childIterator =
  1543               MHnMenuItemModelIterator* childIterator =
  1536 								menuItem->GetMenuStructure();
  1544                 menuItem->GetMenuStructure();
  1537 							if ( childIterator->HasNext() )
  1545               if ( childIterator->HasNext() )
  1538 								{
  1546                 {
  1539 								//this is a cascade item
  1547                 //this is a cascade item
  1540 								//one menu item can contain only one cascade menu
  1548                 //one menu item can contain only one cascade menu
  1541 								//check if there are available cascade menu containers
  1549                 //check if there are available cascade menu containers
  1542 								TInt freeResource = GetNextCascadeMenuResourceId();
  1550                 TInt freeResource = GetNextCascadeMenuResourceId();
  1543 								if ( freeResource != KErrNotFound )
  1551                 if ( freeResource != KErrNotFound )
  1544 									{
  1552                   {
  1545 									//error checking
  1553                   //error checking
  1546 									if( !iCascadeMenuMap.Insert( freeResource,
  1554                   if( !iCascadeMenuMap.Insert( freeResource,
  1547 																childIterator ) )
  1555                                 childIterator ) )
  1548 										{
  1556                     {
  1549 										//add item only if there is an
  1557                     //add item only if there is an
  1550 										//available resource
  1558                     //available resource
  1551 										menuData.iCascadeId = freeResource;
  1559                     menuData.iCascadeId = freeResource;
  1552 										}
  1560                     }
  1553 									}
  1561                   }
  1554 								}
  1562                 }
  1555 							else
  1563               else
  1556 								{
  1564                 {
  1557 								//normal entry
  1565                 //normal entry
  1558 								menuData.iCascadeId = 0;
  1566                 menuData.iCascadeId = 0;
  1559 								}
  1567                 }
  1560 							positionArray.AppendL( menuItem->Position() );
  1568               positionArray.AppendL( menuItem->Position() );
  1561 							menuItemMap.InsertL( menuItem->Position(), menuData );
  1569               menuItemMap.InsertL( menuItem->Position(), menuData );
  1562                         	}
  1570                           }
  1563                         }
  1571                         }
  1564 
  1572 
  1565                     aMenuPane->Reset();
  1573                     aMenuPane->Reset();
  1566                     positionArray.Sort();
  1574                     positionArray.Sort();
  1567 
  1575 
  1801         {
  1809         {
  1802         // We want a highlight to be visible while switching between
  1810         // We want a highlight to be visible while switching between
  1803         // grid and list views but no highlight should be visible
  1811         // grid and list views but no highlight should be visible
  1804         // after opening a folder.
  1812         // after opening a folder.
  1805         TBool highlightVisibleBefore =
  1813         TBool highlightVisibleBefore =
  1806             iCurrentContainer &&
  1814                 iCurrentContainer &&
  1807             aWidgetContainer &&
  1815                 aWidgetContainer &&
  1808 			iCurrentContainer->IsHighlightVisible() &&
  1816                 iCurrentContainer->IsHighlightVisible() &&
  1809 			iCurrentContainer->WidgetType() != aWidgetContainer->WidgetType();
  1817                 iCurrentContainer->WidgetType() != aWidgetContainer->WidgetType();
  1810 
  1818 
  1811         HandleWidgetChangeRefreshL( aWidgetContainer );
  1819         HandleWidgetChangeRefreshL( aWidgetContainer );
  1812 
  1820 
  1813         if ( highlightVisibleBefore )
  1821         if ( highlightVisibleBefore )
  1814             {
  1822             {
  2032 // ---------------------------------------------------------------------------
  2040 // ---------------------------------------------------------------------------
  2033 //
  2041 //
  2034 // ---------------------------------------------------------------------------
  2042 // ---------------------------------------------------------------------------
  2035 //
  2043 //
  2036 void CMmAppUi::SetEditModeL( TBool aIsEditMode )
  2044 void CMmAppUi::SetEditModeL( TBool aIsEditMode )
  2037 	{
  2045   {
  2038 	MMPERF(("CMmAppUi::SetEditModeL %d - START",aIsEditMode));
  2046   MMPERF(("CMmAppUi::SetEditModeL %d - START",aIsEditMode));
  2039     if ( IsEditMode() != aIsEditMode && iCurrentSuiteModel )
  2047     if ( IsEditMode() != aIsEditMode && iCurrentSuiteModel )
  2040         {
  2048         {
  2041 
  2049 
  2042         // stops moving items. This must be called when leaving non-touch edit mode to save
  2050         // stops moving items. This must be called when leaving non-touch edit mode to save
  2043         // the current visible order of the items. In non-touch it is called only once when completing editing
  2051         // the current visible order of the items. In non-touch it is called only once when completing editing
  2044 
  2052 
  2045         iHNInterface->SetEditModeL(aIsEditMode);
  2053         iHNInterface->SetEditModeL(aIsEditMode);
  2046         iCurrentContainer->StopMovingL();
  2054         iCurrentContainer->StopMovingL();
  2047 
  2055 
  2048         if ( aIsEditMode )
  2056         if ( aIsEditMode )
  2049         	{
  2057           {
  2050         	iEditModeStatus = ETransitionToEditMode;
  2058           iEditModeStatus = ETransitionToEditMode;
  2051         	}
  2059           }
  2052         else
  2060         else
  2053         	{
  2061           {
  2054         	if ( iEditModeStatus == ETransitionToEditMode )
  2062           if ( iEditModeStatus == ETransitionToEditMode )
  2055         		{
  2063             {
  2056         		iEditModeStatus = EFastTransitionFromEditMode;
  2064             iEditModeStatus = EFastTransitionFromEditMode;
  2057         		}
  2065             }
  2058         	else
  2066           else
  2059         		{
  2067             {
  2060         		iEditModeStatus = ETransitionFromEditMode;
  2068             iEditModeStatus = ETransitionFromEditMode;
  2061         		}
  2069             }
  2062         	}
  2070           }
  2063 
  2071 
  2064         HandleHighlightOffsetL( aIsEditMode ? EOffsetNext : EOffsetPrevious );
  2072         HandleHighlightOffsetL( aIsEditMode ? EOffsetNext : EOffsetPrevious );
  2065         iCurrentSuiteModel->SetSuiteHighlightL(
  2073         iCurrentSuiteModel->SetSuiteHighlightL(
  2066                 AdjustEditModeHighlightL( iCurrentSuiteModel->GetSuiteHighlight() ) );
  2074                 AdjustEditModeHighlightL( iCurrentSuiteModel->GetSuiteHighlight() ) );
  2067 
  2075 
  2107         }
  2115         }
  2108 
  2116 
  2109     TEventCode type = static_cast< TEventCode >( aEvent.Type() );
  2117     TEventCode type = static_cast< TEventCode >( aEvent.Type() );
  2110 
  2118 
  2111     if ( ( type == EEventFocusLost || type == KAknFullOrPartialForegroundLost )
  2119     if ( ( type == EEventFocusLost || type == KAknFullOrPartialForegroundLost )
  2112     		&& iCurrentContainer )
  2120         && iCurrentContainer )
  2113         {
  2121         {
  2114         iCurrentContainer->CacheWidgetPosition();
  2122         iCurrentContainer->CacheWidgetPosition();
  2115         }
  2123         }
  2116 
  2124 
  2117     // base's HandleWsEventL needs to be called before foreground handling,
  2125     // base's HandleWsEventL needs to be called before foreground handling,
  2129     else if ( type == EEventFocusGained )
  2137     else if ( type == EEventFocusGained )
  2130         {
  2138         {
  2131         HandleFocusGainedL();
  2139         HandleFocusGainedL();
  2132         }
  2140         }
  2133     else if ( type == EEventFocusLost )
  2141     else if ( type == EEventFocusLost )
  2134     	{
  2142         {
  2135     	HandleFocusLostL();
  2143         HandleFocusLostL();
  2136         }
  2144         }
  2137     else if ( type == KAknFullOrPartialForegroundGained )
  2145     else if ( type == KAknFullOrPartialForegroundGained )
  2138         {
  2146         {
  2139         HandleFullOrPartialForegroundGainedL();
  2147         HandleFullOrPartialForegroundGainedL();
  2140         }
  2148         }
  2233                     }
  2241                     }
  2234                 HandleNumberOfItemsChangedL( EItemsRemoved );
  2242                 HandleNumberOfItemsChangedL( EItemsRemoved );
  2235                 }
  2243                 }
  2236                 break;
  2244                 break;
  2237             case ESuiteItemsUpdated:
  2245             case ESuiteItemsUpdated:
  2238             	{
  2246                 {
  2239 				ClearTransitionFromEditModeFlag();
  2247                 ClearTransitionFromEditModeFlag();
  2240                 iCurrentContainer->DrawView();
  2248                 iCurrentContainer->DrawView();
  2241                 }
  2249                 }
  2242                 break;
  2250                 break;
  2243             case ESuiteHighlightChanged:
  2251             case ESuiteHighlightChanged:
  2244                 {
  2252                 {
  2256 // ---------------------------------------------------------------------------
  2264 // ---------------------------------------------------------------------------
  2257 //
  2265 //
  2258 // ---------------------------------------------------------------------------
  2266 // ---------------------------------------------------------------------------
  2259 //
  2267 //
  2260 void CMmAppUi::ClearTransitionFromEditModeFlag()
  2268 void CMmAppUi::ClearTransitionFromEditModeFlag()
  2261 	{
  2269   {
  2262 	if ( iEditModeStatus == ETransitionFromEditMode ||
  2270   if ( iEditModeStatus == ETransitionFromEditMode ||
  2263 		 iEditModeStatus == EFastTransitionFromEditMode )
  2271      iEditModeStatus == EFastTransitionFromEditMode )
  2264 		{
  2272     {
  2265 		iEditModeStatus = ENoEditMode;
  2273     iEditModeStatus = ENoEditMode;
  2266 		}
  2274     }
  2267 	}
  2275   }
  2268 
  2276 
  2269 // ---------------------------------------------------------------------------
  2277 // ---------------------------------------------------------------------------
  2270 //
  2278 //
  2271 // ---------------------------------------------------------------------------
  2279 // ---------------------------------------------------------------------------
  2272 //
  2280 //
  2371             }
  2379             }
  2372         iCurrentSuiteModel = aModel;
  2380         iCurrentSuiteModel = aModel;
  2373         ShowSuiteL();
  2381         ShowSuiteL();
  2374         iGarbage.ResetAndDestroy();
  2382         iGarbage.ResetAndDestroy();
  2375 
  2383 
  2376        	if ( iEditModeStatus == ETransitionToEditMode )
  2384          if ( iEditModeStatus == ETransitionToEditMode )
  2377             {
  2385             {
  2378             iEditModeStatus = EEditMode;
  2386             iEditModeStatus = EEditMode;
  2379             }
  2387             }
  2380         else if ( iEditModeStatus == ETransitionFromEditMode )
  2388         else if ( iEditModeStatus == ETransitionFromEditMode )
  2381             {
  2389             {
  2498         if ( iCurrentContainer && mustDrawImmediately )
  2506         if ( iCurrentContainer && mustDrawImmediately )
  2499             {
  2507             {
  2500             DEBUG(("\t_Mm_:Top item index reset"));
  2508             DEBUG(("\t_Mm_:Top item index reset"));
  2501             iCurrentContainer->ResetWidgetPosition();
  2509             iCurrentContainer->ResetWidgetPosition();
  2502             iCurrentContainer->Widget()->UpdateScrollBarsL();
  2510             iCurrentContainer->Widget()->UpdateScrollBarsL();
  2503 			iCurrentContainer->MakeVisible( ETrue );
  2511       iCurrentContainer->MakeVisible( ETrue );
  2504 			iCurrentContainer->DrawNow();
  2512       iCurrentContainer->DrawNow();
  2505             }
  2513             }
  2506         }
  2514         }
  2507 
  2515 
  2508     DEBUG(("_Mm_:CMmAppUi::CleanupForExitL - OUT"));
  2516     DEBUG(("_Mm_:CMmAppUi::CleanupForExitL - OUT"));
  2509     }
  2517     }
  2514 //
  2522 //
  2515 void CMmAppUi::ShowHomescreenL( TExitType  aExitType  )
  2523 void CMmAppUi::ShowHomescreenL( TExitType  aExitType  )
  2516     {
  2524     {
  2517     TInt appToShowUid(0);
  2525     TInt appToShowUid(0);
  2518     TInt idleid(0);
  2526     TInt idleid(0);
  2519     if (aExitType == EExitToIdle)
  2527     if (aExitType == EExitToIdle || aExitType == EExitToPhone)
  2520         {
  2528         {
  2521         User::LeaveIfError(RProperty::Get(KPSUidAiInformation, KActiveIdleUid,
  2529         User::LeaveIfError(RProperty::Get(KPSUidAiInformation, KActiveIdleUid,
  2522                 appToShowUid));
  2530                 appToShowUid));
  2523         OpenAppL(TUid::Uid(appToShowUid));
  2531         OpenAppL(TUid::Uid(appToShowUid));
  2524         }
  2532         }
  2653 //
  2661 //
  2654 void CMmAppUi::SetMiddleSoftKeyL()
  2662 void CMmAppUi::SetMiddleSoftKeyL()
  2655     {
  2663     {
  2656     DEBUG(("_Mm_:CMmAppUi::SetMiddleSoftKeyL - IN"));
  2664     DEBUG(("_Mm_:CMmAppUi::SetMiddleSoftKeyL - IN"));
  2657     if ( iCurrentSuiteModel && !AknLayoutUtils::PenEnabled() && !IsEditMode() )
  2665     if ( iCurrentSuiteModel && !AknLayoutUtils::PenEnabled() && !IsEditMode() )
  2658     	{
  2666       {
  2659     	DEBUG(("\t_Mm_:suite highlight: %d",
  2667       DEBUG(("\t_Mm_:suite highlight: %d",
  2660     	            iCurrentSuiteModel->GetSuiteHighlight()));
  2668                   iCurrentSuiteModel->GetSuiteHighlight()));
  2661 
  2669 
  2662 		TBool idByContainer = iCurrentContainer->IsHighlightVisible() &&
  2670     TBool idByContainer = iCurrentContainer->IsHighlightVisible() &&
  2663 				iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1;
  2671         iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1;
  2664 		TInt itemId = idByContainer ?
  2672     TInt itemId = idByContainer ?
  2665 			iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) :
  2673       iCurrentSuiteModel->IdByIndex( iCurrentContainer->GetHighlight() ) :
  2666 			iCurrentSuiteModel->IdByIndex( KErrNotFound );
  2674       iCurrentSuiteModel->IdByIndex( KErrNotFound );
  2667 		CHnItemModel* itemModel = iCurrentSuiteModel->GetItemModel( itemId );
  2675     CHnItemModel* itemModel = iCurrentSuiteModel->GetItemModel( itemId );
  2668 
  2676 
  2669 		CHnButtonModel* mskModel = NULL;
  2677     CHnButtonModel* mskModel = NULL;
  2670 
  2678 
  2671 		if ( itemModel )
  2679     if ( itemModel )
  2672 			{
  2680       {
  2673 			mskModel = itemModel->GetMiddleSoftKey();
  2681       mskModel = itemModel->GetMiddleSoftKey();
  2674 			}
  2682       }
  2675 
  2683 
  2676 		if ( mskModel )
  2684     if ( mskModel )
  2677 			{
  2685       {
  2678 			TInt event = (mskModel->GetEventId() == KErrNotFound) ?
  2686       TInt event = (mskModel->GetEventId() == KErrNotFound) ?
  2679 					KKeyIdSelect : mskModel->GetEventId();
  2687           KKeyIdSelect : mskModel->GetEventId();
  2680 			Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  2688       Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition,
  2681 					event, mskModel->GetButtonText());
  2689           event, mskModel->GetButtonText());
  2682 			}
  2690       }
  2683 		else
  2691     else
  2684 			{
  2692       {
  2685 			// reset to default
  2693       // reset to default
  2686 			RefreshCbaL();
  2694       RefreshCbaL();
  2687 			}
  2695       }
  2688     	}
  2696       }
  2689     DEBUG(("_Mm_:CMmAppUi::SetMiddleSoftKeyL - OUT"));
  2697     DEBUG(("_Mm_:CMmAppUi::SetMiddleSoftKeyL - OUT"));
  2690     }
  2698     }
  2691 
  2699 
  2692 // ---------------------------------------------------------------------------
  2700 // ---------------------------------------------------------------------------
  2693 //
  2701 //
  2823 
  2831 
  2824 // ---------------------------------------------------------------------------
  2832 // ---------------------------------------------------------------------------
  2825 //
  2833 //
  2826 // ---------------------------------------------------------------------------
  2834 // ---------------------------------------------------------------------------
  2827 //
  2835 //
       
  2836 void CMmAppUi::HandleTriggerMoveItemL( const TInt aRecipientId,
       
  2837         CLiwGenericParamList* aEventParameters)
       
  2838     {
       
  2839     iHNInterface->TriggerHnEventL( KKeyIdMove, aRecipientId, aEventParameters);
       
  2840     }
       
  2841 
       
  2842 // ---------------------------------------------------------------------------
       
  2843 //
       
  2844 // ---------------------------------------------------------------------------
       
  2845 //
  2828 void CMmAppUi::RefreshIconsL()
  2846 void CMmAppUi::RefreshIconsL()
  2829     {
  2847     {
  2830     iSkinChangeNeeded = EFalse;
  2848     iSkinChangeNeeded = EFalse;
  2831     CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC();
  2849     CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC();
  2832     TLiwGenericParam command(KHnRequest, TLiwVariant( KRefreshIcons));
  2850     TLiwGenericParam command(KHnRequest, TLiwVariant( KRefreshIcons));
  2894 // ---------------------------------------------------------------------------
  2912 // ---------------------------------------------------------------------------
  2895 //
  2913 //
  2896 // ---------------------------------------------------------------------------
  2914 // ---------------------------------------------------------------------------
  2897 //
  2915 //
  2898 void CMmAppUi::HandleFocusGainedL()
  2916 void CMmAppUi::HandleFocusGainedL()
  2899 	{
  2917     {
  2900 	DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  2918     DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  2901 			"- EEventFocusGained"));
  2919       "- EEventFocusGained"));
  2902 
  2920 
  2903 	iHasFocus = ETrue;
  2921     iHasFocus = ETrue;
  2904 
  2922 
  2905     // Tricky: lack of iCurrentSuiteModel indicates that suite evaluation is in
  2923     // Tricky: lack of iCurrentSuiteModel indicates that suite evaluation is in
  2906     // progress - do not call HandlePresentationChangeL if evalution has not
  2924     // progress - do not call HandlePresentationChangeL if evalution has not
  2907     // finished.
  2925     // finished.
  2908 	if ( iCurrentContainer && !iCurrentContainer->IsVisible() &&
  2926     if ( iCurrentContainer && !iCurrentContainer->IsVisible() &&
  2909 	        iCurrentSuiteModel )
  2927           iCurrentSuiteModel )
  2910 		{
  2928         {
  2911 		HandlePresentationChangeL( iCurrentContainer );
  2929         HandlePresentationChangeL( iCurrentContainer );
  2912 		}
  2930         }
  2913 
  2931 
  2914 	if ( iCurrentSuiteModel && iCurrentContainer )
  2932     if ( iCurrentSuiteModel && iCurrentContainer )
  2915 		{
  2933         {
  2916 		iDummyContainer->MakeVisible( EFalse );
  2934         iDummyContainer->MakeVisible( EFalse );
  2917 		iCurrentContainer->MakeVisible( ETrue );
  2935         iCurrentContainer->MakeVisible( ETrue );
  2918 		iCurrentContainer->DrawNow();
  2936         iCurrentContainer->DrawNow();
  2919 		}
  2937         }
  2920 	if( IsForeground() )
  2938     if( IsForeground() )
  2921 		{
  2939         {
  2922 		RefreshUiPanesL();
  2940         RefreshUiPanesL();
  2923 		}
  2941         }
  2924 	if ( iCurrentContainer )
  2942     if ( iCurrentContainer )
  2925 	    {
  2943         {
  2926 	    iCurrentContainer->SetHasFocusL( ETrue );
  2944         iCurrentContainer->SetHasFocusL( ETrue );
  2927 	    }
  2945         }
  2928 	if ( iCurrentSuiteModel )
  2946     if ( iCurrentSuiteModel )
  2929         {
  2947         {
  2930         iCurrentSuiteModel->SetVisibleL( ETrue );
  2948         iCurrentSuiteModel->SetVisibleL( ETrue );
  2931         }
  2949         }
  2932 	}
  2950     }
  2933 
  2951 
  2934 // ---------------------------------------------------------------------------
  2952 // ---------------------------------------------------------------------------
  2935 //
  2953 //
  2936 // ---------------------------------------------------------------------------
  2954 // ---------------------------------------------------------------------------
  2937 //
  2955 //
  2938 void CMmAppUi::HandleFocusLostL()
  2956 void CMmAppUi::HandleFocusLostL()
  2939 	{
  2957   {
  2940 	DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  2958   DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  2941 			"- EEventFocusLost"));
  2959       "- EEventFocusLost"));
  2942 
  2960 
  2943 	iHasFocus = EFalse;
  2961   iHasFocus = EFalse;
  2944 
  2962 
  2945 	if( iCurrentContainer )
  2963   if( iCurrentContainer )
  2946 		{
  2964     {
  2947 		//This is needed in case some popup is displayed
  2965     //This is needed in case some popup is displayed
  2948 		//while touching item in grid. Highlight
  2966     //while touching item in grid. Highlight
  2949 		//should be reset to normal then.
  2967     //should be reset to normal then.
  2950 		if( AknLayoutUtils::PenEnabled() )
  2968     if( AknLayoutUtils::PenEnabled() )
  2951 			{
  2969       {
  2952 			if( iCurrentContainer->WidgetType() == EGridWidget && !IsEditMode() )
  2970       if( iCurrentContainer->WidgetType() == EGridWidget && !IsEditMode() )
  2953 				{
  2971         {
  2954 				iCurrentContainer->Widget()->View()->ItemDrawer()->
  2972         iCurrentContainer->Widget()->View()->ItemDrawer()->
  2955 					SetFlags( CListItemDrawer::EDisableHighlight );
  2973           SetFlags( CListItemDrawer::EDisableHighlight );
  2956 				}
  2974         }
  2957 			iCurrentContainer->Widget()->View()->
  2975       iCurrentContainer->Widget()->View()->
  2958 			ItemDrawer()->ClearFlags( CListItemDrawer::EPressedDownState );
  2976       ItemDrawer()->ClearFlags( CListItemDrawer::EPressedDownState );
  2959 			iCurrentContainer->Widget()->View()->DrawItem(
  2977       iCurrentContainer->Widget()->View()->DrawItem(
  2960 							  iCurrentContainer->Widget()->CurrentItemIndex() ) ;
  2978                 iCurrentContainer->Widget()->CurrentItemIndex() ) ;
  2961 			}
  2979       }
  2962 		if( IsEditMode() && iCurrentContainer->IsDraggable() )
  2980     if( IsEditMode() && iCurrentContainer->IsDraggable() )
  2963 			{
  2981       {
  2964 			HandleDragStopL( iCurrentContainer->GetHighlight() );
  2982       HandleDragStopL( iCurrentContainer->GetHighlight() );
  2965 			iCurrentContainer->DrawNow();
  2983       iCurrentContainer->DrawNow();
  2966 			}
  2984       }
  2967 		iCurrentContainer->SetHasFocusL( EFalse );
  2985     iCurrentContainer->SetHasFocusL( EFalse );
  2968 		}
  2986     }
  2969 	if ( iCurrentSuiteModel )
  2987   if ( iCurrentSuiteModel )
  2970 		{
  2988     {
  2971 		iCurrentSuiteModel->SetVisibleL( EFalse );
  2989     iCurrentSuiteModel->SetVisibleL( EFalse );
  2972 		}
  2990     }
  2973 
  2991 
  2974 	}
  2992   }
  2975 
  2993 
  2976 // ---------------------------------------------------------------------------
  2994 // ---------------------------------------------------------------------------
  2977 //
  2995 //
  2978 // ---------------------------------------------------------------------------
  2996 // ---------------------------------------------------------------------------
  2979 //
  2997 //
  2980 void CMmAppUi::HandleFullOrPartialForegroundGainedL()
  2998 void CMmAppUi::HandleFullOrPartialForegroundGainedL()
  2981 	{
  2999   {
  2982 		DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  3000     DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  2983 						"- KAknFullOrPartialForegroundGained"));
  3001             "- KAknFullOrPartialForegroundGained"));
  2984     //show Menu in TS when launched for the first time
  3002     //show Menu in TS when launched for the first time
  2985     if( isHiddenFromFS )
  3003     if( isHiddenFromFS )
  2986         {
  3004         {
  2987         HideApplicationFromFSW( EFalse );
  3005         HideApplicationFromFSW( EFalse );
  2988         isHiddenFromFS = EFalse;
  3006         isHiddenFromFS = EFalse;
  2989         }
  3007         }
  2990 	
  3008 
  2991 	if (iCurrentContainer && iCurrentSuiteModel )
  3009   if (iCurrentContainer && iCurrentSuiteModel )
  2992 		{
  3010     {
  2993 		iCurrentContainer->HandleForegroundGainedL();
  3011     iCurrentContainer->HandleForegroundGainedL();
  2994 		iDummyContainer->MakeVisible( EFalse );
  3012     iDummyContainer->MakeVisible( EFalse );
  2995 		iCurrentContainer->MakeVisible( ETrue );
  3013     iCurrentContainer->MakeVisible( ETrue );
  2996 		RefreshUiPanesL();
  3014     RefreshUiPanesL();
  2997 		}
  3015     }
  2998 	if (iSkinChangeNeeded && !iSkinChangeInProgress)
  3016   if (iSkinChangeNeeded && !iSkinChangeInProgress)
  2999 		{
  3017     {
  3000 		MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
  3018     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
  3001 		if (skinInstance && !skinInstance->IsUpdateInProgress())
  3019     if (skinInstance && !skinInstance->IsUpdateInProgress())
  3002 			{
  3020       {
  3003 			RefreshIconsL();
  3021       RefreshIconsL();
  3004 
  3022 
  3005 			}
  3023       }
  3006 		}
  3024     }
  3007 	}
  3025   }
  3008 
  3026 
  3009 // ---------------------------------------------------------------------------
  3027 // ---------------------------------------------------------------------------
  3010 //
  3028 //
  3011 // ---------------------------------------------------------------------------
  3029 // ---------------------------------------------------------------------------
  3012 //
  3030 //
  3013 void CMmAppUi::HandleFullOrPartialForegroundLostL()
  3031 void CMmAppUi::HandleFullOrPartialForegroundLostL()
  3014 	{
  3032   {
  3015 	DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  3033   DEBUG(("_Mm_:CMmAppUi::HandleWsEventL "
  3016 			"- KAknFullOrPartialForegroundLost"));
  3034       "- KAknFullOrPartialForegroundLost"));
  3017 	if ( iCurrentContainer )
  3035   if ( iCurrentContainer )
  3018 		{
  3036     {
  3019 		iCurrentContainer->HandleBackgroundGainedL();
  3037     iCurrentContainer->HandleBackgroundGainedL();
  3020 		if ( IsRootdisplayedL() )
  3038     if ( IsRootdisplayedL() )
  3021 			{
  3039       {
  3022 			iCurrentContainer->RestoreWidgetPosition();
  3040       iCurrentContainer->RestoreWidgetPosition();
  3023 			iCurrentContainer->CacheWidgetPosition();
  3041       iCurrentContainer->CacheWidgetPosition();
  3024 			}
  3042       }
  3025 		}
  3043     }
  3026 	}
  3044   }
  3027 
  3045 
  3028 // End of File
  3046 // End of File