uifw/AvKon/src/aknlistquerydialog.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 10 9f56a4e1b8ab
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
    55 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    55 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    56 #include <uikon/eikenvinterface.h>
    56 #include <uikon/eikenvinterface.h>
    57 #endif
    57 #endif
    58 
    58 
    59 #include <AknTasHook.h> // for testability hooks
    59 #include <AknTasHook.h> // for testability hooks
       
    60 #include "akntrace.h"
    60 NONSHARABLE_CLASS(CAknListQueryMediatorObserver): public CBase, public MAknDialogMediatorObserver
    61 NONSHARABLE_CLASS(CAknListQueryMediatorObserver): public CBase, public MAknDialogMediatorObserver
    61     {
    62     {
    62 public:
    63 public:
    63     CAknListQueryMediatorObserver(CArrayFixFlat<TInt>* aItemIdArray, CAknListQueryDialog& aOwner)
    64     CAknListQueryMediatorObserver(CArrayFixFlat<TInt>* aItemIdArray, CAknListQueryDialog& aOwner)
    64         :iItemIdArray(aItemIdArray), iOwner(aOwner)
    65         :iItemIdArray(aItemIdArray), iOwner(aOwner)
   158     }
   159     }
   159 
   160 
   160 EXPORT_C CAknListQueryDialog::CAknListQueryDialog(TInt* aIndex)
   161 EXPORT_C CAknListQueryDialog::CAknListQueryDialog(TInt* aIndex)
   161 	: CAknQueryDialog(ENoTone)
   162 	: CAknQueryDialog(ENoTone)
   162     {
   163     {
       
   164 	_AKNTRACE_FUNC_ENTER;
   163     iIndex = aIndex;
   165     iIndex = aIndex;
   164     iEnterKeyPressed = EFalse;
   166     iEnterKeyPressed = EFalse;
   165 
   167 
   166     GfxTransEffect::Register(this,KGfxContextMenuControlUid);
   168     GfxTransEffect::Register(this,KGfxContextMenuControlUid);
   167     AKNTASHOOK_ADD( this, "CAknListQueryDialog" );
   169     AKNTASHOOK_ADD( this, "CAknListQueryDialog" );
       
   170     _AKNTRACE_FUNC_EXIT;
   168     }
   171     }
   169 
   172 
   170 
   173 
   171 EXPORT_C CAknListQueryDialog::CAknListQueryDialog(CListBoxView::CSelectionIndexArray* aSelectionIndexArray)
   174 EXPORT_C CAknListQueryDialog::CAknListQueryDialog(CListBoxView::CSelectionIndexArray* aSelectionIndexArray)
   172 	: CAknQueryDialog(ENoTone)
   175 	: CAknQueryDialog(ENoTone)
   173 	{
   176 	{
       
   177 	_AKNTRACE_FUNC_ENTER;
   174     iSelectionIndexArray = aSelectionIndexArray;
   178     iSelectionIndexArray = aSelectionIndexArray;
   175     iEnterKeyPressed = EFalse;
   179     iEnterKeyPressed = EFalse;
   176 
   180 
   177     GfxTransEffect::Register(this,KGfxContextMenuControlUid);
   181     GfxTransEffect::Register(this,KGfxContextMenuControlUid);
   178     AKNTASHOOK_ADD( this, "CAknListQueryDialog" );
   182     AKNTASHOOK_ADD( this, "CAknListQueryDialog" );
       
   183     _AKNTRACE_FUNC_EXIT;
   179     }
   184     }
   180 
   185 
   181 EXPORT_C CAknListQueryDialog::~CAknListQueryDialog()
   186 EXPORT_C CAknListQueryDialog::~CAknListQueryDialog()
   182     {
   187     {
       
   188 	_AKNTRACE( "[%s][%s] Enter", "CAknListQueryDialog", "~CAknListQueryDialog" );
   183     AKNTASHOOK_REMOVE();
   189     AKNTASHOOK_REMOVE();
   184     if (iMediatorObs)
   190     if (iMediatorObs)
   185         CEikDialog::SetMediatorObserver(0); // Cover UI support cannot handle dialog it self as external observer  
   191         CEikDialog::SetMediatorObserver(0); // Cover UI support cannot handle dialog it self as external observer  
   186     
   192     
   187     delete iMediatorObs;
   193     delete iMediatorObs;
   188 	delete iIdle;
   194 	delete iIdle;
       
   195 	_AKNTRACE( "[%s][%s] Exit", "CAknListQueryDialog", "~CAknListQueryDialog" );
   189     }
   196     }
   190 
   197 
   191 EXPORT_C CEikListBox *CAknListQueryDialog::ListBox() const 
   198 EXPORT_C CEikListBox *CAknListQueryDialog::ListBox() const 
   192     {
   199     {
   193     return ListControl()->Listbox();
   200     return ListControl()->Listbox();
   230 	}
   237 	}
   231 
   238 
   232 
   239 
   233 EXPORT_C void CAknListQueryDialog::PreLayoutDynInitL()
   240 EXPORT_C void CAknListQueryDialog::PreLayoutDynInitL()
   234     {
   241     {
       
   242     _AKNTRACE_FUNC_ENTER;
   235 	CAknListQuerySearchControl *control1 = (CAknListQuerySearchControl*)ControlOrNull(EFindControl);
   243 	CAknListQuerySearchControl *control1 = (CAknListQuerySearchControl*)ControlOrNull(EFindControl);
   236     CAknSearchField *control = NULL;
   244     CAknSearchField *control = NULL;
   237     CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EPopupWindow;
   245     CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EPopupWindow;
   238 
   246 
   239     if (control1)
   247     if (control1)
   265 		// The next line is needed so that drawing order of list query control and find pane becomes
   273 		// The next line is needed so that drawing order of list query control and find pane becomes
   266 		// correct. Seems that dialog page draws focused line last.
   274 		// correct. Seems that dialog page draws focused line last.
   267 		SetLineNonFocusing(EListQueryControl);
   275 		SetLineNonFocusing(EListQueryControl);
   268 		Line(EFindControl)->SetDrawNoWhiteBackground(ETrue);
   276 		Line(EFindControl)->SetDrawNoWhiteBackground(ETrue);
   269         }        
   277         }        
       
   278     _AKNTRACE_FUNC_EXIT;
   270 	}
   279 	}
   271 
   280 
   272 EXPORT_C void CAknListQueryDialog::SetIconArrayL(CArrayPtr<CGulIcon>* aIcons)
   281 EXPORT_C void CAknListQueryDialog::SetIconArrayL(CArrayPtr<CGulIcon>* aIcons)
   273     {
   282     {
       
   283     _AKNTRACE_FUNC_ENTER;
   274 	CEikFormattedCellListBox* listbox = STATIC_CAST(CEikFormattedCellListBox*,ListBox());
   284 	CEikFormattedCellListBox* listbox = STATIC_CAST(CEikFormattedCellListBox*,ListBox());
   275     CArrayPtr<CGulIcon>* oldicons = listbox->ItemDrawer()->FormattedCellData()->IconArray();
   285     CArrayPtr<CGulIcon>* oldicons = listbox->ItemDrawer()->FormattedCellData()->IconArray();
   276     
   286     
   277 	if (oldicons)
   287 	if (oldicons)
   278         {
   288         {
   279         oldicons->ResetAndDestroy();
   289         oldicons->ResetAndDestroy();
   280         delete oldicons;
   290         delete oldicons;
   281         }
   291         }
   282     listbox->ItemDrawer()->FormattedCellData()->SetIconArrayL(aIcons);
   292     listbox->ItemDrawer()->FormattedCellData()->SetIconArrayL(aIcons);
       
   293     _AKNTRACE_FUNC_EXIT;
   283     }
   294     }
   284 
   295 
   285 EXPORT_C void CAknListQueryDialog::PostLayoutDynInitL()
   296 EXPORT_C void CAknListQueryDialog::PostLayoutDynInitL()
   286     {
   297     {
       
   298     _AKNTRACE_FUNC_ENTER;
   287 	CEikFormattedCellListBox* listbox = STATIC_CAST(CEikFormattedCellListBox*,ListBox());
   299 	CEikFormattedCellListBox* listbox = STATIC_CAST(CEikFormattedCellListBox*,ListBox());
   288     
   300     
   289 	// Now we'll load default icons if existing icon array does not exists.
   301 	// Now we'll load default icons if existing icon array does not exists.
   290     if (!listbox->ItemDrawer()->FormattedCellData()->IconArray())
   302     if (!listbox->ItemDrawer()->FormattedCellData()->IconArray())
   291         {
   303         {
   314         listbox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
   326         listbox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
   315         CleanupStack::Pop(); // icon for EMbmAvkonQgn_prop_checkbox_off
   327         CleanupStack::Pop(); // icon for EMbmAvkonQgn_prop_checkbox_off
   316         CleanupStack::Pop(); // icon for EMbmAvkonQgn_prop_checkbox_on
   328         CleanupStack::Pop(); // icon for EMbmAvkonQgn_prop_checkbox_on
   317         CleanupStack::Pop(); // icons array
   329         CleanupStack::Pop(); // icons array
   318         }
   330         }
       
   331     _AKNTRACE_FUNC_EXIT;
   319     }
   332     }
   320 
   333 
   321 EXPORT_C void CAknListQueryDialog::SetSizeAndPosition(const TSize & /*aSize*/)
   334 EXPORT_C void CAknListQueryDialog::SetSizeAndPosition(const TSize & /*aSize*/)
   322     {
   335     {
       
   336     _AKNTRACE_FUNC_ENTER;
   323     AknPopupLayouts::TAknPopupLayouts layout = AknPopupLayouts::EMenuWindow;
   337     AknPopupLayouts::TAknPopupLayouts layout = AknPopupLayouts::EMenuWindow;
   324     CAknListQueryControl *control = ListControl();
   338     CAknListQueryControl *control = ListControl();
   325     
   339     
   326     switch(control->Listtype())
   340     switch(control->Listtype())
   327         {
   341         {
   406     TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
   420     TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
   407     TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
   421     TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
   408 
   422 
   409     boxData->SetSkinPopupFrame(&KAknsIIDQsnFrPopup,&KAknsIIDQsnFrPopupCenter);
   423     boxData->SetSkinPopupFrame(&KAknsIIDQsnFrPopup,&KAknsIIDQsnFrPopupCenter);
   410     boxData->SetSkinPopupFramePosition(outerRect,innerRect);
   424     boxData->SetSkinPopupFramePosition(outerRect,innerRect);
   411 
   425     _AKNTRACE_FUNC_EXIT;
   412     }
   426     }
   413     
   427     
   414 EXPORT_C void CAknListQueryDialog::HandleListBoxEventL(CEikListBox* aListBox, 
   428 EXPORT_C void CAknListQueryDialog::HandleListBoxEventL(CEikListBox* aListBox, 
   415                                                        TListBoxEvent aEventType)
   429                                                        TListBoxEvent aEventType)
   416     {
   430     {
       
   431 	_AKNTRACE( "[%s][%s] aEventType: %d", "CAknListQueryDialog", "HandleListBoxEventL", aEventType);
   417     if ( AknLayoutUtils::PenEnabled() )
   432     if ( AknLayoutUtils::PenEnabled() )
   418         {
   433         {
   419         switch(aEventType)
   434         switch(aEventType)
   420             {
   435             {
   421             case EEventEnterKeyPressed:
   436             case EEventEnterKeyPressed:
   468     			{
   483     			{
   469     			break;
   484     			break;
   470     			}
   485     			}
   471     		}
   486     		}
   472         }
   487         }
       
   488     _AKNTRACE_FUNC_EXIT;
   473     }
   489     }
   474 
   490 
   475 
   491 
   476 // -----------------------------------------------------------------------------
   492 // -----------------------------------------------------------------------------
   477 // If a parent to the supplied control has its Gc set, this function will find 
   493 // If a parent to the supplied control has its Gc set, this function will find 
   503     }
   519     }
   504 
   520 
   505 EXPORT_C TKeyResponse CAknListQueryDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,
   521 EXPORT_C TKeyResponse CAknListQueryDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,
   506                                                           TEventCode aType)
   522                                                           TEventCode aType)
   507     {
   523     {
       
   524 	_AKNTRACE( "[%s][%s] aKeyEvent.iCode: %d", "CAknListQueryDialog", "OfferKeyEventL", aKeyEvent.iCode);
       
   525 	_AKNTRACE( "[%s][%s] aType: %d", "CAknListQueryDialog", "OfferKeyEventL", aType);
   508     if (aType==EEventKey && aKeyEvent.iCode == EKeyEscape)
   526     if (aType==EEventKey && aKeyEvent.iCode == EKeyEscape)
   509         {
   527         {
   510         CloseState();
   528         CloseState();
   511         return EKeyWasConsumed;
   529         return EKeyWasConsumed;
   512         }
   530         }
   588     STATIC_CAST(CTextListBoxModel*,ListBox()->Model())->SetOwnershipType(aOwnershipType);
   606     STATIC_CAST(CTextListBoxModel*,ListBox()->Model())->SetOwnershipType(aOwnershipType);
   589     }
   607     }
   590 
   608 
   591 EXPORT_C TBool CAknListQueryDialog::OkToExitL(TInt aButtonId)
   609 EXPORT_C TBool CAknListQueryDialog::OkToExitL(TInt aButtonId)
   592     {   
   610     {   
       
   611 	_AKNTRACE( "[%s][%s] aButtonId: %d", "CAknListQueryDialog", "OkToExitL", aButtonId);
   593     CEikListBox* listbox = ListBox();
   612     CEikListBox* listbox = ListBox();
   594 
   613 
   595     if(aButtonId == GetLeftCBAShortKeyPress() || aButtonId == EEikBidOk)
   614     if(aButtonId == GetLeftCBAShortKeyPress() || aButtonId == EEikBidOk)
   596         {
   615         {
   597         if(iIndex)
   616         if(iIndex)
   615 	        TInt numberOfItems(array->Count());
   634 	        TInt numberOfItems(array->Count());
   616 	        iSelectionIndexArray->Reset();
   635 	        iSelectionIndexArray->Reset();
   617 	        for(TInt i(0); i<numberOfItems; i++)
   636 	        for(TInt i(0); i<numberOfItems; i++)
   618 	            iSelectionIndexArray->AppendL(array->At(i));
   637 	            iSelectionIndexArray->AppendL(array->At(i));
   619             }
   638             }
       
   639         _AKNTRACE( "[%s][%s] return ETrue", "CAknListQueryDialog", "OkToExitL");
   620         return ETrue;
   640         return ETrue;
   621         }
   641         }
   622     else if(aButtonId == GetRightCBAShortKeyPress())
   642     else if(aButtonId == GetRightCBAShortKeyPress())
   623         return ETrue;
   643     	{
       
   644 		_AKNTRACE( "[%s][%s] return ETrue", "CAknListQueryDialog", "OkToExitL");
       
   645 		return ETrue;
       
   646     	}
       
   647     _AKNTRACE( "[%s][%s] return EFalse", "CAknListQueryDialog", "OkToExitL");
   624     return EFalse;
   648     return EFalse;
   625     }
   649     }
   626 
   650 
   627 EXPORT_C TInt CAknListQueryDialog::BorderStyle()
   651 EXPORT_C TInt CAknListQueryDialog::BorderStyle()
   628     {
   652     {
   633 #endif
   657 #endif
   634     }
   658     }
   635 
   659 
   636 EXPORT_C void CAknListQueryDialog::CloseState()
   660 EXPORT_C void CAknListQueryDialog::CloseState()
   637     {
   661     {
       
   662     _AKNTRACE_FUNC_ENTER;
   638     TRAP_IGNORE(TryExitL(EAknSoftkeyCancel));
   663     TRAP_IGNORE(TryExitL(EAknSoftkeyCancel));
       
   664     _AKNTRACE_FUNC_EXIT;
   639     }
   665     }
   640 
   666 
   641 EXPORT_C void CAknListQueryDialog::ActivateL()
   667 EXPORT_C void CAknListQueryDialog::ActivateL()
   642     {
   668     {
       
   669     _AKNTRACE_FUNC_ENTER;
   643     TBool notShowingPopup = ListBox()->Model()->NumberOfItems() == 0;
   670     TBool notShowingPopup = ListBox()->Model()->NumberOfItems() == 0;
   644     if (notShowingPopup)
   671     if (notShowingPopup)
   645         {
   672         {
   646         // We do not show if there's no list items.
   673         // We do not show if there's no list items.
   647         MakeVisible(EFalse);
   674         MakeVisible(EFalse);
   668         }
   695         }
   669     else
   696     else
   670         {
   697         {
   671         CAknQueryDialog::ActivateL();
   698         CAknQueryDialog::ActivateL();
   672         }
   699         }
       
   700     _AKNTRACE_FUNC_EXIT;
   673     }
   701     }
   674 
   702 
   675 TInt CAknListQueryDialog::ClosePopup(TAny *aObj)
   703 TInt CAknListQueryDialog::ClosePopup(TAny *aObj)
   676     {
   704     {
       
   705     _AKNTRACE_FUNC_ENTER;
   677     CAknListQueryDialog *popup = (CAknListQueryDialog*)aObj;
   706     CAknListQueryDialog *popup = (CAknListQueryDialog*)aObj;
   678     delete popup->iIdle;
   707     delete popup->iIdle;
   679     popup->iIdle = 0;
   708     popup->iIdle = 0;
   680     popup->CloseState();
   709     popup->CloseState();
       
   710     _AKNTRACE_FUNC_EXIT;
   681     return EFalse;
   711     return EFalse;
   682     }
   712     }
   683     
   713     
   684 EXPORT_C void CAknListQueryDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
   714 EXPORT_C void CAknListQueryDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
   685     {
   715     {
   718 // ---------------------------------------------------------
   748 // ---------------------------------------------------------
   719 //
   749 //
   720 
   750 
   721 TInt CAknListQueryDialog::ClosePopupAcceptingChanges(TAny *aObj)
   751 TInt CAknListQueryDialog::ClosePopupAcceptingChanges(TAny *aObj)
   722     {    
   752     {    
       
   753 	_AKNTRACE_FUNC_ENTER;
   723     if ( AknLayoutUtils::PenEnabled() ) 
   754     if ( AknLayoutUtils::PenEnabled() ) 
   724         {
   755         {
   725         CAknListQueryDialog *popup = (CAknListQueryDialog*)aObj;
   756         CAknListQueryDialog *popup = (CAknListQueryDialog*)aObj;
   726         delete popup->iIdle;
   757         delete popup->iIdle;
   727         popup->iIdle = NULL;
   758         popup->iIdle = NULL;
   728         TRAP_IGNORE( popup->TryExitL( EAknSoftkeyOk ) );
   759         TRAP_IGNORE( popup->TryExitL( EAknSoftkeyOk ) );
       
   760         _AKNTRACE_FUNC_EXIT;
   729         return EFalse;
   761         return EFalse;
   730         }
   762         }
   731     else
   763     else
   732         {
   764         {
       
   765 		_AKNTRACE_FUNC_EXIT;
   733         return EFalse;
   766         return EFalse;
   734         }
   767         }
   735     }
   768     }
   736 
   769 
   737 
   770 
   768 	iTone = (TTone)aTone;
   801 	iTone = (TTone)aTone;
   769 	}
   802 	}
   770 
   803 
   771 EXPORT_C void CAknListQueryDialog::HandleResourceChange(TInt aType)
   804 EXPORT_C void CAknListQueryDialog::HandleResourceChange(TInt aType)
   772 	{
   805 	{
       
   806 	_AKNTRACE_FUNC_ENTER;
   773 	if (aType==KEikDynamicLayoutVariantSwitch)
   807 	if (aType==KEikDynamicLayoutVariantSwitch)
   774 	    {
   808 	    {
   775 	    if (MessageBox())
   809 	    if (MessageBox())
   776 	        {
   810 	        {
   777 	        MessageBox()->SizeChanged();	    
   811 	        MessageBox()->SizeChanged();	    
   778 	        }		
   812 	        }		
   779 	    }	    
   813 	    }	    
   780 	CAknQueryDialog::HandleResourceChange(aType);	
   814 	CAknQueryDialog::HandleResourceChange(aType);
       
   815 	_AKNTRACE_FUNC_EXIT;
   781 	}
   816 	}
   782     
   817     
   783 EXPORT_C void CAknListQueryDialog::PublishDialogL(TInt aDialogIndex, TUid aCatUid, CArrayFixFlat<TInt>* aItemIds)
   818 EXPORT_C void CAknListQueryDialog::PublishDialogL(TInt aDialogIndex, TUid aCatUid, CArrayFixFlat<TInt>* aItemIds)
   784     {
   819     {
   785     CEikDialog::PublishDialogL(aDialogIndex, aCatUid);
   820     CEikDialog::PublishDialogL(aDialogIndex, aCatUid);