notepad/notepad1/inc/NpdListDialog.h
changeset 0 f979ecb2b13e
child 21 9711e452b5e9
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:  Declaration of Notepad List Dialog class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NPDLISTDIALOG_H
       
    20 #define NPDLISTDIALOG_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <eiklbo.h>
       
    24 #include <coeaui.h>
       
    25 #include <AknProgressDialog.h>
       
    26 #include <basched.h>
       
    27 #include "NpdDialogBase.h"
       
    28 #include "NpdModelObserver.h"
       
    29 #include <AiwServiceHandler.h>      //For Application InterWorking
       
    30 #include <AiwCommon.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CAknColumnListBox;
       
    34 class CNotepadModel;
       
    35 class CNotepadEditorDialog;
       
    36 class CSendUi;
       
    37 class CEnvironmentChangeNotifier;
       
    38 class CAknProgressDialog;
       
    39 class CAknAppUi;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43 * Dialog of list mode.
       
    44 * CNotepadListDialog is a dialog for both list of memos and list of templates.
       
    45 *  
       
    46 * @lib NpdLib.lib
       
    47 * @see CNotepadDialogBase
       
    48 */
       
    49 class CNotepadListDialog : public CNotepadDialogBase, 
       
    50     public MEikListBoxObserver,
       
    51     public MCoeViewObserver,
       
    52     public MNotepadModelObserver,
       
    53     public MProgressDialogCallback,
       
    54     public MAiwNotifyCallback
       
    55     {
       
    56     public: // Constructor and destructor
       
    57          enum TNotepadListBoxEvent
       
    58         		{
       
    59         		EOpenListBoxItem = 1,
       
    60         		EOpenListBoxContextMenu
       
    61         		};
       
    62         /**
       
    63         * Constructor.
       
    64         *
       
    65         * @param aResId resource id of type STRUCT NOTEPAD_LIST_DIALOG
       
    66         * @param aSelfPtr pointer to pointer of this
       
    67         * @return Newly constructed CNotepadListDialog object.
       
    68         * @internal
       
    69         */
       
    70         IMPORT_C static CNotepadListDialog* NewL( 
       
    71             TInt aResId, 
       
    72             CEikDialog** aSelfPtr );
       
    73 
       
    74         /**
       
    75         * Destructor.
       
    76         */
       
    77         IMPORT_C virtual ~CNotepadListDialog();
       
    78 
       
    79     public: // New functions
       
    80 
       
    81         /**
       
    82         * Force to switch to editor mode.
       
    83         *
       
    84         * This API function is used when Notepad application is 
       
    85         * opened from Pinboard application.
       
    86         *
       
    87         * When this API is called, Notepad status is changed to editor mode
       
    88         * and a memo whose key is aKey is displayed.
       
    89         *
       
    90         * If a memo whose key is equal to aKey doesn't exist or
       
    91         * aKey is equal to KNotepadPseudoKeyIdForNewNote(-1),
       
    92         * an empty Notepad editor for a new memo is displayed.
       
    93         * 
       
    94         * @param aKey a unique memo id number.
       
    95         */
       
    96         IMPORT_C void EditByKeyL(const TInt aKey);
       
    97 
       
    98         /**
       
    99         * If editor is running, save its contents if need.
       
   100         * This is called from CNotepadAppUi on shutdown.
       
   101         *
       
   102         * @internal
       
   103         * @see CNotepadEditorDialog::SaveL
       
   104         */
       
   105         IMPORT_C void SaveL();
       
   106 
       
   107         /**
       
   108         * Prepare to switch from editor mode to list mode.
       
   109         * This function is called when the editor has closed by
       
   110         * the right softkey 'Done'.
       
   111         *
       
   112         * @param aStatOfSave status of CNotepadEditorDialog::SaveL.
       
   113         * @param aKey a unique key id of the editing item.
       
   114         * @param aEagerSync if this is ETrue, it is necessary to refresh
       
   115         * CNotepadModel immediately.
       
   116         */
       
   117         void HandleEditorExitL( 
       
   118             TInt aStatOfSave, 
       
   119             const TInt aKey, 
       
   120             const TBool aEagerSync );
       
   121 
       
   122         /**
       
   123         * Clear the iEditorDialog. 
       
   124         * Called only from destructor of CNotepadEditorDialog.
       
   125         */
       
   126         void EditorDeleted();
       
   127         
       
   128         /**
       
   129         * Handle list box events
       
   130         * @param aEvent Listbox event type
       
   131         */ 
       
   132         void HandleListBoxPointerEventL(TNotepadListBoxEvent aEvent);
       
   133         
       
   134         /**
       
   135         * From MiddleSoftKeyL
       
   136         * changes middle soft key
       
   137         */
       
   138 		void MiddleSoftKeyL();
       
   139 		/*
       
   140 		*
       
   141 		*/
       
   142 	    void ClearSaveOrMarkedListItemsL(TBool aFlag);
       
   143 
       
   144     private: // Constructor
       
   145 
       
   146         /**
       
   147         * Second phase constructor.
       
   148         *
       
   149         * @param aReader resource reader already opened for 
       
   150         *                "STRUCT NOTEPAD_LIST_DIALOG".
       
   151         */
       
   152         void ConstructL(TResourceReader& aReader);
       
   153 
       
   154     private: // New functions
       
   155 
       
   156         /**
       
   157         * Start editor dialog.
       
   158         *
       
   159         */
       
   160         void StartEditorL();
       
   161 
       
   162         /**
       
   163         * Switch to empty editor mode.
       
   164         */
       
   165   
       
   166   		void OnCmdAddL(); 
       
   167 
       
   168         /**
       
   169         * Switch to editor mode.
       
   170         *
       
   171         * @param aIndex ListBox item index to edit.
       
   172         */
       
   173         void OnCmdOpenL( TInt aIndex );
       
   174 
       
   175         /** 
       
   176         * Show delete confirmation query and return the answer.
       
   177         *
       
   178         * @param aMemos # of items to delete.
       
   179         * @return ETrue if query confirmed Yes, otherwise EFalse.
       
   180         */
       
   181         TBool ConfirmDeleteL(TInt aMemos);
       
   182 
       
   183         /** 
       
   184         * Create key array of selected items.
       
   185         */
       
   186         void CreateKeyArrayOfSelectionsL();
       
   187 
       
   188         /** 
       
   189         * Delete memos.
       
   190         */
       
   191         void OnCmdDeleteL();
       
   192 
       
   193 
       
   194         /** 
       
   195         * Process Send Command.
       
   196         *
       
   197         */
       
   198         void OnCmdSendL(TInt aCommandId);
       
   199 
       
   200         /** 
       
   201         * Create iProgressDialog.
       
   202         *
       
   203         * @param aCount number of items to be processed.
       
   204         * @param aLabelResId a label text resource id.
       
   205         */
       
   206         void CreateProgressDialogL(
       
   207             const TInt aCount, 
       
   208             const TInt aLabelResId = 0 );
       
   209 
       
   210 
       
   211 
       
   212 
       
   213         /**
       
   214         * Main part of EditByKeyL.
       
   215         *
       
   216         * @param aKey a unique memo id number.
       
   217         */
       
   218         void DoEditByKeyL(const TInt aKey);
       
   219 
       
   220         /**
       
   221         * Resource id of prompt text when deleting a single item.
       
   222         *
       
   223         * @return TBUF resource id.
       
   224         */
       
   225         inline TInt QueryDeleteSingleResId() const;
       
   226 
       
   227         /**
       
   228         * Resource id of prompt text when deleting a single item.
       
   229         *
       
   230         * @return TBUF resource id.
       
   231         */
       
   232         inline TInt QueryDeleteMultipleResId() const;
       
   233 
       
   234         /**
       
   235         * Environment change callback entry function.
       
   236         *
       
   237         * @param aThisPtr pointer to this.
       
   238         * @return always TRUE (callback should be called again).
       
   239         */
       
   240         static TInt HandleEnvironmentChangedL(TAny* aThisPtr);
       
   241 
       
   242         /**
       
   243         * Environment change callback entry function.
       
   244         *
       
   245         * @return always TRUE (callback should be called again).
       
   246         */
       
   247         TInt DoHandleEnvironmentChangedL();
       
   248 
       
   249         /**
       
   250         */
       
   251         void SaveCurrentAndSelectionsL();
       
   252 
       
   253         /**
       
   254         */
       
   255         void RestoreCurrentAndSelectionsL();
       
   256 
       
   257         /**
       
   258         */
       
   259         void RestoreCurrent();
       
   260 
       
   261         /**
       
   262         */
       
   263         void RestoreSelectionsL();
       
   264 
       
   265         /**
       
   266         */
       
   267         void ClearSavedCurrentAndSelections();
       
   268 
       
   269         /**
       
   270         */
       
   271         void AdjustTopItemIfNeed();
       
   272 
       
   273         /**
       
   274         */
       
   275         TBool AvoidSyncing() const;
       
   276 
       
   277         /**
       
   278         */
       
   279         inline static TInt LevelOfActiveScheduler();
       
   280 
       
   281         /**
       
   282         * Implementation of HandleViewEventL.
       
   283         * 
       
   284         * @param aEvent view event type.
       
   285         */
       
   286         void DoHandleViewEventL(const TVwsViewEvent& aEvent);
       
   287 
       
   288     private:  // Functions from base classes
       
   289 
       
   290         /**
       
   291         * From MNotepadModelObserver.
       
   292         */
       
   293         void HandleNotepadModelEventL(TEvent aEvent, TInt aParam = 0);
       
   294 
       
   295         /**
       
   296         * From MEikMenuObserver.
       
   297         * 
       
   298         * @param aResourceId resource id.
       
   299         * @param menu pane object.
       
   300         */
       
   301         void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
       
   302 
       
   303 
       
   304 		/**
       
   305         * From MEikMenuObserver.
       
   306         * 
       
   307         * @param aResourceId resource id.
       
   308         * @param menu Bar object.
       
   309         */
       
   310         void DynInitMenuBarL(TInt aResourceId,CEikMenuBar* aMenuBar);
       
   311         
       
   312         
       
   313         /**
       
   314         * From MEikCommandObserver
       
   315         * 
       
   316         * @param aCommandId command.
       
   317         */
       
   318         void ProcessCommandL(TInt aCommandId);
       
   319 
       
   320         /**
       
   321         * From MCoeViewObserver
       
   322         * 
       
   323         * @param aEvent view event type.
       
   324         */
       
   325         void HandleViewEventL(const TVwsViewEvent& aEvent);
       
   326 
       
   327         /**
       
   328         * From MProgressDialogCallback.
       
   329         * 
       
   330         * @param aButtonId button id which is derived from OkToExitL.
       
   331         */
       
   332         void DialogDismissedL( TInt aButtonId );
       
   333 
       
   334         /**
       
   335         * From CEikDialog.
       
   336         */
       
   337         void PreLayoutDynInitL();
       
   338 
       
   339         /**
       
   340         * From CEikDialog.
       
   341         */
       
   342         void PostLayoutDynInitL();
       
   343 
       
   344         /**
       
   345         * From CEikDialog.
       
   346         */
       
   347         TBool OkToExitL( TInt aButtonId );
       
   348 
       
   349         /**
       
   350         * From MEikListBoxObserver.
       
   351         *
       
   352         * @param aListBox List box object.
       
   353         * @param aEventType event type.
       
   354         */
       
   355         void HandleListBoxEventL(
       
   356             CEikListBox* aListBox, 
       
   357             TListBoxEvent aEventType );
       
   358 
       
   359         /**
       
   360         * From CCoeControl.
       
   361         *
       
   362         * @param aContext TCoeHelpContext.
       
   363         */
       
   364         void GetHelpContext(TCoeHelpContext& aContext) const;
       
   365 
       
   366         /**
       
   367         * From CCoeControl
       
   368         *
       
   369         * @param aKeyEvent key event which includes ScanCode etc.
       
   370         * @param aType event type ( up, in, down...).
       
   371         */
       
   372         TKeyResponse OfferKeyEventL(
       
   373             const TKeyEvent& aKeyEvent, 
       
   374             TEventCode aType);
       
   375 
       
   376     private: // From MAiwNotifyCallback
       
   377         /**
       
   378          * Handles any notification caused by asynchronous ExecuteCommandL
       
   379          * or event.
       
   380          * @param aCmdId Service command associated to the event.
       
   381          * @param aEventId Occured event
       
   382          * @param aEventParamList Event parameters, if any, as defined per
       
   383          * each event.
       
   384          * @param aInParamList Input parameters, if any, given in the
       
   385          *        related HandleCommmandL
       
   386          * @return error code for the callback
       
   387          */
       
   388         TInt HandleNotifyL( TInt aCmdId,
       
   389                             TInt aEventId,
       
   390                             CAiwGenericParamList& aEventParamList,
       
   391                             const CAiwGenericParamList& aInParamList
       
   392                           );
       
   393 
       
   394         /**
       
   395         * From CEikColumnListBox/CCoeControl
       
   396         *
       
   397         * @param aType event type.
       
   398         */
       
   399 		void HandleResourceChange(TInt aType);
       
   400 
       
   401     private:  // Reserved
       
   402 
       
   403         /**
       
   404         * Reserved API entry.
       
   405         *
       
   406         * @internal
       
   407         */
       
   408         IMPORT_C void CNotepadListDialog_Reserved();   
       
   409         
       
   410    		CAiwGenericParamList* AiwSyncParamListLC(TInt /*aApplicationId*/);
       
   411 
       
   412     private:  // Inner class
       
   413 
       
   414         /**
       
   415         * CNotepadIdle override CIdle to add Restart function and 
       
   416         * internal state.
       
   417         */
       
   418         class CNotepadIdle : public CIdle
       
   419             {
       
   420             public: // Constructor and destructor
       
   421                 static CNotepadIdle* NewLC(const TInt aMarkCount);
       
   422                 ~CNotepadIdle();
       
   423             public: // New functions
       
   424                 inline TInt MarkCountWhenStarted() const;
       
   425             private: // Constructors 
       
   426                 inline CNotepadIdle(const TInt aMarkCount);
       
   427                 void ConstructL();
       
   428             private: // Data
       
   429                 TInt iMarkCount;
       
   430             };
       
   431 
       
   432         class CKludgeScheduler : public CBaActiveScheduler
       
   433             {
       
   434             public:
       
   435                 inline TInt PublicLevel() const;
       
   436             };
       
   437 
       
   438         class CNotepadProgressDialog : public CAknProgressDialog
       
   439             {
       
   440             public: // Constructor and destructor
       
   441                 CNotepadProgressDialog(
       
   442                     CEikDialog** aSelfPtr,
       
   443                     TBool aVisibilityDelayOff );
       
   444                 ~CNotepadProgressDialog();
       
   445             public: // New functions
       
   446                 void PrepareL( const TInt aCount, const TInt aLabelResId );
       
   447                 void IncrementL( const TInt aIncrement );
       
   448                 inline CEikProgressInfo* ProgressInfo() const;
       
   449             public: // From CAknProgressDialog
       
   450                 void ProcessFinishedL();
       
   451             private: // Data
       
   452                 CEikProgressInfo* iProgressInfo; // not own, set in PrepareL
       
   453                 CArrayFix<TInt>* iInts; // own
       
   454             };
       
   455 
       
   456     private: // Data
       
   457 
       
   458         /**
       
   459         * Flags set to iFlags.
       
   460         */
       
   461         enum TNotepadListFlags
       
   462             {
       
   463             ENotepadObserveView = 0x01,
       
   464             ENotepadItemAdded = 0x02,
       
   465             ENotepadMenuByOkKey = 0x04,
       
   466             ENotepadEverEnvironmentChanged = 0x08,
       
   467             ENotepadEverViewDeactivated = 0x10,
       
   468             ENotepadIsBackground = 0x20
       
   469             };
       
   470 
       
   471         CNotepadModel* iModel; // own
       
   472         CAknColumnListBox* iListBox; // not own (dialog own)
       
   473         TInt iEditorResId;
       
   474         CNotepadEditorDialog* iEditorDialog; // own
       
   475         CSendUi* iSendUi; // own
       
   476         TInt iSavedKey;
       
   477         TUint iFlags;
       
   478         CAknAppUi* iBaseAppUi; // not own. to know whether SendUi is running
       
   479         CNotepadIdle* iIdle; // own
       
   480         CNotepadProgressDialog* iProgressDialog; // own
       
   481         RArray<TInt> iSavedSelectedKeys; // save keys to delete
       
   482         RArray<TInt> iSavedKeysAboveCurrent;
       
   483         CEnvironmentChangeNotifier* iEnvironmentChangeNotifier; // own
       
   484         TInt iBaseLevelOfActiveScheduler;
       
   485         CAiwServiceHandler* iServiceHandler;    /// Own: AIW
       
   486         TBool iSendingEmail;
       
   487         TBool iClockValueChange;
       
   488         TBool shiftflag;
       
   489         TBool iEditorFlag;
       
   490         TBool iNeedSave;
       
   491         TTimeFormat iPreTimeFormat;
       
   492         TTimeFormat iCurrentTimeFormat; 
       
   493     };
       
   494 
       
   495 #include "NpdListDialog.inl"
       
   496 #endif // NPDLISTDIALOG_H
       
   497 
       
   498 // End of File