1 /* |
|
2 * Copyright (c) 2005-2010 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: This file contains class for landmarks editor and viewer |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CLMKEDITORIMPL_H |
|
19 #define CLMKEDITORIMPL_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "CLmkFields.h" |
|
23 #include "MLmkEditorUiBuilder.h" |
|
24 #include "MLmkLocationObserver.h" |
|
25 #include <AknForm.h> // CAknForm |
|
26 #include <EPos_Landmarks.h> // Lm typedefs, constants etc. |
|
27 #include <CLmkEditorDlg.h> // dialog flags |
|
28 #include <AknInfoPopupNoteController.h> |
|
29 #include "CLmkLandMarkCategoriesName.h" |
|
30 #include "clmkmapnavigationinterface.h" |
|
31 #include "mlmkcentralrepositoryobserver.h" |
|
32 #include "lmkwaitdlglauncher.h" |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CPosLandmarkDatabase; |
|
36 class CLmkSender; |
|
37 class MObjectProvider; |
|
38 class CPosLmPartialReadParameters; |
|
39 class CLmkUiUtils; |
|
40 class CPosLandmark; |
|
41 class CLmkEditorFieldArray; |
|
42 class CAknNavigationDecorator; |
|
43 class CLmkLocationService; |
|
44 class TCoeHelpContext; |
|
45 class CLmkCallCmd; |
|
46 class CLmkGoToURLCmd; |
|
47 class MLmkEditorField; |
|
48 class CLmkCentralRepository; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 /** |
|
52 * CLmkEditorImpl class |
|
53 */ |
|
54 class CLmkEditorImpl : public CAknForm, |
|
55 public MLmkEditorUiBuilder, |
|
56 public MLmkLocationObserver, |
|
57 public MLmkListProviderObserver, |
|
58 public MLmkCentralRepositoryObserver, |
|
59 public MLmkWaitDialogLauncherObserver |
|
60 { |
|
61 public: |
|
62 // Constructors and destructor |
|
63 /** |
|
64 * Edit or create new landmark |
|
65 * Create new landmark if aLandmarkId = KPosLmNullItemId |
|
66 * Not take ownership CPosLmPartialReadParameters |
|
67 * @param aDb |
|
68 * @param aSender landmark sender reference |
|
69 * @param aAttributes |
|
70 * @param aEditorMode |
|
71 * @param aLandmarkId |
|
72 * @return newly instantiated object |
|
73 */ |
|
74 IMPORT_C static CLmkEditorImpl* NewL(CPosLandmarkDatabase& aDb, |
|
75 CLmkSender& aSender, TLmkEditorAttributes aAttributes, |
|
76 TLmkEditorMode aEditorMode, TPosLmItemId aLandmarkId); |
|
77 |
|
78 /** |
|
79 * Edit landmark |
|
80 * Not take ownership CPosLandmark or CPosLmPartialReadParameters |
|
81 * @param aDb |
|
82 * @param aSender landmark sender reference |
|
83 * @param aAttributes |
|
84 * @param aEditorFlags |
|
85 * @param aLandmark |
|
86 * @return newly instantiated object |
|
87 */ |
|
88 IMPORT_C static CLmkEditorImpl* NewL(CPosLandmarkDatabase& aDb, |
|
89 CLmkSender& aSender, TLmkEditorAttributes aAttributes, |
|
90 TLmkEditorMode aEditorMode, CPosLandmark* aLandmark); |
|
91 IMPORT_C static CLmkEditorImpl* NewL(CPosLandmarkDatabase& aDb, |
|
92 CLmkSender& aSender, TLmkEditorAttributes aAttributes, |
|
93 TLmkEditorMode aEditorMode, TPosLmItemId* aLandmarkId, |
|
94 CPosLandmark* aLandmark); |
|
95 /** |
|
96 * Destructor. |
|
97 */ |
|
98 ~CLmkEditorImpl(); |
|
99 |
|
100 public: |
|
101 // New functions |
|
102 /** |
|
103 * Set parent |
|
104 * @param aParent |
|
105 */ |
|
106 IMPORT_C void SetMopParent(MObjectProvider* aParent); |
|
107 |
|
108 /** |
|
109 * Set help context |
|
110 * @param aContect |
|
111 */ |
|
112 IMPORT_C void SetHelpContext(TCoeHelpContext aContext); |
|
113 |
|
114 /** |
|
115 * ExecuteLD |
|
116 * @return error code |
|
117 */ |
|
118 IMPORT_C TInt ExecuteLD(); |
|
119 /** |
|
120 * This function when invoked, disables the Map and Navigation related Menu Options |
|
121 * This needs to be invoked before ExecuteLD().By default, the Map and Navigation |
|
122 * menu options are enabled and are shown. |
|
123 * |
|
124 */ |
|
125 IMPORT_C void DisableMapAndNavigationMenuOptions(); |
|
126 /** |
|
127 * This function should be invoked only when,from the landmark |
|
128 * view dialog, edit mode dialog and launched and fields are |
|
129 * updated. This function updates the corresponding the fields |
|
130 * in the landmark viewer dialog. |
|
131 */ |
|
132 void UpdateViewDlgL(); |
|
133 |
|
134 public: |
|
135 // From CAknForm |
|
136 void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane); |
|
137 void ProcessCommandL(TInt aCommandId); |
|
138 void HandleControlStateChangeL(TInt aControlId); |
|
139 void DoNotSaveFormDataL(); |
|
140 TInt EditMode(); |
|
141 public: |
|
142 //from MLmkWaitDialogLauncherObserver |
|
143 void HandleDialogDismissed(TInt aButtonId); |
|
144 |
|
145 public: |
|
146 //from CCoeControl |
|
147 void GetHelpContext(TCoeHelpContext& aContext) const; |
|
148 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
149 |
|
150 protected: |
|
151 //from MLmkLocationObserver |
|
152 void NotifyL(const TInt aStatus); |
|
153 void NotifyErrorL(TInt aErrorCode); |
|
154 |
|
155 public: |
|
156 //from CEikDialog |
|
157 SEikControlInfo CreateCustomControlL(TInt aControlType); |
|
158 MEikDialogPageObserver::TFormControlTypes |
|
159 ConvertCustomControlTypeToBaseControlType(TInt aControlType) const; |
|
160 |
|
161 #ifdef RD_SCALABLE_UI_V2 |
|
162 protected: |
|
163 // From MEikDialogPageObserver |
|
164 void HandleDialogPageEventL(TInt aEventID); |
|
165 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
166 |
|
167 #endif //RD_SCALABLE_UI_V2 |
|
168 //from MEikDialogPageObserver |
|
169 void LineChangedL(TInt aControlId); |
|
170 |
|
171 protected: |
|
172 // from CAknForm |
|
173 void PreLayoutDynInitL(); |
|
174 void PostLayoutDynInitL(); |
|
175 |
|
176 protected: |
|
177 //from CEikDialog |
|
178 TBool OkToExitL(TInt aKeyCode); |
|
179 |
|
180 protected: |
|
181 //from MLmkCentralRepositoryObserver |
|
182 void HandleCentralRepositoryChangeL(); |
|
183 |
|
184 protected: |
|
185 // Constructors and destructor |
|
186 /** |
|
187 * C++ default constructor. |
|
188 * @param aDb |
|
189 * @param aSender landmark sender reference |
|
190 * @param aEditorMode |
|
191 * @return newly instantiated object |
|
192 */ |
|
193 CLmkEditorImpl(CPosLandmarkDatabase& aDb, CLmkSender& aSender, |
|
194 TLmkEditorMode aEditorMode); |
|
195 |
|
196 /** |
|
197 * By default Symbian 2nd phase constructor is private. |
|
198 * @param aLandmarkId, negative if create new |
|
199 * @param aAttiributes |
|
200 */ |
|
201 void ConstructL(TPosLmItemId aLandmarkId, |
|
202 TLmkEditorAttributes aAttributes); |
|
203 |
|
204 /** |
|
205 * By default Symbian 2nd phase constructor is private. |
|
206 * @param aLandmark, Null if create new |
|
207 * @param aAttributes |
|
208 */ |
|
209 void |
|
210 ConstructL(CPosLandmark* aLandmark, |
|
211 TLmkEditorAttributes aAttributes); |
|
212 |
|
213 /** |
|
214 * By default Symbian 2nd phase constructor is private. |
|
215 * @param aLandmarkId, negative if create new |
|
216 * @param aAttiributes |
|
217 */ |
|
218 void ConstructL(TPosLmItemId* aLandmarkId, CPosLandmark* aLandmark, |
|
219 TLmkEditorAttributes aAttributes); |
|
220 |
|
221 /** |
|
222 * Set default things for both other ConstructL() methods. |
|
223 */ |
|
224 void CommonConstructL(TLmkEditorAttributes& aAttributes); |
|
225 |
|
226 /** |
|
227 * Context menu bar construction |
|
228 */ |
|
229 void ConstructContextMenuL(); |
|
230 TBool IsLandmarkDataEmptyL(CPosLandmark* aLandmark); |
|
231 |
|
232 /** |
|
233 * Check whether Coordinates has to be hidden. |
|
234 */ |
|
235 void CheckHideCoordinateL(); |
|
236 |
|
237 private: |
|
238 // from MPbkContactEditorUiBuilder |
|
239 CCoeControl* CreateLineL(const TDesC& aCaption, TInt aControlId, |
|
240 TInt aControlType); |
|
241 CEikCaptionedControl* LineControl(TInt aControlId) const; |
|
242 void DeleteControl(TInt aControlId); |
|
243 void TryChangeFocusL(TInt aControlId); |
|
244 void SetCurrentLineCaptionL(TInt aControlId, const TDesC& aText); |
|
245 CCoeControl* Control(TInt aControlId) const; |
|
246 void SetEditableL(TBool aState); |
|
247 CPosLandmarkDatabase& Database(); |
|
248 CPosLandmark* GetCurrentEditedLandmarkL(); |
|
249 |
|
250 private: |
|
251 // New functions |
|
252 void CreateLabelArrayL(); |
|
253 void CreateLabelL(TInt iResourceId, TInt iPos); |
|
254 TBool IsNameFieldEmptyL(); |
|
255 TBool OkToExitL(); |
|
256 void SelectCategoriesCmdL(); |
|
257 void CurrentLocationCmdL(); |
|
258 void ChangeIconCmdL(); |
|
259 void CategoriesCmdL(); |
|
260 void CategoriesCmdFromXmlL(); |
|
261 void SetCurrentLocationL(const TPosition& aPosition); |
|
262 void ChangeContextImageL(); |
|
263 void AttachAIWMenuInterestL(); |
|
264 |
|
265 void CreateLabelArrayForNormalModeL(); |
|
266 void CreateLabelArrayForJapaneseModeL(); |
|
267 /** |
|
268 * Gets the length of text fields |
|
269 */ |
|
270 TInt GetFieldTextLengthL(MLmkEditorField& afield); |
|
271 |
|
272 //New Functions to update the view dialog when |
|
273 //when the landmark fields are changed during the |
|
274 //editing mode |
|
275 |
|
276 void UpdateTextEditorControlL(MLmkEditorField* aEditorField, |
|
277 CPosLandmark* aLandmark, MLmkFieldData* fieldData, |
|
278 TUint aFiledType, TInt aPrevControlId, TInt aPos); |
|
279 void UpdateCoordinateEditorControlL(MLmkEditorField* aEditorField, |
|
280 MLmkFieldData* fieldData, TReal aValue, TInt aPrevControlId, |
|
281 TInt aPos); |
|
282 void UpdateCategoryEditorControlL(MLmkEditorField* aEditorField, |
|
283 MLmkFieldData* fieldData, TInt aPrevControlId, TInt aPos, |
|
284 CPosLandmark& aLandmark); |
|
285 void UpdateNumberEditorControlL(MLmkEditorField* aEditorField, |
|
286 MLmkFieldData* fieldData, TReal32 aValue, TInt aPrevControlId, |
|
287 TInt aPos); |
|
288 |
|
289 void UpdateNameEditorControlL(MLmkEditorField* aEditorField, |
|
290 CPosLandmark* aLandmark, MLmkFieldData* fieldData); |
|
291 void UpdateDesEditorControlL(MLmkEditorField* aEditorField, |
|
292 CPosLandmark* aLandmark, MLmkFieldData* fieldData, |
|
293 TInt aPrevControlId, TInt aPos); |
|
294 |
|
295 //Pops up info popup after 1 sec. |
|
296 //void ShowMultipleCategoriesInfoPopupL(TBool aRefresh); |
|
297 |
|
298 TBool ShowQueryIfLocationFieldsAlreadyFilledL(); |
|
299 |
|
300 TBool ValidateContentL(); |
|
301 |
|
302 void DoNotSaveDataL(const TUint16 aFieldType); |
|
303 |
|
304 TBool IsFieldEmptyL(const TUint16 aFieldType); |
|
305 |
|
306 TBool CLmkEditorImpl::IsInvalidUriL(); |
|
307 |
|
308 void LaunchLmkEditorL(); |
|
309 |
|
310 void DeleteSelfL(); |
|
311 |
|
312 void UpdateCatInfoNotePosition(); |
|
313 |
|
314 TBool IsCategoryField(); |
|
315 |
|
316 /** |
|
317 * Clears the lat/long/pos acc/alt acc fields |
|
318 */ |
|
319 void ClearPositionInfoL(); |
|
320 |
|
321 protected: |
|
322 /** |
|
323 * Checks if position fields do not have value |
|
324 */ |
|
325 TBool ArePositionFieldEmptyL(); |
|
326 |
|
327 private: |
|
328 #ifdef RD_SCALABLE_UI_V2 |
|
329 /** |
|
330 * Handles touch click command , only for editor |
|
331 */ |
|
332 void HandleEditorCommandL(); |
|
333 #endif //RD_SCALABLE_UI_V2 |
|
334 MLmkEditorField* InsertLineL(MLmkFieldData* aFieldData, |
|
335 TInt aPrevControlId); |
|
336 void DeleteLineL(MLmkEditorField* aEditorField, TInt aCtrlId, TInt aPos); |
|
337 MLmkEditorField* AddOrDeleteLineL(MLmkEditorField* aEditorField, |
|
338 MLmkFieldData* aFieldData, TInt aPrevControlId, TInt aCtrlId, |
|
339 TInt aPos); |
|
340 static TInt MessageQueryCallBack(TAny* aPtr); |
|
341 |
|
342 private: |
|
343 //from MLmkListProviderObserver |
|
344 void HandleListProviderEvent(TLmkListProviderEventType aEvent); |
|
345 |
|
346 void HandleListProviderError(TInt aError); |
|
347 |
|
348 protected: |
|
349 //overriden virtual from CCoeControl |
|
350 virtual void ActivateL(); |
|
351 |
|
352 public: |
|
353 // Added for category name support |
|
354 void SetCategoryName(const TDesC& aCategoryName); |
|
355 //This function is called when moving from view mode to |
|
356 //edit mode, which field to be focussed/ |
|
357 void SetFieldTypeToFocusInEditMode(TUint aFieldType); |
|
358 |
|
359 /** |
|
360 * This function checks if the editing dialog is launched |
|
361 * from the lmk viewer dialog |
|
362 */ |
|
363 TBool IsDlgEditing(); |
|
364 |
|
365 /** |
|
366 * This function sets the mode of the editor dialog as |
|
367 * editing, when launched from lmk viewer dialog |
|
368 * This is to avoid crash in ActivateL |
|
369 */ |
|
370 void SetDlgEditing(TBool aEditing); |
|
371 // For Landscape Support |
|
372 void HandleResourceChange(TInt aType); |
|
373 |
|
374 protected: |
|
375 //for MSK |
|
376 virtual void UpdateMskOnArrowMoveForViewerL(); |
|
377 void AddMskCommandL(TInt aResourceId, TLmkAppCmdId aCommandId); |
|
378 void DimmMiddleSoftKey(); |
|
379 |
|
380 protected: |
|
381 // Data |
|
382 /// Reference to database |
|
383 CPosLandmarkDatabase& iDb; |
|
384 |
|
385 ///Ref: landmark sender |
|
386 CLmkSender& iSender; |
|
387 |
|
388 /// Ref: CPosLmPartialReadParameters |
|
389 CPosLmPartialReadParameters* iPartialLmk; |
|
390 |
|
391 /// TInt |
|
392 TInt iResourceOffset; |
|
393 |
|
394 /// Own: landmark UI utils |
|
395 CLmkUiUtils* iLmkUiUtils; |
|
396 |
|
397 ///Own: |
|
398 CLmkFields* iLmkFields; |
|
399 |
|
400 ///Own: |
|
401 RPointerArray<HBufC> iLabelArray; |
|
402 |
|
403 ///Own: |
|
404 CLmkEditorFieldArray* iEditorFieldArray; |
|
405 |
|
406 TLmkEditorMode iEditorMode; |
|
407 |
|
408 ///Own: |
|
409 CLmkLocationService* iLocationService; |
|
410 |
|
411 TCoeHelpContext iHelpContext; |
|
412 TBool iCalegorySelectionFlag; |
|
413 RArray<TCategoryName> iCategoryNames; |
|
414 |
|
415 ///Ref: |
|
416 // Used to return the created Landmark Id Value. |
|
417 // Don't allocate or delete memory or set to NULL; |
|
418 // The variable might be a local stack variable. |
|
419 // If no landmarks is created then set it to -1 or if successful |
|
420 // then set it to the Landmark Id value. |
|
421 TPosLmItemId* iLandmarkItemId; |
|
422 |
|
423 /// Own: context menu bar |
|
424 CEikMenuBar* iContextMenuBar; |
|
425 CLmkGoToURLCmd* iLmkGoToURLCmd; |
|
426 CLmkCallCmd* iLmkCallCmd; |
|
427 // Flag to determine if Map and Navigation options needs to be shown |
|
428 TBool iMapNavFeature; |
|
429 // Current Input language. (Used for Japanese) |
|
430 TBool iJapaneseInputMode; |
|
431 CPosLandmark* iLandmark; |
|
432 |
|
433 //Own: Pointer to map and navigation interface |
|
434 CLmkMapNavigationInterface* iMapNavInterface; |
|
435 // Flag which indicates receive state of landmark editor dialog |
|
436 // Set to true for receive mode |
|
437 TBool iIsLmkReceiveMode; |
|
438 TLmkAppCmdId iMskCmdId; |
|
439 TInt iCurrentResourceId; |
|
440 |
|
441 //It will be ETrue when coordinates has to be hidden. |
|
442 TBool iIsHideCoordinate; |
|
443 |
|
444 //It will be ETrue when help has to be hidden. |
|
445 TBool iIsHideHelp; |
|
446 |
|
447 // To Handle Drag Pointer Event |
|
448 TBool iIsDragging; |
|
449 |
|
450 private: |
|
451 //added data members |
|
452 //holds the field type of the current focussed item in the dialog |
|
453 TUint iFieldTypeToFocus; |
|
454 //Set true when editor dialog is launched from view dialog. |
|
455 TBool iIsEditing; |
|
456 |
|
457 TBool iBackspaceStartForWebAddressField; |
|
458 |
|
459 TBool iResetWebAddrSize; |
|
460 CAknInfoPopupNoteController* iCatInfoPopupNote; |
|
461 |
|
462 CLmkEditorImpl* iEditor; |
|
463 |
|
464 CLmkCentralRepository* iRepository; |
|
465 |
|
466 /** |
|
467 * Wait dialog launcher |
|
468 * Owns |
|
469 */ |
|
470 CLmkWaitDialogLauncher* iWaitDialogLauncher; |
|
471 TBool iIsEndKey; |
|
472 TBool iIsEditableField; |
|
473 |
|
474 // To check the ownership of iLandmark |
|
475 TBool iIsLmOwned; |
|
476 |
|
477 // To Check category selector launched or not |
|
478 TBool iIsCategorySelctorOpen; |
|
479 }; |
|
480 #endif // CLMKEDITORIMPL_H |
|
481 |
|
482 // End of File |
|