idlefw/plugins/mcsplugin/settings/src/mcspluginsettingscontainer.cpp
branchRCL_3
changeset 14 15e4dd19031c
parent 11 bd874ee5e5e2
child 16 b276298d5729
equal deleted inserted replaced
12:502e5d91ad42 14:15e4dd19031c
     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".
    13 *
    13 *
    14 * Description:  Shortcut settings plug-in container.
    14 * Description:  Shortcut settings plug-in container.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 #include <aknlists.h>
       
    20 #include <AknWaitDialog.h>
       
    21 #include <aknnotewrappers.h>
    18 #include <aknnotewrappers.h>
    22 #include <eikbtgpc.h>
    19 #include <aknlistquerydialog.h>
    23 #include <gslistbox.h>
    20 #include <e32cmn.h>
    24 #include <gsfwviewuids.h>
       
    25 #include <aknradiobuttonsettingpage.h>
    21 #include <aknradiobuttonsettingpage.h>
    26 #include <akntextsettingpage.h>
       
    27 #include <centralrepository.h>
       
    28 #include <StringLoader.h>
    22 #include <StringLoader.h>
    29 
       
    30 #include <csxhelp/ai.hlp.hrh>
    23 #include <csxhelp/ai.hlp.hrh>
    31 #include <hlplch.h>
    24 #include <hlplch.h>
    32 
    25 #include <activefavouritesdbnotifier.h>
    33 // For CActiveFavouritesDbNotifier
       
    34 #include <activefavouritesdbnotifier.h> 
       
    35 #include <mcspluginsettingsres.rsg>
    26 #include <mcspluginsettingsres.rsg>
    36 
    27 
    37 #include "mcspluginsettingscontainer.h"
    28 #include "mcspluginsettingscontainer.h"
    38 #include "mcspluginsettingsmodel.h"
    29 #include "mcspluginsettingsmodel.h"
       
    30 #include "mcspluginsettingsapplist.h"
    39 #include "mcspluginsettingsbkmlist.h"
    31 #include "mcspluginsettingsbkmlist.h"
    40 #include "mcspluginsettings.hrh"
    32 #include "mcspluginsettings.hrh"
    41 #include "mcspluginuids.hrh"
    33 #include "mcspluginuids.hrh"
    42 
    34 
    43 _LIT( KMyMenuData, "matrixmenudata" );
    35 _LIT( KMyMenuData, "matrixmenudata" );
    59 void CMCSPluginSettingsContainer::ConstructL( const TRect& aRect )
    51 void CMCSPluginSettingsContainer::ConstructL( const TRect& aRect )
    60     {
    52     {
    61     iListBox = new (ELeave) CAknSettingStyleListBox;
    53     iListBox = new (ELeave) CAknSettingStyleListBox;
    62     BaseConstructL(aRect, R_AI_MCS_SETTINGS_VIEW_TITLE, NULL);
    54     BaseConstructL(aRect, R_AI_MCS_SETTINGS_VIEW_TITLE, NULL);
    63     StartObservingL();
    55     StartObservingL();
    64     CheckMiddleSoftkeyLabelL();
    56     CheckMiddleSoftkeyLabel();
    65     }
    57     }
    66 
    58 
    67 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    68 // Tells the settings container to start observing for changes
    60 // Tells the settings container to start observing for changes
    69 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    86     TInt err = iNotifier.Open( iMenu ); 
    78     TInt err = iNotifier.Open( iMenu ); 
    87     if ( err == KErrNone )
    79     if ( err == KErrNone )
    88         {
    80         {
    89         iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify );
    81         iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify );
    90         iNotifier.Notify( 0,
    82         iNotifier.Notify( 0,
    91             RMenuNotifier::EItemsAddedRemoved | 
    83             RMenuNotifier::EItemsAddedRemoved,
    92             RMenuNotifier::EItemsReordered |
       
    93             RMenuNotifier::EItemAttributeChanged,
       
    94         iNotifyWatcher->iStatus );
    84         iNotifyWatcher->iStatus );
    95         iNotifyWatcher->WatchNotify( this );
    85         iNotifyWatcher->WatchNotify( this );
    96         }
    86         }
    97     }
    87     }
    98 
    88 
   236     HlpLauncher::LaunchHelpApplicationL( CCoeEnv::Static()->WsSession(), array );
   226     HlpLauncher::LaunchHelpApplicationL( CCoeEnv::Static()->WsSession(), array );
   237     CleanupStack::Pop( array );
   227     CleanupStack::Pop( array );
   238 }
   228 }
   239 
   229 
   240 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   241 // Helper method which indicates if the Applist or Bkmlist is showing
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 TBool CMCSPluginSettingsContainer::IsChangeDialogShowing()
       
   245 {
       
   246     return ( iAppListDialog || iBkmListDialog );
       
   247 }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // Method for closing change dialog (app or bkm) if it is beeing shown
   231 // Method for closing change dialog (app or bkm) if it is beeing shown
   251 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   252 //
   233 //
   253 void CMCSPluginSettingsContainer::CloseChangeDialog()
   234 void CMCSPluginSettingsContainer::CloseChangeDialog()
   254 {
   235 {
   290     {
   271     {
   291         iListBox->HandleItemAdditionL();
   272         iListBox->HandleItemAdditionL();
   292     }
   273     }
   293 
   274 
   294     iListBox->SetCurrentItemIndex( aIndex );
   275     iListBox->SetCurrentItemIndex( aIndex );
   295     CheckMiddleSoftkeyLabelL();
   276     CheckMiddleSoftkeyLabel();
   296 }
   277 }
   297 
   278 
   298 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   299 // From class MMsvSessionObserver.
   280 // From class MMsvSessionObserver.
   300 // Handles an event from the message server.
   281 // Handles an event from the message server.
   312         // fall-through intended here
   293         // fall-through intended here
   313     case EMsvEntriesDeleted:
   294     case EMsvEntriesDeleted:
   314         // fall-through intended here
   295         // fall-through intended here
   315     case EMsvEntriesChanged:
   296     case EMsvEntriesChanged:
   316         {
   297         {
   317         if ( IsChangeDialogShowing() )
       
   318             {
       
   319             CloseChangeDialog();
       
   320             }
       
   321         iModel->UpdateAppListL();
   298         iModel->UpdateAppListL();
       
   299         iModel->UpdateSettingsL();
   322         }
   300         }
   323         break;
   301         break;
   324     default:
   302     default:
   325         break;
   303         break;
   326         }
   304         }
   333 //
   311 //
   334 void CMCSPluginSettingsContainer::ConstructListBoxL(TInt /*aResLbxId*/)
   312 void CMCSPluginSettingsContainer::ConstructListBoxL(TInt /*aResLbxId*/)
   335 {
   313 {
   336 	iListBox->ConstructL(this, EAknListBoxSelectionList);
   314 	iListBox->ConstructL(this, EAknListBoxSelectionList);
   337     // Set empty listbox's text.
   315     // Set empty listbox's text.
   338 	if (iModel->MdcaCount() == 0)
   316     iListBox->View()->SetListEmptyTextL(KNullDesC);
   339 		{
       
   340 		HBufC* text = iCoeEnv->AllocReadResourceLC(R_AI_MCS_SETTINGS_TXT_ALL_FIXED);
       
   341 		iListBox->View()->SetListEmptyTextL(*text);
       
   342 		CleanupStack::PopAndDestroy(text);
       
   343 		}
       
   344 	else
       
   345 		{
       
   346 		 iListBox->View()->SetListEmptyTextL(KNullDesC);  
       
   347 		}
       
   348     iListBox->Model()->SetItemTextArray(iModel);
   317     iListBox->Model()->SetItemTextArray(iModel);
   349     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
   318     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
   350 }
   319 }
   351 
   320 
   352 // ---------------------------------------------------------------------------
   321 // ---------------------------------------------------------------------------
   353 // Chandles a setting change command to select application from a list.
   322 // Handles a setting change command to select application from a list.
   354 // ---------------------------------------------------------------------------
   323 // ---------------------------------------------------------------------------
   355 //
   324 //
   356 TBool CMCSPluginSettingsContainer::HandleAppListChangeCommandL( const TInt& aIndex,
   325 TBool CMCSPluginSettingsContainer::HandleAppListChangeCommandL( const TInt& aIndex,
   357                                                                 const TInt& aSettingIndex )
   326                                                                 const TInt& aSettingIndex )
   358 {
   327 {
   370     iAppListDialog->ConstructL();
   339     iAppListDialog->ConstructL();
   371 
   340 
   372     if (iAppListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   341     if (iAppListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   373         index != oldIndex)
   342         index != oldIndex)
   374         {
   343         {
   375         changed = iModel->ReplaceItemL( iListBox->CurrentItemIndex(), index , EApplication );
   344         changed = iModel->ReplaceItemL( aSettingIndex, index , EApplication );
   376         }
   345         }
   377 
   346 
   378     CleanupStack::PopAndDestroy( title );
   347     CleanupStack::PopAndDestroy( title );
   379     iAppListDialog = NULL;
   348     iAppListDialog = NULL;
   380 
   349 
   401     iBkmListDialog->ConstructL();
   370     iBkmListDialog->ConstructL();
   402 
   371 
   403     if (iBkmListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   372     if (iBkmListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   404         index != oldIndex)
   373         index != oldIndex)
   405         {
   374         {
   406         changed = iModel->ReplaceItemL( iListBox->CurrentItemIndex(), index , EBookmark );
   375         changed = iModel->ReplaceItemL( aSettingIndex, index , EBookmark );
   407         }
   376         }
   408 
   377 
   409     CleanupStack::PopAndDestroy( title );
   378     CleanupStack::PopAndDestroy( title );
   410     iBkmListDialog = NULL;
   379     iBkmListDialog = NULL;
   411     return changed;
   380     return changed;
   449 
   418 
   450 // ---------------------------------------------------------------------------
   419 // ---------------------------------------------------------------------------
   451 // Checks if there is a need to update the middle softkey label.
   420 // Checks if there is a need to update the middle softkey label.
   452 // ---------------------------------------------------------------------------
   421 // ---------------------------------------------------------------------------
   453 //
   422 //
   454 void CMCSPluginSettingsContainer::CheckMiddleSoftkeyLabelL()
   423 void CMCSPluginSettingsContainer::CheckMiddleSoftkeyLabel()
   455 {
   424 {
   456     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   425     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   457     if (cba)
   426     if (cba)
   458     {
   427     {
   459         cba->MakeCommandVisible(EAiScutSettingsCmdChange, (iModel->MdcaCount() != 0));
   428         cba->MakeCommandVisible(EAiScutSettingsCmdChange, (iModel->MdcaCount() != 0));
   473             // fall-through intended here
   442             // fall-through intended here
   474         case RDbNotifier::ERecover  :
   443         case RDbNotifier::ERecover  :
   475             // fall-through intended here
   444             // fall-through intended here
   476         case RDbNotifier::ERollback :
   445         case RDbNotifier::ERollback :
   477             {
   446             {
   478             if ( IsChangeDialogShowing() )
   447             CloseChangeDialog();
   479                 {
       
   480                 CloseChangeDialog();
       
   481                 }
       
   482             iModel->UpdateBkmListL();
   448             iModel->UpdateBkmListL();
   483             }
   449             }
   484             break;
   450             break;
   485         default:
   451         default:
   486             break;
   452             break;
   492 // Handles matrix menu event.
   458 // Handles matrix menu event.
   493 // -----------------------------------------------------------------------------
   459 // -----------------------------------------------------------------------------
   494 //
   460 //
   495 void CMCSPluginSettingsContainer::HandleNotifyL()
   461 void CMCSPluginSettingsContainer::HandleNotifyL()
   496     {
   462     {
   497     if ( IsChangeDialogShowing() )
   463     CloseChangeDialog();
   498         {
   464 
   499         CloseChangeDialog();
       
   500         }
       
   501     iModel->UpdateAppListL();
   465     iModel->UpdateAppListL();
       
   466     ResetCurrentListL(0);
   502     
   467     
   503     // Notification must be activated again
   468     // Notification must be activated again
   504     iNotifyWatcher->Cancel();
   469     iNotifyWatcher->Cancel();
   505     iNotifier.Notify( 0,
   470     iNotifier.Notify( 0,
   506         RMenuNotifier::EItemsAddedRemoved | 
   471         RMenuNotifier::EItemsAddedRemoved,
   507         RMenuNotifier::EItemsReordered |
       
   508         RMenuNotifier::EItemAttributeChanged,
       
   509         iNotifyWatcher->iStatus );
   472         iNotifyWatcher->iStatus );
   510     iNotifyWatcher->WatchNotify( this );
   473     iNotifyWatcher->WatchNotify( this );
   511     }
   474     }
   512 
   475 
   513 // End of File.
   476 // End of File.