calendarui/organizerplugin/aiagendapluginengine/inc/calenagendautils.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Static utility functions. 
       
    15  *                - date utils to help comparisions and calculations witg
       
    16  *                  dates and times. 
       
    17  *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef CALENUTILS_H
       
    22 #define CALENUTILS_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <calcommon.h> // for CalCommon::TCalViewFilter
       
    26 
       
    27 #include <calentry.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CCalInstance;
       
    31 class CCalEntryView;
       
    32 class CCalInstanceView;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 NONSHARABLE_CLASS( CalenAgendaUtils )
       
    36     {
       
    37     public:
       
    38         /**
       
    39          *
       
    40          **/
       
    41         IMPORT_C static void CreateEntryIdListForDayL( RPointerArray<CCalInstance>& aList, 
       
    42                                                        CCalInstanceView* aInstanceView, 
       
    43                                                        const TTime& aDay, 
       
    44                                                        const TBool aSortForPopup = EFalse,
       
    45                                                        const TBool aIncludeToDos = ETrue );
       
    46 
       
    47         /**
       
    48          * Finds all events for a day range.
       
    49          **/
       
    50         IMPORT_C static void FindEventsForDayRangeL( CCalInstanceView* aInstanceView, 
       
    51                                                      RPointerArray<CCalInstance>& aList, 
       
    52                                                      const CalCommon::TCalViewFilter& aFilter, 
       
    53                                                      const TTime& aStartDay,
       
    54                                                      const TTime& aEndDay );
       
    55 
       
    56         /**
       
    57          * Finds all todos for the specified day range.
       
    58          **/
       
    59         IMPORT_C static void FindTodosForDayRangeL( CCalInstanceView* aInstanceView, 
       
    60                                                     RPointerArray<CCalInstance>& aList, 
       
    61                                                     const TTime& aStartDay,
       
    62                                                     const TTime& aEndDay );
       
    63 
       
    64         /**
       
    65          * Removes entries ending aDay at midnight.
       
    66          **/
       
    67         IMPORT_C static void RemoveEntriesEndingAtMidnightL( RPointerArray<CCalInstance>& aList, 
       
    68                                                             const TTime& aDay );
       
    69 
       
    70         /**
       
    71          * Common instance list sort.
       
    72          **/
       
    73         IMPORT_C static void SortInstanceList( RPointerArray<CCalInstance>& aInstanceList );
       
    74 
       
    75         /**
       
    76          * Specific sort for calendar popup (EAnniv and EEvent reversed)
       
    77          **/
       
    78         IMPORT_C static void SortPopupInstanceList( RPointerArray<CCalInstance>& aInstanceList );
       
    79 
       
    80         /**
       
    81          * Checks that if entry ends at starting midnight of the day,
       
    82          * but has started earlier.
       
    83          * Such entries are not shown in day that they end, because end time 
       
    84          * is just marking the end of previous day. 
       
    85          * @returns ETrue, if entry ends at starting midnight of day, but starts before that
       
    86          *          EFalse, otherwise
       
    87          **/
       
    88         IMPORT_C static TBool EndsAtStartOfDayL( CCalInstance* aInstance,
       
    89                                                  const TTime& aDay );
       
    90 
       
    91         /**
       
    92          * @return duration of entry as minutes 
       
    93          **/
       
    94         IMPORT_C static TTimeIntervalMinutes DurationL( const CCalEntry& aEntry );
       
    95 
       
    96 
       
    97         /**
       
    98          * Bullet-proof way to read entry time and get real ttime back
       
    99          * @return start time for meetings, day notes and anniversaries 
       
   100          *         end time (due time) for todos
       
   101          *         today 00:00 for undated todos (and for entries with null start time) 
       
   102          */
       
   103         IMPORT_C static TTime EntryTimeL( const CCalEntry& aEntry );
       
   104         
       
   105         /** 
       
   106          * @return ETrue for appointments and reminders
       
   107          *         EFalse otherwise
       
   108          */
       
   109         IMPORT_C static TBool IsTimedEntryL( CCalEntry::TType aType );
       
   110 
       
   111         /**
       
   112          * Checks if the entry is repeating
       
   113          * @param aEntry : A Calendar Entry
       
   114          * @return ETrue if it has an RRule (Meeting/ToDo) or RDate (Meeting)
       
   115          * @return EFalse otherwise        
       
   116          */
       
   117         IMPORT_C static TBool IsRepeatingL( const CCalEntry& aEntry );
       
   118 
       
   119          /*
       
   120          Returns ETrue if aDes contains only whitespace characters.
       
   121          Returns EFalse otherwise
       
   122          */
       
   123          IMPORT_C static TBool IsEmptyText(const TDesC& aDes);
       
   124 
       
   125     private: // class internal utility functions
       
   126         /**
       
   127          * Common compare for all calendar entries. Order as follows:
       
   128          *  1. ETodo     : done/undone, date, priority, last modified(oldest 1st)
       
   129          *  2. EEvent    : date/time, last modified(oldest 1st)
       
   130          *  3. EAnniv    : date/time, last modified(oldest 1st)
       
   131          *  4. EAppt     : start time, duration(shortest 1st), last modified(oldest 1st)
       
   132          * (5. EReminder : handled as EAppts )
       
   133          **/
       
   134         static TInt EntryCompare( const CCalInstance& aInstance1,
       
   135                                   const CCalInstance& aInstance2 );
       
   136 
       
   137         /**
       
   138          * Special order handling for popup
       
   139          *  1. ETodo     : done/undone, date, priority, last modified(oldest 1st)
       
   140          *  2. EAnniv    : date/time, last modified(oldest 1st)
       
   141          *  3. EEvent    : date/time, last modified(oldest 1st)
       
   142          *  4. EAppts    : start time, duration(shortest 1st), last modified(oldest 1st)
       
   143          * (5. EReminder : handled as EAppts )
       
   144          **/
       
   145         static TInt PopupEntryCompare( const CCalInstance& aInstance1,
       
   146                                        const CCalInstance& aInstance2 );
       
   147 
       
   148         static TInt DoPopupEntryCompareL( const CCalInstance& aInstance1,
       
   149                                           const CCalInstance& aInstance2 );
       
   150 
       
   151         /**
       
   152          * Specific entry comparison functions
       
   153          **/
       
   154         static TInt CompareToDosL( const CCalEntry& aEntry1,
       
   155                                    const CCalEntry& aEntry2 );
       
   156         static TInt CompareNonTimedNotesL( const CCalInstance& aInstance1,
       
   157                                            const CCalInstance& aInstance2 );
       
   158         static TInt CompareTimedNotesL( const CCalInstance& aInstance1,
       
   159                                         const CCalInstance& aInstance2 );
       
   160         static TInt DoEntryCompareL( const CCalInstance& aInstance1,
       
   161                                      const CCalInstance& aInstance2 );
       
   162 
       
   163         enum TCompareResult
       
   164             {
       
   165             EEqual       =  0, // 1. == 2.
       
   166             ELessThan    = -1, // 1. < 2.
       
   167             EGreaterThan =  1  // 1. > 2.
       
   168             };
       
   169 
       
   170     };
       
   171 
       
   172 #endif // CALENUTILS_H
       
   173 
       
   174 
       
   175 // End of File