calendarui/views/inc/caleneventviewcontainer.h
changeset 0 f979ecb2b13e
child 20 21239b3bcd78
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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:  For Event view container of calendar application.
       
    15 *                The class derived from CCalenContainer
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CALENEVENTVIEWCONTAINER_H
       
    21 #define CALENEVENTVIEWCONTAINER_H
       
    22 
       
    23 // system includes
       
    24 
       
    25 // user includes
       
    26 #include "calenentryutil.h"
       
    27 #include "calencontainer.h"
       
    28 #include <eikmenup.h>
       
    29 #include <cenrepnotifyhandler.h>
       
    30 #include <eiklabel.h>
       
    31 #include <AknServerApp.h>
       
    32 // forward declarations
       
    33 class CEikRichTextEditor;
       
    34 class CCalenEntryUtil;
       
    35 class CCalenIconDrawer;
       
    36 class CItemFinder;
       
    37 class CRepository;
       
    38 class CCenRepNotifyHandler;
       
    39 class CFindItemMenu;
       
    40 class CCalCalendarInfo;
       
    41 class CCalenIconDrawer;
       
    42 class CDocumentHandler;
       
    43 
       
    44 // class declaration
       
    45 /**
       
    46  * CCalenEventContainer container control class for EventView.
       
    47  */
       
    48 NONSHARABLE_CLASS(CCalenEventViewContainer):public CCalenContainer,
       
    49 											public MCenRepNotifyHandlerCallback,
       
    50 											public MEikScrollBarObserver,
       
    51 											public MAknServerAppExitObserver
       
    52 	{
       
    53 public:
       
    54 	/**
       
    55      * C++ constructor.
       
    56      */
       
    57     CCalenEventViewContainer( CCalenNativeView* aView,
       
    58                               MCalenServices& aServices );
       
    59                          
       
    60     /**
       
    61      * Destructor.
       
    62      */
       
    63     virtual ~CCalenEventViewContainer();                     
       
    64 
       
    65 private: // Functions from base classes
       
    66     /**
       
    67      * From CCoeControl, child control was resized.
       
    68      */
       
    69     void SizeChanged();
       
    70 
       
    71     /**
       
    72      * From CCoeControl, return child control count.
       
    73      * @return Control count
       
    74      */
       
    75     TInt CountComponentControls() const;
       
    76 
       
    77     /**
       
    78      * From CCoeControl, return child control pointer.
       
    79      * @param aIndex Child control index
       
    80      * @return Child control pointer.
       
    81      */
       
    82     CCoeControl* ComponentControl(TInt aIndex) const;
       
    83 
       
    84     /**
       
    85      * From CCoeControl, process key event.
       
    86      * @param aKeyEvent The key event.
       
    87      * @param aType EEventKey | EEventKeyUp | EEventKeyDown.
       
    88      * @return EKeyWasNotConsumed : Key event was not consumed.
       
    89      */
       
    90     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
    91                                     TEventCode aType);
       
    92 
       
    93     /**
       
    94      * From CCoeControl, process pointer event.
       
    95      */
       
    96     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
    97 
       
    98    /**
       
    99     * From CCoeControl
       
   100     */  
       
   101     void Draw(const TRect& /*aRect*/) const;
       
   102 
       
   103     /**
       
   104      * Pass skin information if needed
       
   105      */
       
   106     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   107 
       
   108     /**
       
   109      * From CCoeControl, Get help context.
       
   110      * @param aContext Help context
       
   111      */
       
   112     void GetHelpContext(TCoeHelpContext& aContext) const;
       
   113 
       
   114     /**
       
   115      * From MActiveStep, refresh EventView data.
       
   116      */
       
   117     TInt DoStepL();
       
   118 
       
   119     /**
       
   120      * From CCoeControl Handles a resource relative event.
       
   121      * 
       
   122      * @param aType The type of change that occured.
       
   123      */
       
   124     void HandleResourceChange(TInt aType);                              
       
   125 
       
   126 
       
   127 private:    // From CCalenContainer
       
   128     /**
       
   129      * From CCalenContainer Third phase constructor.
       
   130      * This function was called CCalenView::ConstructL().
       
   131      */
       
   132     void ConstructImplL();
       
   133     
       
   134     /**
       
   135      * From CCalenContainer.
       
   136      * This methods is called after calendar settings have changed.
       
   137      */
       
   138     void UpdateSize();
       
   139  	
       
   140     /**
       
   141      * Create icon index
       
   142      */
       
   143     void CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray );
       
   144 	
       
   145 
       
   146     /**
       
   147      * This method is called after pointer event in Navi
       
   148      * decoration object.
       
   149      * @param aDirection right or left
       
   150      */
       
   151     void HandleNaviDecoratorEventL(TInt aEventID);
       
   152     
       
   153     void HandleLongTapEventL( const TPoint& aPenEventLocation, 
       
   154                               const TPoint& aPenEventScreenLocation );
       
   155 
       
   156 
       
   157 public: // from MAknServerAppExitObserver
       
   158     
       
   159         /**
       
   160         * Handle the exit of a connected server app.
       
   161         * This implementation provides S60 default behavior
       
   162         * for handling of the EAknCmdExit exit code. Derived classes
       
   163         * should base-call this implementation if they override this
       
   164         * function.
       
   165         *
       
   166         * @since S60 5.0
       
   167         *
       
   168         * @param aReason The reason that the server application exited.
       
   169         * This will either be an error code, or the command id that caused
       
   170         * the server app to exit.
       
   171         */
       
   172         void HandleServerAppExit( TInt aReason );
       
   173 		
       
   174 		
       
   175 		void HandleLocaleChangedL(/* TInt aReason */);
       
   176         
       
   177 public: // New methods
       
   178 
       
   179     CCalInstance* FindPossibleInstanceL(const TCalenInstanceId& aId,
       
   180                                          CCalInstanceView& aInstanceView );
       
   181  
       
   182  	/**
       
   183  	 * Build text editor
       
   184  	 */
       
   185  	void BuildTextEditorL();
       
   186  	
       
   187  	/**
       
   188  	 * Request for instance view
       
   189  	 */
       
   190  	TInt RequestInstanceViewL();
       
   191  	
       
   192  	/**
       
   193  	 * Add the data fields
       
   194  	 */ 
       
   195  	void AddFieldsL();
       
   196  	
       
   197     /**
       
   198      * Complete population
       
   199   	 */	
       
   200     void CompletePopulationL();
       
   201  	
       
   202     /**
       
   203      * Getter for titlepane
       
   204      */ 	
       
   205  	TInt GetTitleTextId();
       
   206  	
       
   207     /**
       
   208 	 * Getter for event view data
       
   209 	 */	
       
   210  	CCalenEntryUtil* GetEventViewData();
       
   211  	
       
   212     /**
       
   213      * Complete a todo entry
       
   214      */
       
   215     void OnCmdCompleteTaskL();
       
   216 
       
   217     /**
       
   218      * Restore a todo entry
       
   219      */
       
   220     void OnCmdRestoreTaskL();
       
   221     /**
       
   222      * Get item finder
       
   223      */
       
   224     CItemFinder* GetItemFinder();
       
   225     /**
       
   226      * Get find item menu
       
   227      */
       
   228     CFindItemMenu* GetFindItemMenu();
       
   229     
       
   230     /**
       
   231      * Returns ETrue if event has geo coordinates else EFalse
       
   232      */
       
   233     TBool IsEventHasMapLocationL();
       
   234     
       
   235     /**
       
   236      * Returns ETrue if event has location text else EFalse
       
   237      */
       
   238     TBool IsEventHasNoLocationTextL();
       
   239   
       
   240     
       
   241  private:
       
   242  	
       
   243  	/**
       
   244  	 * Set the layout data for LAF
       
   245  	 */
       
   246  	void SetLayoutFromLookAndFeelL(); 	
       
   247     
       
   248     /**
       
   249      * Convert values from twips to pixels
       
   250     */
       
   251     TInt PixelsToTwips(TInt aPixels);
       
   252  	
       
   253  	/**
       
   254  	 * Set up the Font style
       
   255  	 */
       
   256  	void SetupFontL(); 	
       
   257  	
       
   258 	/**
       
   259 	* Creates and initiliazes the icon drawer
       
   260 	* Returns the newly created pointer to the object of CCalenIconDrawer
       
   261 	*/
       
   262  	CCalenIconDrawer* CreateAndInitializeIconsDrawerL();
       
   263  	
       
   264   /**
       
   265    * Set the icons
       
   266    */	
       
   267  	void SetIconsL(CCalenIconDrawer* aIconDrawer);
       
   268  	
       
   269  	/**
       
   270      * Populate the icon drawer with the icons for this entry
       
   271      */
       
   272     void PopulateIconDrawerL( CCalenIconDrawer& aIconDrawer );
       
   273     
       
   274 	/**
       
   275 	* Calculates the number of lines before the location field in the document
       
   276 	* so that map icon is placed at correct place
       
   277 	**/
       
   278     void CalcNumOfLinesBeforeLocation();
       
   279 	
       
   280     /**
       
   281      * Formats the heading and adds it the the view
       
   282      * Headings are bolded with no indentation.
       
   283      */
       
   284     void SetFormatAndAddHeadingL( const TDesC& aHeading );
       
   285 
       
   286     /**
       
   287      * Formats the body and adds it the the view
       
   288      * Body text is not bolded and indented from the leading margin
       
   289      * according to the Calendar viewer LAF
       
   290      */
       
   291     void SetFormatAndAddBodyL( const TDesC& aBody );
       
   292 
       
   293     /**
       
   294      * Formats the text and adds it to the view
       
   295      */
       
   296     void AddFormattedTextL( const TDesC& aText );
       
   297 
       
   298     /**
       
   299      * Add a text field to the view.
       
   300      */
       
   301     void AddTextFieldL( TInt aHeadingResource, const TDesC& aBody );
       
   302 
       
   303     /**
       
   304      * Add a text field to the view.
       
   305      */
       
   306     void AddTextFieldL( TInt aHeadingResource, TInt aBodyResource );
       
   307 
       
   308     /**
       
   309      * Add a empty line to the view.
       
   310      */
       
   311     void AddEmptyLineL();
       
   312 
       
   313     /**
       
   314      * Add a subject field to the view.
       
   315      */
       
   316     void AddSubjectFieldL();
       
   317 
       
   318     /**
       
   319      * Add a location field to the view.
       
   320      */
       
   321     void AddLocationFieldL();
       
   322 
       
   323     /**
       
   324      * Add a priority field to the form.
       
   325      */
       
   326     void AddPriorityFieldL();
       
   327 
       
   328     /**
       
   329      * Add a time field to the form.
       
   330      */
       
   331     void AddTimeFieldL( TInt aHeadingResource, const TTime& aTime );
       
   332 
       
   333     /**
       
   334      * Add a date field to the form.
       
   335      */
       
   336     void AddDateFieldL( const TTime& aDate );
       
   337 
       
   338     /**
       
   339      * Add a date field to the form.
       
   340      */
       
   341     void AddDateFieldL( TInt aHeadingResource, const TTime& aDate );
       
   342 
       
   343     /**
       
   344      * Add a "date - date" field to the form.
       
   345      */
       
   346     void AddDateDateFieldL( const TTime& aStartDate, const TTime& aEndDate );
       
   347 
       
   348     /**
       
   349      * Add an alarm date-time field to the form, in the order: DD.DD.DDDD TT:TT according to localisation.
       
   350      */
       
   351     void AddAlarmDateAndTimeFieldL( const TTime& aTime );
       
   352 
       
   353     /**
       
   354      * Set alarm to form.
       
   355      */
       
   356     void AddAlarmDateTimeFieldL();
       
   357 
       
   358     /**
       
   359      * Add the repeat information to the form for a recurring appointment
       
   360      * @since Series 60 3.1
       
   361      */
       
   362     void AddRepeatFieldL();
       
   363 
       
   364     /**
       
   365      * Add the time fields to the form
       
   366      * @since Series 60 3.1
       
   367      */
       
   368     void AddTimeFieldL();
       
   369 
       
   370     /**
       
   371      * Add a description to the form
       
   372      * @since Series 60 3.1
       
   373      */
       
   374     void AddDescriptionFieldL();
       
   375 
       
   376     /**
       
   377      * Add a since field to the form
       
   378      * @since Series 60 3.1
       
   379      */
       
   380     void AddSinceFieldL();
       
   381     
       
   382 	/**
       
   383 	* Adds the attachments names to the viewer
       
   384 	*/
       
   385     void AddAttachmentNameL(const TDesC& aText);
       
   386 	
       
   387    /**
       
   388     * Getter for min and max times
       
   389     */ 
       
   390     void GetMinAndMaxTimesL( RArray<TCalTime>& aTimes,
       
   391                          TCalTime& aMinTime,
       
   392                          TCalTime& aMaxTime );
       
   393    /**
       
   394     * Remove duplicate times
       
   395     */ 	
       
   396     void RemoveDuplicateTimesL( RArray<TCalTime>& aTimes );  
       
   397 
       
   398    /**
       
   399     * Remove excluded times
       
   400     */  
       
   401     void RemoveExcludedTimesL( RArray<TCalTime>& aStartDates,
       
   402                                RArray<TCalTime>& aExDates,
       
   403                                RPointerArray<CCalEntry>& aChildEntries );                          
       
   404    /**
       
   405     * RDate expansion stuff
       
   406     */	
       
   407 	TBool GetSeriesRepeatInformationL( CCalEntry& aEntry,
       
   408 	                                   TCalenRepeatIndex& aRepeatIndex,
       
   409 	                                   TTime& aSeriesStart,
       
   410 	                                   TTime& aSeriesEnd );
       
   411 
       
   412 
       
   413     /**
       
   414      * Check if the given text will fit in the the given width
       
   415      * Used to determine if dates will wrap or not
       
   416      */
       
   417     TBool TryToFitL( const TDesC& aStr, TInt aMaxWidth, const CFont& aFont );
       
   418 	
       
   419     /**
       
   420      * Convert from a calendar TUint priority to a TInt for the form.
       
   421      */
       
   422     TInt CalendarPriorityToFormPriority( CCalenEntryUtil::TTodoPriority aCalPriority );	
       
   423 	
       
   424    /**
       
   425     * Build Search Buffer
       
   426     */ 
       
   427     void BuildSearchBufferL();
       
   428     
       
   429     /**
       
   430      * Get the text fields from the form as a descriptior.
       
   431      */
       
   432     void GetTextFieldsFromFormL( TDes& aDesc );
       
   433     
       
   434     /**
       
   435      * Fetch the current entry's parent from agenda. This should be used
       
   436      * sparingly as it is expensive. It may be worth seeing if there
       
   437      * is any performance improvement by fetching the parent from
       
   438      * CCalenDefaultViewers and passing it through to the constructor of
       
   439      * the editors and viewers, instead of fetching it internally to each
       
   440      * viewer/editor.
       
   441      */
       
   442     CCalEntry& ParentEntryL();
       
   443 
       
   444     /**
       
   445      * Fetch all the instances of an entry from agenda. This should be used
       
   446      * sparingly as it is expensive. It may be worth seeing if there
       
   447      * is any performance improvement by fetching the parent from
       
   448      * CCalenDefaultViewers and passing it through to the constructor of
       
   449      * the editors and viewers, instead of fetching it internally to each
       
   450      * viewer/editor.
       
   451      */
       
   452     RPointerArray<CCalEntry>& AllInstancesL();
       
   453     /**
       
   454       * Get the available label rect for this container
       
   455       */
       
   456      TRect GetLabelRectL( );    
       
   457 	 
       
   458 	 
       
   459      void SetLabelContentL( CEikLabel& aLabel );
       
   460 
       
   461     /**
       
   462     * Reads the shared data value used to initialize automatic highlighting
       
   463     * @return TBool, ETrue if automatic highlighting is to be used
       
   464     */
       
   465     void ReadAutoHlCenRepValueAndSetNotifyL();
       
   466     
       
   467     /**
       
   468     * From MCenRepNotifyHandlerCallback
       
   469     * Handles the incoming notifications of key changes
       
   470     * @since Series60 3.0
       
   471     * @param aId, Key that has changed
       
   472     * @param aNewValue, New value of the key    
       
   473     */
       
   474     void HandleNotifyInt( TUint32 aId, TInt aNewValue );
       
   475 
       
   476     /**
       
   477     * From MCenRepNotifyHandlerCallback
       
   478     * Handles the notifier errors
       
   479     * @since Series60 3.0
       
   480     * @param aId, Key that has changed
       
   481     * @param aNewValue, New value of the key    
       
   482     */
       
   483     void HandleNotifyError( TUint32 aId,TInt aError,CCenRepNotifyHandler* aHandler );
       
   484     
       
   485 	/**
       
   486 	* Set the state of automatic highlighting
       
   487 	* @param aSwitchON, ETrue if automatic highlighting is to used, otherwise EFalse
       
   488 	*/
       
   489     void SetAutomaticHighlightL( const TBool aSwitchON );
       
   490     
       
   491     /**
       
   492 	* This method is used when phone number is 
       
   493 	* found and pressing phone key would make call
       
   494 	*/
       
   495     void HandleNumberCallL();
       
   496 
       
   497     /**
       
   498      * Add calendar info field to the viewer
       
   499      */
       
   500     void AddCalendarInfoFieldL();
       
   501     
       
   502     /*
       
   503      * @brief Find calendarinfo object based on calendar name
       
   504      * 
       
   505      * @param aName calendar filename
       
   506      * @param aCalendarInfo referance for calendarinfo
       
   507      * @return TBool find status
       
   508      */
       
   509     static TBool CalendarInfoIdentifierL(const HBufC* aName,
       
   510             const CCalCalendarInfo& aCalendarInfo);
       
   511     /**
       
   512      * Adds the attachment field in the viewer
       
   513      */
       
   514     void AddAttachmentFieldL();
       
   515     
       
   516 	/**
       
   517 	* Checks if user has tapped on the attahcment names and then opens the corresponding 
       
   518 	* attachment
       
   519 	*/
       
   520     void CheckAndOpenTappedAttachment(TTmPosInfo2* posInfo);
       
   521 	
       
   522 	/**
       
   523 	* Opens the respective atatchment tapped
       
   524 	*/
       
   525     void OpenViewerL(TInt attachmentToBeOpened);
       
   526     
       
   527     /**
       
   528      * Opens the attachment  
       
   529      * 
       
   530      * @param RFile File handler to be opened
       
   531      * @param aExitObserver Exit observer that listens for exiting from the attahcment viewer
       
   532      * @return None
       
   533      */
       
   534      void OpenAttachmentViewerL(RFile& file, MAknServerAppExitObserver& aExitObserver);
       
   535 
       
   536 public:
       
   537     
       
   538     /**
       
   539      * From MEikScrollBarObserver: to Handle scrollbar events
       
   540      * @param CEikScrollBar* : Pointer to the scrollbar
       
   541      * @param TEikScrollEvent : Event on the Scrollbar
       
   542      */
       
   543      void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
       
   544 	 
       
   545 	 /**
       
   546      * Overridden HandleStopCommandL()from base class CCalenContainer.h
       
   547      * To stop the alarm in auto snooze case.and to open the event viewer in normal mode.
       
   548      */
       
   549      void HandleStopCommandL();
       
   550 
       
   551 protected:
       
   552 
       
   553     class TTextPos
       
   554         {
       
   555         public:
       
   556             TInt  iDocStart;
       
   557             TInt  iDocEnd;
       
   558         };
       
   559      
       
   560 private:
       
   561  
       
   562  	HBufC* iSearchBuf;  //Buffer for search text used by find api
       
   563     HBufC* iTimeFormat; // buffer for the time format string
       
   564     HBufC* iDateFormat; // buffer for the date format string 
       
   565  	 
       
   566     CParaFormat* iParaFormat;   // para format for the rich text obj. owned
       
   567     TParaFormatMask iParaFormatMask;    // specifying validity of paraformat
       
   568 
       
   569     TCharFormat iCharFormat;                // character formating for the rich text obj
       
   570     TCharFormatMask iCharFormatMask;  // specifying validity of icharformat
       
   571 
       
   572     TFontSpec iHeadingFontSpec;     // font weight of heading text
       
   573     TFontSpec iBodyFontSpec;          // font weight of body text
       
   574 
       
   575     const CFont* iBodyFont; // not owned
       
   576     const CFont* iHeadingFont; // not owned
       
   577     TInt iMaxWidth;         // maximum width in pixel of text area of the rich text
       
   578     TInt iHeadingIndent;    // indent of the heading text measured in twips
       
   579     TInt iBodyIndent;   // indent of the body text measured in twips
       
   580     TInt iIconDrawerWidthInPixels; // width of the icon drawer in pixels
       
   581     TInt iEmptyLineHeight;  // height of the empty line in twips 
       
   582 
       
   583     CEikRichTextEditor* iTextEditor;    // rich text obj. owned
       
   584     CAknsBasicBackgroundControlContext* iBgContext; // for skins support   
       
   585     
       
   586     CCalenEntryUtil* iEventViewData; // event view data
       
   587     
       
   588     CCalEntry* iEntry; //entry viewed in event view
       
   589     TInt iTitleTextId; // title pane text id
       
   590          
       
   591      // The array of entries returned from FetchL(), based on the entry being edited.
       
   592      // This allows retrieving of the parent entry using ParentEntryL(), which should
       
   593      // be used instead of direct access to this array.
       
   594      RPointerArray<CCalEntry> iFetchedEntries;
       
   595      
       
   596 private:
       
   597      CRepository* iCenRepSession; // Central Repository session
       
   598      // Notifier to listen changes of offline state
       
   599      CCenRepNotifyHandler* iNotifier;
       
   600      TInt iNumOfLinesBeforeLocField; // Number of lines before locaiton field in the rich text editor
       
   601      TInt iTimeFieldLines;  // Number of lines occupied by time field on the viewer
       
   602      TBool iAutomaticHlValue;
       
   603      TBool iAutomaticHlInitialized;   
       
   604      CItemFinder*  iAutoFinder; // text finder 
       
   605      CFindItemMenu* iFindMenu;  
       
   606      TCursorSelection iSelectedText; // Cursor selection for the text editor
       
   607      TBool iLocaleChanged;
       
   608      CEikLabel* iLabel; 
       
   609      CDocumentHandler*               iDocHandler; 
       
   610 	 RArray<TTextPos> iAttachmentPosInfoArray;	// Array of start and end positions of each attachment names on the viewer
       
   611 
       
   612 	};
       
   613 
       
   614 #endif // CALENEVENTCONTAINER_H