uiservicetab/vimpstui/inc/cvimpstuidoublelistboxtabviewcontrol.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 10:12:18 +0200
changeset 0 5e5d6b214f4f
child 16 d20aea8a18b6
permissions -rw-r--r--
Revision: 201003 Kit: 201005

/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  tabbed view control implementation class with doublestyle listbox 
*
*/

#ifndef     __CVIMPSTUIDOUBLELISTBOXTABVIEWCONTROL_H
#define     __CVIMPSTUIDOUBLELISTBOXTABVIEWCONTROL_H

#include "mvimpstuitabbedviewcontrol.h"
#include "mvimpstprocessArrayobserver.h"
#include "cvimpstuidoublestylelistbox.h"

class CVIMPSTUiDoubleStyleListBox;

// CLASS DECLARATION
/**
 * Tabbed view control. Shows list of contacts.
 *  @lib vimpstui.lib
 *  @since S60 v5.0 
 */
class CVIMPSTUiDoubleListBoxTabViewControl :public CCoeControl,
								            public MVIMPSTProcessArrayObserver,
								            public MEikListBoxObserver,
        									public MCoeControlObserver,
        									public MVIMPSTUiTabbedViewControl
    {
    public: // Constructor and destructor
        /**
         * Creates a new CImContactsTabbedViewControl.
         *
         * @param aTabbedView reference to view.
         * @param aKeyEventHandler Key event handler to be used
         * @param aCommandHandler reference to commandhandler
         * @param aServiceId Id of the service
         * @param aBrandHandler reference to brandhandler
         * @param aEngine reference to engine
         */
        static CVIMPSTUiDoubleListBoxTabViewControl* NewL( CVIMPSTUiTabbedView& aTabbedView, MPbk2KeyEventHandler* aKeyEventHandler, 
        										MVIMPSTCmdHandler& aCommandHandler,
        										TUint32 aServiceId,
        										CVIMPSTUiBrandData& aBrandHandler,
        										MVIMPSTEngine& aEngine );
        
        /**
         * Creates a new CImContactsTabbedViewControl and leaves it to
         * cleanup stack.
         * @see NewL
         *
         * @param aTabbedView reference to view.
         * @param aKeyEventHandler Key event handler to be used
         * @param aCommandHandler reference to commandhandler
         * @param aServiceId Id of the service
         * @param aBrandHandler reference to brandhandler
         * @param aEngine reference to engine
         */
        static CVIMPSTUiDoubleListBoxTabViewControl* NewLC( CVIMPSTUiTabbedView& aTabbedView,MPbk2KeyEventHandler* aKeyEventHandler,
        											MVIMPSTCmdHandler& aCommandHandler,
        											TUint32 aServiceId,
        											CVIMPSTUiBrandData& aBrandHandler,
        											MVIMPSTEngine& aEngine  );
        
        /**
         * Destructor.
         */
        ~CVIMPSTUiDoubleListBoxTabViewControl();
    
    public : // from MIMArrayProcessObserver
        /**
         * @see MIMArrayProcessObserver.
         */
        void HandleAdditionL(TVIMPSTEnums::TItem type, TInt aIndex);
        
       	 /**
          * @see MIMArrayProcessObserver.
          */
     	void HandleDeletionL(TVIMPSTEnums::TItem type, TInt aIndex);
     	/**
     	 * @see MIMArrayProcessObserver.
     	 */
     	void  HandleAvatarChangeL( const TDesC& aUserId );

    public://from MEikListBoxObserver
    
		/**
         * From MEikListBoxObserver, Handles event's generated by listbox
		 * @see MEikListBoxObserver
         */
		void HandleListBoxEventL( CEikListBox* aListBox,
			TListBoxEvent aEventType );
    
    public: //from MCoeControlObserver
    	/**
	     * Handles events from findpane and forwards them to listbox filter.
	     * @see MCoeControlObserver
	     */
	    void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType );
	    
    
        /**
         * Get access to listbox model's filter
         * @return model's filter
         */                     
        CAknListBoxFilterItems* ListFilter();
        
     
    public: // New functions
        
        /**
         * Returns the currently focused item's index.
         * @return TInt, current item index.
         */
        TInt CurrentItemIndex() const;
        
        /**
         * Sets the currently focused item's index.
         *
         * @param aIndex new currently focused index
         */
        void SetCurrentItemIndex( TInt aIndex );
        
		/**
         * Sets the currently focused item's index and updates the control
         * on the display.
         *
         * @param aIndex new currently focused index
         */
        void SetCurrentItemIndexAndDraw( TInt aIndex );
        
        /**
         * Handles item addition for this control.
         */
        void HandleItemAdditionL();
        
        /**
         * Handles item removal for this control.
         */
        void HandleItemRemovalL();

        /**
         * Sets list box empty text.
         *
         * @param aResourceId resource id of a empty text
         */
        void SetListEmptyTextL( TInt aResourceId );
        
        /**
         * send the message using selected item
         * this will launch the conversation view if im is enabled.
         */
        void SendMessageL();
        
        /**
         * Updates view after edit.
         * @param aIndex is the index of item that has changed.
         * @param aType is list item type. 
         */
        void UpdateViewL( TInt aIndex, TVIMPSTEnums::TItem aType);
        
        
     	/**
     	 * @see MVIMPSTUiTabbedViewControl.
     	 */
		void HandleAvatarDeleteL( const TDesC& aUserId );

        /**
	     * LoadsBitmap array.
	     */	
        void LoadBitmapsL();
        
     
        
        /**
         * Gets the owned listbox control
         *
         * @return the owned list box
         */
        CVIMPSTUiDoubleStyleListBox& ListBox() const;
        
        /**
        * Activates find-pane
		*/
		void ActivateFindPaneL();

        /**
        * De-activates find-pane
		*/
		void DeactivateFindPaneL();
		
	   /**
		*Handle the avatar deletion in UI
		*/
		void SetFocussedId(const TDesC& aContact)  ;

		/**
		* the avatar deletion in UI
		*/
		TPtrC GetFocussedId() ;
		
    private: // From CCoeControl, standard control functionality
        
        /**
         * @see CCoeControl
         */
        TKeyResponse OfferKeyEventL
            ( const TKeyEvent& aKeyEvent, TEventCode aType );
        
        /**
         * @see CCoeControl
         */
        void SizeChanged();
        
        /**
         * @see CCoeControl
         */
        TInt CountComponentControls() const;
        
        /**
         * @see CCoeControl
         */
        CCoeControl* ComponentControl( TInt aIndex ) const;
        
        /**
         * @see CCoeControl
         */
        void FocusChanged( TDrawNow aDrawNow );
           

    private: // Implementation
        /**
         * Standard C++ constructor
         *
         * @param aTabbedView reference to view.
         * @param aKeyEventHandler Key event handler to be used
         * @param aCommandHandler reference to commandhandler
         * @param aServiceId Id of the service
         * @param aBrandHandler reference to brandhandler
         * @param aEngine reference to engine
         */    
        CVIMPSTUiDoubleListBoxTabViewControl(   CVIMPSTUiTabbedView& aTabbedView,MPbk2KeyEventHandler* aKeyEventHandler,
                    							MVIMPSTCmdHandler& aCommandHandler,
                    							TUint32 aServiceId,
                    							CVIMPSTUiBrandData& aBrandHandler,
                    							MVIMPSTEngine& aEngine );
        
        /**
         * Performs the 2nd phase of construction.
         * 
         */        
        void ConstructL();
		
		/**
         * Layouts current components according to AVKON LAF
		 */
		void SetLayout();
		
		/**
		 *  NOTE : PASSING NULL DESCRIPTOR IS NOT ALLOWED  
		 *  NO CHECK FOR THE NULL DESCPRIPTOR
		 * 
		 *  Utility function to create Icons from
		 *  image data using Image processor
		 * 
		 * @param aAvatarContent : avatar content 
		 * 
		 * @return  CGulIcon icon created , returns NULL in case of errors
		 */
		CGulIcon*  AvatarToIconL( const TDesC8& aAvatarContent );
		
		
		void SetFocusAndMakeItemVisible();
		
    public:
        
        /**
        * Sets the iClrFindPaneFlag
        */
        void SetClrFindPaneFlag(TBool aFlag);
        
        /**
        * Checks if the last contact is focused and Sets the iLastItemFlag
        */            
        void CheckAndSetLastItemFlag(); 
     
        /**
         * returns the CCoeControl* pointer
         */
        CCoeControl* CoeControl();
        
        /**
         * Sets the lock status of softkeys
         * @param aLock new status of lock (ETrue: locked, EFalse: Unlocked)
         */                     
        void SetCbaLockL( TBool aLock );

        /**
         * Updates Softkeys according to current focus
         * @param aUseDefaultCba Flag to force the default sofkeys for view.
         * Default value is false.
         */                     
        void UpdateCbaL( TBool aUseDefaultCba = EFalse );

		
    private: // Data
    
    	// not owned
    	 CVIMPSTUiTabbedView& iTabbedView;
    	 
    	// Not owned: key event handler
    	MPbk2KeyEventHandler* iKeyEventHandler;
    	
    	//Holds the Ref to CMd Handler - Doesnt Own
    	MVIMPSTCmdHandler& iCommandHandler;
    	
    	//Doesnt Own
        MVIMPSTProcessArray& iArrayProcess;         
         
        //Service Id 
		TUint32 iServiceId ;
		
		//doesnt own - Brand Handler
		CVIMPSTUiBrandData& iBrandHandler;
		
		//doesnt own - Engine Handler
		MVIMPSTEngine& iEngine;
		   	
        // Owns. Listbox to view friends-list data
        CVIMPSTUiDoubleStyleListBox* iListBox;
         
        // Owns. Search field.
		CAknSearchField* iFindbox;
		
		// is find pane visible.
        TBool iFindPaneIsVisible;
        
        //current state
        TBool iCurrentState;
        
          // Owns: Flag to check whether the last contact was selected
        TBool iLastItemFlag;
   
        CFbsBitmap* iBitmap;  
       
        TInt iAvatarError;
        
        // CBA. not owned
        CEikButtonGroupContainer* iCba;     

        // Lock status foc softkeys
        TBool iCbaLock;
        
        // Storage for previous focus
        TVIMPSTEnums::TItem iLastFocusedItemType;
        
        //flag to check to clear find pane
        TBool iClrFindPaneFlag;
		
		//indicate command to be executed on enter key Event.
		TInt iCurrentCmdToExe;
        

    };

#endif // __CVIMPSTUIDOUBLELISTBOXTABVIEWCONTROL_H

// End of file