calendarui/controller/inc/calendeleteui.h
branchRCL_3
changeset 30 bd7edf625bdd
parent 29 12af337248b1
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Controller class for deleting related UI behavior
    14 * Description:   Controller class for deleting related UI behavior
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 
    19 #ifndef CALENDELETEUI_H
    20 #ifndef CALENDELETEUI_H
    20 #define CALENDELETEUI_H
    21 #define CALENDELETEUI_H
    21 
    22 
    22 // System Includes
    23 // INCLUDES
    23 #include <QObject>
       
    24 #include <e32base.h>
    24 #include <e32base.h>
    25 #include <hbdatetimepicker.h>
    25 #include <calcommon.h>
    26 #include <agendautil.h>
    26 #include <eikenv.h>
    27 
    27 #include <AknWaitDialog.h>
    28 //User Includes
    28 #include <calprogresscallback.h>
    29 #include "calenactionuiutils.h"
    29 #include <calencommandhandler.h>
    30 #include "calennotificationhandler.h"
    30 #include <calennotificationhandler.h>
    31 #include "calencommandhandler.h"
    31 #include <calenactionuiutils.h>
    32 #include "hb_calencommands.hrh"
       
    33 
    32 
    34 // FORWARD DECLARATIONS
    33 // FORWARD DECLARATIONS
       
    34 class CAknWaitDialog;
       
    35 class CCalenGlobalData;
    35 class CCalenController;
    36 class CCalenController;
    36 class HbAction;
    37 class CCalInstanceView;
    37 
    38 class CCalInstance;
    38 enum TDeleteConfirmationType
    39 class CCalEntry;
    39 {
    40 class CCalEntryView;
    40 	EDeleteEntry = 1,
       
    41 	EDeleteToDo,
       
    42 	EDeleteToDos,
       
    43 	EDeleteAll,
       
    44 	EDeleteEvent
       
    45 };
       
    46 
    41 
    47 // CLASS DECLARATION
    42 // CLASS DECLARATION
    48 /**
    43 /**
    49  * CalenDeleteUi encapsulates deleting related behavior
    44  * CCalenDeleteUi encapsulates deleting related behavior
    50  * in Calendar application.
    45  * in Calendar application.
    51  */
    46  */
    52  class CalenDeleteUi : public QObject,
    47 NONSHARABLE_CLASS( CCalenDeleteUi ) : public CBase,
    53                           public MCalenNotificationHandler,
    48                                       public MCalProgressCallBack,
    54                           public MCalenCommandHandler                               
    49                                       public MCalenNotificationHandler,
    55                                       
    50                                       public MCalenCommandHandler,
       
    51                                       public MProgressDialogCallback
    56     {
    52     {
    57     Q_OBJECT
    53 
    58 
    54     public: // public API
    59 public: // public API
    55 	
    60     /**
    56         /**
    61      * Symbian 1st phase constructor
    57          * Symbian 1st phase constructor
    62      * @param aController Reference to CCCalenController
    58          * @param aController Reference to CCalenController
    63      */
    59          */
    64     static CalenDeleteUi* NewL(CCalenController& aController );
    60         static CCalenDeleteUi* NewL( CCalenController& aController );
    65 
    61 
    66     /**
    62         /**
    67      * Destructor
    63          * Destructor
    68      */
    64          */
    69     virtual ~CalenDeleteUi();
    65         virtual ~CCalenDeleteUi();
    70 
    66 
    71 public:  // MCalenCommandHandler
    67     public: // From MCalenCommandHandler
    72     /**
    68         
    73      * Handles action ui commands
    69         /**
    74      * @param aCommand Command to be handled
    70          * Handles key presses.
    75      */
    71          * 
    76     TBool HandleCommandL( const TCalenCommand& aCommand );
    72          * @param aCommand The command Id of the key.
    77 
    73          */
    78 public:  // New functions
    74         TBool HandleCommandL( const TCalenCommand& aCommand );
    79     /**
    75         
    80      * UI sequence for deleting single entry. Shows UI queries and notes and
    76         /**
    81      * performs delete. Current entry is taken from Calendar Context
    77          * Allows extending this API without breaking BC.
    82      */
    78          * 
    83     void DeleteCurrentEntryL();
    79          * @param aExtensionUid specifies
    84 
    80          * @return extension of the requested type
    85     /**
    81          */
    86      * UI sequence for deleting all entries. Shows UI queries and notes and
    82         TAny* CalenCommandHandlerExtensionL( TUid aExtensionUid );
    87      * performs delete asynchronosuly.
    83 
    88      */
    84     public:  // New functions
    89     void DeleteAllEntriesL();
    85         /**
    90 
    86          * UI sequence for deleting single entry. Shows UI queries and notes and
    91     /**
    87          * performs delete. Current entry is taken from Calendar Context
    92      * UI sequence for deleting entries before given date.
    88          */
    93      * Shows UI queries and notes and performs delete asynchronosuly.
    89         void DeleteCurrentEntryL();
    94      */
    90 
    95     void DeleteEntriesBeforeDateL();
    91         /**
    96     
    92          * UI sequence for deleting all entries. Shows UI queries and notes and
    97     /**
    93          * performs delete asynchronosuly.
    98      * UI sequence for deleting series repeating entry
    94          */
    99      * Becasue a ThisAndAll repeat type has already been chosen by user,
    95         void DeleteAllEntriesL();
   100      * no repeat query is required. Performs delete asynchronosuly.
    96 
   101      */
    97         /**
   102      void DeleteThisOrAllL( AgendaUtil::RecurrenceRange aRepeatType );
    98          * UI sequence for deleting entries before given date.
   103      
    99          * Shows UI queries and notes and performs delete asynchronosuly.
   104 public:  // from MCalenNotificationHandler
   100          */
   105     /**
   101         void DeleteEntriesBeforeDateL();
   106      * Handle notifications
   102 
   107      * @param aNotification Notification to be handled
   103         /**
   108      */
   104          * UI sequence for deleting series repeating entry
   109     void HandleNotification(const TCalenNotification aNotification );
   105          * Becasue a ThisAndAll repeat type has already been chosen by user,
   110 
   106          * no repeat query is required. Performs delete asynchronosuly.
   111 private: // own methods
   107          */
   112     /**
   108         void DeleteThisOrAllL( CalCommon::TRecurrenceRange aRepeatType );
   113      * Handles deleting all entries in time range from aFirstDay to aLastDay.
   109 
   114      * Shows wait notification and given confirmation notifications.
   110     public:  // from MCalenNotificationHandler
   115      */
   111         /**
   116     void HandleDeleteMultipleEventsL( const QDateTime& aFirstDay,
   112          * Handle notifications
   117                                       const QDateTime& aLastDay,
   113          * @param aNotification Notification to be handled
   118                                       int aConfNoteId );
   114          */
   119 
   115         void HandleNotification(const TCalenNotification aNotification );
   120     /**
   116 
   121      * Delete entries from given range
   117     private: // From MCalProgressCallBack
   122      */
   118         /**
   123     void DeleteDayRangeL( const QDateTime& aStart, const QDateTime& aEnd );
   119          * From MCalProgressCallBack
   124 
   120          */
   125     /**
   121         void Completed( TInt aError );
   126      * Delete entries than end at given midnight.
   122 
   127      * This is needed when deleting multiple entries, to handle
   123         /**
   128      * e.g all-day notes that extends to next day's midnight.
   124          * From MCalProgressCallBack
   129      */
   125          */
   130     void deleteEntriesEndingAtMidnight( QDateTime aMidnight );
   126         TBool NotifyProgress();
   131 
   127 
   132     /**
   128         /**
   133      * Delete entry without querying the user
   129          * From MCalProgreeCallBack
   134      */
   130          */
   135     TBool DeleteEntryWithoutQueryL();
   131         void Progress( TInt aPercentageCompleted );
   136     
   132 
   137     /**
   133     private: // own methods
   138      * Delete the given entry. Ask the user whether to delete the
   134         /**
   139      * instance or the entire series.
   135          * Handles deleting all entries in time range from aFirstDay to aLastDay.
   140      */
   136          * Shows wait notification and given confirmation notifications.
   141     void DeleteSingleInstanceL( AgendaEntry& aInstance );
   137          */
   142 
   138         void HandleDeleteMultipleEventsL( const TTime& aFirstDay,
   143     /**
   139                 const TTime& aLastDay,
   144      * Delete the given entry, using aRepeatType to determine
   140                 TInt aConfNoteId );
   145      * whether to delete the instance or the entire series.
   141 
   146      */
   142         /**
   147     void DeleteSingleInstanceL( AgendaEntry& aInstance, 
   143          * Delete entries from given range
   148             AgendaUtil::RecurrenceRange aRepeatType );
   144          */
   149     
   145         void DeleteDayRangeL( const TTime& aStart, const TTime& aEnd );
   150     /**
   146 
   151      * Delete single instance.
   147         /**
   152      * @param aInstance Pointer to the instance to be deleted
   148          * Delete entries than end at given midnight.
   153      * @param aHasRepeatType Whether or not the instance is repeating
   149          * This is needed when deleting multiple entries, to handle
   154      * @param aRepeatType Repeat type choosen to apply on delete
   150          * e.g all-day notes that extends to next day's midnight.
   155      * @return ETrue is user confirms to delete, EFalse otherwise
   151          */
   156      */
   152         void DeleteEntriesEndingAtMidnightL( TTime aMidnight );
   157     void DoDeleteSingleInstanceL( AgendaEntry& aInstance,
   153 
   158                                    bool aHasRepeatType,
   154         /**
   159                                    AgendaUtil::RecurrenceRange aRepeatType );
   155          * just a wrapper for leave
   160     
   156          */
   161     /**
   157         void DoCompletedL( TInt aFirstPassError );
   162      * Leaving function, handle ECalenNotifyViewCreated
   158 
   163      */
   159         /**
   164     void HandleECalenNotifyViewCreatedL();
   160          * Delete entry by passing CCalEntryView and CCalEntry
   165     
   161          * Will query user for confirmation before deletion
   166    /**
   162          * @return ETrue user confirms to delete EFalse otherwise 
   167     * Get the date from user.
   163          */
   168     */
   164         TBool DeleteEntryL( CCalEntryView* aEntryView, CCalEntry* aEntry );
   169     void dateQuery();
   165 
   170     
   166         /**
   171     /**
   167          * Delete entry without querying the user
   172      * Shows a confirmation query to the user if
   168          */
   173      * he/she wants to delete the particular instance
   169         TBool DeleteEntryWithoutQueryL();
   174      * or the entire series of a repeating entry
   170 
   175      */
   171         /**
   176     void showRepeatingEntryDeleteQuery();
   172          * Delete the given entry. Ask the user whether to delete the
   177     
   173          * instance or the entire series.
   178     /**
   174          */
   179      * Shows a confirmation query to the user if
   175         TBool DeleteSingleInstanceL( CCalInstance* aInstance );
   180      * he/she wants to delete instance/instances
   176 
   181      */
   177         /**
   182     void showDeleteQuery(const TDeleteConfirmationType type,
   178          * Delete the given entry, using aRepeatType to determine
   183                          const int count = 0);
   179          * whether to delete the instance or the entire series.
   184     
   180          */
   185 private: // own methods
   181         TBool DeleteSingleInstanceL( CCalInstance* aInstance, 
   186     /**
   182                 CalCommon::TRecurrenceRange aRepeatType );
   187      * C++ constructor
   183 
   188      */
   184         /**
   189     CalenDeleteUi( CCalenController& aController, QObject *parent = 0 );
   185          * Show the confirmation query with confirmation type and number of entries this query is for
   190     
   186          * @param aType Type of query: EDeleteEntry/ EDeleteTodo/ EDeleteTodos/ EDeleteAll
   191     /**
   187          */
   192      * Symbian 2nd phase constructor
   188         TInt ShowDeleteConfirmationQueryL( const CalenActionUiUtils::TDeleteConfirmationType aType,
   193      */
   189                 const TInt aCount=0 );
   194     void ConstructL();
   190 
   195 
   191         /**
   196 protected:  // Methods derived from MProgressDialogCallback
   192          * Delete single instance.
   197     /**
   193          * @param aInstance Pointer to the instance to be deleted
   198      * From MProgressDialogCallback
   194          * @param aHasRepeatType Whether or not the instance is repeating
   199      * Callback method
   195          * @param aRepeatType Repeat type choosen to apply on delete
   200      * called when a dialog is dismissed
   196          * @return ETrue is user confirms to delete, EFalse otherwise
   201      */
   197          */
   202     void DialogDismissedL( const int aButtonId );
   198         TBool DoDeleteSingleInstanceL( CCalInstance* aInstance,
   203 
   199                 TBool aHasRepeatType,
   204 public slots:
   200                 CalCommon::TRecurrenceRange aRepeatType );
   205 
   201 
   206     void doCompleted( int aFirstPassError );
   202         /**
   207     void handleDateQuery(HbAction* action);
   203          * Attempt to delete the instance using the Meeting Request utilities,
   208     void handleDeletion(HbAction* action);
   204          * if MR viewers is enabled.
   209     void handleDeleteCancel();
   205          * @param aInstance Pointer to the instance to be delete
   210     
   206          * @param aRepeatType Repeat Type choosen to apply on delete
   211 private slots:
   207          * @return ETrue if user confirms to delete, EFalse otherwise
   212     void handleRepeatedEntryDelete(int index);
   208          */
   213     void entryDeleted(ulong id);
   209         TBool TryDeleteWithMrUtilsL( CCalInstance* aInstance, 
   214 
   210                 CalCommon::TRecurrenceRange aRepeatType );
   215 private:
   211 
   216     
   212         /**
   217     /**
   213          * Leaving function, handle ECalenNotifyViewCreated
   218      * Delete entry using entry local uid
   214          */
   219      */
   215         void HandleECalenNotifyViewCreatedL();
   220     void DeleteEntryL(ulong& aEntryLocalUid);
   216 
   221     
   217         /**
   222     /**
   218          * Multiple entries delete query
   223      * Displays wait dialog while deleting marked entries
   219          */ 
   224      */
   220         TInt ShowMultipleEntriesDeleteQueryL(TInt aCount);
   225     void DisplayWaitDialogL();
   221 
   226     
   222     private: // own methods
   227     /**
   223         /**
   228      * Dismiss wait dialog and show information note
   224          * C++ constructor
   229      */
   225          */
   230     void MarkedEntriesDeletedL();
   226         CCalenDeleteUi( CCalenController& aController );
   231     
   227 
   232 private: // data
   228         /**
   233     
   229          * Symbian 2nd phase constructor
   234     bool iIsDeleting; // True, if asynchronous delete is running
   230          */
   235     QDateTime iStartTime;
   231         void ConstructL();
   236     QDateTime iEndTime;
   232 
   237     HbDateTimePicker *mDatePicker;
   233     protected:  // Methods derived from MProgressDialogCallback
   238     HbAction *mDeleteAction;
   234         /**
   239     HbAction *mCancelAction;
   235          * From MProgressDialogCallback
   240     // Confirmation note id is stored here. Note is shown when asynchronous
   236          * Callback method
   241     // delete completes.
   237          * called when a dialog is dismissed
   242     int iConfirmationNoteId;
   238          */
   243     CCalenController& iController;
   239         void DialogDismissedL( const TInt aButtonId );
   244     TCalenCommandId mDeleteCommand;
   240 
   245     AgendaUtil::RecurrenceRange mRecurrenceRange;
   241     private:
   246     
   242 
   247     // Stored command if the entry view
   243         /**
   248     // needs to constructed asyncronously
   244          * Delete entry using entry local uid
   249     TCalenCommand iStoredCommand;
   245          */
   250     int iMutlipleContextIdsCount;
   246         void DeleteEntryL(TCalLocalUid& aEntryLocalUid, TInt aColId );
   251     bool iMoreEntriesToDelete;
   247 
   252     bool iDisplayQuery;
   248         /**
   253     int iEntriesToDelete;
   249          * Displays wait dialog while deleting marked entries
       
   250          */
       
   251         void DisplayWaitDialogL();
       
   252 
       
   253         /**
       
   254          * Dismiss wait dialog and show information note
       
   255          */
       
   256         void MarkedEntriesDeletedL();
       
   257 
       
   258         /**
       
   259          * Handles launching of the delete entries list query 
       
   260          */
       
   261         void HandleDeleteAllEntriesL();
       
   262 
       
   263     private: // data
       
   264 
       
   265         CEikonEnv* iEikEnv;
       
   266         CAknWaitDialog* iWaitDialog;
       
   267 
       
   268         TBool iIsDeleting; // True, if asynchronous delete is running
       
   269         TTime iStartTime;
       
   270         TTime iEndTime;
       
   271         // Confirmation note id is stored here. Note is shown when asynchronous
       
   272         // delete completes.
       
   273         TInt iConfirmationNoteId;
       
   274         CCalenGlobalData* iGlobalData;
       
   275         CCalenController& iController;
       
   276 
       
   277         // Stored command if the entry view
       
   278         // needs to constructed asyncronously
       
   279         TCalenCommand iStoredCommand;
       
   280         TInt iMutlipleContextIdsCount;
       
   281         TBool iMoreEntriesToDelete;
       
   282         TBool iDisplayQuery;
       
   283         TInt iEntriesToDelete;
       
   284         TInt iToShowDeleteNote;
       
   285         TInt iNumberOfCalendars;
       
   286         
       
   287         RArray<TInt> iDeleteColIds;
       
   288         CalCommon::TCalTimeRange *iDelAllRange;
       
   289 
   254     };
   290     };
   255 
   291 
   256 #endif // CALENDELETEUI_H
   292 #endif // CALENDELETEUI_H
   257 
   293 
   258 // End of File
   294 // End of File