|
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 #endif //RD_SCALABLE_UI_V2 |
|
166 |
|
167 //from MEikDialogPageObserver |
|
168 void LineChangedL(TInt aControlId); |
|
169 |
|
170 protected: |
|
171 // from CAknForm |
|
172 void PreLayoutDynInitL(); |
|
173 void PostLayoutDynInitL(); |
|
174 |
|
175 protected: |
|
176 //from CEikDialog |
|
177 TBool OkToExitL(TInt aKeyCode); |
|
178 |
|
179 protected: |
|
180 //from MLmkCentralRepositoryObserver |
|
181 void HandleCentralRepositoryChangeL(); |
|
182 |
|
183 protected: |
|
184 // Constructors and destructor |
|
185 /** |
|
186 * C++ default constructor. |
|
187 * @param aDb |
|
188 * @param aSender landmark sender reference |
|
189 * @param aEditorMode |
|
190 * @return newly instantiated object |
|
191 */ |
|
192 CLmkEditorImpl(CPosLandmarkDatabase& aDb, CLmkSender& aSender, |
|
193 TLmkEditorMode aEditorMode); |
|
194 |
|
195 /** |
|
196 * By default Symbian 2nd phase constructor is private. |
|
197 * @param aLandmarkId, negative if create new |
|
198 * @param aAttiributes |
|
199 */ |
|
200 void ConstructL(TPosLmItemId aLandmarkId, |
|
201 TLmkEditorAttributes aAttributes); |
|
202 |
|
203 /** |
|
204 * By default Symbian 2nd phase constructor is private. |
|
205 * @param aLandmark, Null if create new |
|
206 * @param aAttributes |
|
207 */ |
|
208 void ConstructL(CPosLandmark* aLandmark, |
|
209 TLmkEditorAttributes aAttributes); |
|
210 |
|
211 /** |
|
212 * By default Symbian 2nd phase constructor is private. |
|
213 * @param aLandmarkId, negative if create new |
|
214 * @param aAttiributes |
|
215 */ |
|
216 void ConstructL(TPosLmItemId* aLandmarkId, CPosLandmark* aLandmark, |
|
217 TLmkEditorAttributes aAttributes); |
|
218 |
|
219 /** |
|
220 * Set default things for both other ConstructL() methods. |
|
221 */ |
|
222 void CommonConstructL(TLmkEditorAttributes& aAttributes); |
|
223 |
|
224 /** |
|
225 * Context menu bar construction |
|
226 */ |
|
227 void ConstructContextMenuL(); |
|
228 |
|
229 /** |
|
230 * Checks Landmarks Coordinate Data Is available or not. |
|
231 */ |
|
232 TBool IsLandmarkDataEmptyL(CPosLandmark* aLandmark); |
|
233 |
|
234 /** |
|
235 * Check whether Coordinates has to be hidden. |
|
236 */ |
|
237 void CheckHideCoordinateL(); |
|
238 |
|
239 private: |
|
240 // from MPbkContactEditorUiBuilder |
|
241 CCoeControl* CreateLineL(const TDesC& aCaption, TInt aControlId, |
|
242 TInt aControlType); |
|
243 CEikCaptionedControl* LineControl(TInt aControlId) const; |
|
244 void DeleteControl(TInt aControlId); |
|
245 void TryChangeFocusL(TInt aControlId); |
|
246 void SetCurrentLineCaptionL(TInt aControlId, const TDesC& aText); |
|
247 CCoeControl* Control(TInt aControlId) const; |
|
248 void SetEditableL(TBool aState); |
|
249 CPosLandmarkDatabase& Database(); |
|
250 CPosLandmark* GetCurrentEditedLandmarkL(); |
|
251 |
|
252 private: |
|
253 // New functions |
|
254 void CreateLabelArrayL(); |
|
255 void CreateLabelL(TInt iResourceId, TInt iPos); |
|
256 TBool IsNameFieldEmptyL(); |
|
257 TBool OkToExitL(); |
|
258 void SelectCategoriesCmdL(); |
|
259 void CurrentLocationCmdL(); |
|
260 void ChangeIconCmdL(); |
|
261 void CategoriesCmdL(); |
|
262 void CategoriesCmdFromXmlL(); |
|
263 void SetCurrentLocationL(const TPosition& aPosition); |
|
264 void ChangeContextImageL(); |
|
265 void AttachAIWMenuInterestL(); |
|
266 |
|
267 void CreateLabelArrayForNormalModeL(); |
|
268 void CreateLabelArrayForJapaneseModeL(); |
|
269 /** |
|
270 * Gets the length of text fields |
|
271 */ |
|
272 TInt GetFieldTextLengthL(MLmkEditorField& afield); |
|
273 |
|
274 //New Functions to update the view dialog when |
|
275 //when the landmark fields are changed during the |
|
276 //editing mode |
|
277 |
|
278 void UpdateTextEditorControlL(MLmkEditorField* aEditorField, |
|
279 CPosLandmark* aLandmark, MLmkFieldData* fieldData, |
|
280 TUint aFiledType, TInt aPrevControlId, TInt aPos); |
|
281 void UpdateCoordinateEditorControlL(MLmkEditorField* aEditorField, |
|
282 MLmkFieldData* fieldData, TReal aValue, TInt aPrevControlId, |
|
283 TInt aPos); |
|
284 void UpdateCategoryEditorControlL(MLmkEditorField* aEditorField, |
|
285 MLmkFieldData* fieldData, TInt aPrevControlId, TInt aPos, |
|
286 CPosLandmark& aLandmark); |
|
287 void UpdateNumberEditorControlL(MLmkEditorField* aEditorField, |
|
288 MLmkFieldData* fieldData, TReal32 aValue, TInt aPrevControlId, |
|
289 TInt aPos); |
|
290 |
|
291 void UpdateNameEditorControlL(MLmkEditorField* aEditorField, |
|
292 CPosLandmark* aLandmark, MLmkFieldData* fieldData); |
|
293 void UpdateDesEditorControlL(MLmkEditorField* aEditorField, |
|
294 CPosLandmark* aLandmark, MLmkFieldData* fieldData, |
|
295 TInt aPrevControlId, TInt aPos); |
|
296 |
|
297 TBool ShowQueryIfLocationFieldsAlreadyFilledL(); |
|
298 |
|
299 TBool ValidateContentL(); |
|
300 |
|
301 void DoNotSaveDataL(const TUint16 aFieldType); |
|
302 |
|
303 TBool IsFieldEmptyL(const TUint16 aFieldType); |
|
304 |
|
305 TBool IsInvalidUriL(); |
|
306 |
|
307 void LaunchLmkEditorL(); |
|
308 |
|
309 void DeleteSelfL(); |
|
310 |
|
311 void UpdateCatInfoNotePosition(); |
|
312 |
|
313 TBool IsCategoryField(); |
|
314 |
|
315 /** |
|
316 * Clears the lat/long/pos acc/alt acc fields |
|
317 */ |
|
318 void ClearPositionInfoL(); |
|
319 |
|
320 protected: |
|
321 /** |
|
322 * Checks if position fields do not have value |
|
323 */ |
|
324 TBool ArePositionFieldEmptyL(); |
|
325 |
|
326 private: |
|
327 #ifdef RD_SCALABLE_UI_V2 |
|
328 /** |
|
329 * Handles touch click command , only for editor |
|
330 */ |
|
331 void HandleEditorCommandL(); |
|
332 #endif //RD_SCALABLE_UI_V2 |
|
333 MLmkEditorField* InsertLineL(MLmkFieldData* aFieldData, |
|
334 TInt aPrevControlId); |
|
335 void DeleteLineL(MLmkEditorField* aEditorField, TInt aCtrlId, TInt aPos); |
|
336 MLmkEditorField* AddOrDeleteLineL(MLmkEditorField* aEditorField, |
|
337 MLmkFieldData* aFieldData, TInt aPrevControlId, TInt aCtrlId, |
|
338 TInt aPos); |
|
339 static TInt MessageQueryCallBack(TAny* aPtr); |
|
340 |
|
341 private: |
|
342 //from MLmkListProviderObserver |
|
343 void HandleListProviderEvent(TLmkListProviderEventType aEvent); |
|
344 |
|
345 void HandleListProviderError(TInt aError); |
|
346 |
|
347 protected: |
|
348 //overriden virtual from CCoeControl |
|
349 virtual void ActivateL(); |
|
350 |
|
351 public: |
|
352 // Added for category name support |
|
353 void SetCategoryName(const TDesC& aCategoryName); |
|
354 //This function is called when moving from view mode to |
|
355 //edit mode, which field to be focussed/ |
|
356 void SetFieldTypeToFocusInEditMode(TUint aFieldType); |
|
357 |
|
358 /** |
|
359 * This function checks if the editing dialog is launched |
|
360 * from the lmk viewer dialog |
|
361 */ |
|
362 TBool IsDlgEditing(); |
|
363 |
|
364 /** |
|
365 * This function sets the mode of the editor dialog as |
|
366 * editing, when launched from lmk viewer dialog |
|
367 * This is to avoid crash in ActivateL |
|
368 */ |
|
369 void SetDlgEditing(TBool aEditing); |
|
370 // For Landscape Support |
|
371 void HandleResourceChange(TInt aType); |
|
372 |
|
373 protected: |
|
374 //for MSK |
|
375 virtual void UpdateMskOnArrowMoveForViewerL(); |
|
376 void AddMskCommandL(TInt aResourceId, TLmkAppCmdId aCommandId); |
|
377 void DimmMiddleSoftKey(); |
|
378 |
|
379 protected: |
|
380 // Data |
|
381 /// Reference to database |
|
382 CPosLandmarkDatabase& iDb; |
|
383 |
|
384 /// Ref: landmark sender |
|
385 CLmkSender& iSender; |
|
386 |
|
387 /// Ref: CPosLmPartialReadParameters |
|
388 CPosLmPartialReadParameters* iPartialLmk; |
|
389 |
|
390 /// TInt |
|
391 TInt iResourceOffset; |
|
392 |
|
393 /// Own: landmark UI utils |
|
394 CLmkUiUtils* iLmkUiUtils; |
|
395 |
|
396 /// Own: |
|
397 CLmkFields* iLmkFields; |
|
398 |
|
399 /// Own: |
|
400 RPointerArray<HBufC> iLabelArray; |
|
401 |
|
402 /// Own: |
|
403 CLmkEditorFieldArray* iEditorFieldArray; |
|
404 |
|
405 TLmkEditorMode iEditorMode; |
|
406 |
|
407 ///Own: |
|
408 CLmkLocationService* iLocationService; |
|
409 |
|
410 TCoeHelpContext iHelpContext; |
|
411 TBool iCalegorySelectionFlag; |
|
412 RArray<TCategoryName> iCategoryNames; |
|
413 |
|
414 ///Ref: |
|
415 // Used to return the created Landmark Id Value. |
|
416 // Don't allocate or delete memory or set to NULL; |
|
417 // The variable might be a local stack variable. |
|
418 // If no landmarks is created then set it to -1 or if successful |
|
419 // then set it to the Landmark Id value. |
|
420 TPosLmItemId* iLandmarkItemId; |
|
421 |
|
422 /// Own: context menu bar |
|
423 CEikMenuBar* iContextMenuBar; |
|
424 CLmkGoToURLCmd* iLmkGoToURLCmd; |
|
425 CLmkCallCmd* iLmkCallCmd; |
|
426 // Flag to determine if Map and Navigation options needs to be shown |
|
427 TBool iMapNavFeature; |
|
428 // Current Input language. (Used for Japanese) |
|
429 TBool iJapaneseInputMode; |
|
430 CPosLandmark* iLandmark; |
|
431 |
|
432 // Own: Pointer to map and navigation interface |
|
433 CLmkMapNavigationInterface* iMapNavInterface; |
|
434 // Flag which indicates receive state of landmark editor dialog |
|
435 // Set to true for receive mode |
|
436 TBool iIsLmkReceiveMode; |
|
437 TLmkAppCmdId iMskCmdId; |
|
438 TInt iCurrentResourceId; |
|
439 |
|
440 // It will be ETrue when coordinates has to be hidden. |
|
441 TBool iIsHideCoordinate; |
|
442 |
|
443 // It will be ETrue when help has to be hidden. |
|
444 TBool iIsHideHelp; |
|
445 |
|
446 private: |
|
447 // added data members |
|
448 // holds the field type of the current focussed item in the dialog |
|
449 TUint iFieldTypeToFocus; |
|
450 // Set true when editor dialog is launched from view dialog. |
|
451 TBool iIsEditing; |
|
452 |
|
453 TBool iBackspaceStartForWebAddressField; |
|
454 |
|
455 TBool iResetWebAddrSize; |
|
456 |
|
457 CAknInfoPopupNoteController* iCatInfoPopupNote; |
|
458 // Own: |
|
459 CLmkListProviderBase* iListProvider; |
|
460 |
|
461 CLmkEditorImpl* iEditor; |
|
462 |
|
463 CLmkCentralRepository* iRepository; |
|
464 |
|
465 /** |
|
466 * Wait dialog launcher |
|
467 * Owns |
|
468 */ |
|
469 CLmkWaitDialogLauncher* iWaitDialogLauncher; |
|
470 |
|
471 TBool iIsEndKey; |
|
472 |
|
473 TBool iIsEditableField; |
|
474 |
|
475 // To check the ownership of iLandmark |
|
476 TBool iIsLmOwned; |
|
477 // To Check category selector launched or not |
|
478 TBool iIsCategorySelctorOpen; |
|
479 }; |
|
480 #endif // CLMKEDITORIMPL_H |
|
481 |
|
482 // End of File |