homesync/contentmanager/mediaservant/src/msfillbrowseview.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CMSFillBrowseView class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <mediaservant.rsg>
       
    21 #include <StringLoader.h>
       
    22 #include <hlplch.h>
       
    23 
       
    24 #include "msfillbrowsecontainer.h"
       
    25 #include "msconstants.h"
       
    26 #include "msfillbrowseview.h"
       
    27 #include "msappui.h"
       
    28 #include "msdebug.h"
       
    29 
       
    30 // --------------------------------------------------------------------------
       
    31 // CMSFillBrowseView::CMSFillBrowseView()
       
    32 // --------------------------------------------------------------------------
       
    33 //
       
    34 CMSFillBrowseView::CMSFillBrowseView(CMSAppUi& aAppUi )
       
    35     {
       
    36     LOG(_L("[MediaServant]\t CMSFillBrowseView::CMSFillBrowseView"));
       
    37 
       
    38     iAppUi = &aAppUi;
       
    39     }
       
    40 
       
    41 // --------------------------------------------------------------------------
       
    42 // CMSFillBrowseView::ConstructL()
       
    43 // --------------------------------------------------------------------------
       
    44 //
       
    45 void CMSFillBrowseView::ConstructL()
       
    46     {
       
    47     LOG(_L("[MediaServant]\t CMSFillBrowseView::ConstructL"));
       
    48 
       
    49     BaseConstructL( R_MS_FILL_BROWSE_VIEW );
       
    50     }
       
    51 
       
    52 // --------------------------------------------------------------------------
       
    53 // CMSFillBrowseView::~CMSFillBrowseView()
       
    54 // --------------------------------------------------------------------------
       
    55 //
       
    56 CMSFillBrowseView::~CMSFillBrowseView()
       
    57     {
       
    58     LOG(_L("[MediaServant]\t CMSFillBrowseView::~CMSFillBrowseView"));
       
    59 
       
    60     DoDeactivate();
       
    61     }
       
    62 // --------------------------------------------------------------------------
       
    63 // TUid CMSFillBrowseView::Id()
       
    64 // --------------------------------------------------------------------------
       
    65 //
       
    66 TUid CMSFillBrowseView::Id() const
       
    67     {
       
    68     LOG(_L("[MediaServant]\t CMSFillBrowseView::Id"));
       
    69 
       
    70     return KMSFillBrowseViewId;
       
    71     }
       
    72 
       
    73 // --------------------------------------------------------------------------
       
    74 // CMSFillBrowseView::HandleCommandL(TInt aCommand)
       
    75 // --------------------------------------------------------------------------
       
    76 //
       
    77 void CMSFillBrowseView::HandleCommandL( TInt aCommand )
       
    78     {
       
    79     LOG(_L("[MediaServant]\t CMSFillBrowseView::HandleCommandL"));
       
    80 
       
    81     switch ( aCommand )
       
    82         {
       
    83         case EAknSoftkeyBack:
       
    84             {
       
    85             // update status before exit
       
    86             iContainer->SetFileStatusesL();            
       
    87             // back to fill list view
       
    88             iAppUi->ChangeViewL( KMSBrowseViewId, KMSFillViewId );
       
    89             break;
       
    90             }
       
    91 
       
    92         case EMSCmdLock:
       
    93             {
       
    94             iContainer->SetStatusOfFiles( ECmLocalCopy );
       
    95             break;
       
    96             }
       
    97 
       
    98         case EMSCmdUnLock:
       
    99             {
       
   100             iContainer->SetStatusOfFiles( ECmFilled );
       
   101             break;
       
   102             }
       
   103 
       
   104         case EMSCmdRandomize:
       
   105             {
       
   106             iContainer->RandomizeListL();
       
   107             break;
       
   108             }
       
   109 
       
   110         case EAknCmdMark:   // fall through
       
   111         case EAknCmdUnmark: // fall through
       
   112         case EAknMarkAll:   // fall through
       
   113         case EAknUnmarkAll:
       
   114             {
       
   115             // Gets pointer of current listbox.
       
   116             CEikListBox* listbox = iContainer->ListBox();
       
   117 
       
   118             if ( listbox )
       
   119                 {
       
   120                 AknSelectionService::HandleMarkableListProcessCommandL(
       
   121                                                         aCommand, listbox );
       
   122                 }
       
   123             break;
       
   124             }
       
   125         case EAknCmdHelp :
       
   126             {
       
   127             TRAP_IGNORE( HlpLauncher::LaunchHelpApplicationL(
       
   128                         iEikonEnv->WsSession(),
       
   129             iEikonEnv->EikAppUi()->AppHelpContextL() ));
       
   130             break;
       
   131             }
       
   132 
       
   133         default:
       
   134             {
       
   135             // update status before exit
       
   136             iContainer->SetFileStatusesL();
       
   137 
       
   138             AppUi()->HandleCommandL( aCommand );
       
   139             break;
       
   140             }
       
   141         }
       
   142     }
       
   143 
       
   144 
       
   145 
       
   146 // --------------------------------------------------------------------------
       
   147 // CMSFillBrowseView::DoActivateL(...)
       
   148 // --------------------------------------------------------------------------
       
   149 //
       
   150 void CMSFillBrowseView::DoActivateL(
       
   151    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   152    const TDesC8& /*aCustomMessage*/)
       
   153     {
       
   154     LOG(_L("[MediaServant]\t CMSFillBrowseView::DoActivateL"));
       
   155 
       
   156     // Set title pane text to default
       
   157     SetTitlePaneTextL( KMSDefaultTitleId );
       
   158 
       
   159     if ( !iContainer )
       
   160         {
       
   161         iContainer = new (ELeave) CMSFillBrowseContainer(
       
   162                                                     *iAppUi,
       
   163                                                     *this );
       
   164         iContainer->ConstructL( ClientRect() );
       
   165         iContainer->SetMopParent( this );
       
   166         AppUi()->AddToViewStackL( *this, iContainer );
       
   167         iContainer->ActivateL();
       
   168 
       
   169         // marked item indexes
       
   170         iSelections = iContainer->ListBox()->SelectionIndexes();
       
   171 
       
   172         }
       
   173    }
       
   174 
       
   175 // --------------------------------------------------------------------------
       
   176 // CMSFillBrowseView::DoDeactivate()
       
   177 // --------------------------------------------------------------------------
       
   178 //
       
   179 void CMSFillBrowseView::DoDeactivate()
       
   180     {
       
   181     LOG(_L("[MediaServant]\t CMSFillBrowseView::DoDeactivate"));
       
   182 
       
   183     if ( iContainer )
       
   184         {
       
   185         AppUi()->RemoveFromStack( iContainer );
       
   186         }
       
   187 
       
   188     delete iContainer; // Deletes the container class object.
       
   189     iContainer = NULL;
       
   190 
       
   191     ClearCurrentNaviPaneText();
       
   192     }
       
   193 
       
   194 
       
   195 // --------------------------------------------------------------------------
       
   196 // CMSFillBrowseView::DynInitMenuPaneL
       
   197 // --------------------------------------------------------------------------
       
   198 //
       
   199 void CMSFillBrowseView::DynInitMenuPaneL( TInt aResourceId,
       
   200                                          CEikMenuPane* aMenuPane)
       
   201     {
       
   202     LOG(_L("[MediaServant]\t CMSFillBrowseView::DynInitMenuPaneL"));
       
   203 
       
   204     TInt numberOfItems = iContainer->ListBox()->Model()->NumberOfItems();
       
   205 
       
   206     if ( aResourceId == R_MS_FILL_BROWSE_MENU )
       
   207         {
       
   208         // check if random lists exist or there is no items
       
   209         if ( iContainer->HasListRandomRule() == EFalse )
       
   210             {
       
   211             aMenuPane->SetItemDimmed( EMSCmdRandomize, ETrue );
       
   212             }
       
   213 
       
   214         if ( numberOfItems )
       
   215             {
       
   216             TCmListItemStatus fileStatus = iContainer->FileStatus(
       
   217                                 iContainer->ListBox()->CurrentItemIndex() );
       
   218 
       
   219             if (  fileStatus == ECmToBeFilled ||
       
   220                   fileStatus == ECmToBeShrinked )
       
   221                 {
       
   222                 aMenuPane->SetItemDimmed( EMSCmdUnLock, ETrue );
       
   223                 aMenuPane->SetItemDimmed( EMSCmdLock, ETrue );
       
   224                 aMenuPane->SetItemDimmed( EMSCmdMark, ETrue );
       
   225                 }
       
   226             else
       
   227                 {
       
   228                 if ( fileStatus == ECmFilled )
       
   229                     {
       
   230                     aMenuPane->SetItemDimmed( EMSCmdUnLock, ETrue );
       
   231                     }
       
   232                 else // ECmLocalCopy
       
   233                     {
       
   234                     aMenuPane->SetItemDimmed( EMSCmdLock, ETrue );
       
   235                     }
       
   236                 }
       
   237             }
       
   238         else
       
   239             {
       
   240             aMenuPane->SetItemDimmed( EMSCmdLock, ETrue );
       
   241             aMenuPane->SetItemDimmed( EMSCmdUnLock, ETrue );
       
   242             aMenuPane->SetItemDimmed( EMSCmdMark, ETrue );
       
   243             }
       
   244         }
       
   245 
       
   246     // mark submenu
       
   247     if ( aResourceId == R_MS_MARK_MENUPANE && numberOfItems )
       
   248         {
       
   249 
       
   250         if ( iSelections->Count() == 0 )
       
   251             {
       
   252             aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );
       
   253             aMenuPane->SetItemDimmed( EAknUnmarkAll, ETrue );
       
   254             }
       
   255         else
       
   256             {
       
   257             // index of selected item
       
   258             TInt itemIdx = 0;
       
   259             // highlighted item index
       
   260             TInt currentItem = iContainer->ListBox()->CurrentItemIndex();
       
   261             // Sort criteria, offset = 0
       
   262             TKeyArrayFix sortKey( 0, ECmpTUint );
       
   263             TInt found = iSelections->Find( currentItem, sortKey, itemIdx );
       
   264             if ( found == 0 )
       
   265                 {
       
   266                 aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
       
   267                 }
       
   268             }
       
   269         }
       
   270     }
       
   271 
       
   272 // End of File
       
   273