landmarksui/app/src/CLmkCategoryContentsContainer.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2  * Copyright (c) 2002-2010 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:    Provides LM category contents view's container class methods.
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <aknsfld.h>
       
    20 #include <aknlists.h>
       
    21 #include <landmarks.rsg>
       
    22 #include <eikmenub.h>
       
    23 #include <layoutmetadata.cdl.h> // To Check TOUCH Support
       
    24 #include <bldvariant.hrh>
       
    25 #include <AknDef.h>
       
    26 #include <EPos_CPosLandmark.h>
       
    27 #include "CLmkUiUtils.h"
       
    28 #include "CLmkAppUi.h"
       
    29 #include "CLmkSender.h"
       
    30 #include "landmarks.hrh"
       
    31 #include <csxhelp/lm.hlp.hrh>
       
    32 #include "CLmkCategoryContentsView.h"
       
    33 #include "CLmkCategoryContentsContainer.h"
       
    34 #include "CLmkAppLmSelectorImpl.h"
       
    35 #include "CLmkByCategoryView.h"
       
    36 #include <lmkui.rsg>
       
    37 #include "Debug.h"
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 // ----------------------------------------------------------------------------
       
    41 // CLmkCategoryContentsContainer::NewL
       
    42 // ----------------------------------------------------------------------------
       
    43 //
       
    44 CLmkCategoryContentsContainer* CLmkCategoryContentsContainer::NewL(
       
    45         MLmkKeyProcessor& aKeyProcessor, MObjectProvider* aParent,
       
    46         const TRect& aRect, CAknView& aView)
       
    47     {
       
    48     CLmkCategoryContentsContainer* self =
       
    49             new (ELeave) CLmkCategoryContentsContainer(aKeyProcessor, aView);
       
    50     CleanupStack::PushL(self);
       
    51     self->SetMopParent(aParent);
       
    52     self->ConstructL(aRect);
       
    53     CleanupStack::Pop(); // self
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // CLmkCategoryContentsContainer::ConstructL
       
    59 // ----------------------------------------------------------------------------
       
    60 //
       
    61 void CLmkCategoryContentsContainer::ConstructL(const TRect& aRect)
       
    62     {
       
    63     CLmkLbWithFilterContainer::ConstructL(aRect);
       
    64     iFindBox->SetObserver(this);
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // CLmkCategoryContentsContainer::CLmkCategoryContentsContainer
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 
       
    72 CLmkCategoryContentsContainer::CLmkCategoryContentsContainer(
       
    73         MLmkKeyProcessor& aKeyProcessor, CAknView& aView) :
       
    74     CLmkLbWithFilterContainer(aKeyProcessor, KLM_HLP_CATEGORY_CONTENTS),
       
    75             iView(aView)
       
    76     {
       
    77     iIsEditorOpened = EFalse;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CLmkCategoryContentsContainer::~CLmkCategoryContentsContainer
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 CLmkCategoryContentsContainer::~CLmkCategoryContentsContainer()
       
    85     {
       
    86     NaviPane().Pop(iNaviDeco); // Pop category name from navi pane
       
    87     }
       
    88 
       
    89 // ----------------------------------------------------------------------------
       
    90 // CLmkCategoryContentsContainer::SetupTitlePaneL
       
    91 // ----------------------------------------------------------------------------
       
    92 //
       
    93 void CLmkCategoryContentsContainer::SetupTitlePaneL()
       
    94     {
       
    95     CLmkUiUtils::ChangeTitlePaneL(R_LMK_BYLM_VIEW_TITLE);
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------------------------------
       
    99 // CLmkCategoryContentsContainer::SetupSelectorAndListL
       
   100 // ----------------------------------------------------------------------------
       
   101 //
       
   102 void CLmkCategoryContentsContainer::SetupSelectorAndListL(
       
   103         CPosLandmarkDatabase& aDb, CLmkSender& aSender)
       
   104     {
       
   105     CLmkByCategoryView* categoryView =
       
   106             static_cast<CLmkByCategoryView*> (ViewAppUi()->View(TUid::Uid(
       
   107                     ELmkByCategoryView)));
       
   108 
       
   109     // Create this classes selector based on category selector:
       
   110     iSelector = CLmkAppLmSelectorImpl::NewL(aDb,
       
   111             categoryView->BorrowMemento(), aSender, ETrue);
       
   112     iSelector->SetMskObserver(this);
       
   113     iListBox = &(iSelector->CreateListBoxL(this, EAknCtSingleGraphicListBox,
       
   114 #ifdef RD_SCALABLE_UI_V2
       
   115             EAknListBoxStylusMarkableList,
       
   116 #else
       
   117             EAknListBoxMarkableList,
       
   118 #endif //RD_SCALABLE_UI_V2
       
   119             R_LMK_EMPTY_NO_LANDMARKS, R_LMK_GUIDE_NEW_LANDMARK));
       
   120     }
       
   121 
       
   122 // ----------------------------------------------------------------------------
       
   123 // CLmkCategoryContentsContainer::SetupNaviPaneL
       
   124 // ----------------------------------------------------------------------------
       
   125 //
       
   126 void CLmkCategoryContentsContainer::SetupNaviPaneL()
       
   127     {
       
   128     // Show category name in navi pane:
       
   129     CAknNavigationControlContainer& naviPane = NaviPane();
       
   130     CLmkAppLmSelectorImpl* selector =
       
   131             static_cast<CLmkAppLmSelectorImpl*> (iSelector);
       
   132     iNaviDeco = naviPane.CreateNavigationLabelL(selector->CategoryNameL());
       
   133     naviPane.PushL(*iNaviDeco); // activate navi label in navi pane
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CLmkCategoryContentsContainer::OfferKeyEventL()
       
   138 // ---------------------------------------------------------
       
   139 //
       
   140 TKeyResponse CLmkCategoryContentsContainer::OfferKeyEventL(
       
   141         const TKeyEvent& aKeyEvent, TEventCode aType)
       
   142     {
       
   143     DEBUG( CLmkCategoryContentsContainer::OfferKeyEventL entered );
       
   144     DEBUG2( aKeyEvent.iCode=%d aKeyEvent.iScanCode=%d,
       
   145             aKeyEvent.iCode,
       
   146             aKeyEvent.iScanCode
       
   147     );
       
   148     DEBUG3( aKeyEvent.iModifiers=%d aKeyEvent.iRepeats=%d aType=%d,
       
   149             aKeyEvent.iModifiers,
       
   150             aKeyEvent.iRepeats,
       
   151             aType
       
   152     );
       
   153 
       
   154     TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift)
       
   155             || (aKeyEvent.iModifiers & EModifierLeftShift)
       
   156             || (aKeyEvent.iModifiers & EModifierRightShift);
       
   157 
       
   158     if (aKeyEvent.iScanCode == EStdKeyUpArrow || aKeyEvent.iScanCode
       
   159             == EStdKeyDownArrow)
       
   160         {
       
   161         if (aType == EEventKey)
       
   162             {
       
   163             if (iListBox->OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed)
       
   164                 {
       
   165                 if (shiftKeyPressed)
       
   166                     UpdateMskContainerL();
       
   167                 return EKeyWasConsumed;
       
   168                 }
       
   169             }
       
   170         return EKeyWasNotConsumed;
       
   171         }
       
   172 
       
   173     CLmkAppSelectorImplBase& selector = SelectorImpl();
       
   174     TInt markedCount(selector.ListMarkedItemCountL());
       
   175     TInt visibleCount(selector.ListVisibleItemCount());
       
   176     DEBUG1( CLmkCategoryContentsContainer::OfferKeyEventL markedCount=%d,markedCount );
       
   177     DEBUG1( CLmkCategoryContentsContainer::OfferKeyEventL visibleCount=%d,visibleCount );
       
   178 
       
   179     if (aKeyEvent.iCode == EKeyOK && !shiftKeyPressed && aType == EEventKey)
       
   180         {
       
   181         if (visibleCount > 0 && markedCount < 1)
       
   182             {
       
   183             // Launch landmark viewer here
       
   184             selector.ProcessCommandL(ELmkCmdOpenLm);
       
   185             iIsEditorOpened = ETrue;
       
   186             return EKeyWasConsumed;
       
   187             }
       
   188         else
       
   189             {
       
   190             DEBUG( CLmkCategoryContentsContainer::OfferKeyEventL EKeyOK show menubar );
       
   191             CEikMenuBar* menubar =
       
   192                     static_cast<CAknViewAppUi*> (iAvkonAppUi)->View(
       
   193                             TUid::Uid(ELmkCategoryContentsView))->MenuBar();
       
   194             if (menubar)
       
   195                 {
       
   196                 menubar->SetMenuTitleResourceId(R_LMK_OK_MENUBAR);
       
   197 
       
   198                 menubar->StopDisplayingMenuBar();
       
   199                 TRAPD(err,menubar->TryDisplayMenuBarL());
       
   200                 DEBUG1( CLmkCategoryContentsContainer::OfferKeyEventL menubar->TryDisplayMenuBarL() = %d,err );
       
   201                 // set ordinary menubar back even in case of error:                                         
       
   202                 menubar->SetMenuTitleResourceId(R_LMK_BYLM_MENUBAR);
       
   203                 User::LeaveIfError(err);
       
   204                 }
       
   205 
       
   206             return EKeyWasConsumed;
       
   207             }
       
   208         }
       
   209     else if (shiftKeyPressed && aType == EEventKeyUp)
       
   210         {
       
   211         UpdateMskContainerL();
       
   212         }
       
   213     else
       
   214         {
       
   215         DEBUG( CLmkCategoryContentsContainer::OfferKeyEventL send event key & other keys handling );
       
   216         // 'send' eveny key processing        
       
   217         if (visibleCount > 0 && markedCount < 1)
       
   218             {
       
   219             // Check TOUCH Support
       
   220             if (aKeyEvent.iCode == EKeyPhoneSend
       
   221                     && (!Layout_Meta_Data::IsPenEnabled()))
       
   222                 {
       
   223                 selector.ProcessCommandL(ELmkCmdCall);
       
   224                 }
       
   225             }
       
   226         if (iIsEditorOpened)
       
   227             {
       
   228             DEBUG( CLmkCategoryContentsContainer::OfferKeyEventL iIsEditorOpened entered );
       
   229             SelectorImpl().HandleListProviderEvent(ELmkEventListReady);
       
   230             }
       
   231         }
       
   232     iIsEditorOpened = EFalse;
       
   233     TKeyResponse response = CLmkLbWithFilterContainer::OfferKeyEventL(
       
   234             aKeyEvent, aType);
       
   235     
       
   236     DEBUG( CLmkCategoryContentsContainer::OfferKeyEventL End );
       
   237     return response;
       
   238     }
       
   239 
       
   240 // ----------------------------------------------------------------------------
       
   241 // CLmkCategoryContentsContainer::HandleControlEventL()
       
   242 // Called by framework when the view size is changed
       
   243 // ----------------------------------------------------------------------------
       
   244 //
       
   245 void CLmkCategoryContentsContainer::HandleControlEventL(
       
   246         CCoeControl* aControl, TCoeEvent aEventType)
       
   247     {
       
   248     if (aEventType == EEventStateChanged && aControl == iFindBox)
       
   249         {
       
   250         SelectorImpl().ProcessCommandL(ELmkCmdFindBoxSearchAfresh);
       
   251         }
       
   252     if (aEventType == EEventStateChanged && aControl == iListBox )
       
   253         {
       
   254         if (static_cast<CTextListBoxModel*> (ListBox().Model())->ItemTextArray()->MdcaCount()
       
   255                 == 0)
       
   256             {
       
   257             (static_cast<CLmkCategoryContentsView *> (&iView))->HandleCommandL(
       
   258                     EAknSoftkeyBack);
       
   259             }
       
   260         }
       
   261     }
       
   262 
       
   263 // ----------------------------------------------------------------------------
       
   264 // CLmkCategoryContentsContainer::GetSelectedLandmarksL
       
   265 // ----------------------------------------------------------------------------
       
   266 //
       
   267 TInt CLmkCategoryContentsContainer::GetSelectedLandmarksL(RPointerArray<
       
   268         CPosLandmark> &aArray)
       
   269     {
       
   270     return (static_cast<CLmkAppLmSelectorImpl*> (iSelector))->GetSelectedLandmarksL(
       
   271             aArray);
       
   272     }
       
   273 
       
   274 // ----------------------------------------------------------------------------
       
   275 // CLmkCategoryContentsContainer::IsLandmarkDataEmptyL
       
   276 // ----------------------------------------------------------------------------
       
   277 //
       
   278 TBool CLmkCategoryContentsContainer::IsLandmarkDataEmptyL(
       
   279         CPosLandmark* aLandmark)
       
   280     {
       
   281     return (static_cast<CLmkAppLmSelectorImpl*> (iSelector))->IsLandmarkDataEmptyL(
       
   282             aLandmark);
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 //CLmkCategorySettingsContainer::HandleResourceChange
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void CLmkCategoryContentsContainer::HandleResourceChange(TInt aType)
       
   290     {
       
   291     CCoeControl::HandleResourceChange(aType);
       
   292     if (aType == KEikDynamicLayoutVariantSwitch)
       
   293         {
       
   294         (static_cast<CLmkCategoryContentsView *> (&iView))->Update();
       
   295         }
       
   296     if (iListBox)
       
   297         {
       
   298         iListBox->DrawNow();
       
   299         }
       
   300     if (iFindBox && iFindBox->IsVisible())
       
   301         {
       
   302         iFindBox->DrawNow();
       
   303         }
       
   304     }
       
   305 
       
   306 // ----------------------------------------------------------------------------
       
   307 // CLmkByLmContainer::FocusChanged()
       
   308 // ----------------------------------------------------------------------------
       
   309 //
       
   310 void CLmkCategoryContentsContainer::FocusChanged(TDrawNow aDrawNow)
       
   311     {
       
   312     if (iListBox)
       
   313         {
       
   314         iListBox->SetFocus(IsFocused(), aDrawNow);
       
   315         }
       
   316     if (iFindBox && iFindBox->IsVisible())
       
   317         {
       
   318         iFindBox->SetFocus(IsFocused(), aDrawNow);
       
   319         }
       
   320     }
       
   321 
       
   322 // ----------------------------------------------------------------------------
       
   323 // CLmkCategoryContentsContainer::IsEditorOpened()
       
   324 // ----------------------------------------------------------------------------
       
   325 //
       
   326 TBool CLmkCategoryContentsContainer::IsEditorOpened()
       
   327     {
       
   328     return iIsEditorOpened;
       
   329     }
       
   330 
       
   331 // ----------------------------------------------------------------------------
       
   332 // CLmkByLmContainer::SetEditorOpenedBool()
       
   333 // ----------------------------------------------------------------------------
       
   334 //
       
   335 void CLmkCategoryContentsContainer::SetEditorOpenedBool(TBool aBoolvalue)
       
   336     {
       
   337     iIsEditorOpened = aBoolvalue;
       
   338     }
       
   339 
       
   340 // ----------------------------------------------------------------------------
       
   341 // CLmkCategoryContentsContainer::UpdateMskContainerL()
       
   342 // ----------------------------------------------------------------------------
       
   343 //
       
   344 void CLmkCategoryContentsContainer::UpdateMskContainerL()
       
   345     {
       
   346     CLmkBaseView* view = reinterpret_cast<CLmkBaseView*> (&iView);
       
   347     view->UpdateMskViewL(ResolveMskDisplayItem());
       
   348     }
       
   349 
       
   350 // ----------------------------------------------------------------------------
       
   351 // CLmkCategoryContentsContainer::RemoveFromThisCategory()
       
   352 // ----------------------------------------------------------------------------
       
   353 //
       
   354 void CLmkCategoryContentsContainer::RemoveFromThisCategoryL()
       
   355     {
       
   356     iIsRemoveOperation = ETrue;
       
   357     CLmkBaseView* view = reinterpret_cast<CLmkBaseView*> (&iView);
       
   358     view->UpdateMskViewL(ENoMsk);
       
   359     (static_cast<CLmkAppLmSelectorImpl*> (iSelector))->RemoveLandmarksFromCategoryL();
       
   360     }
       
   361 
       
   362 // ----------------------------------------------------------------------------
       
   363 // CLmkCategoryContentsContainer::IsUncategorizedCategory()
       
   364 // ----------------------------------------------------------------------------
       
   365 //
       
   366 TBool CLmkCategoryContentsContainer::IsUncategorizedCategory()
       
   367     {
       
   368     CLmkAppLmSelectorImpl* selector =
       
   369             static_cast<CLmkAppLmSelectorImpl*> (iSelector);
       
   370     return selector->IsCriteriaUnCategorizedCat();
       
   371     }
       
   372 
       
   373 // ---------------------------------------------------------
       
   374 // CLmkCategoryContentsContainer::ResolveMskDisplayItem()
       
   375 // ---------------------------------------------------------
       
   376 //
       
   377 TLmkMskDispItem CLmkCategoryContentsContainer::ResolveMskDisplayItem()
       
   378     {
       
   379     TLmkMskDispItem dispItem = ELabel;
       
   380     if ((!SelectorImpl().ListVisibleItemCount()))
       
   381         {
       
   382         dispItem = ENoMsk;
       
   383         }
       
   384     else
       
   385         {
       
   386         const CArrayFix<TInt>* markedIndexes = NULL;
       
   387         markedIndexes = SelectorImpl().MarkedIndexes();
       
   388         if (markedIndexes->Count() > 0)
       
   389             {
       
   390             dispItem = EContextMenu;
       
   391             }
       
   392         }
       
   393     return dispItem;
       
   394     }
       
   395 
       
   396 // ----------------------------------------------------------------------------
       
   397 // CLmkByLmContainer::UpdateMskContainerForFilterL()
       
   398 // ----------------------------------------------------------------------------
       
   399 //
       
   400 void CLmkCategoryContentsContainer::UpdateMskContainerForFilterL()
       
   401     {
       
   402     iSearchInitiated = ETrue;
       
   403     UpdateMskContainerL();
       
   404     iSearchInitiated = EFalse;
       
   405     }
       
   406 // End of File