calendarui/controller/inc/calenmultipledbui.h
branchRCL_3
changeset 66 bd7edf625bdd
child 67 1539a383d7b6
child 86 ed599363c2d7
equal deleted inserted replaced
65:12af337248b1 66:bd7edf625bdd
       
     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:  Container base class of Calendar application.
       
    15  *                This class is the derivation origin of Calendar container.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CALENMULTIDBUI_H_
       
    21 #define CALENMULTIDBUI_H_
       
    22 
       
    23 // System includes.
       
    24 #include <AknDialog.h>
       
    25 #include <coemain.h>
       
    26 #include <eiklbo.h>
       
    27 #include <aknlists.h>
       
    28 #include <calenservices.h>
       
    29 
       
    30 #include <calennotificationhandler.h>
       
    31 
       
    32 // User includes. 
       
    33 #include "calencontroller.h" 
       
    34 
       
    35 // Forward declarations.
       
    36 class CEikColumnListBox;
       
    37 class TAknsItemID;
       
    38 class CAknIconArray;
       
    39 class CAknSingleGraphicHeadingStyleListBox;
       
    40 class CAknsBasicBackgroundControlContext;
       
    41 class CAknNavigationControlContainer;
       
    42 class CAknToolbar;
       
    43 class CAknButton;
       
    44 class CCalenMultipleDbListbox;
       
    45 class CCalenMultiDBEditor;
       
    46 
       
    47 class CCalenMultipleDbUi : public CAknDialog,
       
    48                            public MEikListBoxObserver,
       
    49                            public MCalenNotificationHandler
       
    50     {
       
    51 private:
       
    52     
       
    53     /**
       
    54      * @brief Default constructor
       
    55      * 
       
    56      * @param aController reference to the controller
       
    57      */
       
    58     CCalenMultipleDbUi(CCalenController& aController );
       
    59     
       
    60     /**
       
    61      * @brief second phase constructor
       
    62      */
       
    63     void ConstructL();
       
    64     
       
    65 public:
       
    66     
       
    67     /**
       
    68      * @brief first phase construction
       
    69      * 
       
    70      * @aController reference to the controller 
       
    71      */
       
    72     static CCalenMultipleDbUi* NewL( CCalenController& aController );
       
    73     
       
    74     /**
       
    75      * @brief destructor
       
    76      */
       
    77     ~CCalenMultipleDbUi();
       
    78     
       
    79     /**
       
    80     * @brief From CAknDialog.Handles focus change
       
    81     * 
       
    82     * @param aDrawNow draw status from CAknDialog.
       
    83     */ 
       
    84     void FocusChanged( TDrawNow aDrawNow );
       
    85     
       
    86 protected:
       
    87     /**
       
    88     * @brief From CEikDialog.Dynamic initialization of the menu pane
       
    89     *
       
    90     * @param aResourceId menu pane resource
       
    91     * @param aMenuPane pointer to the menupane
       
    92     */ 
       
    93     void DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane ) ;
       
    94 
       
    95    /**
       
    96     * @brief From MEikMenuObserver.Handles the commands in dialog
       
    97     *
       
    98     * @param aCommandId Not used.
       
    99     */ 
       
   100     void ProcessCommandL( TInt aCommandId ) ;
       
   101    
       
   102     /** 
       
   103     * @brief From CCoeControl.Handles key events.
       
   104     *
       
   105     * @aKeyEvent key event generated
       
   106     * @aType type of the event code 
       
   107     */
       
   108     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) ;
       
   109    
       
   110     /** 
       
   111      * @brief From CCoeControl.Handles pointer events
       
   112      *
       
   113      * aPointerEvent reference to the pointer event
       
   114      */
       
   115     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   116     
       
   117     /**
       
   118      * @brief From CEikDialog.Handles a dialog button press 
       
   119      * for the specified button. 
       
   120      *
       
   121      * @aButtonId soft key pressed 
       
   122      * @return  
       
   123      */
       
   124     TBool OkToExitL( TInt aButtonId ) ;
       
   125     
       
   126     /** 
       
   127     * brief From MObjectProvider. 
       
   128     * Gets Mop supply object of the given type.  
       
   129     *
       
   130     * @param aId Identifier for the supply object.
       
   131     * @return Pointer to the supply object type ID.
       
   132     */
       
   133     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   134     
       
   135     /**
       
   136     * brief From CEikDialog.Prepare of controls
       
   137     */
       
   138     void PreLayoutDynInitL();
       
   139     
       
   140     /**
       
   141     * From @c CEikDialog.
       
   142     * 
       
   143     **/
       
   144     void PostLayoutDynInitL();
       
   145     
       
   146     /**
       
   147     * From @c CCoeControl.
       
   148     * Called when controls extent is set.
       
   149     **/
       
   150     void SizeChanged();
       
   151     
       
   152     /**
       
   153     * From @c CCoeControl.
       
   154     **/ 
       
   155     void HandleResourceChange(TInt aType);
       
   156     
       
   157     /**
       
   158     * From @c CCoeControl.
       
   159     * 
       
   160     * @param aIndex index of the control
       
   161     * @return Pointer to the Control.
       
   162     **/
       
   163     CCoeControl* ComponentControl( TInt aIndex) const;
       
   164     
       
   165     /**
       
   166     * From @c CCoeControl.
       
   167     * 
       
   168     * @return Pointer to the Control.
       
   169     **/
       
   170     TInt CountComponentControls() const;
       
   171     
       
   172     
       
   173     /**
       
   174     * From @c CCoeControl.
       
   175     * 
       
   176     * @param aRect
       
   177     **/
       
   178     void Draw(const TRect &aRect) const;
       
   179     
       
   180     
       
   181     
       
   182 private: //Internal
       
   183     
       
   184     /*
       
   185      * Construction of listbox ui
       
   186      * @return void
       
   187      */
       
   188     void ConstructListL();
       
   189     
       
   190     /* 
       
   191      * Update listbox contents 
       
   192      * @return void
       
   193      */
       
   194     void UpdateListboxL();
       
   195     
       
   196     /*
       
   197      * setup title pane for the status pane
       
   198      * @return void 
       
   199      */
       
   200     void SetTitlePaneL();  
       
   201     
       
   202     /*
       
   203      * Create icons based on MCalenServices::TCalenIcon indices
       
   204      * @param aIndexArray MCalenServices::TCalenIcons array for services
       
   205      * @return CAknIconArray* pointer to array of icons
       
   206      */
       
   207     CAknIconArray*  CreateIconsL(RArray<MCalenServices::TCalenIcons>& aIndexArray );
       
   208     
       
   209     /*
       
   210      * Used for marking list item as visible/hidden
       
   211      * @param aMark TBool based on bool value item is made visible/hidden
       
   212      * @return void
       
   213      */
       
   214     void DoSelectionL( TBool aMark );
       
   215     
       
   216     /*
       
   217      * Add new listbox item (calendar)
       
   218      * @return TInt return value of editor 
       
   219      */
       
   220     TInt AddItemL();
       
   221     
       
   222     /*
       
   223      * Editing listbox item (calendar)
       
   224      * @return TInt return value of editor
       
   225      */
       
   226     TInt EditItemL();
       
   227     
       
   228     /*
       
   229      * Delete an listbox item (calendar)
       
   230      * @return void
       
   231      */
       
   232     TInt DeleteItemL();
       
   233     /*
       
   234      * Load icons into memory
       
   235      * @return void
       
   236      */
       
   237     void PrepareIconsL();
       
   238     
       
   239     /*
       
   240      * Check if any chnages has occured before modifying an item(calendar)
       
   241      * @param aDbInfoOriginal CCalCalendarInfo object before editing
       
   242      * @param aDbInfoModified CCalCalendarInfo object after editing
       
   243      */
       
   244     TBool CheckForChangesL( CCalCalendarInfo& aCalendarInfoOriginal,
       
   245                 CCalCalendarInfo& aCalendarInfoModified);
       
   246     
       
   247     /*
       
   248      * Callback for CAsyncCallBack class
       
   249      * @param aThisPtr* this pointer.
       
   250      * @return TInt status.
       
   251      */
       
   252     static TInt AsyncCallBackL(TAny* aThisPtr);
       
   253     
       
   254     /*
       
   255      * Async method to handle all async commnds
       
   256      * @param aCommand Async command
       
   257      */
       
   258     void HandleAsyncCommandL(const TInt aCommand);
       
   259 
       
   260     /*
       
   261      * Async method to handle all async commnds
       
   262      * @param aCommand Async command
       
   263      */
       
   264     void DoAsyncActionL(const TInt aCommand);
       
   265 
       
   266     /*
       
   267      * @brief Creates button for the toolbar.
       
   268 	 * @param aIcon Icon to be displayed for a button.
       
   269 	 * @param aDisplayTextID text to be displayed for a button.
       
   270 	 * @param aToolbar toolbar reference.
       
   271      */    
       
   272     CAknButton* CreateButtonL( CGulIcon* aIcon, TInt aDisplayTextID,
       
   273                                TInt aTooltipID, CAknToolbar& aToolbar );
       
   274     
       
   275     /*
       
   276      * @brief set the calendar properties for newly added calendar
       
   277      * @param aCalendarinfo a reference to CCalCalendarInfo.
       
   278      */
       
   279     void SetCalendarAddPropertiesL(CCalCalendarInfo& aCalendarInfo);
       
   280 
       
   281     /*
       
   282      * @brief update the calendar properties for calendar being edited.
       
   283      * @param aCalendarinfo a reference to CCalCalendarInfo.
       
   284      */
       
   285     void SetCalendarUpdatePropertiesL(CCalCalendarInfo& aCalendarInfo);
       
   286     
       
   287     /*
       
   288      * Refocus the items in list when delete action happened. 
       
   289      */
       
   290     void ReAdjustListItemFocusL(const TInt aCurrentIndex);
       
   291     
       
   292     /**
       
   293      * From CCoeControl Gets help context
       
   294      * @param aContext Help context
       
   295      */
       
   296     void GetHelpContext(TCoeHelpContext& aContext) const;
       
   297 
       
   298 public:  // from MCalenNotificationHandler
       
   299 	/** 
       
   300 	* @brief Handle notifications
       
   301 	* @param aNotification Nofication to be handled
       
   302 	*/
       
   303 	void HandleNotification(const TCalenNotification aNotification );
       
   304 	
       
   305 public:   // from MEikListBoxObserver
       
   306     /**
       
   307     * Handles list box events.
       
   308     *
       
   309     * @param aListBox   The originating list box.
       
   310     * @param aEventType A code for the event. Further information 
       
   311     *                   may be obtained by accessing the list box itself.
       
   312     */
       
   313     void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
   314     
       
   315 public:
       
   316     
       
   317     /*
       
   318      * Updates after add/edit had been performed.
       
   319      * Called from editor before exiting the dialog.
       
   320      * @param aItemAdded ETure if add else edit.
       
   321      */
       
   322     TInt UpdateOnAddOrEditL(TBool aItemAdded);
       
   323     
       
   324     /*
       
   325      * Exit the dialog;
       
   326      */
       
   327     void ExitDialogL();
       
   328     
       
   329 private:
       
   330     CCalenMultipleDbListbox* iListBox;
       
   331     CAknsBasicBackgroundControlContext* iBgContext; //Owns
       
   332     CAknNavigationControlContainer*   iNaviContainer; //Not own
       
   333     CCalenController& iController;
       
   334     CDesCArrayFlat* iDesArray; //Owns
       
   335     TRect iRect;
       
   336     RArray<MCalenServices::TCalenIcons> iIconIndices;
       
   337     CAknIconArray* iIconList;
       
   338     RArray<TInt32> iColorUidArray;
       
   339     CCalenMultiDBEditor* iDbEditor;//Not not owned
       
   340     TBool iConflictOccured;
       
   341     TBool iIsDbEditorOpen ; 
       
   342     
       
   343     CCalCalendarInfo* iCalendarInfoNew;
       
   344     CCalCalendarInfo* iCalendarInfoOriginal;
       
   345     CCalCalendarInfo* iCalendarInfoEdited;
       
   346     
       
   347     CAsyncCallBack*  iAsyncAction;
       
   348     TInt             iAsyncActionCmd;
       
   349     TInt             iCurrentIndex;
       
   350     HBufC* iCalEditedDefaultName;
       
   351     };
       
   352 
       
   353 
       
   354 NONSHARABLE_CLASS( CCalenMultipleDbListboxItemDrawer ) : public CFormattedCellListBoxItemDrawer
       
   355     {
       
   356     
       
   357     public:
       
   358         CCalenMultipleDbListboxItemDrawer( MTextListBoxModel* aTextListBoxModel,
       
   359                                                const CFont* aFont,
       
   360                                                CFormattedCellListBoxData* aFormattedCellData,
       
   361                                                CEikListBox* aListBox ,
       
   362                                                const RArray<TInt32>& aColorUidArray);
       
   363     
       
   364     ~CCalenMultipleDbListboxItemDrawer();
       
   365 
       
   366     private: // from CWordWrappedFormattedCellItemDrawer
       
   367     void DrawItem(TInt aItemIndex, 
       
   368                   TPoint aItemRectPos, 
       
   369                   TBool aItemIsSelected, 
       
   370                   TBool aItemIsCurrent, 
       
   371                   TBool aViewIsEmphasized,
       
   372                   TBool aViewIsDimmed) const;
       
   373     
       
   374     private:
       
   375     CEikListBox* iListBox; //Not owns
       
   376     const RArray<TInt32>& iColorUidArray; //Not owns
       
   377     CGulIcon* iIcon;
       
   378     };
       
   379 
       
   380 NONSHARABLE_CLASS( CCalenMultipleDbListbox ): public CAknDoubleGraphicStyleListBox
       
   381     {
       
   382     public:
       
   383         CCalenMultipleDbListbox(const RArray<TInt32>& aColorUidArray);
       
   384         
       
   385     private: //from CAknDouble2GraphicStyleListBox
       
   386         //CListBoxView* MakeViewClassInstanceL();
       
   387         void CreateItemDrawerL();
       
   388         void SizeChanged();
       
   389         void SizeChangedL();  
       
   390         
       
   391     private:
       
   392         const RArray<TInt32>& iColorUidArray;//Not owns
       
   393     };
       
   394 
       
   395 #endif /*CALENMULTIDBUI_H_*/