author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:11:35 +0300 | |
branch | RCL_3 |
changeset 78 | 356f28cd5ca0 |
parent 66 | bd7edf625bdd |
child 86 | ed599363c2d7 |
permissions | -rw-r--r-- |
66 | 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: Include common routine for each note editor. |
|
15 |
* For example, handling menu, key event, error handling etc. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include <AknColourSelectionGrid.h> |
|
20 |
#include <eikrted.h> |
|
21 |
#include <aknnotewrappers.h> |
|
22 |
#include <bldvariant.hrh> |
|
23 |
#include <coeaui.h> |
|
24 |
#include <eikcapc.h> |
|
25 |
#include <eikedwin.h> |
|
26 |
#include <StringLoader.h> |
|
27 |
#include <aknnavi.h> |
|
28 |
#include <txtrich.h> |
|
29 |
#include <hlplch.h> |
|
30 |
#include <calcalendarinfo.h> |
|
31 |
#include <Calendar.rsg> |
|
32 |
#include <calencommonui.rsg> |
|
33 |
#include <sysutil.h> |
|
34 |
#include <ErrorUI.h> |
|
35 |
||
36 |
#include "calenmultidbeditor.h" |
|
37 |
#include "calendarui_debug.h" |
|
38 |
#include "calendar.hrh" |
|
39 |
#include "calentitlepane.h" |
|
40 |
#include "calencontroller.h" |
|
41 |
#include "calenmultipledbui.h" |
|
42 |
||
43 |
// Constants. |
|
44 |
const TUint16 KIllegalChars[] = { |
|
45 |
'<', '>', '"', '/', '//', '|', ':', '*', '?', |
|
46 |
0xFF02, // Full width quote |
|
47 |
0xFF0A, // Full width asterisk |
|
48 |
0xFF0F, // Full width slash |
|
49 |
0xFF1A, // Full width colon |
|
50 |
0xFF1C, // Full width left arrow |
|
51 |
0xFF1E, // Full width right arrow |
|
52 |
0xFF1F, // Full width question mark |
|
53 |
0xFF3C, // Full width back slash |
|
54 |
0xFF5C, // Full width pipe |
|
55 |
0x201C, // Left quote |
|
56 |
0x201D, // Right quote |
|
57 |
0x201F, // Reversed quote |
|
58 |
0x21B2, // Downwards arrow with tip leftwards |
|
59 |
0, // Array terminator |
|
60 |
}; |
|
61 |
const TInt KCalenMaxELAFTextEditorLength(256); |
|
62 |
const TInt KOne( 1 ); |
|
63 |
const TInt KBuffLength ( 16 ); |
|
64 |
const TInt KTen( 10 ); |
|
65 |
||
66 |
// Literals. |
|
67 |
_LIT( KFormatStringTwoDigit, "%02d" ); |
|
68 |
_LIT( KFormatString, "%d" ); |
|
69 |
||
70 |
// ================= MEMBER FUNCTIONS ======================= |
|
71 |
||
72 |
// ---------------------------------------------------------------------------- |
|
73 |
// CCalenMultiDBEditor::NewL |
|
74 |
// Two-phased constructor. |
|
75 |
// ---------------------------------------------------------------------------- |
|
76 |
// |
|
77 |
CCalenMultiDBEditor* CCalenMultiDBEditor::NewL( |
|
78 |
CCalenMultipleDbUi& aMultipleDbui, CCalCalendarInfo& aCalendarInfo, |
|
79 |
CCalenController& aController, TBool aEditFlag) |
|
80 |
{ |
|
81 |
TRACE_ENTRY_POINT; |
|
82 |
||
83 |
CCalenMultiDBEditor* self = new (ELeave) CCalenMultiDBEditor( |
|
84 |
aMultipleDbui, aCalendarInfo, aController, aEditFlag); |
|
85 |
CleanupStack::PushL(self); |
|
86 |
self->ConstructL(); |
|
87 |
CleanupStack::Pop(self); |
|
88 |
||
89 |
TRACE_EXIT_POINT; |
|
90 |
return self; |
|
91 |
} |
|
92 |
||
93 |
// ----------------------------------------------------------------------------- |
|
94 |
// CCalenMultiDBEditor::~CCalenMultiDBEditor |
|
95 |
// Destructor. |
|
96 |
// ----------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
CCalenMultiDBEditor::~CCalenMultiDBEditor() |
|
99 |
{ |
|
100 |
TRACE_ENTRY_POINT; |
|
101 |
||
102 |
if(iRgbColors) |
|
103 |
{ |
|
104 |
iRgbColors->Reset(); |
|
105 |
delete iRgbColors; |
|
106 |
iRgbColors = NULL; |
|
107 |
} |
|
108 |
||
109 |
if(iCalendarName) |
|
110 |
{ |
|
111 |
delete iCalendarName; |
|
112 |
iCalendarName = NULL; |
|
113 |
} |
|
114 |
||
115 |
if( iNaviContainer ) |
|
116 |
{ |
|
117 |
iNaviContainer->Pop(); // Remove navi pane used by settings view |
|
118 |
iNaviContainer = NULL; // iNaviContainer is not owned |
|
119 |
} |
|
120 |
TRACE_EXIT_POINT; |
|
121 |
} |
|
122 |
||
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// CCalenMultiDBEditor::CCalenMultiDBEditor |
|
125 |
// C++ constructor can NOT contain any code, that might leave. |
|
126 |
// This overload is used when the repeat type is known. |
|
127 |
// (other items were commented in a header). |
|
128 |
// ----------------------------------------------------------------------------- |
|
129 |
// |
|
130 |
CCalenMultiDBEditor::CCalenMultiDBEditor(CCalenMultipleDbUi& aMultipleDbui, |
|
131 |
CCalCalendarInfo& aCalendarInfo, CCalenController& aController, |
|
132 |
TBool aEditFlag) : |
|
133 |
iCalendarInfo(aCalendarInfo), iController( |
|
134 |
aController), iEditFlag(aEditFlag), |
|
135 |
iMultipleDbUi(aMultipleDbui) |
|
136 |
{ |
|
137 |
TRACE_ENTRY_POINT; |
|
138 |
||
139 |
iCalendarStatus = ECalenMultiDbVisible; |
|
140 |
||
141 |
TRACE_EXIT_POINT; |
|
142 |
} |
|
143 |
||
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// CCalenMultiDBEditor::ConstructL |
|
146 |
// Leaving construction common to all editors. |
|
147 |
// (other items were commented in a header). |
|
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
void CCalenMultiDBEditor::ConstructL() |
|
151 |
{ |
|
152 |
TRACE_ENTRY_POINT; |
|
153 |
||
154 |
iConflict = CCalenMultiDBEditor::EConflictNone; |
|
155 |
||
156 |
CAknDialog::ConstructL( R_CALEN_MULTIDB_MENUBAR ); // superclass |
|
157 |
SetTitlePaneL(); |
|
158 |
iCalendarName = HBufC::NewL(KCalenMaxELAFTextEditorLength); |
|
159 |
||
160 |
//Initial color value |
|
161 |
iColVal = iCalendarInfo.Color().Value(); |
|
162 |
iChoosenColor = TRgb(iColVal); |
|
163 |
||
164 |
iPicture = new( ELeave )CDbColorPicture( TSize( 0, 0 ) ); |
|
165 |
iPicture->SetRgbColorsL(iChoosenColor); |
|
166 |
||
167 |
||
168 |
||
169 |
LoadColorsL(); |
|
170 |
||
171 |
TRACE_EXIT_POINT; |
|
172 |
} |
|
173 |
||
174 |
// ----------------------------------------------------------------------------- |
|
175 |
// CCalenMultiDBEditor::LoadColorsL |
|
176 |
// (other items were commented in a header). |
|
177 |
// ----------------------------------------------------------------------------- |
|
178 |
// |
|
179 |
void CCalenMultiDBEditor::LoadColorsL() |
|
180 |
{ |
|
181 |
TRACE_ENTRY_POINT |
|
182 |
||
183 |
if(iRgbColors) |
|
184 |
{ |
|
185 |
iRgbColors->Reset(); |
|
186 |
delete iRgbColors; |
|
187 |
iRgbColors = NULL; |
|
188 |
} |
|
189 |
||
190 |
iRgbColors = new(ELeave) CArrayFixFlat<TRgb>(2); |
|
191 |
||
192 |
iRgbColors->AppendL(KCalenDarkBlue); |
|
193 |
iRgbColors->AppendL(KCalenDarkGreen); |
|
194 |
iRgbColors->AppendL(KCalenDarkRed); |
|
195 |
iRgbColors->AppendL(KCalenMegenta); |
|
196 |
iRgbColors->AppendL(KCalenBlue); |
|
197 |
iRgbColors->AppendL(KCalenGreen); |
|
198 |
iRgbColors->AppendL(KCalenOrange); |
|
199 |
iRgbColors->AppendL(KCalenlightMagenta); |
|
200 |
iRgbColors->AppendL(KCalenCyan); |
|
201 |
iRgbColors->AppendL(KCalenlightGreen); |
|
202 |
iRgbColors->AppendL(KCalenYellow); |
|
203 |
iRgbColors->AppendL(KCalenlightPink); |
|
204 |
iRgbColors->AppendL(KCalenlightBlue); |
|
205 |
iRgbColors->AppendL(KCalenGold); |
|
206 |
iRgbColors->AppendL(KCalenDarkOrange); |
|
207 |
iRgbColors->AppendL(KCalenPink); |
|
208 |
||
209 |
TRACE_EXIT_POINT |
|
210 |
} |
|
211 |
||
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// CCalenMultiDBEditor::ProcessCommandL |
|
214 |
// Process commands from the user. |
|
215 |
// (other items were commented in a header). |
|
216 |
// ----------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
void CCalenMultiDBEditor::ProcessCommandL( TInt aCommandId ) |
|
219 |
{ |
|
220 |
TRACE_ENTRY_POINT; |
|
221 |
||
222 |
HideMenu(); |
|
223 |
||
224 |
switch(aCommandId) |
|
225 |
{ |
|
226 |
case ECalenMultiDbHelp: |
|
227 |
{ |
|
228 |
HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
229 |
(iEikonEnv->AppUi())->AppHelpContextL ()); |
|
230 |
} |
|
231 |
break; |
|
232 |
case EAknCmdExit: |
|
233 |
case EAknSoftkeyExit: |
|
234 |
{ |
|
235 |
TryExitL( EAknSoftkeyExit ); |
|
236 |
} |
|
237 |
break; |
|
238 |
||
239 |
case EAknSoftkeyChange: |
|
240 |
{ |
|
241 |
if( ECalenMultiDbHiddenVisible == IdOfFocusControl() ) |
|
242 |
{ |
|
243 |
iCalendarStatus = iCalendarInfo.Enabled(); |
|
244 |
||
245 |
if( ECalenMultiDbHidden == iCalendarStatus ) |
|
246 |
{ |
|
247 |
SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
248 |
iCalendarStatus = ECalenMultiDbVisible; |
|
249 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
250 |
} |
|
251 |
else |
|
252 |
{ |
|
253 |
SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
254 |
iCalendarStatus = ECalenMultiDbHidden; |
|
255 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
256 |
} |
|
257 |
} |
|
258 |
else if ( ECalenMultiDbColor == IdOfFocusControl() ) |
|
259 |
{ |
|
260 |
GetColorL(); |
|
261 |
} |
|
262 |
} |
|
263 |
break; |
|
264 |
||
265 |
case EAknSoftkeyOpen: |
|
266 |
{ |
|
267 |
GetColorL(); |
|
268 |
} |
|
269 |
break; |
|
270 |
||
271 |
default: |
|
272 |
{ |
|
273 |
// No implementation yet. |
|
274 |
} |
|
275 |
break; |
|
276 |
} |
|
277 |
||
278 |
TRACE_EXIT_POINT; |
|
279 |
} |
|
280 |
||
281 |
// ----------------------------------------------------------------------------- |
|
282 |
// CCalenMultiDBEditor::HandleEditCommandL |
|
283 |
// Process commands from the user. |
|
284 |
// (other items were commented in a header). |
|
285 |
// ----------------------------------------------------------------------------- |
|
286 |
// |
|
287 |
void CCalenMultiDBEditor::HandleEditCommandL() |
|
288 |
{ |
|
289 |
switch(IdOfFocusControl()) |
|
290 |
{ |
|
291 |
case ECalenMultiDbColor: |
|
292 |
{ |
|
293 |
GetColorL(); |
|
294 |
} |
|
295 |
break; |
|
296 |
default: |
|
297 |
{ |
|
298 |
// No implementation yet. |
|
299 |
} |
|
300 |
break; |
|
301 |
} |
|
302 |
} |
|
303 |
||
304 |
||
305 |
// ----------------------------------------------------------------------------- |
|
306 |
// CCalenMultiDBEditor::SetConflict |
|
307 |
// (other items were commented in a header). |
|
308 |
// ----------------------------------------------------------------------------- |
|
309 |
// |
|
310 |
void CCalenMultiDBEditor::SetConflict(TCalendarConflicts aConflict) |
|
311 |
{ |
|
312 |
TRACE_ENTRY_POINT |
|
313 |
iConflict = aConflict; |
|
314 |
TRACE_EXIT_POINT |
|
315 |
} |
|
316 |
||
317 |
// ----------------------------------------------------------------------------- |
|
318 |
// CCalenMultiDBEditor::Conflict |
|
319 |
// (other items were commented in a header). |
|
320 |
// ----------------------------------------------------------------------------- |
|
321 |
// |
|
322 |
CCalenMultiDBEditor::TCalendarConflicts CCalenMultiDBEditor::Conflict() const |
|
323 |
{ |
|
324 |
TRACE_ENTRY_POINT |
|
325 |
TRACE_EXIT_POINT |
|
326 |
return iConflict; |
|
327 |
} |
|
328 |
||
329 |
// ----------------------------------------------------------------------------- |
|
330 |
// CCalenMultiDBEditor::HandleNotification |
|
331 |
// (other items were commented in a header). |
|
332 |
// ----------------------------------------------------------------------------- |
|
333 |
// |
|
334 |
||
335 |
// ----------------------------------------------------------------------------- |
|
336 |
// CCalenMultiDBEditor::OkToExitL |
|
337 |
// Handle CBA-key on a form. |
|
338 |
// (other items were commented in a header). |
|
339 |
// ----------------------------------------------------------------------------- |
|
340 |
// |
|
341 |
TBool CCalenMultiDBEditor::OkToExitL(TInt aButtonId) |
|
342 |
{ |
|
343 |
TRACE_ENTRY_POINT; |
|
344 |
TBool isExitForm(EFalse); |
|
345 |
||
346 |
switch(aButtonId) |
|
347 |
{ |
|
348 |
case EAknSoftkeyOpen: |
|
349 |
{ |
|
350 |
GetColorL(); |
|
351 |
} |
|
352 |
break; |
|
353 |
||
354 |
case EAknSoftkeyOptions: |
|
355 |
{ |
|
356 |
DisplayMenuL(); |
|
357 |
isExitForm = EFalse; |
|
358 |
} |
|
359 |
break; |
|
360 |
||
361 |
case EAknSoftkeyChange: |
|
362 |
{ |
|
363 |
isExitForm=EFalse; |
|
364 |
if( ECalenMultiDbHiddenVisible == IdOfFocusControl() ) |
|
365 |
{ |
|
366 |
iCalendarStatus = iCalendarInfo.Enabled(); |
|
367 |
||
368 |
if( ECalenMultiDbHidden == iCalendarStatus ) |
|
369 |
{ |
|
370 |
SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
371 |
iCalendarStatus = ECalenMultiDbVisible; |
|
372 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
373 |
} |
|
374 |
else |
|
375 |
{ |
|
376 |
SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
377 |
iCalendarStatus = ECalenMultiDbHidden; |
|
378 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
379 |
} |
|
380 |
} |
|
381 |
else if ( ECalenMultiDbColor == IdOfFocusControl() ) |
|
382 |
{ |
|
383 |
GetColorL(); |
|
384 |
} |
|
385 |
} |
|
386 |
break; |
|
387 |
||
388 |
case EAknSoftkeyDone: |
|
389 |
{ |
|
390 |
isExitForm = SaveNoteL(aButtonId); |
|
391 |
if (isExitForm) |
|
392 |
{ |
|
393 |
TInt err = iMultipleDbUi.UpdateOnAddOrEditL(!iEditFlag); |
|
394 |
if (err != KErrNone) |
|
395 |
{ |
|
396 |
ShowErrorNoteL(err); |
|
397 |
} |
|
398 |
} |
|
399 |
} |
|
400 |
break; |
|
401 |
case EAknSoftkeyExit: |
|
402 |
case EAknCmdExit: |
|
403 |
{ |
|
404 |
isExitForm = SaveNoteL(aButtonId); |
|
405 |
if (isExitForm) |
|
406 |
{ |
|
407 |
TInt err = iMultipleDbUi.UpdateOnAddOrEditL(!iEditFlag); |
|
408 |
if (err != KErrNone) |
|
409 |
{ |
|
410 |
ShowErrorNoteL(err); |
|
411 |
} |
|
412 |
} |
|
413 |
isExitForm = ETrue; |
|
414 |
iMultipleDbUi.ExitDialogL(); |
|
415 |
} |
|
416 |
break; |
|
417 |
case EAknSoftkeyQuit: |
|
418 |
{ |
|
419 |
isExitForm = ETrue; |
|
420 |
} |
|
421 |
break; |
|
422 |
default: |
|
423 |
{ |
|
424 |
isExitForm=CAknForm::OkToExitL(aButtonId); |
|
425 |
} |
|
426 |
break; |
|
427 |
} |
|
428 |
TRACE_EXIT_POINT; |
|
429 |
||
430 |
return isExitForm; |
|
431 |
} |
|
432 |
||
433 |
// ----------------------------------------------------------------------------- |
|
434 |
// CCalenMultiDBEditor::OfferKeyEventL |
|
435 |
// Passes key events to MsgEditorView to enable scrolling. |
|
436 |
// (other items were commented in a header). |
|
437 |
// ----------------------------------------------------------------------------- |
|
438 |
TKeyResponse CCalenMultiDBEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
439 |
{ |
|
440 |
TRACE_ENTRY_POINT; |
|
441 |
TKeyResponse keyResponse(EKeyWasNotConsumed); |
|
78
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
442 |
TInt ctrlid=IdOfFocusControl(); |
66 | 443 |
|
444 |
if (aType == EEventKey) |
|
445 |
{ |
|
446 |
switch (aKeyEvent.iCode) |
|
447 |
{ |
|
78
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
448 |
case EKeyOK: |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
449 |
if( ctrlid == ECalenMultiDbColor) |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
450 |
{ |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
451 |
GetColorL(); |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
452 |
} |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
453 |
else if ( ctrlid == ECalenMultiDbHiddenVisible ) |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
454 |
{ |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
455 |
iCalendarStatus = iCalendarInfo.Enabled(); |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
456 |
if( ECalenMultiDbHidden == iCalendarStatus ) |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
457 |
{ |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
458 |
SetVisiblityFieldL( ECalenMultiDbVisible ); |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
459 |
iCalendarStatus = ECalenMultiDbVisible; |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
460 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
461 |
} |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
462 |
else |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
463 |
{ |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
464 |
SetVisiblityFieldL( ECalenMultiDbHidden ); |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
465 |
iCalendarStatus = ECalenMultiDbHidden; |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
466 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
467 |
} |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
468 |
} |
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
469 |
break; |
66 | 470 |
case EKeyEscape: |
471 |
TryExitL( EAknCmdExit ); |
|
472 |
keyResponse = EKeyWasConsumed; |
|
473 |
break; |
|
474 |
default: |
|
475 |
keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); |
|
476 |
break; |
|
477 |
} |
|
478 |
} |
|
479 |
else |
|
480 |
{ |
|
481 |
// Swallow all other keyevents to prevent the active container processing them. |
|
482 |
keyResponse = EKeyWasConsumed; |
|
483 |
} |
|
484 |
TRACE_EXIT_POINT; |
|
485 |
return keyResponse; |
|
486 |
} |
|
487 |
||
488 |
// ----------------------------------------------------------------------------- |
|
489 |
// CCalenMultiDBEditor::PreLayoutDynInitL() |
|
490 |
// Updates fields just before the form is shown. |
|
491 |
// (other items were commented in a header). |
|
492 |
// ----------------------------------------------------------------------------- |
|
493 |
// |
|
494 |
void CCalenMultiDBEditor::PreLayoutDynInitL() |
|
495 |
{ |
|
496 |
TRACE_ENTRY_POINT; |
|
497 |
||
498 |
||
499 |
||
500 |
// Set data to controls in the editor. |
|
501 |
SetDataToFormL(); |
|
502 |
||
503 |
TRACE_EXIT_POINT; |
|
504 |
} |
|
505 |
||
506 |
// ----------------------------------------------------------------------------- |
|
507 |
// CCalenMultiDBEditor::SetDataToFormL() |
|
508 |
// Reads data from the entry and updates the form with the appropriate values. |
|
509 |
// (other items were commented in a header). |
|
510 |
// ----------------------------------------------------------------------------- |
|
511 |
// |
|
512 |
void CCalenMultiDBEditor::SetDataToFormL() |
|
513 |
{ |
|
514 |
TRACE_ENTRY_POINT; |
|
515 |
//First filed "Name" of the Form |
|
516 |
CEikEdwin* edwin = |
|
517 |
reinterpret_cast<CEikEdwin*>(Control(ECalenMultiDbName)); |
|
518 |
||
519 |
if( edwin ) |
|
520 |
{ |
|
521 |
edwin->SetTextLimit(KCalenMaxELAFTextEditorLength); |
|
522 |
edwin->SetSelectionL( edwin->TextLength(), 0 ); |
|
523 |
} |
|
524 |
||
525 |
SetEditableL(ETrue); |
|
526 |
Line(ECalenMultiDbName)->SetFocus(ETrue); |
|
527 |
Line(ECalenMultiDbName)->ActivateL(); |
|
528 |
||
529 |
HBufC* calendarName = iCalendarInfo.NameL().AllocLC(); |
|
530 |
||
531 |
// Check for the empty text. |
|
532 |
if( ( !calendarName->Size() ) ) |
|
533 |
{ |
|
534 |
CleanupStack::PopAndDestroy(calendarName); |
|
535 |
TInt index( KOne ); |
|
536 |
calendarName = StringLoader::LoadLC( R_CALE_DB_CALENDAR ); |
|
537 |
TBuf< KBuffLength > numBuf; |
|
538 |
||
539 |
// Check if name is already there or not. |
|
540 |
while( IsNameFoundL( *calendarName ) ) |
|
541 |
{ |
|
542 |
CleanupStack::PopAndDestroy( calendarName ); |
|
543 |
numBuf.Zero(); |
|
544 |
if( index < KTen ) |
|
545 |
{ |
|
546 |
numBuf.Format( KFormatStringTwoDigit, index ); |
|
547 |
} |
|
548 |
else |
|
549 |
{ |
|
550 |
numBuf.Format( KFormatString, index ); |
|
551 |
} |
|
552 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
553 |
numBuf ); |
|
554 |
calendarName = StringLoader::LoadLC( |
|
555 |
R_CALE_DB_CALENDAR_DEFAULT_NAME, numBuf ); |
|
556 |
||
557 |
++index; |
|
558 |
} |
|
559 |
} |
|
560 |
SetEdwinTextL( ECalenMultiDbName, calendarName ); |
|
561 |
CleanupStack::PopAndDestroy(calendarName); |
|
562 |
||
563 |
//Second field "Color" of the form |
|
564 |
// Instantiate CDbColorPicture object 300x300 twips in size |
|
565 |
CEikRichTextEditor* colorControl = static_cast<CEikRichTextEditor*>(Control(ECalenMultiDbColor)); |
|
566 |
||
567 |
//Prepare the iPicture header, which will be inserted into the rich text |
|
568 |
TPictureHeader header; |
|
569 |
header.iPicture = TSwizzle<CPicture>(iPicture); |
|
570 |
||
571 |
// Position where we insert iPicture is not valid as it always draws icon depending the rect we provide |
|
572 |
colorControl->RichText()->InsertL(0, header); |
|
573 |
colorControl->AddFlagToUserFlags(CEikEdwin::EAvkonDisableCursor | CEikEdwin::EReadOnly ); |
|
574 |
GetLineByLineAndPageIndex(1,0)->DrawNow(); |
|
575 |
||
576 |
iCalendarStatus = iCalendarInfo.Enabled(); |
|
577 |
||
578 |
||
579 |
||
580 |
if( ECalenMultiDbHidden == iCalendarStatus ) |
|
581 |
{ |
|
582 |
SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
583 |
} |
|
584 |
else |
|
585 |
{ |
|
586 |
SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
587 |
} |
|
588 |
TRACE_EXIT_POINT; |
|
589 |
} |
|
590 |
||
591 |
// --------------------------------------------------------- |
|
592 |
// CCalenMultiDBEditor::DynInitMenuPaneL |
|
593 |
// Gets called before form is displayed |
|
594 |
// (other items were commented in a header). |
|
595 |
// --------------------------------------------------------- |
|
596 |
// |
|
597 |
void CCalenMultiDBEditor::DynInitMenuPaneL( TInt aResourceId, |
|
598 |
CEikMenuPane* aMenuPane ) |
|
599 |
{ |
|
600 |
TRACE_ENTRY_POINT; |
|
601 |
||
602 |
if( aResourceId != R_CALEN_MULTIDB_MENUPANE ) |
|
603 |
{ |
|
604 |
return; |
|
605 |
} |
|
606 |
||
607 |
// Execute the following commands if the resource belongs to calendar. |
|
608 |
// Display the menu items based on the current focused control. |
|
609 |
if( ECalenMultiDbName == IdOfFocusControl() ) |
|
610 |
{ |
|
611 |
aMenuPane->SetItemDimmed( EAknSoftkeyChange, ETrue ); |
|
612 |
} |
|
613 |
||
614 |
TRACE_EXIT_POINT; |
|
615 |
} |
|
616 |
||
617 |
// --------------------------------------------------------------------------- |
|
618 |
// CCalenMultiDBEditor::GetColorL |
|
619 |
// From class CAknSettingItem. |
|
620 |
// GetColorL overridden to launch colour selection grid. |
|
621 |
// --------------------------------------------------------------------------- |
|
622 |
// |
|
623 |
void CCalenMultiDBEditor::GetColorL() |
|
624 |
{ |
|
625 |
TRACE_ENTRY_POINT; |
|
626 |
iNoneChoosen = ETrue; |
|
627 |
||
628 |
// Construct colour selection grid |
|
629 |
CAknDialog *dlg = CAknColourSelectionGrid::NewL(iRgbColors, EFalse, |
|
630 |
iNoneChoosen,iChoosenColor ); |
|
631 |
||
632 |
dlg->ExecuteLD(R_CALEN_MULTIDB_EDITOR_COLOR_GRID_DLG); |
|
633 |
||
634 |
TRACE_EXIT_POINT; |
|
635 |
} |
|
636 |
||
637 |
// --------------------------------------------------------------------------- |
|
638 |
// CCalenMultiDBEditor::FocusChanged |
|
639 |
// --------------------------------------------------------------------------- |
|
640 |
// |
|
641 |
void CCalenMultiDBEditor::FocusChanged(TDrawNow /*aDrawNow*/) |
|
642 |
{ |
|
643 |
TRACE_ENTRY_POINT |
|
644 |
||
645 |
if(IsFocused() && !iNoneChoosen) |
|
646 |
{ |
|
647 |
iColVal = iChoosenColor.Value(); |
|
648 |
TRAP_IGNORE(iPicture->SetRgbColorsL(iChoosenColor)); |
|
649 |
GetLineByLineAndPageIndex(1, 0)->DrawNow(); |
|
650 |
} |
|
651 |
||
652 |
TRACE_EXIT_POINT |
|
653 |
} |
|
654 |
||
655 |
// --------------------------------------------------------------------------- |
|
656 |
// CCalenMultiDBEditor::SaveNoteL |
|
657 |
// Try to save note. Initializes all the member variables of DBInfo. |
|
658 |
// --------------------------------------------------------------------------- |
|
659 |
// |
|
660 |
TBool CCalenMultiDBEditor::SaveNoteL( TInt aButtonId ) |
|
661 |
{ |
|
662 |
TRACE_ENTRY_POINT; |
|
663 |
||
664 |
if (CheckSpaceBelowCriticalLevelL()) |
|
665 |
{ |
|
666 |
TRACE_EXIT_POINT; |
|
667 |
return EFalse; |
|
668 |
} |
|
669 |
||
670 |
if (Conflict() == CCalenMultiDBEditor::EConflictDelete) |
|
671 |
{ |
|
672 |
CAknNoteDialog *note = new (ELeave) CAknNoteDialog( |
|
673 |
CAknNoteDialog::EWarningTone, CAknNoteDialog::ENoTimeout); |
|
674 |
HBufC* buf = StringLoader::LoadLC( |
|
675 |
R_QTN_CALENDAREDITOR_NOTE_DB_CONFLICT_DELETE, iEikonEnv); |
|
676 |
note->SetTextL(*buf); |
|
677 |
note->ExecuteLD(R_CALEN_CALENDAREDITOR_CONFLICT_DIALOG); |
|
678 |
CleanupStack::PopAndDestroy(buf); |
|
679 |
return ETrue; |
|
680 |
} |
|
681 |
else if (Conflict() == CCalenMultiDBEditor::EConflictUpdate) |
|
682 |
{ |
|
683 |
CAknNoteDialog *note = new (ELeave) CAknNoteDialog( |
|
684 |
CAknNoteDialog::EWarningTone, CAknNoteDialog::ENoTimeout); |
|
685 |
HBufC* buf = StringLoader::LoadLC( |
|
686 |
R_QTN_CALENDAREDITOR_NOTE_DB_CONFLICT_UPDATE, iEikonEnv); |
|
687 |
note->SetTextL(*buf); |
|
688 |
note->ExecuteLD(R_CALEN_CALENDAREDITOR_CONFLICT_DIALOG); |
|
689 |
CleanupStack::PopAndDestroy(buf); |
|
690 |
return ETrue; |
|
691 |
} |
|
692 |
else |
|
693 |
{ |
|
694 |
} |
|
695 |
||
696 |
TBool retValue = ETrue; |
|
697 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
698 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
699 |
CleanupClosePushL(calendarInfoList); |
|
700 |
const TBool continueOnError = ETrue; |
|
701 |
ReadDataFromFormL(continueOnError); |
|
702 |
||
703 |
iCalendarName->Des().Trim(); |
|
704 |
// Check for the empty text |
|
705 |
if ((!iCalendarName->Size())) |
|
706 |
{ |
|
707 |
// If in editing mode, just save the name used before. |
|
708 |
if (iEditFlag) |
|
709 |
{ |
|
710 |
iCalendarName->Des().Copy(iCalendarInfo.NameL()); |
|
711 |
SetEdwinTextL(ECalenMultiDbName, iCalendarName); |
|
712 |
} |
|
713 |
else |
|
714 |
{ |
|
715 |
// else use the default name. |
|
716 |
TInt index(KOne); |
|
717 |
HBufC* calendarName = StringLoader::LoadLC(R_CALE_DB_CALENDAR); |
|
718 |
TBuf<KBuffLength> numBuf; |
|
719 |
||
720 |
// Check if the name is already present. |
|
721 |
while (IsNameFoundL(*calendarName)) |
|
722 |
{ |
|
723 |
CleanupStack::PopAndDestroy(calendarName); |
|
724 |
numBuf.Zero(); |
|
725 |
if (index < KTen) |
|
726 |
{ |
|
727 |
numBuf.Format(KFormatStringTwoDigit, index); |
|
728 |
} |
|
729 |
else |
|
730 |
{ |
|
731 |
numBuf.Format(KFormatString, index); |
|
732 |
} |
|
733 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( |
|
734 |
numBuf); |
|
735 |
calendarName = StringLoader::LoadLC( |
|
736 |
R_CALE_DB_CALENDAR_DEFAULT_NAME, numBuf); |
|
737 |
||
738 |
++index; |
|
739 |
} |
|
740 |
||
741 |
iCalendarName->Des().Append(calendarName->Des()); |
|
742 |
||
743 |
CleanupStack::PopAndDestroy(calendarName); |
|
744 |
SetEdwinTextL(ECalenMultiDbName, iCalendarName); |
|
745 |
} |
|
746 |
||
747 |
} |
|
748 |
||
749 |
// Check for the validity of the calendar name. |
|
750 |
if (IsNameValid(*iCalendarName)) |
|
751 |
{ |
|
752 |
// Name is valid. then check if it already exists or not. |
|
753 |
if (IsNameEditedL(*iCalendarName)) |
|
754 |
{ |
|
755 |
TInt index = calendarInfoList.Find(*iCalendarName, |
|
756 |
CCalenMultiDBEditor::CalenInfoIdentifierL); |
|
757 |
if (index != KErrNotFound) |
|
758 |
{ |
|
759 |
retValue = EFalse; |
|
760 |
if (EAknCmdExit != aButtonId) |
|
761 |
{ |
|
762 |
HBufC* infoText = StringLoader::LoadLC( |
|
763 |
R_QTN_CALE_DB_ALREADY_EXISTS_NOTE, |
|
764 |
iCalendarName->Des()); |
|
765 |
CAknInformationNote* dialog = |
|
766 |
new (ELeave) CAknInformationNote(ETrue); |
|
767 |
dialog->ExecuteLD(*infoText); |
|
768 |
CleanupStack::PopAndDestroy(infoText); |
|
769 |
} |
|
770 |
} |
|
771 |
else |
|
772 |
{ |
|
773 |
iCalendarInfo.SetNameL(*iCalendarName); |
|
774 |
} |
|
775 |
} |
|
776 |
||
777 |
} |
|
778 |
else |
|
779 |
{ |
|
780 |
if (EAknCmdExit != aButtonId) |
|
781 |
{ |
|
782 |
retValue = EFalse; |
|
783 |
HBufC* infoText(NULL); |
|
784 |
infoText |
|
785 |
= AreIllegalChars(*iCalendarName) |
|
786 |
? StringLoader::LoadLC( |
|
787 |
R_CALEN_ILLEGAL_CHARACTERS) |
|
788 |
: StringLoader::LoadLC( |
|
789 |
R_CALEN_BAD_FILE_NAME); |
|
790 |
CAknInformationNote* dialog = new (ELeave) CAknInformationNote( |
|
791 |
ETrue); |
|
792 |
dialog->ExecuteLD(*infoText); |
|
793 |
CleanupStack::PopAndDestroy(infoText); |
|
794 |
} |
|
795 |
} |
|
796 |
||
797 |
if (IsColorEditedL(iColVal)) |
|
798 |
{ |
|
799 |
iCalendarInfo.SetColor(iColVal); |
|
800 |
} |
|
801 |
||
802 |
if (IsVisiblityFieldEditedL(iCalendarStatus)) |
|
803 |
{ |
|
804 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
805 |
} |
|
806 |
||
807 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
808 |
TRACE_EXIT_POINT; |
|
809 |
return retValue; |
|
810 |
} |
|
811 |
||
812 |
// --------------------------------------------------------------------------- |
|
813 |
// CCalenMultiDBEditor::ExecuteLD |
|
814 |
// Launches the MultiDB Form |
|
815 |
// --------------------------------------------------------------------------- |
|
816 |
// |
|
817 |
TInt CCalenMultiDBEditor::ExecuteLD() |
|
818 |
{ |
|
819 |
TRACE_ENTRY_POINT; |
|
820 |
TRACE_EXIT_POINT; |
|
821 |
return CAknForm::ExecuteLD(R_CALEN_MULTIDB_EDITOR); |
|
822 |
} |
|
823 |
||
824 |
// --------------------------------------------------------------------------- |
|
825 |
// CCalenMultiDBEditor::ReadDataFromFormL |
|
826 |
// Read all the data from the form. |
|
827 |
// --------------------------------------------------------------------------- |
|
828 |
// |
|
829 |
void CCalenMultiDBEditor::ReadDataFromFormL( TBool /*aContinueOnError */) |
|
830 |
{ |
|
831 |
TRACE_ENTRY_POINT; |
|
832 |
//Initial Name value |
|
833 |
TPtr summary = iCalendarName->Des(); |
|
834 |
||
835 |
CEikEdwin* edwin = reinterpret_cast<CEikEdwin*> (Control( |
|
836 |
ECalenMultiDbName)); |
|
837 |
GetEdwinText(summary, ECalenMultiDbName); |
|
838 |
||
839 |
TRACE_EXIT_POINT; |
|
840 |
} |
|
841 |
// --------------------------------------------------------------------------- |
|
842 |
// CCalenMultiDBEditor::IsNameEditedL |
|
843 |
// Checks wether Name got edited or not. |
|
844 |
// --------------------------------------------------------------------------- |
|
845 |
// |
|
846 |
TBool CCalenMultiDBEditor::IsNameEditedL(const TDesC& aName) |
|
847 |
{ |
|
848 |
TRACE_ENTRY_POINT; |
|
849 |
HBufC* calendarName = iCalendarInfo.NameL().AllocLC(); |
|
850 |
calendarName->Des().Trim(); |
|
851 |
||
852 |
TBool isEdited = EFalse; |
|
853 |
if (calendarName->CompareF(aName)) |
|
854 |
{ |
|
855 |
isEdited = ETrue; |
|
856 |
} |
|
857 |
CleanupStack::PopAndDestroy(); |
|
858 |
TRACE_EXIT_POINT; |
|
859 |
||
860 |
return isEdited; |
|
861 |
} |
|
862 |
||
863 |
// --------------------------------------------------------------------------- |
|
864 |
// CCalenMultiDBEditor::IsNameFoundL |
|
865 |
// Checks wether Name got edited or not. |
|
866 |
// --------------------------------------------------------------------------- |
|
867 |
// |
|
868 |
TBool CCalenMultiDBEditor::IsNameFoundL(const TDesC& aName) |
|
869 |
{ |
|
870 |
TRACE_ENTRY_POINT; |
|
871 |
||
872 |
TBool retValue = EFalse; |
|
873 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
874 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
875 |
CleanupClosePushL(calendarInfoList); |
|
876 |
HBufC *calendarName = aName.AllocLC(); |
|
877 |
||
878 |
TInt index = calendarInfoList.Find( *calendarName, |
|
879 |
CCalenMultiDBEditor::CalenInfoIdentifierL ); |
|
880 |
||
881 |
CleanupStack::PopAndDestroy( calendarName ); |
|
882 |
CleanupStack::PopAndDestroy( &calendarInfoList ); |
|
883 |
||
884 |
// Name is matched. |
|
885 |
if(index != KErrNotFound) |
|
886 |
{ |
|
887 |
retValue = ETrue; |
|
888 |
} |
|
889 |
||
890 |
TRACE_EXIT_POINT; |
|
891 |
return retValue; |
|
892 |
} |
|
893 |
||
894 |
// --------------------------------------------------------------------------- |
|
895 |
// CCalenMultiDBEditor::AreIllegalChars |
|
896 |
// Rest of the details are commented in header. |
|
897 |
// --------------------------------------------------------------------------- |
|
898 |
// |
|
899 |
TBool CCalenMultiDBEditor::AreIllegalChars( const TDesC& aName ) |
|
900 |
{ |
|
901 |
TRACE_ENTRY_POINT; |
|
902 |
||
903 |
for ( TInt i( 0 ); KIllegalChars[ i ]; i++ ) |
|
904 |
{ |
|
905 |
if ( aName.Locate( KIllegalChars[ i ] ) != KErrNotFound ) |
|
906 |
{ |
|
907 |
// name is valid. |
|
908 |
return ETrue; |
|
909 |
} |
|
910 |
} |
|
911 |
TRACE_EXIT_POINT; |
|
912 |
||
913 |
return EFalse; |
|
914 |
} |
|
915 |
||
916 |
// --------------------------------------------------------------------------- |
|
917 |
// CCalenMultiDBEditor::IsValidName |
|
918 |
// Rest of the details are commented in header. |
|
919 |
// --------------------------------------------------------------------------- |
|
920 |
// |
|
921 |
TBool CCalenMultiDBEditor::IsNameValid( const TDesC& aName ) |
|
922 |
{ |
|
923 |
TRACE_ENTRY_POINT; |
|
924 |
||
925 |
// Check name for bad chars |
|
926 |
const TUint16 KMinAllowedChar = 0x0020; |
|
927 |
const TUint16 KParagraphSeparator = 0x2029; |
|
928 |
const TUint16 KDot = '.'; |
|
929 |
||
930 |
TInt nameLen( aName.Length() ); |
|
931 |
if ( !nameLen ) |
|
932 |
{ |
|
933 |
return EFalse; |
|
934 |
} |
|
935 |
||
936 |
for ( TInt i( 0 ); i < nameLen; i++ ) |
|
937 |
{ |
|
938 |
TUint16 ch( aName[ i ] ); |
|
939 |
if ( ch < KMinAllowedChar || ch == KParagraphSeparator ) |
|
940 |
{ |
|
941 |
return EFalse; |
|
942 |
} |
|
943 |
} |
|
944 |
||
945 |
// File system ignores totally dot in the end of name, so |
|
946 |
// we set here as not valid name, so that user gets correctly informed |
|
947 |
if ( aName[ nameLen - 1 ] == KDot || AreIllegalChars( aName ) ) |
|
948 |
{ |
|
949 |
return EFalse; |
|
950 |
} |
|
951 |
return ETrue; |
|
952 |
} |
|
953 |
||
954 |
// --------------------------------------------------------------------------- |
|
955 |
// CCalenMultiDBEditor::IsColorEditedL |
|
956 |
// Checks wether Color got edited or not. |
|
957 |
// --------------------------------------------------------------------------- |
|
958 |
// |
|
959 |
TBool CCalenMultiDBEditor::IsColorEditedL(TInt iColVal) |
|
960 |
{ |
|
961 |
TRACE_ENTRY_POINT; |
|
962 |
TRACE_EXIT_POINT; |
|
963 |
return (iCalendarInfo.Color() != iColVal); |
|
964 |
} |
|
965 |
||
966 |
// --------------------------------------------------------------------------- |
|
967 |
// CCalenMultiDBEditor::IsVisiblityFieldEditedL |
|
968 |
// Checks the visibility status of the calendar being edited. |
|
969 |
// --------------------------------------------------------------------------- |
|
970 |
// |
|
971 |
TBool CCalenMultiDBEditor::IsVisiblityFieldEditedL( TInt aCalendarStatus ) |
|
972 |
{ |
|
973 |
TRACE_ENTRY_POINT; |
|
974 |
TRACE_EXIT_POINT; |
|
975 |
return (iCalendarInfo.Enabled() != aCalendarStatus ); |
|
976 |
} |
|
977 |
||
978 |
||
979 |
// ---------------------------------------------------------------------------- |
|
980 |
// CCalenMultiDBEditor::HandleDialogPageEventL |
|
981 |
// Process pointer event on the dialog. |
|
982 |
// (other items were commented in a header). |
|
983 |
// ---------------------------------------------------------------------------- |
|
984 |
void CCalenMultiDBEditor::HandleDialogPageEventL( TInt aEventID ) |
|
985 |
{ |
|
986 |
TRACE_ENTRY_POINT; |
|
987 |
||
988 |
CAknForm::HandleDialogPageEventL( aEventID ); |
|
989 |
if ( aEventID == MEikDialogPageObserver::EDialogPageTapped ) |
|
990 |
{ |
|
991 |
TInt focusControl( IdOfFocusControl() ); |
|
992 |
||
993 |
switch(focusControl) |
|
994 |
{ |
|
995 |
case ECalenMultiDbColor: |
|
996 |
{ |
|
997 |
GetColorL(); |
|
998 |
} |
|
999 |
break; |
|
1000 |
||
1001 |
||
1002 |
||
1003 |
case ECalenMultiDbHiddenVisible: |
|
1004 |
{ |
|
1005 |
iCalendarStatus = iCalendarInfo.Enabled(); |
|
1006 |
||
1007 |
if( ECalenMultiDbHidden == iCalendarStatus ) |
|
1008 |
{ |
|
1009 |
SetVisiblityFieldL( ECalenMultiDbVisible ); |
|
1010 |
iCalendarStatus = ECalenMultiDbVisible; |
|
1011 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
1012 |
} |
|
1013 |
else |
|
1014 |
{ |
|
1015 |
SetVisiblityFieldL( ECalenMultiDbHidden ); |
|
1016 |
iCalendarStatus = ECalenMultiDbHidden; |
|
1017 |
iCalendarInfo.SetEnabled(iCalendarStatus); |
|
1018 |
} |
|
1019 |
} |
|
1020 |
break; |
|
1021 |
||
1022 |
default: |
|
1023 |
{ |
|
1024 |
||
1025 |
} |
|
1026 |
break; |
|
1027 |
} |
|
1028 |
} |
|
1029 |
TRACE_EXIT_POINT; |
|
1030 |
} |
|
1031 |
||
1032 |
// ----------------------------------------------------------------------------- |
|
1033 |
// CCalenMultiDBEditor::LineChangedL |
|
1034 |
// This function gets called by the framework each time line is changed in |
|
1035 |
// the dialog (form). . |
|
1036 |
// We will use it for MSK label switching. |
|
1037 |
// (other items were commented in a header). |
|
1038 |
// ----------------------------------------------------------------------------- |
|
1039 |
// |
|
1040 |
void CCalenMultiDBEditor::LineChangedL( TInt aControlId ) |
|
1041 |
{ |
|
1042 |
TRACE_ENTRY_POINT; |
|
1043 |
||
1044 |
CEikButtonGroupContainer& cba = ButtonGroupContainer (); |
|
1045 |
TInt resId = 0; |
|
1046 |
TInt controlId = aControlId; |
|
1047 |
||
1048 |
switch( controlId ) |
|
1049 |
{ |
|
1050 |
case ECalenMultiDbName: |
|
1051 |
{ |
|
1052 |
resId = R_CALEN_MULTIDB_MSK_EMPTY_CBA; |
|
1053 |
} |
|
1054 |
break; |
|
1055 |
||
1056 |
case ECalenMultiDbColor: |
|
1057 |
case ECalenMultiDbHiddenVisible: |
|
1058 |
{ |
|
1059 |
resId = R_CALEN_MULTIDB_MSK_CHANGE_CBA; |
|
1060 |
} |
|
1061 |
break; |
|
1062 |
||
1063 |
default: |
|
1064 |
{ |
|
1065 |
// No implementation yet. |
|
1066 |
} |
|
1067 |
break; |
|
1068 |
} |
|
1069 |
||
1070 |
// set desired CBA |
|
1071 |
cba.SetCommandSetL( resId ); |
|
1072 |
cba.DrawNow(); |
|
1073 |
||
1074 |
TRACE_EXIT_POINT; |
|
1075 |
} |
|
1076 |
||
1077 |
// ----------------------------------------------------------------------------- |
|
1078 |
// CCalenEditorBase::PostLayoutDynInitL |
|
1079 |
// This is called in CEikDialog::ExecuteLD() after a form is drawn. |
|
1080 |
// (other items were commented in a header). |
|
1081 |
// ----------------------------------------------------------------------------- |
|
1082 |
// |
|
1083 |
void CCalenMultiDBEditor::PostLayoutDynInitL() |
|
1084 |
{ |
|
1085 |
TRACE_ENTRY_POINT; |
|
1086 |
SetEditableL(ETrue); |
|
1087 |
||
1088 |
LineChangedL( ECalenMultiDbName ); |
|
1089 |
||
1090 |
CAknForm::PostLayoutDynInitL(); // chain back up to baseclass |
|
1091 |
TRACE_EXIT_POINT; |
|
1092 |
} |
|
1093 |
||
1094 |
// ----------------------------------------------------------------------------- |
|
1095 |
// CCalenMultipleDbUi::CalenInfoIdentifierL |
|
1096 |
// ----------------------------------------------------------------------------- |
|
1097 |
// |
|
1098 |
TBool CCalenMultiDBEditor::CalenInfoIdentifierL( const HBufC* aName, |
|
1099 |
const CCalCalendarInfo& aCalendarInfo ) |
|
1100 |
{ |
|
1101 |
TRACE_ENTRY_POINT; |
|
1102 |
HBufC* calendarName = aCalendarInfo.NameL().AllocLC(); |
|
1103 |
calendarName->Des().Trim(); |
|
1104 |
TBool retVal = EFalse; |
|
1105 |
retVal = calendarName->Compare(*aName); |
|
1106 |
CleanupStack::PopAndDestroy(); |
|
1107 |
TRACE_EXIT_POINT; |
|
1108 |
return (!retVal); |
|
1109 |
} |
|
1110 |
||
1111 |
// ----------------------------------------------------------------------------- |
|
1112 |
// CDbColorPicture::SetVisiblityFieldL |
|
1113 |
// Rest of the details are commented in header. |
|
1114 |
// ----------------------------------------------------------------------------- |
|
1115 |
// |
|
1116 |
void CCalenMultiDBEditor::SetVisiblityFieldL( TBool aStatusVal ) |
|
1117 |
{ |
|
1118 |
TRACE_ENTRY_POINT; |
|
1119 |
HBufC* statusString( NULL ); |
|
1120 |
CEikEdwin* fieldText =( CEikEdwin* )Control( ECalenMultiDbHiddenVisible ); |
|
1121 |
if( aStatusVal ) |
|
1122 |
{ |
|
1123 |
// load string Visible |
|
1124 |
statusString = StringLoader::LoadLC( R_CALE_DB_SHOWN_SETTING ,iCoeEnv ); |
|
1125 |
} |
|
1126 |
else |
|
1127 |
{ |
|
1128 |
// load string Hidden |
|
1129 |
statusString = StringLoader::LoadLC( R_CALE_DB_HIDDEN_SETTING ,iCoeEnv ); |
|
1130 |
} |
|
1131 |
// set status field string |
|
1132 |
fieldText->SetTextL( statusString ); |
|
1133 |
fieldText->DrawDeferred(); |
|
1134 |
CleanupStack::PopAndDestroy( statusString ); |
|
1135 |
TRACE_EXIT_POINT; |
|
1136 |
} |
|
1137 |
||
1138 |
// ----------------------------------------------------------------------------- |
|
1139 |
// CCalenMultiDBEditor::SetTitlePaneL |
|
1140 |
// Rest of the details are commented in header. |
|
1141 |
// ----------------------------------------------------------------------------- |
|
1142 |
// |
|
1143 |
void CCalenMultiDBEditor::SetTitlePaneL() |
|
1144 |
{ |
|
1145 |
TRACE_ENTRY_POINT; |
|
1146 |
||
1147 |
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
1148 |
||
1149 |
// Set empty navi pane label |
|
1150 |
iNaviContainer = static_cast<CAknNavigationControlContainer*>( |
|
1151 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
1152 |
iNaviContainer->PushDefaultL(); |
|
1153 |
||
1154 |
// Set title text |
|
1155 |
CAknTitlePane* tp = static_cast<CAknTitlePane*>( |
|
1156 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
1157 |
||
1158 |
HBufC* titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDAR , iCoeEnv ); |
|
1159 |
tp->SetTextL( *titleText ); |
|
1160 |
CleanupStack::PopAndDestroy( titleText ); |
|
1161 |
||
1162 |
TRACE_EXIT_POINT; |
|
1163 |
} |
|
1164 |
||
1165 |
// ----------------------------------------------------------------------------- |
|
1166 |
// CCalenMultiDBEditor::SetSyncFieldL |
|
1167 |
// Rest of the details are commented in header. |
|
1168 |
// ----------------------------------------------------------------------------- |
|
1169 |
// |
|
1170 |
void CCalenMultiDBEditor::SetSyncFieldL( TBool aSyncVal ) |
|
1171 |
{ |
|
1172 |
TRACE_ENTRY_POINT; |
|
1173 |
||
1174 |
if(!ControlOrNull(ECalenMultiDbSyncStatus)) |
|
1175 |
{ |
|
1176 |
return; |
|
1177 |
} |
|
1178 |
||
1179 |
HBufC* syncString( NULL ); |
|
1180 |
CEikEdwin* syncFieldText =( CEikEdwin* )Control( ECalenMultiDbSyncStatus ); |
|
1181 |
if( EFalse == aSyncVal ) |
|
1182 |
{ |
|
1183 |
// load string Off |
|
1184 |
syncString = StringLoader::LoadLC( R_CALE_SYNC_OFF , iCoeEnv ); |
|
1185 |
} |
|
1186 |
else |
|
1187 |
{ |
|
1188 |
// load string On |
|
1189 |
syncString = StringLoader::LoadLC( R_CALE_SYNC_ON ,iCoeEnv ); |
|
1190 |
} |
|
1191 |
// set sync field string |
|
1192 |
syncFieldText->SetTextL( syncString ); |
|
1193 |
syncFieldText->DrawDeferred(); |
|
1194 |
CleanupStack::PopAndDestroy( syncString ); |
|
1195 |
TRACE_EXIT_POINT; |
|
1196 |
} |
|
1197 |
||
1198 |
// ----------------------------------------------------------------------------- |
|
1199 |
// CheckSpaceBelowCriticalLevelL |
|
1200 |
// Checks if the Flash File System storage will fall below critical level. |
|
1201 |
// If there is not enough space, display an error message and return EFalse. |
|
1202 |
// Return ETrue otherwise. |
|
1203 |
// (other items were commented in a header). |
|
1204 |
// ----------------------------------------------------------------------------- |
|
1205 |
// |
|
1206 |
TBool CCalenMultiDBEditor::CheckSpaceBelowCriticalLevelL() |
|
1207 |
{ |
|
1208 |
TRACE_ENTRY_POINT; |
|
1209 |
||
1210 |
TBool retcode(EFalse); |
|
1211 |
if ( SysUtil::FFSSpaceBelowCriticalLevelL( &( iCoeEnv->FsSession() ) ) ) |
|
1212 |
{ |
|
1213 |
ShowErrorNoteL(KErrDiskFull); |
|
1214 |
retcode = ETrue; |
|
1215 |
} |
|
1216 |
TRACE_EXIT_POINT; |
|
1217 |
return retcode; |
|
1218 |
} |
|
1219 |
||
1220 |
// ----------------------------------------------------------------------------- |
|
1221 |
// CCalenMultiDBEditor::ShowErrorNoteL |
|
1222 |
// ----------------------------------------------------------------------------- |
|
1223 |
// |
|
1224 |
void CCalenMultiDBEditor::ShowErrorNoteL(TInt aError) |
|
1225 |
{ |
|
1226 |
TRACE_ENTRY_POINT |
|
1227 |
CErrorUI* errorUi = CErrorUI::NewLC(); |
|
1228 |
errorUi->ShowGlobalErrorNoteL( aError ); |
|
1229 |
CleanupStack::PopAndDestroy( errorUi ); |
|
1230 |
TRACE_EXIT_POINT |
|
1231 |
} |
|
1232 |
||
1233 |
// ----------------------------------------------------------------------------- |
|
1234 |
// CDbColorPicture::CDbColorPicture |
|
1235 |
// C++ Constructor |
|
1236 |
// ----------------------------------------------------------------------------- |
|
1237 |
// |
|
1238 |
CDbColorPicture::CDbColorPicture(TSize aSize) |
|
1239 |
: iSize(aSize) |
|
1240 |
{ |
|
1241 |
TRACE_ENTRY_POINT; |
|
1242 |
TRACE_EXIT_POINT; |
|
1243 |
} |
|
1244 |
||
1245 |
// ----------------------------------------------------------------------------- |
|
1246 |
// CDbColorPicture::ExternalizeL |
|
1247 |
// Pure virtual from CPicture, intentionally empty. |
|
1248 |
// ----------------------------------------------------------------------------- |
|
1249 |
// |
|
1250 |
void CDbColorPicture::ExternalizeL(RWriteStream& ) const |
|
1251 |
{ |
|
1252 |
TRACE_ENTRY_POINT; |
|
1253 |
TRACE_EXIT_POINT; |
|
1254 |
} |
|
1255 |
||
1256 |
// ----------------------------------------------------------------------------- |
|
1257 |
// CDbColorPicture::GetOriginalSizeInTwips |
|
1258 |
// Convert size to twips |
|
1259 |
// ----------------------------------------------------------------------------- |
|
1260 |
// |
|
1261 |
void CDbColorPicture::GetOriginalSizeInTwips(TSize& /*aSize*/ ) const |
|
1262 |
{ |
|
1263 |
TRACE_ENTRY_POINT; |
|
1264 |
TRACE_EXIT_POINT; |
|
1265 |
} |
|
1266 |
||
1267 |
// ----------------------------------------------------------------------------- |
|
1268 |
// CDbColorPicture::SetRgbColorsL |
|
1269 |
// ----------------------------------------------------------------------------- |
|
1270 |
// |
|
1271 |
void CDbColorPicture::SetRgbColorsL(TRgb aColors) |
|
1272 |
{ |
|
1273 |
TRACE_ENTRY_POINT; |
|
1274 |
iColors = aColors; |
|
1275 |
TRACE_EXIT_POINT; |
|
1276 |
} |
|
1277 |
||
1278 |
// ----------------------------------------------------------------------------- |
|
1279 |
// CDbColorPicture::Draw |
|
1280 |
// Draw funtion to draw the map icon |
|
1281 |
// ----------------------------------------------------------------------------- |
|
1282 |
// |
|
1283 |
void CDbColorPicture::Draw(CGraphicsContext& aGc, |
|
1284 |
const TPoint& aTopLeft , |
|
1285 |
const TRect& /*aClipRect*/ , |
|
1286 |
MGraphicsDeviceMap* /*aMap*/ ) const |
|
1287 |
{ |
|
1288 |
TRACE_ENTRY_POINT; |
|
1289 |
||
1290 |
||
1291 |
//aGc.Reset(); |
|
1292 |
aGc.CancelClippingRect(); |
|
1293 |
||
1294 |
TSize pixelsize; |
|
1295 |
pixelsize.iWidth = 225; |
|
1296 |
pixelsize.iHeight = 16; |
|
1297 |
TPoint aPoint; |
|
1298 |
TRect area = TRect(aTopLeft, pixelsize); |
|
1299 |
area.Move(0,-11); |
|
1300 |
// Draw a datbase color rectangle |
|
1301 |
aGc.SetBrushColor(iColors); |
|
1302 |
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1303 |
||
1304 |
aGc.DrawRect(area); |
|
1305 |
} |
|
1306 |
||
1307 |
// End of File |