phonebookui/Phonebook2/remotecontactlookup/engine/inc/cpbkxrclsearchresultdlg.h
branchRCL_3
changeset 20 f4a778e096c2
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     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:  Definition of the class CPbkxRclSearchResultDlg.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBKXRCLSEARCHRESULTDIALOG_H
       
    20 #define CPBKXRCLSEARCHRESULTDIALOG_H
       
    21 
       
    22 #include <coemain.h>
       
    23 
       
    24 #include "cpbkxrclbasedlg.h"
       
    25 #include "pbkxrclengineconstants.h"
       
    26 #include "fsccontactactionmenudefines.h"  //"pbkxcontactactionmenudefines.h"
       
    27 
       
    28 class CAknNavigationControlContainer;
       
    29 class CAknNavigationDecorator;
       
    30 class CAknTitlePane;
       
    31 class CContactCard;
       
    32 class CPbkContactEngine;
       
    33 class CPbkxRclActionServiceWrapper;
       
    34 class CPbkxContactActionMenu;
       
    35 class CGulIcon;
       
    36 class CFscContactActionMenu;
       
    37 class CAknLongTapDetector;
       
    38 class CIdle;
       
    39 /**
       
    40 * Dialog for showing remote contact lookup search results.
       
    41 *
       
    42 * Offers menu options and acion menu to initiate actions for contacts.
       
    43 */
       
    44 class CPbkxRclSearchResultDlg : 
       
    45     public CPbkxRclBaseDlg, 
       
    46     public MCoeForegroundObserver,
       
    47     public MEikListBoxObserver, 
       
    48     public MFsActionMenuPositionGiver
       
    49     {                          
       
    50 public: // constructor and destructor
       
    51     
       
    52     /**
       
    53     * Creates new object and returns pointer to it.
       
    54     *
       
    55     * @param aIndex Index which user selected from the list (probably not used?)
       
    56     * @param aArray Array of items.
       
    57     * @param aCommand Command observer for observing menu commands.
       
    58     * @param aContactItems Contact items to be shown on the dialog.
       
    59     * @param aContactEngine Contact engine for creating pbk contact items.
       
    60     * @param aActionService Action service wrapper.
       
    61     * @param aNaviText Navi text to be displayed.
       
    62     * @param aContactSelectorEnabled Flag indicating whether RCL is in contact
       
    63     *                                selector mode or not.
       
    64     * @return Created object.
       
    65     */
       
    66     static CPbkxRclSearchResultDlg* NewL(
       
    67         TInt &aIndex,
       
    68         CDesCArray* aArray,
       
    69         MEikCommandObserver* aCommand,
       
    70         RPointerArray<CContactCard>& aContactItems,
       
    71         CPbkContactEngine& aContactEngine,
       
    72         CPbkxRclActionServiceWrapper& aActionService,
       
    73         TBool aContactSelectorEnabled,
       
    74         TBool aMoreThanMaxResults);
       
    75         
       
    76     /**
       
    77     * Destructor.
       
    78     */
       
    79     virtual ~CPbkxRclSearchResultDlg();
       
    80 
       
    81 public: // methods from base classes
       
    82 
       
    83     /**
       
    84     * Hides menu items that are not usable.
       
    85     *
       
    86     * @param aResourceId Menu resource id.
       
    87     * @param aMenu Menu pane.
       
    88     */
       
    89     virtual void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane *aMenuPane );
       
    90 
       
    91     /**
       
    92     * Gets help context for this view.
       
    93     *
       
    94     * @param aContext On return, contains help context information
       
    95     */
       
    96     virtual void GetHelpContext( TCoeHelpContext& aContext ) const;
       
    97  
       
    98     /**
       
    99     * Dialog is popped on foreground.
       
   100     */
       
   101     virtual void HandleGainingForeground();
       
   102 
       
   103     /**
       
   104     * Dialog is popped background.
       
   105     */
       
   106     virtual void HandleLosingForeground();
       
   107     
       
   108     /**
       
   109     * From MEikListBoxObserver
       
   110     * Handles listbox pointer events
       
   111     */
       
   112     void HandleListBoxEventL(
       
   113             CEikListBox *aListBox, TListBoxEvent aEventType );
       
   114 
       
   115 
       
   116 public: // new methods
       
   117 
       
   118     /**
       
   119     * Executes dialog and destroys it after dialog is closed.
       
   120     */
       
   121     void ExecuteLD();
       
   122 
       
   123     /**
       
   124     * Returns index of the currently selected item.
       
   125     *
       
   126     * @return Index of the currently selected item.
       
   127     */
       
   128     TInt CurrentItemIndex() const;
       
   129 
       
   130     /**
       
   131     * Sets index of the currently selected item.
       
   132     *
       
   133     * @param aIndex Index to be set.
       
   134     */
       
   135     void SetCurrentItemIndexL( TInt aIndex );
       
   136     
       
   137     /**
       
   138     * Sets current contact to action service.
       
   139     *
       
   140     * This affect menu item visibility.
       
   141     */
       
   142     void SetCurrentContactToActionServiceL();
       
   143     
       
   144     /**
       
   145     * Closes dialog.
       
   146     */
       
   147     void Close();
       
   148     
       
   149     /**
       
   150     * Updates search result dialog.
       
   151     *
       
   152     * @param aNaviText New navi text.
       
   153     */
       
   154     void UpdateDialogL();
       
   155     
       
   156     /**
       
   157     * Sends business card of the currently selected contact.
       
   158     */
       
   159     void SendBusinessCardL();
       
   160 
       
   161     //Fix for: PKAO-7NNCJ2
       
   162     /**
       
   163     * Informs dialog that info dialog is visible.
       
   164     */
       
   165     void InfoDlgVisible( TBool aVisible );
       
   166     
       
   167     /**
       
   168      * Set the internal flag telling wether last search found more than
       
   169      * maximum number of results. 
       
   170      * 
       
   171      * @param aMoreThanMax ETrue\EFalse
       
   172      */
       
   173     void SetMoreThanMaxResults(TBool aMoreThanMax);
       
   174     
       
   175     /**
       
   176      * The state of the internal flag telling wether last search
       
   177      * found more than maximum number of results.
       
   178      * 
       
   179      * @return TBool ETrue\EFalse
       
   180      */
       
   181     TBool MoreThanMaxResults();
       
   182 
       
   183 protected: // redefinition of functions of the base class
       
   184 
       
   185     /**
       
   186     * From CAknSelectionListDialog.
       
   187     *
       
   188     * Handles key events.
       
   189     *
       
   190     * @param aKeyEvent Key event.
       
   191     * @param aType Type of the key event.
       
   192     * @return Key response (handled/not handled).
       
   193     */
       
   194     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   195 
       
   196     TBool OkToExitL( TInt aButtonId );
       
   197     
       
   198 private: // methods used internally
       
   199     
       
   200    /**
       
   201     * Sets up title pane text.
       
   202     */
       
   203     void SetTitlePaneTextL();
       
   204     
       
   205     /**
       
   206     * Sets up status pane.
       
   207     */
       
   208     void SetupStatusPaneL();
       
   209     
       
   210     /**
       
   211     * Updates status pane.
       
   212     */
       
   213     void UpdateStatusPaneL();
       
   214 
       
   215     /**
       
   216     * Resets status pane.
       
   217     */
       
   218     void ResetStatusPane();
       
   219 
       
   220     /**
       
   221     * Creates list box entries.
       
   222     */
       
   223     void CreateListBoxEntriesL();
       
   224 
       
   225     /**
       
   226     * Creates given list box entry.
       
   227     *
       
   228     * @param aIndex Index of the list box entry.
       
   229     */
       
   230     void CreateListBoxEntryL( TInt aIndex );
       
   231     
       
   232     /**
       
   233     * Updates given list box entry.
       
   234     *
       
   235     * @param aIndex List box entry index.
       
   236     */
       
   237     void UpdateListBoxEntryL( TInt aIndex );
       
   238 
       
   239     /**
       
   240     * Loads navi text from resources.
       
   241     *
       
   242     * @return Navi text.
       
   243     */
       
   244     void LoadNaviTextL();
       
   245 
       
   246     /**
       
   247     * Returns ETrue if there is at least one call action available.
       
   248     *
       
   249     * @return ETrue if there is at least one call action available.
       
   250     */
       
   251     TBool CallActionsAvailable() const;
       
   252 
       
   253     /**
       
   254     * Creates and initializes action menu.
       
   255     */
       
   256     void InitializeActionMenuL();
       
   257 
       
   258     /**
       
   259     * Shows action menu and handles possible custom command.
       
   260     */
       
   261     void ShowActionMenuL( const TPoint& aPenEventScreenLocation );
       
   262 
       
   263     /**
       
   264     * Calculates action menu position based on currently selected
       
   265     * item.
       
   266     *
       
   267     * @return Action menu position.
       
   268     */
       
   269     TFscContactActionMenuPosition GetActionMenuPosition();
       
   270 
       
   271     /**
       
   272     * Returns ETrue if action menu is available.
       
   273     *
       
   274     * @return ETrue if action menu is available.
       
   275     */
       
   276     TBool ActionMenuAvailable() const;
       
   277 
       
   278     /**
       
   279     * Creates and adds save as contact action to action menu.
       
   280     */
       
   281     void CreateAndAddSaveAsContactActionL();
       
   282 
       
   283     /**
       
   284     * Returns ETrue if scrolling is in progress.
       
   285     *
       
   286     * Scrolling means that user is pressing up or down arrow so that
       
   287     * it creates multiple key presses.
       
   288     *
       
   289     * @return ETrue if scrolling is enabled.
       
   290     */ 
       
   291     TBool ScrollingInProgress() const;
       
   292     
       
   293     /**
       
   294     * This method is called when scrolling has stopped.
       
   295     */
       
   296     void ScrollingStoppedL();
       
   297     
       
   298     /**
       
   299      * Shows a note to user that more than max number of
       
   300      * results found and only N number of those is shown
       
   301      */
       
   302     void DisplayTooManyResultsInfoNoteL();
       
   303 
       
   304 private: // constructors
       
   305 
       
   306     /**
       
   307     * Constructor.
       
   308     *
       
   309     * @param aIndex Index which user selected from the list (probably not used?)
       
   310     * @param aArray Array of items.
       
   311     * @param aCommand Command observer for observing menu commands.
       
   312     * @param aContactItems Contact items to be shown on the dialog.
       
   313     * @param aContactEngine Contact engine for creating pbk contact items.
       
   314     * @param aActionService For executing menu commands.
       
   315     * @param aContactSelectorEnabled Flag indicating whether RCL is in contact
       
   316     *                                selector mode or not.
       
   317     */ 
       
   318     CPbkxRclSearchResultDlg(
       
   319         TInt& aIndex,
       
   320         CDesCArray* aArray,
       
   321         MEikCommandObserver* aCommand,
       
   322         RPointerArray<CContactCard>& aContactItems,
       
   323         CPbkContactEngine& aContactEngine,
       
   324         CPbkxRclActionServiceWrapper& aActionService,
       
   325         TBool aContactSelectorEnabled,
       
   326         TBool aMoreThanMaxResults);
       
   327         
       
   328 
       
   329     /**
       
   330     * Second-phase constructor.
       
   331     *
       
   332     * @param aNaviText Navi text to be displayed.
       
   333     */
       
   334     void ConstructL();
       
   335 
       
   336     /**
       
   337     * Constructs menu bar.
       
   338     * 
       
   339     * @param aResourceId - menubar resource id 
       
   340     */
       
   341     void ConstructMenuBarL( TInt aResourceId );
       
   342   
       
   343 private:
       
   344     
       
   345     /**
       
   346     * From CCoeControl,HandlePointerEventL.
       
   347     */
       
   348     void HandlePointerEventL(const TPointerEvent& aPointerEvent);    
       
   349     
       
   350     
       
   351     /**
       
   352     * From MFsActionMenuPositionGiver
       
   353     */    
       
   354     TPoint ActionMenuPosition();
       
   355     
       
   356     
       
   357     CAknLongTapDetector& LongTapDetectorL();
       
   358     
       
   359     /**
       
   360      * Idle callback for the "more than 50 results" info note.
       
   361      * 
       
   362      * For smooth showing of the note, an idle object is used to
       
   363      * schedule the display of the note.
       
   364      * 
       
   365      * @param aSelf - handle for the object that made the request
       
   366      */
       
   367     static TInt TooManyResultsIdleCallbackL(TAny* aSelf );
       
   368     
       
   369 private: // data
       
   370     
       
   371     // Indexes of icon array.
       
   372     enum TIconIndex
       
   373         {
       
   374         EActionMenuEnabled = 0    // Action menu enabled icon
       
   375         };
       
   376 
       
   377     // Contact engine.
       
   378     CPbkContactEngine& iContactEngine;
       
   379 
       
   380     // Contact action service wrapper. Used to execute menu commands.
       
   381     CPbkxRclActionServiceWrapper& iContactActionService;
       
   382 
       
   383     // Contact action menu for executing commands. Owned.
       
   384     CFscContactActionMenu* iActionMenu;
       
   385     
       
   386     // Items. Not owned.
       
   387     CDesCArray* iItems;
       
   388 
       
   389     // Navi pane of the current UI application. Not owned.
       
   390     CAknNavigationControlContainer* iNaviPane;
       
   391     
       
   392     // Navigation label to be shown while result dialog is shown. Owned.
       
   393     CAknNavigationDecorator* iNaviDecorator;
       
   394     
       
   395     // Contact items. Not owned.
       
   396     RPointerArray<CContactCard>& iContactItems;
       
   397 
       
   398     // Flag indicating if contact selector is enabled.
       
   399     TBool iContactSelectorEnabled;
       
   400 
       
   401     // Flag indicating whether dialog should be closed after processing user command.
       
   402     TBool iClose;
       
   403 
       
   404     // Selected item index.
       
   405     TInt& iSelectedItemIndex;
       
   406 
       
   407     // Navigation label text. Owned.
       
   408     RBuf iNaviText;
       
   409 
       
   410     // Icon for add recipient action menu item. Owned.
       
   411     CGulIcon* iAddRecipientIcon;
       
   412 
       
   413     // Flag indicating whether save as contact action menu item is
       
   414     // already added.
       
   415     TBool iSaveAsAdded;
       
   416 
       
   417     // Set when dialog is exiting. After that no key presses are handled.
       
   418     TBool iExit;
       
   419     
       
   420     // Flag indicating that up or down arrow is held down.
       
   421     TBool iKeyDown;
       
   422 
       
   423     // Counter how many keypresses has occurred since key has been pressed 
       
   424     // down.
       
   425     TInt iKeyCounter;
       
   426 
       
   427     //Fix for: PWAN-7MC7WA
       
   428     //Flag indicating that CAS query was performed
       
   429     TBool iIsScrollLaunched;
       
   430     
       
   431     //Fix for: PKAO-7NNCJ2
       
   432     //Flag indicating that info dialog is visible. Owned.
       
   433     TBool iIsInfoDlgVisible;
       
   434     
       
   435     //Holds the position of the Contact Action Menu
       
   436     TPoint iActionMenuPosition;
       
   437     
       
   438     //ETrue - If Contact Action Menu is being Shown
       
   439     TBool iActionMenuStarted;
       
   440 	
       
   441     ///ETrue - if the more than max results note needs to be shown
       
   442     TBool iMoreThanMaxResults;
       
   443     
       
   444     TBool iFocusableContactPointed;
       
   445     
       
   446     // Title pane text. Owned.
       
   447     HBufC* iTitleText;
       
   448     // Original title pane text (of the caller view). Owned.
       
   449     HBufC* iOriginalTitleText;
       
   450    
       
   451     // Pointer reference to title pane. Not owned.
       
   452     CAknTitlePane* iTitlePane;
       
   453     
       
   454     /// own. idle object for scheduling the showing of the "more than 50 results" 
       
   455     /// info note
       
   456     CIdle* iIdleNote;
       
   457     };
       
   458 
       
   459 #endif