phonebookui/Phonebook2/xSPExtensionManager/src/CxSPSortViewControl.cpp
branchRCL_3
changeset 21 b3431bff8c19
parent 0 e686773b3f54
child 35 4ae315f230bc
equal deleted inserted replaced
15:e8e3147d53eb 21:b3431bff8c19
    24 #include <avkon.mbg>
    24 #include <avkon.mbg>
    25 #include <eikclbd.h>
    25 #include <eikclbd.h>
    26 #include <gulicon.h>
    26 #include <gulicon.h>
    27 #include <AknGlobalNote.h>
    27 #include <AknGlobalNote.h>
    28 #include <StringLoader.h>
    28 #include <StringLoader.h>
       
    29 #include <avkon.hrh>
    29 
    30 
    30 // internal includes
    31 // internal includes
    31 #include "CxSPLoader.h"
    32 #include "CxSPLoader.h"
    32 #include "MxSPFactory.h"
    33 #include "MxSPFactory.h"
    33 #include "CxSPViewIdChanger.h"
    34 #include "CxSPViewIdChanger.h"
    37 #include "CGlobalNoteObserver.h"
    38 #include "CGlobalNoteObserver.h"
    38 #include <MPbk2ApplicationServices2.h>
    39 #include <MPbk2ApplicationServices2.h>
    39 #include <MPbk2ApplicationServices.h>
    40 #include <MPbk2ApplicationServices.h>
    40 #include <CPbk2ServiceManager.h>
    41 #include <CPbk2ServiceManager.h>
    41 #include <MPbk2AppUi.h>
    42 #include <MPbk2AppUi.h>
       
    43 #include <CPbk2UIExtensionView.h>
    42 
    44 
    43 // CONSTANTS
    45 // CONSTANTS
    44 _LIT( KTab, "\t" );
    46 _LIT( KTab, "\t" );
    45 const TUint KMaxListBoxBufSize( 256 ); // Maximum listbox item text size
    47 const TUint KMaxListBoxBufSize( 256 ); // Maximum listbox item text size
    46 
    48 
    56 	}
    58 	}
    57 
    59 
    58 // ================= MEMBER FUNCTIONS =======================
    60 // ================= MEMBER FUNCTIONS =======================
    59 
    61 
    60 CxSPSortViewControl::CxSPSortViewControl( CxSPViewIdChanger& aViewIdChanger, 
    62 CxSPSortViewControl::CxSPSortViewControl( CxSPViewIdChanger& aViewIdChanger, 
    61 											CxSPArray& aExtensions ) :
    63 											CxSPArray& aExtensions,
       
    64 											CPbk2UIExtensionView& aView ) :
    62 											iViewIdChanger( aViewIdChanger ),
    65 											iViewIdChanger( aViewIdChanger ),
    63 											iExtensions(aExtensions),
    66 											iExtensions(aExtensions),
    64 											iGlobalNote(0),
    67 											iGlobalNote(0),
    65 											iGlobalNoteObserver(0)
    68 											iGlobalNoteObserver(0),
       
    69 											iView( aView )
    66     {
    70     {
    67     }
    71     }
    68 
    72 
    69 void CxSPSortViewControl::ConstructL()
    73 void CxSPSortViewControl::ConstructL()
    70     {
    74     {
    80         (CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);	
    84         (CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);	
    81 	SetListBoxContentsL();
    85 	SetListBoxContentsL();
    82     }
    86     }
    83 
    87 
    84 CxSPSortViewControl* CxSPSortViewControl::NewL( CxSPViewIdChanger& aViewIdChanger,
    88 CxSPSortViewControl* CxSPSortViewControl::NewL( CxSPViewIdChanger& aViewIdChanger,
    85 											CxSPArray& aExtensions )
    89 											CxSPArray& aExtensions, 
    86     {
    90 											CPbk2UIExtensionView& aView )
    87     CxSPSortViewControl* self = NewLC( aViewIdChanger, aExtensions );
    91     {
       
    92     CxSPSortViewControl* self = NewLC( aViewIdChanger, aExtensions, aView );
    88     CleanupStack::Pop(self);
    93     CleanupStack::Pop(self);
    89     return self;
    94     return self;
    90     }
    95     }
    91 
    96 
    92 CxSPSortViewControl* CxSPSortViewControl::NewLC( CxSPViewIdChanger& aViewIdChanger,
    97 CxSPSortViewControl* CxSPSortViewControl::NewLC( CxSPViewIdChanger& aViewIdChanger,
    93 											CxSPArray& aExtensions )
    98 											CxSPArray& aExtensions, 
       
    99 											CPbk2UIExtensionView& aView )
    94     {
   100     {
    95     CxSPSortViewControl* self =
   101     CxSPSortViewControl* self =
    96         new (ELeave) CxSPSortViewControl( aViewIdChanger, aExtensions );
   102         new (ELeave) CxSPSortViewControl( aViewIdChanger, aExtensions, aView );
    97     CleanupStack::PushL(self);
   103     CleanupStack::PushL(self);
    98     self->ConstructL();
   104     self->ConstructL();
    99     return self;
   105     return self;
   100     }
   106     }
   101 
   107 
   109 
   115 
   110 TKeyResponse CxSPSortViewControl::OfferKeyEventL
   116 TKeyResponse CxSPSortViewControl::OfferKeyEventL
   111         (const TKeyEvent& aKeyEvent,TEventCode aType)
   117         (const TKeyEvent& aKeyEvent,TEventCode aType)
   112     {
   118     {
   113     TKeyResponse result = EKeyWasNotConsumed;
   119     TKeyResponse result = EKeyWasNotConsumed;
   114 	if( iListBox )
   120     
       
   121 	if( iListBox && result == EKeyWasNotConsumed )
   115         {
   122         {
   116         result = iListBox->OfferKeyEventL(aKeyEvent, aType);
   123         result = iListBox->OfferKeyEventL(aKeyEvent, aType);
   117         }
   124         }
       
   125 	
       
   126     // Update popup when moving up or down in the list
       
   127      switch(aKeyEvent.iCode)
       
   128          {
       
   129          case EKeyUpArrow:
       
   130          case EKeyDownArrow:
       
   131              {
       
   132              const CListBoxView::CSelectionIndexArray* inds = iListBox->SelectionIndexes();
       
   133              TInt count = inds->Count();
       
   134              
       
   135              if ( count <= 0 )
       
   136                  {
       
   137                  iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS  );
       
   138                  }
       
   139              else
       
   140                  {
       
   141                  iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL );
       
   142                  }
       
   143              iView.Cba()->DrawDeferred();
       
   144 
       
   145              break;
       
   146              }
       
   147          case EKeyEnter:
       
   148          case EKeyOK: 
       
   149              {
       
   150              const CListBoxView::CSelectionIndexArray* inds = iListBox->SelectionIndexes();
       
   151              TInt count = inds->Count();
       
   152              
       
   153              if ( count <= 0 )
       
   154                  {
       
   155                  SetCurrentItemMarkedL( ETrue );
       
   156                  iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL );
       
   157                  }
       
   158              else
       
   159                  {
       
   160                  MoveMarkedItemL();
       
   161                  iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS  );
       
   162                  }
       
   163              iView.Cba()->DrawDeferred();
       
   164              break;
       
   165              }
       
   166          default:
       
   167              {
       
   168              break;
       
   169              }
       
   170          }
   118     return result;
   171     return result;
   119     }
   172     }
   120 
   173 
   121 void CxSPSortViewControl::SizeChanged()
   174 void CxSPSortViewControl::SizeChanged()
   122     {
   175     {
   135 
   188 
   136 CCoeControl* CxSPSortViewControl::ComponentControl
   189 CCoeControl* CxSPSortViewControl::ComponentControl
   137         (TInt /*aIndex*/) const
   190         (TInt /*aIndex*/) const
   138     {
   191     {
   139     return iListBox;
   192     return iListBox;
       
   193     }
       
   194 
       
   195 void CxSPSortViewControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   196     {
       
   197     if ( iListBox )
       
   198         {
       
   199         iListBox->HandlePointerEventL( aPointerEvent );
       
   200         }
       
   201     }
       
   202 
       
   203 CCoeControl& CxSPSortViewControl::ComponentControl() const
       
   204     {
       
   205     return *iListBox;
   140     }
   206     }
   141 
   207 
   142 void CxSPSortViewControl::SetListBoxContentsL()
   208 void CxSPSortViewControl::SetListBoxContentsL()
   143 	{ 
   209 	{ 
   144 	_LIT( KFormat, "%d" );
   210 	_LIT( KFormat, "%d" );
   279 	
   345 	
   280 	
   346 	
   281 void CxSPSortViewControl::MoveMarkedItemL()
   347 void CxSPSortViewControl::MoveMarkedItemL()
   282 	{
   348 	{
   283 	TInt currentIndex = iListBox->CurrentItemIndex();
   349 	TInt currentIndex = iListBox->CurrentItemIndex();
       
   350 
   284 	TInt markedIndex = -1;
   351 	TInt markedIndex = -1;
   285 	
   352 	
   286 	const CListBoxView::CSelectionIndexArray* inds = iListBox->SelectionIndexes();
   353 	const CListBoxView::CSelectionIndexArray* inds = iListBox->SelectionIndexes();
   287 	TInt count = inds->Count();
   354 	TInt count = inds->Count();
   288 	if( count == 1 ) // sanity check, single selection list should have only one selection
   355 	if( count == 1 ) // sanity check, single selection list should have only one selection