omads/omadsappui/AspSyncUtil/inc/AspFilterDialog.h
branchRCL_3
changeset 24 8e7494275d3a
parent 23 2bb96f4ecad8
child 25 4f0867e42d62
equal deleted inserted replaced
23:2bb96f4ecad8 24:8e7494275d3a
     1 /*
       
     2 * Copyright (c) 2005 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:  Contains general data definitions for AspSyncUtil.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef ASPFILTERDIALOG_H
       
    20 #define ASPFILTERDIALOG_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <eiklbo.h>
       
    26 #include <aknlists.h>
       
    27 #include <aknnavide.h>
       
    28 #include <AknDialog.h>
       
    29 
       
    30 #include <CAknCommonDialogsBase.h>  // TCommonDialogType
       
    31 #include <AknRadioButtonSettingPage.h>  // CAknRadioButtonSettingPage
       
    32 #include <AknCheckBoxSettingPage.h>  // CAknRadioButtonSettingPage
       
    33 
       
    34 
       
    35 #include "AspDialogUtil.h"
       
    36 
       
    37 
       
    38 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 
       
    43 /**
       
    44 * CAspFilterDialog
       
    45 * 
       
    46 * CAspFilterDialog shows list of sync filter items. 
       
    47 */
       
    48 NONSHARABLE_CLASS (CAspFilterDialog) : public CAknDialog, public MEikListBoxObserver
       
    49     {
       
    50 	public:
       
    51 	    /**
       
    52         * Launches content dialog.
       
    53         * @param aParam Class that contains dialog parameters.
       
    54         * @return Completion code.
       
    55         */
       
    56 		static TBool ShowDialogL(TAspParam& aParam);
       
    57 
       
    58 	private:
       
    59 
       
    60 		/**
       
    61 		* C++ default constructor.
       
    62 		* @param aParam Class that contains dialog parameters.
       
    63 		* @return None.
       
    64 		*/
       
    65 		CAspFilterDialog(TAspParam& aParam);
       
    66 
       
    67 						
       
    68         /**
       
    69         * Two-phased constructor.
       
    70 		* @param aParam Class that contains dialog parameters.
       
    71         */
       
    72 		static CAspFilterDialog* NewL(TAspParam& aParam);
       
    73 
       
    74         /**
       
    75         * By default Symbian 2nd phase constructor is private.
       
    76         */
       
    77 		void ConstructL();
       
    78 
       
    79 	    /**
       
    80         * Destructor.
       
    81         */
       
    82 		~CAspFilterDialog();
       
    83 
       
    84 	private:	
       
    85 
       
    86 	   /**
       
    87 		* From the base class.
       
    88         * Called when dialog is activated.
       
    89         * @return None.
       
    90         */
       
    91 		void ActivateL();
       
    92 
       
    93 		/**
       
    94 		* From the base class.
       
    95         * Handles key presses.
       
    96         * @param aKeyEvent Key code.
       
    97 		* @param aType Key type.
       
    98         * @return Result code.
       
    99         */
       
   100 		TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
   101 	
       
   102 		
       
   103 		/**
       
   104 		* From the base class.
       
   105 		* Handles menu events.
       
   106 		* @param  aCommandId Command id.
       
   107 		* @return None.
       
   108 		*/
       
   109 		virtual void ProcessCommandL(TInt aCommandId);
       
   110 
       
   111 		/**
       
   112         * From the base class
       
   113 		* Called by framework before menu is shown.
       
   114         * @param aResourceId Menu resource id.
       
   115 		* @param aMenuPane Pointer to the menu.
       
   116         * @return None.
       
   117         */
       
   118 		void DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane);
       
   119 
       
   120 		/**
       
   121 		* Handle content parameter editing.
       
   122 		* @return None.
       
   123 		*/
       
   124 		void HandleOKL();
       
   125 
       
   126 		/**
       
   127 		* Method to get context sensitive help topic.
       
   128         * @param aContext Help topic to open.
       
   129 		* @return None.
       
   130         */
       
   131 		void GetHelpContext(TCoeHelpContext& aContext) const;
       
   132 		
       
   133 	
       
   134 		/**
       
   135         * From the base class.
       
   136 		* Called by framework before exiting the dialog.
       
   137         * @param aButtonId Id of the pressed button
       
   138 		* @return ETrue to exit\ EFalse to not to exit.
       
   139         */
       
   140 		TBool OkToExitL(TInt aButtonId);
       
   141 	
       
   142 		/**
       
   143         * From the base class.
       
   144 		* Called by framework before the dialog is shown.
       
   145 		* @return None.
       
   146         */
       
   147 		void PreLayoutDynInitL();
       
   148 
       
   149 		/**
       
   150         * From MEikListBoxObserver.
       
   151 		* Handle listbox events.
       
   152         * @param aListBox Pointer to used listbox.
       
   153 		* @param aEventType Event type.
       
   154         * @return None.
       
   155         */
       
   156 		void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
   157 
       
   158 	private:
       
   159 
       
   160 		/**
       
   161 		* Check that mandatory fields are set
       
   162 		* @return Index of the invalid mandatory item.
       
   163 		*/
       
   164 		TInt CheckMandatoryFieldsL();
       
   165 	
       
   166 		/**
       
   167 		* Save content parameters into profile.
       
   168     	* @return None.
       
   169 		*/
       
   170 		void SaveSettingsL();
       
   171 
       
   172 		/**
       
   173 
       
   174 
       
   175 		/**
       
   176 		* Set filter type setting visibility.
       
   177 		* @param aVisible Visibility.
       
   178 		* @return None.
       
   179 		*/
       
   180 		void SetFilterSettingsVisibility(TBool aVisible);
       
   181     
       
   182     private:
       
   183     		
       
   184 		/**
       
   185         * Add settings titles into listbox.
       
   186         * @param aListBox.
       
   187         * @param aItemList List of setting items.
       
   188         * @return None.
       
   189         */
       
   190 		void UpdateListBoxL(CEikTextListBox* aListBox, CAspSettingList* aItemList);
       
   191 		
       
   192 		/**
       
   193         * Create one CAspListItemData for each setting.
       
   194         * @param None.
       
   195         * @return None.
       
   196         */
       
   197 		void CreateSettingsListL();
       
   198 		
       
   199 		/**
       
   200         * Adds one setting item into item list.
       
   201         * @param aItem.
       
   202 		* @return None.
       
   203         */
       
   204 		void AddItemL(CAspFilterItem* aFilterItem);
       
   205 		
       
   206 		/**
       
   207         * Initalizes setting item needed for listbox handling.
       
   208         * @param aItem.
       
   209         * @return None.
       
   210         */
       
   211 		static void InitSettingItemL(CAspListItemData* aItem);
       
   212 
       
   213 
       
   214     public:
       
   215         static TBool EditFilterL(CAspListItemData& aItem);
       
   216         
       
   217     private:
       
   218 		static TBool EditSettingItemL(CAspListItemData& aItem);
       
   219         static TBool EditSettingItemQueryL(CAspListItemData& aItem);
       
   220 
       
   221         static TBool EditSettingItemTextL(CAspListItemData& aItem);
       
   222         static TBool EditSettingItemListL(CAspListItemData& aItem);
       
   223         static TBool EditSettingItemBooleanL(CAspListItemData& aItem);
       
   224         static TBool EditSettingItemNumberL(CAspListItemData& aItem);
       
   225         static TBool EditSettingItemDateL(CAspListItemData& aItem);
       
   226         static TBool EditSettingItemTimeL(CAspListItemData& aItem);
       
   227 
       
   228         
       
   229         static TBool EditMultiChoiceListL(CAspListItemData& aItem);
       
   230         static TBool EditSingleChoiceListL(CAspListItemData& aItem);
       
   231 
       
   232 	 
       
   233     private:
       
   234 		/**
       
   235 		* Utility function.
       
   236 		* @param aIndex Listbox index.
       
   237 		* @return setting item with listbox position aIndex.
       
   238         */
       
   239 		CAspListItemData* ItemForIndex(TInt aIndex);
       
   240 
       
   241 		/**
       
   242         * Utility function.
       
   243         * @param aItemId Item id.
       
   244         * @return Pointer to setting item.
       
   245         */
       
   246 		CAspListItemData* Item(TInt aItemId);
       
   247 
       
   248   
       
   249 		/**
       
   250 		* Utility function.
       
   251 		* @param None.
       
   252 		* @return Sync profile.
       
   253         */
       
   254 		RSyncMLDataSyncProfile& Profile();
       
   255 
       
   256 		/**
       
   257 		* Utility function.
       
   258 		* @param None.
       
   259 		* @return Sync task.
       
   260         */
       
   261 		//RSyncMLTask& Task();
       
   262 
       
   263 		/**
       
   264 		* Utility function.
       
   265 		* @param None.
       
   266 		* @return Listbox.
       
   267         */
       
   268 		CAknSettingStyleListBox* ListBox();
       
   269 		
       
   270 		/**
       
   271 		* Utility function.
       
   272 		* @param None.
       
   273 		* @return Pointer to resource handler.
       
   274 		*/
       
   275 		CAspResHandler* ResHandler();
       
   276 		
       
   277 		
       
   278 		/**
       
   279         * Set setting item visibility (normal/readonly/hidden).
       
   280         * @param None.
       
   281 		* @return None.
       
   282         */
       
   283 		void SetVisibility();
       
   284 
       
   285 		
       
   286 		
       
   287 
       
   288 	private:
       
   289 		// id of the calling application
       
   290 		TInt iApplicationId;
       
   291 
       
   292 		// list box for setting items 
       
   293 		CAknSettingStyleListBox* iListBox;
       
   294 		
       
   295 		// setting items
       
   296 		CAspSettingList *iSettingList;
       
   297 		
       
   298 		// CEikStatusPane contains dialog title and image
       
   299 		CEikStatusPane* iStatusPane;
       
   300 
       
   301 		// for title and icon handling
       
   302 		CStatusPaneHandler* iStatusPaneHandler;
       
   303 
       
   304 		// session with sync server
       
   305 		RSyncMLSession* iSyncSession;
       
   306 		
       
   307 		// long buffer for string handling
       
   308 		TBuf<KBufSize255> iBuf;
       
   309 		
       
   310 		// sync task
       
   311 		CAspFilter* iFilter;
       
   312 		
       
   313 		// dialog parameters
       
   314 		TAspParam* iDialogParam;
       
   315 		
       
   316 		// resource handler
       
   317 		CAspResHandler* iResHandler;
       
   318 	};
       
   319 
       
   320 
       
   321 /**
       
   322 * MAspChoiceListObserver
       
   323 *
       
   324 * MAspChoiceListObserver is for handling choice list events.
       
   325 */
       
   326 class MAspChoiceListObserver
       
   327     {
       
   328     public:
       
   329 	    virtual TBool HandleChoiceListEventL(TInt aEvent, TInt aListType) = 0;
       
   330     };
       
   331 
       
   332 
       
   333 /**
       
   334 * CAspChoiceListSettingPage
       
   335 *
       
   336 * Radio button setting page that contains "User defined" option.
       
   337 */
       
   338 NONSHARABLE_CLASS (CAspChoiceListSettingPage) : public CAknRadioButtonSettingPage
       
   339 	{
       
   340     public:
       
   341 	enum TEditorType
       
   342 		{
       
   343 		ETypeNormal,
       
   344 	    ETypeUserDefined
       
   345 		};
       
   346 	
       
   347     public: 
       
   348 	    CAspChoiceListSettingPage(TInt aResourceID, TInt& aCurrentSelectionIndex,
       
   349                                   const MDesCArray* aItemArray, 
       
   350                                   MAspChoiceListObserver* aObserver, TInt aType);
       
   351         ~CAspChoiceListSettingPage();            
       
   352 	
       
   353     protected: // From CCoeControl
       
   354 	    void ProcessCommandL(TInt aCommandId);
       
   355 	    
       
   356 	private:
       
   357 	    MAspChoiceListObserver* iObserver;
       
   358 	    TInt iType;
       
   359 	};
       
   360 
       
   361 
       
   362 /**
       
   363 * CAspMultiChoiceListSettingPage
       
   364 *
       
   365 * Check box button setting page that contains "User defined" option.
       
   366 */
       
   367 NONSHARABLE_CLASS (CAspMultiChoiceListSettingPage) : public CAknCheckBoxSettingPage
       
   368 	{
       
   369     public:
       
   370 	enum TEditorType
       
   371 		{
       
   372 		ETypeNormal,
       
   373 	    ETypeUserDefined
       
   374 		};
       
   375 	
       
   376     public: 
       
   377 	    CAspMultiChoiceListSettingPage(TInt aResourceID, CSelectionItemList* aItemArray, 
       
   378                                   MAspChoiceListObserver* aObserver, TInt aType);
       
   379         ~CAspMultiChoiceListSettingPage();            
       
   380 	
       
   381     protected: // From CCoeControl
       
   382 	    void ProcessCommandL(TInt aCommandId);
       
   383 	    
       
   384 	private:
       
   385 	    MAspChoiceListObserver* iObserver;
       
   386 	    TInt iType;
       
   387 	    CSelectionItemList* iSelectionList;
       
   388 	};
       
   389 
       
   390 
       
   391 
       
   392 /**
       
   393 * CAspChoiceList
       
   394 *
       
   395 * CAspChoiceList implemets choicelist with "User defined" item.
       
   396 */
       
   397 NONSHARABLE_CLASS (CAspChoiceList) : public CBase, public MAspChoiceListObserver
       
   398     {
       
   399     public:
       
   400 	enum TListType
       
   401 		{
       
   402 		ETypeNormal,
       
   403 		ETypeTextUserDefined,
       
   404 	    ETypeIntegerUserDefined,
       
   405 	    ETypeDateUserDefined,
       
   406 	    ETypeTimeUserDefined
       
   407 		};
       
   408 
       
   409     public:
       
   410 		static CAspChoiceList* NewLC(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength);
       
   411 		~CAspChoiceList();
       
   412 	private:
       
   413 		CAspChoiceList(const TDesC& aTitle, CSelectionItemList* iList, TInt aType, TInt aMaxLength);
       
   414 		void ConstructL();
       
   415     
       
   416     public:
       
   417         TBool ShowListL();
       
   418       
       
   419     public:
       
   420         void AddItemL(CSelectionItemList* aList, TDes& aText, TBool aEnable);
       
   421         void AddItemL(TDes& aText, TBool aEnable);
       
   422         void AddItemL(TInt aNumber, TBool aEnable);
       
   423         void AddUserDefinedL();
       
   424         void RemoveUserDefinedL();
       
   425         CDesCArray* DesArrayLC(CSelectionItemList* aList);
       
   426         void SetSelectedIndex(CSelectionItemList* aList, TInt aIndex);
       
   427         TInt SelectedIndex(CSelectionItemList* aList);
       
   428         TBool EditTextL(TDes& aText, const TDesC& aTitle);
       
   429 
       
   430 
       
   431     private: // from MAspChoiceListObserver
       
   432 	    TBool HandleChoiceListEventL(TInt aEvent, TInt aListType);
       
   433 
       
   434 
       
   435 	private:
       
   436 	    TInt  iUserDefinedInt;
       
   437 	    TBuf<KBufSize>  iUserDefinedText;
       
   438 	    TInt iMaxTextLength;
       
   439 	    
       
   440 	    TInt iListType;
       
   441         TBuf<KBufSize> iTitle;
       
   442         CSelectionItemList* iSelectionList;
       
   443     };
       
   444 
       
   445 
       
   446 
       
   447 /**
       
   448 * CAspMultiChoiceList
       
   449 *
       
   450 * CAspChoiceList implemets multiple selection choicelist with "User defined" item.
       
   451 */
       
   452 NONSHARABLE_CLASS (CAspMultiChoiceList) : public CBase, public MAspChoiceListObserver
       
   453     {
       
   454     public:
       
   455 		static CAspMultiChoiceList* NewLC(const TDesC& aTitle, CSelectionItemList* aList, TInt aType, TInt aMaxLength);
       
   456 		~CAspMultiChoiceList();
       
   457 	private:
       
   458 		CAspMultiChoiceList(const TDesC& aTitle, CSelectionItemList* iList, TInt aType, TInt aMaxLength);
       
   459 		void ConstructL();
       
   460     
       
   461     public:
       
   462         TBool ShowListL();
       
   463 
       
   464     
       
   465     public:
       
   466         void AddItemL(CSelectionItemList* aList, TDes& aText, TBool aEnable);
       
   467         void AddItemL(TDes& aText, TBool aEnable);
       
   468         void AddItemL(TInt aNumber, TBool aEnable);
       
   469         void AddUserDefinedL();
       
   470         void RemoveUserDefinedL();
       
   471         TBool EditTextL(TDes& aText, const TDesC& aTitle);
       
   472     
       
   473     private: // from MAspChoiceListObserver
       
   474 	    TBool HandleChoiceListEventL(TInt aEvent, TInt aListType);
       
   475 
       
   476 	private:
       
   477 	    TInt  iUserDefinedInt;
       
   478 	    TBuf<KBufSize>  iUserDefinedText;
       
   479 	    TInt iMaxTextLength;
       
   480 	    
       
   481 	    TInt iListType;
       
   482         TBuf<KBufSize> iTitle;
       
   483         CSelectionItemList* iSelectionList;
       
   484     };
       
   485 
       
   486 
       
   487 
       
   488 #endif      // ASPFILTERDIALOG_H
       
   489             
       
   490 // End of File