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: Implementation of List of Memos/Templates mode.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
|
|
21 |
#include <bldvariant.hrh>
|
|
22 |
#include <eikmenup.h>
|
|
23 |
#include <eikclbd.h>
|
|
24 |
#include <eikapp.h>
|
|
25 |
#include <aknlists.h>
|
|
26 |
#include <bacntf.h>
|
|
27 |
#include <sendui.h>
|
|
28 |
#include <Sendnorm.rsg>
|
|
29 |
#include <txtglobl.h>
|
|
30 |
#include <AknIconArray.h>
|
|
31 |
#include <StringLoader.h>
|
|
32 |
#include <AknDlgShut.h>
|
|
33 |
#include <AknProgressDialog.h>
|
|
34 |
#include <eikprogi.h>
|
|
35 |
#include <eikimage.h>
|
|
36 |
|
|
37 |
#include <AvkonIcons.hrh>
|
|
38 |
#include <avkon.mbg>
|
|
39 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
40 |
#include <gulicon.h>
|
|
41 |
#include <aknconsts.h>
|
|
42 |
#include <hlplch.h>
|
|
43 |
#include <featmgr.h>
|
|
44 |
#include <StringLoader.h>
|
|
45 |
#include <NpdLib.rsg>
|
|
46 |
#include <AiwCommon.hrh>
|
|
47 |
#include <AiwGenericParam.h>
|
|
48 |
#include <CMessageData.h>
|
|
49 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
50 |
#include <vwsdefpartner.h>
|
|
51 |
#endif
|
|
52 |
#include "NpdLib.hrh"
|
|
53 |
#include "NpdListDialog.h"
|
|
54 |
#include "NpdEditorDialog.h"
|
|
55 |
#include "NpdModel_platsec.h"
|
|
56 |
#include "NpdLib.h"
|
|
57 |
#include "NpdListBox.h"
|
|
58 |
|
|
59 |
#include <csxhelp/nmake.hlp.hrh>
|
|
60 |
#include <csxhelp/mce.hlp.hrh>
|
|
61 |
|
|
62 |
// Next is for KNotepadPseudoKeyIdForNewNote
|
|
63 |
//
|
|
64 |
#include "NpdApi.h"
|
|
65 |
#include "NpdLibPanic.h"
|
|
66 |
|
|
67 |
//number of fixed item
|
|
68 |
//currently, Notepad application have one fixed "New Note" item in main view.
|
|
69 |
const TInt KNumberOfFixedItem = 1;
|
|
70 |
|
|
71 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CNotepadListDialog::NewL
|
|
75 |
// Constructor.
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
EXPORT_C CNotepadListDialog* CNotepadListDialog::NewL(
|
|
79 |
TInt aResId, // Resource Id of type NOTEPAD_LIST_DIALOG
|
|
80 |
CEikDialog** aSelfPtr )
|
|
81 |
{
|
|
82 |
CNotepadListDialog* self = new(ELeave) CNotepadListDialog();
|
|
83 |
self->iSelfPtr = aSelfPtr;
|
|
84 |
CleanupStack::PushL(self);
|
|
85 |
TResourceReader rr;
|
|
86 |
self->iCoeEnv->CreateResourceReaderLC(rr, aResId); // Push rr
|
|
87 |
self->ConstructL( rr );
|
|
88 |
CleanupStack::PopAndDestroy(); // rr
|
|
89 |
CleanupStack::Pop(); // self
|
|
90 |
return self;
|
|
91 |
}
|
|
92 |
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
// CNotepadListDialog::~CNotepadListDialog
|
|
95 |
// Destructor.
|
|
96 |
//
|
|
97 |
// In destructor of CNotepadEditorDialog,
|
|
98 |
// CNotepadListDialog::iEditorDialog (pointer to the object) will be
|
|
99 |
// NULLed using CNotepadListDialog::EditorDeleted().
|
|
100 |
// So it is guaranteed that iEditorDialog is NULL iff the object is alive.
|
|
101 |
//
|
|
102 |
// *1* It seems that 'delete iProgressDialog must precceed delete iModel
|
|
103 |
// to avoid a crash when PowerOff while deleting or adding to pinboard.
|
|
104 |
// Because the focus is changed in deleting iProgressDialog
|
|
105 |
// (caused by RemoveFromStack).
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
EXPORT_C CNotepadListDialog::~CNotepadListDialog()
|
|
109 |
{
|
|
110 |
delete iIdle;
|
|
111 |
delete iProgressDialog; // *1*
|
|
112 |
delete iEditorDialog;
|
|
113 |
if ( iFlags & ENotepadObserveView )
|
|
114 |
{
|
|
115 |
iEikonEnv->EikAppUi()->RemoveViewObserver(this);
|
|
116 |
}
|
|
117 |
delete iModel;
|
|
118 |
delete iSendUi;
|
|
119 |
iSavedSelectedKeys.Close();
|
|
120 |
iSavedKeysAboveCurrent.Close();
|
|
121 |
delete iEnvironmentChangeNotifier;
|
|
122 |
if ( iServiceHandler )
|
|
123 |
{
|
|
124 |
|
|
125 |
delete iServiceHandler;
|
|
126 |
iServiceHandler = NULL;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
// CNotepadListDialog::EditByKeyL
|
|
132 |
// Called from CNotepadAppUi.
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
EXPORT_C void CNotepadListDialog::EditByKeyL(const TInt aKey)
|
|
136 |
{
|
|
137 |
__ASSERT_DEBUG( IsNotepad(),
|
|
138 |
Panic(ENotepadLibraryPanicOnlySupportedInNotepad) );
|
|
139 |
if ( iBaseAppUi == iEikonEnv->EikAppUi() // SendUi is not running
|
|
140 |
/*&& !iBaseAppUi->IsDisplayingDialog()*/ // Dialog is not running
|
|
141 |
&& !iModel->IsDeleting() )
|
|
142 |
{
|
|
143 |
DoEditByKeyL(aKey);
|
|
144 |
}
|
|
145 |
}
|
|
146 |
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
// CNotepadListDialog::SaveL
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
EXPORT_C void CNotepadListDialog::SaveL()
|
|
152 |
{
|
|
153 |
if ( iEditorDialog )
|
|
154 |
{
|
|
155 |
iEditorDialog->SaveOnExitL(EFalse);
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
// CNotepadListDialog::HandleEditorExitL
|
|
161 |
// This function is called from CNotepadEditorDialog.
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CNotepadListDialog::HandleEditorExitL(
|
|
165 |
TInt aStatOfSave,
|
|
166 |
const TInt aKey,
|
|
167 |
const TBool aEagerSync )
|
|
168 |
{
|
|
169 |
iEditorFlag= EFalse;
|
|
170 |
if ( aKey != KNotepadPseudoKeyIdForNewNote )
|
|
171 |
{
|
|
172 |
iSavedKey = aKey;
|
|
173 |
}
|
|
174 |
if ( aStatOfSave == CNotepadModel::ENotepadModelRowAdded )
|
|
175 |
{
|
|
176 |
iFlags |= ENotepadItemAdded;
|
|
177 |
}
|
|
178 |
else
|
|
179 |
{
|
|
180 |
iFlags &= ~ENotepadItemAdded;
|
|
181 |
}
|
|
182 |
if ( aEagerSync && iClockValueChange )
|
|
183 |
{
|
|
184 |
iModel->SetItemArrayFlags();
|
|
185 |
iClockValueChange = EFalse;
|
|
186 |
}
|
|
187 |
if (aStatOfSave == CNotepadModel::ENotepadModelRowDeleted)
|
|
188 |
{
|
|
189 |
iListBox->HandleItemRemovalL();
|
|
190 |
DrawNow();
|
|
191 |
}
|
|
192 |
iModel->SyncL(EFalse);
|
|
193 |
RestoreCurrentAndSelectionsL();
|
|
194 |
DrawNow();
|
|
195 |
// MSK
|
|
196 |
MiddleSoftKeyL();
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
// CNotepadListDialog::EditorDeleted
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
void CNotepadListDialog::EditorDeleted()
|
|
204 |
{
|
|
205 |
iEditorDialog = NULL;
|
|
206 |
iModel->SetNotepadModelObserver(this);
|
|
207 |
}
|
|
208 |
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
// CNotepadListDialog::ConstructL
|
|
211 |
// private second-phase constructor
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CNotepadListDialog::ConstructL( TResourceReader& aReader )
|
|
215 |
{
|
|
216 |
iNeedSave = EFalse;
|
|
217 |
iSavedKey = KNotepadInvalidKeyId;
|
|
218 |
iSendingEmail = EFalse;
|
|
219 |
CNotepadDialogBase::ConstructL( aReader ); // menubar, dialog
|
|
220 |
TInt modelResId(aReader.ReadInt32()); // LLINK model;
|
|
221 |
iModel = CNotepadModel::NewL(
|
|
222 |
iCoeEnv->FsSession(), modelResId );
|
|
223 |
iEditorResId = aReader.ReadInt32(); // LLINK editor_dialog
|
|
224 |
TPtrC ptr = aReader.ReadTPtrC(); // LTEXT title
|
|
225 |
if ( ptr.Length() )
|
|
226 |
{
|
|
227 |
SetTitleL(&ptr);
|
|
228 |
}
|
|
229 |
|
|
230 |
iSendUi = CSendUi::NewL();
|
|
231 |
if ( IsNotepad() )
|
|
232 |
{
|
|
233 |
TCallBack callback(HandleEnvironmentChangedL, this);
|
|
234 |
iEnvironmentChangeNotifier = CEnvironmentChangeNotifier::NewL(
|
|
235 |
EActivePriorityLogonA, callback);
|
|
236 |
iEnvironmentChangeNotifier->Start();
|
|
237 |
}
|
|
238 |
iEikonEnv->EikAppUi()->AddViewObserverL(this);
|
|
239 |
iFlags |= ENotepadObserveView;
|
|
240 |
iClockValueChange = EFalse;
|
|
241 |
iBaseAppUi = iAvkonAppUi;
|
|
242 |
iModel->SetNotepadModelObserver(this);
|
|
243 |
iBaseLevelOfActiveScheduler = LevelOfActiveScheduler() + 1;
|
|
244 |
// Create instance of CAiwServiceHandler
|
|
245 |
iServiceHandler = CAiwServiceHandler::NewL();
|
|
246 |
// Attach menu services
|
|
247 |
iServiceHandler->AttachMenuL( R_NOTEPAD_LIST_MENU_SECOND, R_NOTEPAD_APP_INTEREST );
|
|
248 |
if ( FeatureManager::FeatureSupported( KFeatureIdFfEnablePrintingFramework ) )
|
|
249 |
{
|
|
250 |
iServiceHandler->AttachMenuL( R_NOTEPAD_LIST_MENU_FIRST, R_PS_AIW_INTEREST );
|
|
251 |
}
|
|
252 |
}
|
|
253 |
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
// CNotepadListDialog::StartEditorL
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
//
|
|
258 |
void CNotepadListDialog::StartEditorL()
|
|
259 |
{
|
|
260 |
iEditorFlag=ETrue;
|
|
261 |
HideMenu();
|
|
262 |
__ASSERT_DEBUG(iEditorResId, User::Invariant());
|
|
263 |
|
|
264 |
iEditorDialog = CNotepadEditorDialog::NewL(iEditorResId, iModel, this,
|
|
265 |
iSendUi);
|
|
266 |
|
|
267 |
iEditorDialog->ExecuteLD();
|
|
268 |
iListBox->ClearSelection();
|
|
269 |
ClearSavedCurrentAndSelections();
|
|
270 |
SaveCurrentAndSelectionsL();
|
|
271 |
}
|
|
272 |
|
|
273 |
// -----------------------------------------------------------------------------
|
|
274 |
// CNotepadListDialog::OnCmdAddL
|
|
275 |
// -----------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
void CNotepadListDialog::OnCmdAddL()
|
|
278 |
{
|
|
279 |
StartEditorL();
|
|
280 |
iEditorDialog->SwitchTextL(KNotepadPseudoKeyIdForNewNote);
|
|
281 |
}
|
|
282 |
|
|
283 |
// -----------------------------------------------------------------------------
|
|
284 |
// CNotepadListDialog::OnCmdOpenL
|
|
285 |
// -----------------------------------------------------------------------------
|
|
286 |
//
|
|
287 |
void CNotepadListDialog::OnCmdOpenL(TInt aIndex)
|
|
288 |
{
|
|
289 |
if ( iModel->MdcaCount() == 0 )
|
|
290 |
{
|
|
291 |
return;
|
|
292 |
}
|
|
293 |
StartEditorL();
|
|
294 |
iEditorDialog->SwitchTextL(iModel->Key(aIndex));
|
|
295 |
}
|
|
296 |
|
|
297 |
// -----------------------------------------------------------------------------
|
|
298 |
// CNotepadListDialog::ConfirmDeleteL
|
|
299 |
// -----------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
TBool CNotepadListDialog::ConfirmDeleteL(TInt aMemos)
|
|
302 |
{
|
|
303 |
TBool isConfirmed(ETrue);
|
|
304 |
if ( aMemos >= 2 )
|
|
305 |
{
|
|
306 |
HBufC* prompt = StringLoader::LoadLC(
|
|
307 |
QueryDeleteMultipleResId(), aMemos, iCoeEnv);
|
|
308 |
isConfirmed = ExecuteConfirmationQueryL(prompt);
|
|
309 |
CleanupStack::PopAndDestroy(); // prompt
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{
|
|
313 |
isConfirmed = ExecuteConfirmationQueryL(QueryDeleteSingleResId());
|
|
314 |
}
|
|
315 |
return isConfirmed;
|
|
316 |
}
|
|
317 |
|
|
318 |
// -----------------------------------------------------------------------------
|
|
319 |
// CNotepadListDialog::CreateKeyArrayOfSelectionsL
|
|
320 |
// -----------------------------------------------------------------------------
|
|
321 |
//
|
|
322 |
void CNotepadListDialog::CreateKeyArrayOfSelectionsL()
|
|
323 |
{
|
|
324 |
const CListBoxView::CSelectionIndexArray* selections =
|
|
325 |
iListBox->SelectionIndexes();
|
|
326 |
const TInt markCount( selections->Count() );
|
|
327 |
iSavedSelectedKeys.Reset();
|
|
328 |
for (TInt i(0); i < markCount; i++)
|
|
329 |
{
|
|
330 |
User::LeaveIfError(
|
|
331 |
iSavedSelectedKeys.Append(iModel->Key((*selections)[i])) );
|
|
332 |
}
|
|
333 |
}
|
|
334 |
|
|
335 |
// -----------------------------------------------------------------------------
|
|
336 |
// CNotepadListDialog::OnCmdDeleteL
|
|
337 |
//
|
|
338 |
// IsNotepad IsTemplates
|
|
339 |
// markCount >= 2 **A**(1) **A**(2)
|
|
340 |
// markCount == 1 **C** **A**(3)
|
|
341 |
// markCOunt == 0 **C** **B**(3)
|
|
342 |
//
|
|
343 |
// According to UI specs (Notepad and Message Centre),
|
|
344 |
// in the case of the block **C**, no progress note is needed but
|
|
345 |
// we must show a progress note if markCount>=2 or IsTempates
|
|
346 |
// (block **A** or **B**).
|
|
347 |
//
|
|
348 |
// And there are 3 different labels defined;
|
|
349 |
// (1) "Deleting"
|
|
350 |
// (2) "Deleting template %0N of %1N"
|
|
351 |
// (3) "Deleting template"
|
|
352 |
// Block **B** also create the progress note, but it is different from **A**
|
|
353 |
// in the point that it must create a KeyArray by itself.
|
|
354 |
// -----------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
void CNotepadListDialog::OnCmdDeleteL()
|
|
357 |
{
|
|
358 |
TInt markCount( iListBox->SelectionIndexes()->Count() );
|
|
359 |
//For clear key,if nothing can be deleted ,do not handle the clear key
|
|
360 |
if ( iModel->MdcaCount() == 0 || ( markCount == 0 && !iListBox->IsHighlightEnabled() ) )
|
|
361 |
{
|
|
362 |
return;
|
|
363 |
}
|
|
364 |
|
|
365 |
//Fixed Item 'New Note' in notes should not be deleted
|
|
366 |
if ( IsNoteListDialog() && ( iListBox->CurrentItemIndex() == 0 ) && markCount == 0 )
|
|
367 |
{
|
|
368 |
return;
|
|
369 |
}
|
|
370 |
|
|
371 |
ClearSavedCurrentAndSelections();
|
|
372 |
SaveCurrentAndSelectionsL();
|
|
373 |
|
|
374 |
TInt deleteCount;
|
|
375 |
if ( iListBox->IsHighlightEnabled() && markCount == 0 )
|
|
376 |
{
|
|
377 |
//for an Item highlighted and no Item marked
|
|
378 |
deleteCount = 1;
|
|
379 |
}
|
|
380 |
else
|
|
381 |
{
|
|
382 |
deleteCount = markCount;
|
|
383 |
}
|
|
384 |
|
|
385 |
if ( ConfirmDeleteL( deleteCount ) )
|
|
386 |
{
|
|
387 |
//be sure that the marks or the items might have gone while confirming
|
|
388 |
//
|
|
389 |
if ( markCount > 0 ?
|
|
390 |
( deleteCount = iListBox->SelectionIndexes()->Count() ) > 0 :
|
|
391 |
iModel->MdcaCount() > 0 )
|
|
392 |
{
|
|
393 |
// assert "deleteCount >= 1"
|
|
394 |
if ( deleteCount >= 2 || ( IsTemplates() && markCount ) )
|
|
395 |
{ //**A**
|
|
396 |
// Both Notepad and MCE specs require ProgressDialog
|
|
397 |
// in deleting multiple items.
|
|
398 |
// Only MCE shows ProgressDialog even in deleting one item.
|
|
399 |
//
|
|
400 |
CreateProgressDialogL(deleteCount,
|
|
401 |
deleteCount == 1 ? // when just one template is marked
|
|
402 |
R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATE :
|
|
403 |
( IsTemplates() ? // when two or more templates are marked
|
|
404 |
R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATES :
|
|
405 |
0 )); // default label for Notepad
|
|
406 |
iModel->DeleteByKeysL(iSavedSelectedKeys); // start CIdle
|
|
407 |
}
|
|
408 |
else if ( IsTemplates() ) // MCE, delete a focused item
|
|
409 |
{ //**B**
|
|
410 |
// MCE spec requires ProgressDialog even in deleting one item
|
|
411 |
//
|
|
412 |
RArray<TInt> keys(1);
|
|
413 |
CleanupClosePushL(keys);
|
|
414 |
User::LeaveIfError(keys.Append(iSavedKey));
|
|
415 |
CreateProgressDialogL( deleteCount,
|
|
416 |
R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATE );
|
|
417 |
iModel->DeleteByKeysL(keys); // start CIdle
|
|
418 |
CleanupStack::PopAndDestroy();// keys
|
|
419 |
}
|
|
420 |
else
|
|
421 |
{ //**C**
|
|
422 |
// Notepad spec doesn't require ProgressDialog
|
|
423 |
// in deleting a single item
|
|
424 |
//
|
|
425 |
iModel->DeleteL( markCount == 0 ? iSavedKey :
|
|
426 |
iSavedSelectedKeys[0] );
|
|
427 |
}
|
|
428 |
}
|
|
429 |
}
|
|
430 |
iModel->SyncL(EFalse); // sync might be delayed while confirming
|
|
431 |
}
|
|
432 |
|
|
433 |
// -----------------------------------------------------------------------------
|
|
434 |
// CNotepadListDialog::OnCmdSendL
|
|
435 |
// -----------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
void CNotepadListDialog::OnCmdSendL(TInt aCommandId)
|
|
438 |
{
|
|
439 |
if ( iModel->MdcaCount() == 0 )
|
|
440 |
{
|
|
441 |
return;
|
|
442 |
}
|
|
443 |
if ( iListBox->SelectionIndexes()->Count() > 0 )
|
|
444 |
{
|
|
445 |
ClearSavedCurrentAndSelections();
|
|
446 |
SaveCurrentAndSelectionsL();
|
|
447 |
TUid serviceUid = SendByKeysL(*iSendUi, aCommandId, *iModel, iSavedSelectedKeys);
|
|
448 |
iModel->SyncL(EFalse); // sync might be delayed while SendAsL.
|
|
449 |
TUid EmailUid = {0x10001028};
|
|
450 |
if ( serviceUid == EmailUid )
|
|
451 |
{
|
|
452 |
iSendingEmail = ETrue;
|
|
453 |
}
|
|
454 |
}
|
|
455 |
else
|
|
456 |
{
|
|
457 |
HBufC* text = iModel->ContentL(iListBox->CurrentItemIndex());
|
|
458 |
CleanupStack::PushL(text);
|
|
459 |
iSavedKey = iModel->Key(iListBox->CurrentItemIndex());
|
|
460 |
SendAsL( *iSendUi, aCommandId, EFalse, text );
|
|
461 |
CleanupStack::PopAndDestroy(); // text
|
|
462 |
iModel->SyncL(EFalse); // sync might be delayed while SendAsL.
|
|
463 |
}
|
|
464 |
}
|
|
465 |
|
|
466 |
// -----------------------------------------------------------------------------
|
|
467 |
// CNotepadListDialog::CreateProgressDialogL
|
|
468 |
// -----------------------------------------------------------------------------
|
|
469 |
//
|
|
470 |
void CNotepadListDialog::CreateProgressDialogL(
|
|
471 |
const TInt aCount,
|
|
472 |
const TInt aLabelResId )
|
|
473 |
{
|
|
474 |
__ASSERT_DEBUG( aCount >= 1,
|
|
475 |
Panic(ENotepadLibraryPanicInvalidFinalValueOfProgressNote) );
|
|
476 |
delete iProgressDialog;
|
|
477 |
iProgressDialog = NULL;
|
|
478 |
iProgressDialog = new(ELeave) CNotepadProgressDialog(
|
|
479 |
REINTERPRET_CAST( CEikDialog**, &iProgressDialog ), EFalse);
|
|
480 |
|
|
481 |
iProgressDialog->SetMopParent(this);
|
|
482 |
|
|
483 |
iProgressDialog->PrepareLC(R_NOTEPAD_DELETE_PROGRESS_NOTE);
|
|
484 |
|
|
485 |
iProgressDialog->PrepareL(aCount, aLabelResId);
|
|
486 |
iProgressDialog->ProgressInfo()->SetFinalValue(
|
|
487 |
aLabelResId == 0 ?
|
|
488 |
aCount * 2 // In Notepad deleting a item is done by 2 steps
|
|
489 |
: aCount );
|
|
490 |
iProgressDialog->SetCallback(this);
|
|
491 |
iProgressDialog->RunLD();
|
|
492 |
}
|
|
493 |
|
|
494 |
// -----------------------------------------------------------------------------
|
|
495 |
// CNotepadListDialog::DoEditByKeyL
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
//
|
|
498 |
void CNotepadListDialog::DoEditByKeyL(const TInt aKey)
|
|
499 |
{
|
|
500 |
iModel->SyncL(EFalse);
|
|
501 |
if ( iEditorDialog )
|
|
502 |
{
|
|
503 |
iEditorDialog->EditByKeyL(aKey, *iBaseAppUi);
|
|
504 |
}
|
|
505 |
else if ( aKey != KNotepadPseudoKeyIdForNewNote
|
|
506 |
&& iModel->SeekKey(aKey) == 0 )
|
|
507 |
{
|
|
508 |
// Open the memo with the given key (aKey)
|
|
509 |
OnCmdOpenL( iModel->IndexOf(aKey) );
|
|
510 |
}
|
|
511 |
else
|
|
512 |
{
|
|
513 |
// Launch empty editor (pinned number -1 means "Write a Note")
|
|
514 |
OnCmdAddL();
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
// -----------------------------------------------------------------------------
|
|
519 |
// CNotepadListDialog::HandleEnvironmentChangedL
|
|
520 |
// private static function.
|
|
521 |
// -----------------------------------------------------------------------------
|
|
522 |
//
|
|
523 |
TInt CNotepadListDialog::HandleEnvironmentChangedL( TAny* aThisPtr )
|
|
524 |
{
|
|
525 |
return STATIC_CAST(CNotepadListDialog*,
|
|
526 |
aThisPtr)->DoHandleEnvironmentChangedL();
|
|
527 |
}
|
|
528 |
|
|
529 |
// -----------------------------------------------------------------------------
|
|
530 |
// CNotepadListDialog::DoHandleEnvironmentChangedL
|
|
531 |
//
|
|
532 |
// Just after first time iCrossoverNotifier->Start() is called,
|
|
533 |
// HandleDateChanged seems to be called.
|
|
534 |
// To avoid calling ForceListSync at the first callback,
|
|
535 |
// we use a flag ENotepadEverEnvironmentChanged.
|
|
536 |
// When this function is called at first, the flag is off and so
|
|
537 |
// ForceListSync is blocked by condition
|
|
538 |
// ( iFlags & ENotepadEverEnvironmentChanged )
|
|
539 |
// and then the flag is set to be on.
|
|
540 |
//
|
|
541 |
// Even if this function may LEAVE, the notification will not be
|
|
542 |
// cancelled (ie. the callback is made on further EnvironmentChange.
|
|
543 |
// -----------------------------------------------------------------------------
|
|
544 |
//
|
|
545 |
TInt CNotepadListDialog::DoHandleEnvironmentChangedL()
|
|
546 |
{
|
|
547 |
iClockValueChange = ((iEnvironmentChangeNotifier->Change()
|
|
548 |
& ( EChangesMidnightCrossover | EChangesLocale | EChangesSystemTime )) != 0);
|
|
549 |
|
|
550 |
if ( ( iFlags & ENotepadEverEnvironmentChanged ) && iClockValueChange)
|
|
551 |
{
|
|
552 |
iModel->HandleDateChangedL((iFlags & ENotepadIsBackground));
|
|
553 |
}
|
|
554 |
iFlags |= ENotepadEverEnvironmentChanged;
|
|
555 |
|
|
556 |
return TRUE; // callback should be called again.
|
|
557 |
}
|
|
558 |
|
|
559 |
// -----------------------------------------------------------------------------
|
|
560 |
// CNotepadListDialog::SaveCurrentAndSelectionsL
|
|
561 |
// does nothing if already saved.
|
|
562 |
// -----------------------------------------------------------------------------
|
|
563 |
//
|
|
564 |
void CNotepadListDialog::SaveCurrentAndSelectionsL()
|
|
565 |
{
|
|
566 |
if ( iSavedKey != KNotepadInvalidKeyId ) // ie. already saved
|
|
567 |
{
|
|
568 |
return;
|
|
569 |
}
|
|
570 |
if ( iModel->MdcaCount() == 0 ) // empty
|
|
571 |
{
|
|
572 |
ClearSavedCurrentAndSelections();
|
|
573 |
}
|
|
574 |
else
|
|
575 |
{
|
|
576 |
// save current
|
|
577 |
//
|
|
578 |
TInt currentIndex( iListBox->CurrentItemIndex() );
|
|
579 |
iSavedKey = iModel->Key(currentIndex);
|
|
580 |
iSavedKeysAboveCurrent.Reset();
|
|
581 |
for ( TInt i(0); i < currentIndex; i++ )
|
|
582 |
{
|
|
583 |
User::LeaveIfError(
|
|
584 |
iSavedKeysAboveCurrent.Append(iModel->Key(i)));
|
|
585 |
}
|
|
586 |
// save selections
|
|
587 |
//
|
|
588 |
CreateKeyArrayOfSelectionsL();
|
|
589 |
}
|
|
590 |
}
|
|
591 |
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
// CNotepadListDialog::RestoreCurrentAndSelectionsL
|
|
594 |
//
|
|
595 |
// The case **1** is posible, eg. in following case;
|
|
596 |
// 1. Launch Notepad and suspend it by Application key in empty List mode,
|
|
597 |
// 2. Save a certain file as a memo using NpdTest.app,
|
|
598 |
// 3. Launch Pinboard and select "Write a note",
|
|
599 |
// then crash (if **1** were not done).
|
|
600 |
//
|
|
601 |
// Why this function TRAP RestoreSelectionsL?
|
|
602 |
// 1. We must do SetDisableRedraw(EFalse) even if LEAVE,
|
|
603 |
// 2. We must do ClearSavedCurrentAndSelections even if LEAVE.
|
|
604 |
// -----------------------------------------------------------------------------
|
|
605 |
//
|
|
606 |
void CNotepadListDialog::RestoreCurrentAndSelectionsL()
|
|
607 |
{
|
|
608 |
const TBool isEmpty( iModel->MdcaCount() == 0 );
|
|
609 |
if ( !isEmpty && iListBox->CurrentItemIndex() < 0 ) // **1**
|
|
610 |
{
|
|
611 |
iListBox->SetCurrentItemIndex(0);
|
|
612 |
}
|
|
613 |
if ( iSavedKey != KNotepadInvalidKeyId ) // ie. has saved
|
|
614 |
{
|
|
615 |
TInt err(KErrNone);
|
|
616 |
if ( !isEmpty ) // not empty
|
|
617 |
{
|
|
618 |
TBool redrawDisabledByThisFunction(EFalse);
|
|
619 |
if ( !iListBox->View()->RedrawDisabled() )
|
|
620 |
{
|
|
621 |
iListBox->View()->SetDisableRedraw(ETrue);
|
|
622 |
redrawDisabledByThisFunction = ETrue;
|
|
623 |
}
|
|
624 |
RestoreCurrent();
|
|
625 |
AdjustTopItemIfNeed();
|
|
626 |
|
|
627 |
TRAP(err, RestoreSelectionsL();); // LEAVE should be postponed
|
|
628 |
if ( redrawDisabledByThisFunction )
|
|
629 |
{
|
|
630 |
iListBox->View()->SetDisableRedraw(EFalse);
|
|
631 |
}
|
|
632 |
}
|
|
633 |
ClearSavedCurrentAndSelections();
|
|
634 |
if (iNeedSave)
|
|
635 |
{
|
|
636 |
SaveCurrentAndSelectionsL();
|
|
637 |
iNeedSave = EFalse;
|
|
638 |
}
|
|
639 |
User::LeaveIfError(err);
|
|
640 |
/* iListBox->ScrollBarFrame()->MoveVertThumbTo(
|
|
641 |
iListBox->CurrentItemIndex());*/
|
|
642 |
}
|
|
643 |
}
|
|
644 |
|
|
645 |
// -----------------------------------------------------------------------------
|
|
646 |
// CNotepadListDialog::RestoreCurrent
|
|
647 |
// -----------------------------------------------------------------------------
|
|
648 |
//
|
|
649 |
void CNotepadListDialog::RestoreCurrent()
|
|
650 |
{
|
|
651 |
__ASSERT_DEBUG( iModel->MdcaCount() > 0,
|
|
652 |
Panic(ENotepadLibraryPanicNoItem) );
|
|
653 |
TInt resultIndex( iModel->IndexOf( iSavedKey ) );
|
|
654 |
if ( resultIndex == KNotepadModelInvalidIndex ) // not found
|
|
655 |
{
|
|
656 |
const TInt savedIndex( iSavedKeysAboveCurrent.Count() );
|
|
657 |
if ( savedIndex == 0 )
|
|
658 |
{
|
|
659 |
resultIndex = 0;
|
|
660 |
}
|
|
661 |
else
|
|
662 |
{
|
|
663 |
for ( TInt i(savedIndex - 1); i >= 0; --i )
|
|
664 |
{
|
|
665 |
TInt index( iModel->IndexOf(iSavedKeysAboveCurrent[i]) );
|
|
666 |
if ( index == KNotepadModelInvalidIndex ||
|
|
667 |
index >= savedIndex )
|
|
668 |
{
|
|
669 |
//the key no longer exists above current
|
|
670 |
iSavedKeysAboveCurrent.Remove(i);
|
|
671 |
}
|
|
672 |
}
|
|
673 |
resultIndex = iSavedKeysAboveCurrent.Count();
|
|
674 |
if ( resultIndex >= iModel->MdcaCount() )
|
|
675 |
{
|
|
676 |
resultIndex = iModel->MdcaCount() - 1; // assert "count>0"
|
|
677 |
}
|
|
678 |
}
|
|
679 |
}
|
|
680 |
iListBox->View()->CalcBottomItemIndex(); // to avoid crash in next line
|
|
681 |
iListBox->SetCurrentItemIndex( resultIndex );
|
|
682 |
}
|
|
683 |
|
|
684 |
// -----------------------------------------------------------------------------
|
|
685 |
// CNotepadListDialog::RestoreSelectionsL
|
|
686 |
// -----------------------------------------------------------------------------
|
|
687 |
//
|
|
688 |
void CNotepadListDialog::RestoreSelectionsL()
|
|
689 |
{
|
|
690 |
iListBox->ClearSelection();
|
|
691 |
for ( TInt i(0); i < iSavedSelectedKeys.Count() ; i++ )
|
|
692 |
{
|
|
693 |
TInt selectedIndex( iModel->IndexOf(iSavedSelectedKeys[i]) );
|
|
694 |
if ( selectedIndex != KNotepadModelInvalidIndex ) // found
|
|
695 |
{
|
|
696 |
iListBox->View()->SelectItemL(selectedIndex);
|
|
697 |
}
|
|
698 |
}
|
|
699 |
}
|
|
700 |
|
|
701 |
// -----------------------------------------------------------------------------
|
|
702 |
// CNotepadListDialog::ClearSavedCurrentAndSelections
|
|
703 |
// -----------------------------------------------------------------------------
|
|
704 |
//
|
|
705 |
void CNotepadListDialog::ClearSavedCurrentAndSelections()
|
|
706 |
{
|
|
707 |
iSavedKey = KNotepadPseudoKeyIdForNewNote;
|
|
708 |
iSavedKeysAboveCurrent.Reset();
|
|
709 |
iSavedKeysAboveCurrent.Compress();
|
|
710 |
iSavedSelectedKeys.Reset();
|
|
711 |
iSavedSelectedKeys.Compress();
|
|
712 |
}
|
|
713 |
|
|
714 |
// -----------------------------------------------------------------------------
|
|
715 |
// CNotepadListDialog::AdjustTopItemIfNeed
|
|
716 |
// -----------------------------------------------------------------------------
|
|
717 |
//
|
|
718 |
void CNotepadListDialog::AdjustTopItemIfNeed()
|
|
719 |
{
|
|
720 |
__ASSERT_DEBUG( iModel->MdcaCount() > 0,
|
|
721 |
Panic(ENotepadLibraryPanicNoItem) );
|
|
722 |
if ( iFlags & ENotepadItemAdded )
|
|
723 |
{
|
|
724 |
iFlags &= ~ENotepadItemAdded;
|
|
725 |
const TInt count( iModel->MdcaCount() );
|
|
726 |
const TInt index( iListBox->CurrentItemIndex() );
|
|
727 |
const TInt lines( iListBox->View()->NumberOfItemsThatFitInRect(
|
|
728 |
iListBox->View()->ViewRect() ) );
|
|
729 |
iListBox->View()->SetTopItemIndex(
|
|
730 |
(count - lines) >= index ? index :
|
|
731 |
( count > lines ? count - lines : 0 ) );
|
|
732 |
}
|
|
733 |
}
|
|
734 |
|
|
735 |
// -----------------------------------------------------------------------------
|
|
736 |
// CNotepadListDialog::AvoidSyncing
|
|
737 |
// -----------------------------------------------------------------------------
|
|
738 |
//
|
|
739 |
TBool CNotepadListDialog::AvoidSyncing() const
|
|
740 |
{
|
|
741 |
return (((iEditorDialog != NULL) && iEditorDialog->IsFocused()) || iModel->IsDeleting()
|
|
742 |
|| (LevelOfActiveScheduler() != iBaseLevelOfActiveScheduler)
|
|
743 |
|| ((iFlags & ENotepadIsBackground) && !iClockValueChange)
|
|
744 |
|| (iBaseAppUi != iEikonEnv->EikAppUi()));
|
|
745 |
}
|
|
746 |
|
|
747 |
// -----------------------------------------------------------------------------
|
|
748 |
// CNotepadListDialog::DoHandleViewEventL
|
|
749 |
//
|
|
750 |
// When launching Notepad application,
|
|
751 |
// the event TVwsViewEvent::EVwsActivateView occurs
|
|
752 |
// but we have nothing to do at that time
|
|
753 |
// (because all operations are for resuming).
|
|
754 |
// In order to avoid doing such needless operations,
|
|
755 |
// we use the flag ENotepadEverViewDeactivated which denotes
|
|
756 |
// whether the view has deactivated.
|
|
757 |
// This flag is set first time TVwsViewEvent::EVwsDeactivateView,
|
|
758 |
// and will never be cleared in this object's lifetime.
|
|
759 |
// -----------------------------------------------------------------------------
|
|
760 |
//
|
|
761 |
void CNotepadListDialog::DoHandleViewEventL(const TVwsViewEvent& aEvent)
|
|
762 |
{
|
|
763 |
TLocale local;
|
|
764 |
switch ( aEvent.iEventType )
|
|
765 |
{
|
|
766 |
case TVwsViewEvent::EVwsActivateView:
|
|
767 |
iFlags &= ~ENotepadIsBackground;
|
|
768 |
if ( iFlags & ENotepadEverViewDeactivated )
|
|
769 |
{
|
|
770 |
iCurrentTimeFormat = local.TimeFormat();
|
|
771 |
if ( !AvoidSyncing()||( iCurrentTimeFormat != iPreTimeFormat )||(iModel->ItemArrayFlags())& CNotepadModel::ENotepadRequireDbViewUpdate )
|
|
772 |
{
|
|
773 |
iModel->SetItemArrayFlags();
|
|
774 |
iModel->SyncL(EFalse);
|
|
775 |
iNeedSave = ETrue;
|
|
776 |
if (iEditorFlag)
|
|
777 |
{
|
|
778 |
RestoreCurrentAndSelectionsL();
|
|
779 |
}
|
|
780 |
if( iCurrentTimeFormat!= iPreTimeFormat )
|
|
781 |
{
|
|
782 |
break;
|
|
783 |
}
|
|
784 |
iListBox->DrawNow();
|
|
785 |
}
|
|
786 |
}
|
|
787 |
break;
|
|
788 |
case TVwsViewEvent::EVwsDeactivateView:
|
|
789 |
iPreTimeFormat = local.TimeFormat();
|
|
790 |
iFlags |= ENotepadIsBackground;
|
|
791 |
iFlags |= ENotepadEverViewDeactivated;
|
|
792 |
if ( !iEditorDialog
|
|
793 |
&& LevelOfActiveScheduler() == iBaseLevelOfActiveScheduler
|
|
794 |
&& iBaseAppUi == iEikonEnv->EikAppUi() //SendUi isn't running
|
|
795 |
&& !iModel->IsDeleting() )
|
|
796 |
{
|
|
797 |
ClearSavedCurrentAndSelections();
|
|
798 |
if ( !iSendingEmail )
|
|
799 |
{
|
|
800 |
SaveCurrentAndSelectionsL();
|
|
801 |
}
|
|
802 |
iSendingEmail = EFalse;
|
|
803 |
}
|
|
804 |
break;
|
|
805 |
default:
|
|
806 |
break;
|
|
807 |
}
|
|
808 |
}
|
|
809 |
|
|
810 |
// -----------------------------------------------------------------------------
|
|
811 |
// CNotepadListDialog::HandleNotepadModelEventL
|
|
812 |
// -----------------------------------------------------------------------------
|
|
813 |
//
|
|
814 |
void CNotepadListDialog::HandleNotepadModelEventL(
|
|
815 |
TEvent aEvent,
|
|
816 |
TInt aParam )
|
|
817 |
{
|
|
818 |
switch ( aEvent )
|
|
819 |
{
|
|
820 |
case EDatabaseChanged:
|
|
821 |
if ( !AvoidSyncing() )
|
|
822 |
{
|
|
823 |
if(iClockValueChange)
|
|
824 |
{
|
|
825 |
iModel->SetItemArrayFlags();
|
|
826 |
iClockValueChange = EFalse;
|
|
827 |
}
|
|
828 |
iModel->SyncL(EFalse);
|
|
829 |
}
|
|
830 |
break;
|
|
831 |
case EAbortDeletion:
|
|
832 |
// no need for DialogDismissedL, so no need for ProcessFinishedL
|
|
833 |
delete iProgressDialog;
|
|
834 |
iProgressDialog = NULL;
|
|
835 |
break;
|
|
836 |
case ECompleteDeletion:
|
|
837 |
if ( iProgressDialog )
|
|
838 |
{
|
|
839 |
iProgressDialog->ProcessFinishedL();
|
|
840 |
}
|
|
841 |
break;
|
|
842 |
case EProgressDeletion:
|
|
843 |
if ( iProgressDialog && aParam > 0 )
|
|
844 |
{
|
|
845 |
iProgressDialog->IncrementL(aParam);
|
|
846 |
}
|
|
847 |
break;
|
|
848 |
case EStartItemArrayChange:
|
|
849 |
SaveCurrentAndSelectionsL();
|
|
850 |
break;
|
|
851 |
case EAbortItemArrayChange:
|
|
852 |
iListBox->View()->SetDisableRedraw(EFalse);
|
|
853 |
iListBox->Reset();
|
|
854 |
iListBox->DrawDeferred();
|
|
855 |
//MSK
|
|
856 |
MiddleSoftKeyL();
|
|
857 |
break;
|
|
858 |
case EProgressItemArrayChange:
|
|
859 |
// skip RestoreCurrentAndSelectionsL
|
|
860 |
iListBox->View()->SetDisableRedraw(EFalse);
|
|
861 |
iListBox->DrawDeferred();
|
|
862 |
break;
|
|
863 |
case ECompleteItemArrayChange:
|
|
864 |
iListBox->HandleItemRemovalL();
|
|
865 |
iNeedSave = ETrue;
|
|
866 |
RestoreCurrentAndSelectionsL();
|
|
867 |
iListBox->View()->SetDisableRedraw(EFalse);
|
|
868 |
iListBox->DrawNow();
|
|
869 |
//MSK
|
|
870 |
MiddleSoftKeyL();
|
|
871 |
break;
|
|
872 |
default:
|
|
873 |
break;
|
|
874 |
}
|
|
875 |
}
|
|
876 |
|
|
877 |
// -----------------------------------------------------------------------------
|
|
878 |
// CNotepadListDialog::DynInitMenuPaneL
|
|
879 |
// from MEikMenuObserver
|
|
880 |
// -----------------------------------------------------------------------------
|
|
881 |
//
|
|
882 |
void CNotepadListDialog::DynInitMenuPaneL(
|
|
883 |
TInt aResourceId,
|
|
884 |
CEikMenuPane* aMenuPane )
|
|
885 |
{
|
|
886 |
__ASSERT_DEBUG( aResourceId > 0,
|
|
887 |
Panic(ENotepadLibraryPanicNoMenuResource) );
|
|
888 |
__ASSERT_DEBUG( aMenuPane, Panic(ENotepadLibraryPanicNullMenuPane) );
|
|
889 |
__ASSERT_DEBUG( iListBox, Panic(ENotepadLibraryPanicNullListControl) );
|
|
890 |
__ASSERT_DEBUG( iModel, Panic(ENotepadLibraryPanicNoModel) );
|
|
891 |
if ( iServiceHandler->HandleSubmenuL( *aMenuPane ) )
|
|
892 |
{
|
|
893 |
return;
|
|
894 |
}
|
|
895 |
|
|
896 |
ClearSavedCurrentAndSelections();
|
|
897 |
SaveCurrentAndSelectionsL();
|
|
898 |
iModel->SyncL(EFalse);
|
|
899 |
CNotepadDialogBase::DynInitMenuPaneL( aResourceId, aMenuPane );
|
|
900 |
|
|
901 |
TInt memoCount = iModel->MdcaCount();
|
|
902 |
if ( IsNoteListDialog() )
|
|
903 |
{
|
|
904 |
memoCount = memoCount - KNumberOfFixedItem;
|
|
905 |
}
|
|
906 |
|
|
907 |
const TInt markCount(iListBox->SelectionIndexes()->Count());
|
|
908 |
TInt index;
|
|
909 |
switch (aResourceId )
|
|
910 |
{
|
|
911 |
case R_SENDUI_MENU:
|
|
912 |
index = 2;
|
|
913 |
iSendUi->AddSendMenuItemL(*aMenuPane, index, ENotepadCmdSend );
|
|
914 |
break;
|
|
915 |
case R_NOTEPAD_LIST_MENU_SECOND:
|
|
916 |
if( !(iFlags & ENotepadMenuByOkKey) || (memoCount && !markCount))
|
|
917 |
{
|
|
918 |
iServiceHandler->InitializeMenuPaneL( *aMenuPane, aResourceId, ECmdLast, iServiceHandler->InParamListL() );
|
|
919 |
}
|
|
920 |
if ( iFlags & ENotepadMenuByOkKey )
|
|
921 |
{
|
|
922 |
if ( !memoCount || markCount )
|
|
923 |
{
|
|
924 |
aMenuPane->DeleteMenuItem(ECmdAiwPlaceholder);
|
|
925 |
}
|
|
926 |
}
|
|
927 |
// go through into next case
|
|
928 |
case R_NOTEPAD_TEMPLATE_LIST_MENU_SECOND:
|
|
929 |
{
|
|
930 |
if(!FeatureManager::FeatureSupported(KFeatureIdHelp))
|
|
931 |
{
|
|
932 |
aMenuPane->DeleteMenuItem(EAknCmdHelp);
|
|
933 |
}
|
|
934 |
if ( iFlags & ENotepadMenuByOkKey )
|
|
935 |
{
|
|
936 |
if ( !memoCount || markCount )
|
|
937 |
{
|
|
938 |
if( markCount )
|
|
939 |
aMenuPane->DeleteMenuItem(ENotepadCmdAdd);
|
|
940 |
}
|
|
941 |
if(FeatureManager::FeatureSupported(KFeatureIdHelp))
|
|
942 |
{
|
|
943 |
aMenuPane->DeleteMenuItem(EAknCmdHelp);
|
|
944 |
}
|
|
945 |
aMenuPane->DeleteMenuItem(EAknCmdExit);
|
|
946 |
}
|
|
947 |
}
|
|
948 |
break;
|
|
949 |
case R_NOTEPAD_LIST_MENU_FIRST:
|
|
950 |
case R_NOTEPAD_TEMPLATE_LIST_MENU_FIRST:
|
|
951 |
{
|
|
952 |
if ( IsNotepad() )
|
|
953 |
{
|
|
954 |
if ( FeatureManager::FeatureSupported( KFeatureIdFfEnablePrintingFramework ) )
|
|
955 |
{
|
|
956 |
// Initiliaze menu
|
|
957 |
if ( memoCount )
|
|
958 |
{
|
|
959 |
iServiceHandler->InitializeMenuPaneL( *aMenuPane,
|
|
960 |
aResourceId,
|
|
961 |
ENotepadCmdPrint,
|
|
962 |
iServiceHandler->InParamListL()
|
|
963 |
);
|
|
964 |
}
|
|
965 |
else
|
|
966 |
// If listbox is empty, delete Print AIW menu item.
|
|
967 |
{
|
|
968 |
aMenuPane->DeleteMenuItem( ENotepadCmdPrint );
|
|
969 |
}
|
|
970 |
} // KFeatureIdFfEnablePrintingFramework
|
|
971 |
else
|
|
972 |
{
|
|
973 |
aMenuPane->DeleteMenuItem( ENotepadCmdPrint );
|
|
974 |
}
|
|
975 |
}
|
|
976 |
TInt currIndex = iListBox->CurrentItemIndex();
|
|
977 |
TKeyArrayFix itemKey(0,ECmpTUint);
|
|
978 |
TInt ignore;
|
|
979 |
TInt itemMarked = iListBox->SelectionIndexes()->Find( currIndex, itemKey, ignore );
|
|
980 |
|
|
981 |
if ( memoCount > 0 &&
|
|
982 |
( markCount == 0 || IsNotepad() || IsTemplates()) )
|
|
983 |
{
|
|
984 |
// this must preceed DeleteMenuItem(ENotepadCmdOpen)
|
|
985 |
InsertSendMenuItemAfterL( *iSendUi, *aMenuPane,
|
|
986 |
ENotepadCmdOpen );
|
|
987 |
}
|
|
988 |
|
|
989 |
if ( memoCount == 0 )
|
|
990 |
{
|
|
991 |
aMenuPane->DeleteMenuItem( ENotepadCmdDelete );
|
|
992 |
}
|
|
993 |
|
|
994 |
//delete 'Open' item from Option list at the following situations:
|
|
995 |
//no memo,have item marked,user select the 'New note'
|
|
996 |
if ( ( memoCount == 0 ) || ( markCount >= 1 ) ||
|
|
997 |
( ( currIndex == 0 ) && IsNotepad() ) )
|
|
998 |
{
|
|
999 |
// this must after InsertSendMenuItemAfterL
|
|
1000 |
aMenuPane->DeleteMenuItem( ENotepadCmdOpen );
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
if ( markCount >= 1 && IsNoteListDialog() && ( memoCount > 0 ) )
|
|
1004 |
{
|
|
1005 |
aMenuPane->SetItemSpecific( ENotepadCmdSend, EFalse );
|
|
1006 |
aMenuPane->SetItemSpecific( ENotepadCmdDelete, EFalse );
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
if ( IsTemplateListDialog() && ( memoCount > 0 ) )
|
|
1010 |
{
|
|
1011 |
aMenuPane->SetItemSpecific( ENotepadCmdSend, ETrue );
|
|
1012 |
if ( markCount >= 1 )
|
|
1013 |
{
|
|
1014 |
aMenuPane->SetItemDimmed( ENotepadCmdSend, ETrue );
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
if ( iListBox->CurrentItemIndex() == 0 && IsNotepad() && memoCount > 0 && markCount == 0 )
|
|
1019 |
{
|
|
1020 |
aMenuPane->SetItemDimmed( ENotepadCmdDelete, ETrue );
|
|
1021 |
aMenuPane->SetItemDimmed( ENotepadCmdSend, ETrue );
|
|
1022 |
}
|
|
1023 |
}
|
|
1024 |
break;
|
|
1025 |
default:
|
|
1026 |
{
|
|
1027 |
if ( IsTemplates() )
|
|
1028 |
{
|
|
1029 |
AknSelectionService::HandleMarkableListDynInitMenuPane(
|
|
1030 |
aResourceId, aMenuPane, iListBox );
|
|
1031 |
}
|
|
1032 |
else
|
|
1033 |
{
|
|
1034 |
HandleMarkListDynInitMenuPane( aResourceId, aMenuPane, iListBox );
|
|
1035 |
}
|
|
1036 |
break;
|
|
1037 |
}
|
|
1038 |
}
|
|
1039 |
}
|
|
1040 |
|
|
1041 |
// -----------------------------------------------------------------------------
|
|
1042 |
// CNotepadListDialog::DynInitMenuBarL
|
|
1043 |
// from MEikMenuObserver
|
|
1044 |
// -----------------------------------------------------------------------------
|
|
1045 |
//
|
|
1046 |
void CNotepadListDialog::DynInitMenuBarL(
|
|
1047 |
TInt aResourceId,
|
|
1048 |
CEikMenuBar* aMenuBar )
|
|
1049 |
|
|
1050 |
{
|
|
1051 |
|
|
1052 |
__ASSERT_DEBUG( aResourceId > 0,
|
|
1053 |
Panic(ENotepadLibraryPanicNoMenuResource) );
|
|
1054 |
__ASSERT_DEBUG( aMenuBar, Panic(ENotepadLibraryPanicNoMenuResource) );
|
|
1055 |
|
|
1056 |
if (iMskFlag)
|
|
1057 |
{
|
|
1058 |
|
|
1059 |
aMenuBar->SetMenuType(CEikMenuBar::EMenuContext);
|
|
1060 |
iMskFlag= EFalse;
|
|
1061 |
}
|
|
1062 |
else
|
|
1063 |
{
|
|
1064 |
aMenuBar->SetMenuType(CEikMenuBar::EMenuOptions);
|
|
1065 |
}
|
|
1066 |
|
|
1067 |
|
|
1068 |
}
|
|
1069 |
|
|
1070 |
// -----------------------------------------------------------------------------
|
|
1071 |
// CNotepadListDialog::ProcessCommandL
|
|
1072 |
// from MEikCommandObserver
|
|
1073 |
// -----------------------------------------------------------------------------
|
|
1074 |
//
|
|
1075 |
void CNotepadListDialog::ProcessCommandL(TInt aCommandId)
|
|
1076 |
{
|
|
1077 |
HideMenu();
|
|
1078 |
switch ( aCommandId )
|
|
1079 |
{
|
|
1080 |
case ENotepadCmdOpen: // Open memo
|
|
1081 |
OnCmdOpenL( iListBox->CurrentItemIndex() );
|
|
1082 |
break;
|
|
1083 |
case ENotepadCmdAdd:
|
|
1084 |
OnCmdAddL();
|
|
1085 |
break;
|
|
1086 |
case ENotepadCmdDelete:
|
|
1087 |
OnCmdDeleteL();
|
|
1088 |
break;
|
|
1089 |
case ENotepadCmdSend:
|
|
1090 |
OnCmdSendL(aCommandId);
|
|
1091 |
break;
|
|
1092 |
case EAknMarkAll:
|
|
1093 |
{
|
|
1094 |
if ( IsNotepad() )
|
|
1095 |
{
|
|
1096 |
iListBox->ClearSelection();
|
|
1097 |
TInt num = iListBox->Model()->NumberOfItems();
|
|
1098 |
if ( num < 2 )
|
|
1099 |
return;
|
|
1100 |
TInt ii = 0;
|
|
1101 |
CArrayFixFlat<TInt>* array = new (ELeave) CArrayFixFlat<TInt> (
|
|
1102 |
20 );
|
|
1103 |
CleanupStack::PushL(array);
|
|
1104 |
array->SetReserveL(num);
|
|
1105 |
for ( ii = 1; ii < num; ii++ )
|
|
1106 |
{
|
|
1107 |
array->AppendL( ii );
|
|
1108 |
}
|
|
1109 |
iListBox->SetSelectionIndexesL( array );
|
|
1110 |
CleanupStack::PopAndDestroy(); //array
|
|
1111 |
break;
|
|
1112 |
}
|
|
1113 |
}
|
|
1114 |
default:
|
|
1115 |
{
|
|
1116 |
const TInt aiwServiceCmd( iServiceHandler ? iServiceHandler->ServiceCmdByMenuCmd( aCommandId ) : 0 );
|
|
1117 |
if ( aiwServiceCmd == KAiwCmdPrint )
|
|
1118 |
{
|
|
1119 |
CAiwGenericParamList& inParams = iServiceHandler->InParamListL();
|
|
1120 |
|
|
1121 |
// Note index
|
|
1122 |
TAiwGenericParam noteParam( EGenericParamNoteItem );
|
|
1123 |
const TInt32 noteKey = iModel->Key( iListBox->CurrentItemIndex() );
|
|
1124 |
noteParam.Value().Set( noteKey );
|
|
1125 |
inParams.AppendL( noteParam );
|
|
1126 |
|
|
1127 |
// Application uid
|
|
1128 |
const TUid uid( KUidNotepad ); // Notepad Uid3
|
|
1129 |
TAiwGenericParam uidParam( EGenericParamApplication );
|
|
1130 |
uidParam.Value().Set( uid );
|
|
1131 |
inParams.AppendL( uidParam );
|
|
1132 |
|
|
1133 |
// Execute service command with given parameters
|
|
1134 |
iServiceHandler->ExecuteMenuCmdL( aCommandId,
|
|
1135 |
inParams,
|
|
1136 |
iServiceHandler->OutParamListL(),
|
|
1137 |
0,
|
|
1138 |
this
|
|
1139 |
);
|
|
1140 |
break;
|
|
1141 |
}
|
|
1142 |
|
|
1143 |
AknSelectionService::HandleMarkableListProcessCommandL(
|
|
1144 |
aCommandId, iListBox);
|
|
1145 |
CNotepadDialogBase::ProcessCommandL(aCommandId);
|
|
1146 |
TInt appid = EGenericParamContactItem;
|
|
1147 |
CAiwGenericParamList* list = AiwSyncParamListLC( appid );
|
|
1148 |
iServiceHandler->ExecuteMenuCmdL( aCommandId, *list, iServiceHandler->OutParamListL() );
|
|
1149 |
CleanupStack::PopAndDestroy(list);
|
|
1150 |
//MSK
|
|
1151 |
MiddleSoftKeyL();
|
|
1152 |
break;
|
|
1153 |
}
|
|
1154 |
}
|
|
1155 |
}
|
|
1156 |
|
|
1157 |
// -----------------------------------------------------------------------------
|
|
1158 |
// CNotepadListDialog::AiwSyncParamListLC
|
|
1159 |
// -----------------------------------------------------------------------------
|
|
1160 |
//
|
|
1161 |
CAiwGenericParamList* CNotepadListDialog::AiwSyncParamListLC(TInt /*aApplicationId*/)
|
|
1162 |
{
|
|
1163 |
TAiwVariant variant;
|
|
1164 |
variant.Set(KNullDesC);
|
|
1165 |
TAiwGenericParam param(EGenericParamNoteItem, variant);
|
|
1166 |
CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
|
|
1167 |
list->AppendL(param);
|
|
1168 |
return list;
|
|
1169 |
}
|
|
1170 |
|
|
1171 |
// -----------------------------------------------------------------------------
|
|
1172 |
// CNotepadListDialog::HandleViewEventL
|
|
1173 |
// from MCoeViewObserver
|
|
1174 |
// It seems that observing a view is canceled once this function leave,
|
|
1175 |
// So we decide to avoid leaving in this function.
|
|
1176 |
// -----------------------------------------------------------------------------
|
|
1177 |
//
|
|
1178 |
void CNotepadListDialog::HandleViewEventL(const TVwsViewEvent& aEvent)
|
|
1179 |
{
|
|
1180 |
if ( aEvent.iViewOneId.iAppUid.iUid != aEvent.iViewTwoId.iAppUid.iUid )
|
|
1181 |
{
|
|
1182 |
TRAPD(err, DoHandleViewEventL(aEvent); );
|
|
1183 |
if ( err != KErrNone )
|
|
1184 |
{
|
|
1185 |
iCoeEnv->HandleError(err);
|
|
1186 |
}
|
|
1187 |
}
|
|
1188 |
}
|
|
1189 |
|
|
1190 |
// -----------------------------------------------------------------------------
|
|
1191 |
// CNotepadListDialog::DialogDismissedL
|
|
1192 |
// From MProgressDialogCallback.
|
|
1193 |
//
|
|
1194 |
// MProgressDialogCallback::DialogDismissedL is called from
|
|
1195 |
// CAknProgressDialog::OkToExitL.
|
|
1196 |
// This means that if DialogDismissedL LEAVEs, CAknProgressDialog fails to
|
|
1197 |
// exit.
|
|
1198 |
// We want to kill our ProgressDialog even though SyncL leaves,
|
|
1199 |
// so we decide to TRAP SyncL.
|
|
1200 |
// -----------------------------------------------------------------------------
|
|
1201 |
//
|
|
1202 |
void CNotepadListDialog::DialogDismissedL( TInt /*aButtonId*/ )
|
|
1203 |
{
|
|
1204 |
iModel->CancelDeletion();
|
|
1205 |
DrawDeferred();
|
|
1206 |
}
|
|
1207 |
|
|
1208 |
// -----------------------------------------------------------------------------
|
|
1209 |
// CNotepadListDialog::PreLayoutDynInitL
|
|
1210 |
// from CEikDialog
|
|
1211 |
// -----------------------------------------------------------------------------
|
|
1212 |
//
|
|
1213 |
void CNotepadListDialog::PreLayoutDynInitL()
|
|
1214 |
{
|
|
1215 |
iListBox = STATIC_CAST(CAknColumnListBox*, Control(ENotepadIdListBox));
|
|
1216 |
__ASSERT_DEBUG( iListBox, Panic(ENotepadLibraryPanicNullListControl) );
|
|
1217 |
iListBox->SetListBoxObserver(this);
|
|
1218 |
if ( IsTemplates() )
|
|
1219 |
{
|
|
1220 |
HBufC* text = iCoeEnv->AllocReadResourceLC(R_NOTEPAD_MCE_EMPTY_LIST);
|
|
1221 |
iListBox->View()->SetListEmptyTextL(*text);
|
|
1222 |
CleanupStack::PopAndDestroy(); // text
|
|
1223 |
}
|
|
1224 |
else
|
|
1225 |
{
|
|
1226 |
HBufC* primaryText = iCoeEnv->AllocReadResourceLC(R_NOTEPAD_EMPTY_LIST_PRIMARY_TEXT);
|
|
1227 |
HBufC* secondaryText;
|
|
1228 |
if(AknLayoutUtils::PenEnabled())
|
|
1229 |
{
|
|
1230 |
secondaryText = iCoeEnv->AllocReadResourceLC(R_NOTEPAD_EMPTY_LIST_SECONDARY_TEXT);
|
|
1231 |
}
|
|
1232 |
else
|
|
1233 |
{
|
|
1234 |
secondaryText = iCoeEnv->AllocReadResourceLC(R_NOTEPAD_EMPTY_LIST_SECONDARY_TEXT_NONTOUCH);
|
|
1235 |
}
|
|
1236 |
HBufC* buf = HBufC::NewLC(KMaxFileName);
|
|
1237 |
TPtr16 ptr = buf->Des();
|
|
1238 |
ptr.Append(*primaryText);
|
|
1239 |
ptr.Append(KNewLine);
|
|
1240 |
ptr.Append(*secondaryText);
|
|
1241 |
|
|
1242 |
iListBox->View()->SetListEmptyTextL(ptr);
|
|
1243 |
|
|
1244 |
CleanupStack::PopAndDestroy(buf);
|
|
1245 |
CleanupStack::PopAndDestroy(secondaryText);
|
|
1246 |
CleanupStack::PopAndDestroy(primaryText);
|
|
1247 |
}
|
|
1248 |
(iListBox->Model())->SetItemTextArray(iModel);
|
|
1249 |
(iListBox->Model())->SetOwnershipType(ELbmDoesNotOwnItemArray);
|
|
1250 |
CAknIconArray* iconArray = new(ELeave) CAknIconArray(1);
|
|
1251 |
CleanupStack::PushL(iconArray);
|
|
1252 |
CFbsBitmap* markBitmap = NULL;
|
|
1253 |
CFbsBitmap* markBitmapMask = NULL;
|
|
1254 |
|
|
1255 |
//CListItemDrawer is using this logical color as default for its marked icons
|
|
1256 |
TRgb defaultColor;
|
|
1257 |
defaultColor = CEikonEnv::Static()->Color(EColorControlText);
|
|
1258 |
|
|
1259 |
AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(),
|
|
1260 |
KAknsIIDQgnIndiMarkedAdd,
|
|
1261 |
KAknsIIDQsnIconColors,
|
|
1262 |
EAknsCIQsnIconColorsCG13,
|
|
1263 |
markBitmap,
|
|
1264 |
markBitmapMask,
|
|
1265 |
KAvkonBitmapFile,
|
|
1266 |
EMbmAvkonQgn_indi_marked_add,
|
|
1267 |
EMbmAvkonQgn_indi_marked_add_mask,
|
|
1268 |
defaultColor
|
|
1269 |
);
|
|
1270 |
|
|
1271 |
CGulIcon* markIcon = CGulIcon::NewL(markBitmap,markBitmapMask);
|
|
1272 |
iconArray->AppendL(markIcon);
|
|
1273 |
if ( IsTemplates() )
|
|
1274 |
{
|
|
1275 |
iconArray->AppendFromResourceL(R_NOTEPAD_TEMPLATE_ICON_ARRAY);
|
|
1276 |
}
|
|
1277 |
CleanupStack::Pop(); // iconArray
|
|
1278 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
|
|
1279 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
1280 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
1281 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
1282 |
// MSK
|
|
1283 |
MiddleSoftKeyL();
|
|
1284 |
}
|
|
1285 |
|
|
1286 |
// -----------------------------------------------------------------------------
|
|
1287 |
// CNotepadListDialog::PostLayoutDynInitL
|
|
1288 |
// -----------------------------------------------------------------------------
|
|
1289 |
//
|
|
1290 |
void CNotepadListDialog::PostLayoutDynInitL()
|
|
1291 |
{
|
|
1292 |
iListBox->UpdateScrollBarsL(); // indispensable
|
|
1293 |
}
|
|
1294 |
|
|
1295 |
// -----------------------------------------------------------------------------
|
|
1296 |
// CNotepadListDialog::OkToExitL
|
|
1297 |
// -----------------------------------------------------------------------------
|
|
1298 |
//
|
|
1299 |
TBool CNotepadListDialog::OkToExitL( TInt aButtonId )
|
|
1300 |
{
|
|
1301 |
iFlags &= ~ENotepadMenuByOkKey;
|
|
1302 |
TBool isOk(ETrue);
|
|
1303 |
iMskFlag=EFalse;
|
|
1304 |
//if txt file is more than 1M, editor will exit, so iEditorFlag should be set false.
|
|
1305 |
if (iEditorDialog == NULL)
|
|
1306 |
{
|
|
1307 |
iEditorFlag = EFalse;
|
|
1308 |
}
|
|
1309 |
switch ( aButtonId )
|
|
1310 |
{
|
|
1311 |
case EAknSoftkeyContextOptions:
|
|
1312 |
{
|
|
1313 |
iMskFlag=ETrue;
|
|
1314 |
if(shiftflag)
|
|
1315 |
{
|
|
1316 |
shiftflag =EFalse;
|
|
1317 |
iListBox->View()->ToggleItemL(iListBox->View()->CurrentItemIndex());
|
|
1318 |
MiddleSoftKeyL();
|
|
1319 |
isOk= EFalse;
|
|
1320 |
break;
|
|
1321 |
}
|
|
1322 |
if(iModel->MdcaCount() == 0 || iListBox->SelectionIndexes()->Count())
|
|
1323 |
{
|
|
1324 |
iFlags |= ENotepadMenuByOkKey;
|
|
1325 |
DisplayMenuL();
|
|
1326 |
isOk= EFalse;
|
|
1327 |
}
|
|
1328 |
else
|
|
1329 |
{
|
|
1330 |
ProcessCommandL(ENotepadCmdOpen);
|
|
1331 |
isOk= EFalse;
|
|
1332 |
}
|
|
1333 |
}
|
|
1334 |
break;
|
|
1335 |
case ENotepadCmdOpen:
|
|
1336 |
if(shiftflag)
|
|
1337 |
{
|
|
1338 |
shiftflag =EFalse;
|
|
1339 |
iListBox->View()->ToggleItemL(iListBox->View()->CurrentItemIndex());
|
|
1340 |
MiddleSoftKeyL();
|
|
1341 |
isOk= EFalse;
|
|
1342 |
break;
|
|
1343 |
}
|
|
1344 |
ProcessCommandL(ENotepadCmdOpen);
|
|
1345 |
isOk= EFalse;
|
|
1346 |
break;
|
|
1347 |
case ENotepadCmdAdd:
|
|
1348 |
|
|
1349 |
OnCmdAddL();
|
|
1350 |
isOk= EFalse;
|
|
1351 |
break;
|
|
1352 |
case EAknSoftkeyExit: // list of memos
|
|
1353 |
iAvkonAppUi->ProcessCommandL(EAknCmdExit);
|
|
1354 |
isOk = EFalse;
|
|
1355 |
break;
|
|
1356 |
case EAknSoftkeyBack: // list of templates
|
|
1357 |
isOk = ETrue;
|
|
1358 |
break;
|
|
1359 |
default:
|
|
1360 |
if ( !iEditorFlag )
|
|
1361 |
{
|
|
1362 |
isOk = CNotepadDialogBase::OkToExitL( aButtonId );
|
|
1363 |
}
|
|
1364 |
else
|
|
1365 |
{
|
|
1366 |
isOk = EFalse;
|
|
1367 |
}
|
|
1368 |
break;
|
|
1369 |
}
|
|
1370 |
return isOk;
|
|
1371 |
}
|
|
1372 |
|
|
1373 |
// -----------------------------------------------------------------------------
|
|
1374 |
// CNotepadListDialog::HandleListBoxEventL
|
|
1375 |
// from MEikListBoxObserver
|
|
1376 |
// -----------------------------------------------------------------------------
|
|
1377 |
//
|
|
1378 |
void CNotepadListDialog::HandleListBoxEventL(
|
|
1379 |
CEikListBox* aListBox,
|
|
1380 |
TListBoxEvent aEventType )
|
|
1381 |
{
|
|
1382 |
switch(aEventType)
|
|
1383 |
{
|
|
1384 |
case EEventEnterKeyPressed:
|
|
1385 |
|
|
1386 |
// create a new note with enter key when selected New Note in notes
|
|
1387 |
if( aListBox->CurrentItemIndex() == 0 && IsNotepad() )
|
|
1388 |
{
|
|
1389 |
OnCmdAddL();
|
|
1390 |
}
|
|
1391 |
else
|
|
1392 |
{
|
|
1393 |
OnCmdOpenL( aListBox->CurrentItemIndex() );
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
break;
|
|
1397 |
case EEventItemSingleClicked:
|
|
1398 |
if ( IsNotepad() )
|
|
1399 |
{
|
|
1400 |
if ( aListBox->Model()->NumberOfItems() != 0
|
|
1401 |
&& aListBox->SelectionIndexes()->Count() == 0 )
|
|
1402 |
{
|
|
1403 |
|
|
1404 |
HandleListBoxPointerEventL(
|
|
1405 |
CNotepadListDialog::EOpenListBoxItem);
|
|
1406 |
}
|
|
1407 |
else
|
|
1408 |
{
|
|
1409 |
HandleListBoxPointerEventL(
|
|
1410 |
CNotepadListDialog::EOpenListBoxContextMenu );
|
|
1411 |
}
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
if( IsTemplates() && AknLayoutUtils::PenEnabled() )
|
|
1415 |
{
|
|
1416 |
if( !aListBox->SelectionIndexes()->Count() )
|
|
1417 |
{
|
|
1418 |
OnCmdOpenL(aListBox->CurrentItemIndex());
|
|
1419 |
}
|
|
1420 |
else
|
|
1421 |
{
|
|
1422 |
iFlags |= ENotepadMenuByOkKey;
|
|
1423 |
iMskFlag=ETrue;
|
|
1424 |
DisplayMenuL();
|
|
1425 |
}
|
|
1426 |
}
|
|
1427 |
break;
|
|
1428 |
default:
|
|
1429 |
break;
|
|
1430 |
}
|
|
1431 |
MiddleSoftKeyL();
|
|
1432 |
}
|
|
1433 |
|
|
1434 |
// -----------------------------------------------------------------------------
|
|
1435 |
// CNotepadListDialog::GetHelpContext
|
|
1436 |
// from CCoeControl
|
|
1437 |
// -----------------------------------------------------------------------------
|
|
1438 |
//
|
|
1439 |
void CNotepadListDialog::GetHelpContext(TCoeHelpContext& aContext) const
|
|
1440 |
{
|
|
1441 |
switch ( iResId )
|
|
1442 |
{
|
|
1443 |
case R_NOTEPAD_LIST_DIALOG_ORG:
|
|
1444 |
aContext.iMajor = KUidNotepad;
|
|
1445 |
aContext.iContext = KNMAKE_HLP_MEMO_LIST;
|
|
1446 |
break;
|
|
1447 |
case R_NOTEPAD_TEMPLATE_LIST_DIALOG_ORG:
|
|
1448 |
aContext.iMajor = KUidMce;
|
|
1449 |
aContext.iContext = KMCE_HLP_TEMPLATES;
|
|
1450 |
break;
|
|
1451 |
default:
|
|
1452 |
break;
|
|
1453 |
}
|
|
1454 |
}
|
|
1455 |
|
|
1456 |
// -----------------------------------------------------------------------------
|
|
1457 |
// CNotepadListDialog::OfferKeyEventL
|
|
1458 |
// from CCoeControl
|
|
1459 |
//
|
|
1460 |
// Notepad specification says that
|
|
1461 |
// in pushing numeric keys in list mode, Notepad will change into
|
|
1462 |
// edit mode for a new memo and
|
|
1463 |
// the numeric key code is insert in the opened editor.
|
|
1464 |
// The problem is that Multi-tap FEP requires
|
|
1465 |
// KeyDown event to start FepInlineEdit. If Multi-tap FEP catch KeyIn event
|
|
1466 |
// without any preceeding KeyDown event, it will crash.
|
|
1467 |
// So we decide to add simulated KeyDown event for multi-tap FEP.
|
|
1468 |
// This is done in CNotepadEditorDialog.
|
|
1469 |
// -----------------------------------------------------------------------------
|
|
1470 |
//
|
|
1471 |
TKeyResponse CNotepadListDialog::OfferKeyEventL(
|
|
1472 |
const TKeyEvent& aKeyEvent,
|
|
1473 |
TEventCode aType )
|
|
1474 |
{
|
|
1475 |
TBool hashKey = (aKeyEvent.iScanCode == EStdKeyHash ) ? ETrue : EFalse;
|
|
1476 |
shiftflag =EFalse;
|
|
1477 |
TKeyResponse keyResponse(EKeyWasConsumed);
|
|
1478 |
if ( MenuShowing() || aType != EEventKey ||
|
|
1479 |
( aKeyEvent.iModifiers & EAllStdModifiers ) )
|
|
1480 |
{
|
|
1481 |
keyResponse = CAknDialog::OfferKeyEventL(aKeyEvent, aType);
|
|
1482 |
if((aKeyEvent.iModifiers & EModifierShift) && (aType & EEventKeyDown))
|
|
1483 |
{
|
|
1484 |
shiftflag = ETrue;
|
|
1485 |
MiddleSoftKeyL();
|
|
1486 |
}
|
|
1487 |
|
|
1488 |
if(aType == EEventKeyUp && hashKey)
|
|
1489 |
{
|
|
1490 |
MiddleSoftKeyL();
|
|
1491 |
}
|
|
1492 |
}
|
|
1493 |
else if ( aKeyEvent.iCode == EKeyBackspace )
|
|
1494 |
{
|
|
1495 |
// Clear key make deletion
|
|
1496 |
//
|
|
1497 |
OnCmdDeleteL();
|
|
1498 |
}
|
|
1499 |
else if ( (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) &&
|
|
1500 |
(iModel->MdcaCount() == 0
|
|
1501 |
|| iListBox->SelectionIndexes()->Count()))
|
|
1502 |
{
|
|
1503 |
iFlags |= ENotepadMenuByOkKey;
|
|
1504 |
DisplayMenuL();
|
|
1505 |
return keyResponse;
|
|
1506 |
}
|
|
1507 |
else if ( TChar(aKeyEvent.iCode).IsAlphaDigit() )
|
|
1508 |
{
|
|
1509 |
OnCmdAddL();
|
|
1510 |
iEditorDialog->SetInitialKeyEventL(aKeyEvent);
|
|
1511 |
}
|
|
1512 |
else
|
|
1513 |
{
|
|
1514 |
keyResponse = CAknDialog::OfferKeyEventL(aKeyEvent, aType);
|
|
1515 |
}
|
|
1516 |
return keyResponse;
|
|
1517 |
}
|
|
1518 |
|
|
1519 |
// ---------------------------------------------------------
|
|
1520 |
// CNotepadListDialog::HandleResourceChange
|
|
1521 |
// Notifier for changing orientation
|
|
1522 |
// ---------------------------------------------------------
|
|
1523 |
//
|
|
1524 |
void CNotepadListDialog::HandleResourceChange(TInt aType)
|
|
1525 |
{
|
|
1526 |
if (aType == KEikDynamicLayoutVariantSwitch)
|
|
1527 |
{
|
|
1528 |
SetRect(iAvkonAppUi->ClientRect());
|
|
1529 |
iListBox->HandleResourceChange(aType);
|
|
1530 |
iListBox->DrawDeferred();
|
|
1531 |
}
|
|
1532 |
else
|
|
1533 |
{
|
|
1534 |
CAknDialog::HandleResourceChange(aType);
|
|
1535 |
}
|
|
1536 |
}
|
|
1537 |
|
|
1538 |
// -----------------------------------------------------------------------------
|
|
1539 |
// CNotepadListDialog::ClearSavedMarkListItems()
|
|
1540 |
// -----------------------------------------------------------------------------
|
|
1541 |
//
|
|
1542 |
void CNotepadListDialog::ClearSaveOrMarkedListItemsL(TBool aFlag)
|
|
1543 |
{
|
|
1544 |
if( aFlag )
|
|
1545 |
{
|
|
1546 |
iListBox->ClearSelection();
|
|
1547 |
iListBox->DrawDeferred();
|
|
1548 |
MiddleSoftKeyL();
|
|
1549 |
}
|
|
1550 |
|
|
1551 |
ClearSavedCurrentAndSelections();
|
|
1552 |
}
|
|
1553 |
// CNotepadListDialog::CNotepadListDialog_Reserved
|
|
1554 |
// -----------------------------------------------------------------------------
|
|
1555 |
//
|
|
1556 |
EXPORT_C void CNotepadListDialog::CNotepadListDialog_Reserved()
|
|
1557 |
{
|
|
1558 |
}
|
|
1559 |
|
|
1560 |
// -----------------------------------------------------------------------------
|
|
1561 |
// CNotepadListDialog::CNotepadIdle::NewLC
|
|
1562 |
// -----------------------------------------------------------------------------
|
|
1563 |
//
|
|
1564 |
CNotepadListDialog::CNotepadIdle* CNotepadListDialog::CNotepadIdle::NewLC(
|
|
1565 |
TBool aIsAddingFocusedItem )
|
|
1566 |
{
|
|
1567 |
CNotepadIdle* self = new(ELeave) CNotepadIdle(aIsAddingFocusedItem);
|
|
1568 |
CleanupStack::PushL(self);
|
|
1569 |
self->ConstructL();
|
|
1570 |
return self; // self stays on CleanupStack
|
|
1571 |
}
|
|
1572 |
|
|
1573 |
// -----------------------------------------------------------------------------
|
|
1574 |
// CNotepadListDialog::CNotepadIdle::~CNotepadIdle
|
|
1575 |
// -----------------------------------------------------------------------------
|
|
1576 |
//
|
|
1577 |
CNotepadListDialog::CNotepadIdle::~CNotepadIdle()
|
|
1578 |
{
|
|
1579 |
}
|
|
1580 |
|
|
1581 |
// -----------------------------------------------------------------------------
|
|
1582 |
// CNotepadListDialog::CNotepadIdle::ConstructL
|
|
1583 |
// -----------------------------------------------------------------------------
|
|
1584 |
//
|
|
1585 |
void CNotepadListDialog::CNotepadIdle::ConstructL()
|
|
1586 |
{
|
|
1587 |
CActiveScheduler::Add(this);
|
|
1588 |
}
|
|
1589 |
|
|
1590 |
// -----------------------------------------------------------------------------
|
|
1591 |
// CNotepadListDialog::CNotepadProgressDialog::CNotepadProgressDialog
|
|
1592 |
// -----------------------------------------------------------------------------
|
|
1593 |
//
|
|
1594 |
CNotepadListDialog::CNotepadProgressDialog::CNotepadProgressDialog(
|
|
1595 |
CEikDialog** aSelfPtr,
|
|
1596 |
TBool aVisibilityDelayOff )
|
|
1597 |
:CAknProgressDialog(aSelfPtr, aVisibilityDelayOff)
|
|
1598 |
{
|
|
1599 |
}
|
|
1600 |
|
|
1601 |
// -----------------------------------------------------------------------------
|
|
1602 |
// CNotepadListDialog::CNotepadProgressDialog::~CNotepadProgressDialog
|
|
1603 |
// -----------------------------------------------------------------------------
|
|
1604 |
//
|
|
1605 |
CNotepadListDialog::CNotepadProgressDialog::~CNotepadProgressDialog()
|
|
1606 |
{
|
|
1607 |
delete iInts;
|
|
1608 |
}
|
|
1609 |
|
|
1610 |
// -----------------------------------------------------------------------------
|
|
1611 |
// CNotepadListDialog::CNotepadProgressDialog::PrepareL
|
|
1612 |
// -----------------------------------------------------------------------------
|
|
1613 |
//
|
|
1614 |
void CNotepadListDialog::CNotepadProgressDialog::PrepareL(
|
|
1615 |
const TInt aCount,
|
|
1616 |
const TInt aLabelResId )
|
|
1617 |
{
|
|
1618 |
iProgressInfo = GetProgressInfoL();
|
|
1619 |
switch ( aLabelResId )
|
|
1620 |
{
|
|
1621 |
case R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATE: // delete one template
|
|
1622 |
{
|
|
1623 |
HBufC* buf = StringLoader::LoadLC(R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATE);
|
|
1624 |
SetTextL(*buf);
|
|
1625 |
CleanupStack::PopAndDestroy(buf);
|
|
1626 |
}
|
|
1627 |
break;
|
|
1628 |
case R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATES: // delete templates
|
|
1629 |
{
|
|
1630 |
iInts = new(ELeave) CArrayFixFlat<TInt>(2);
|
|
1631 |
iInts->AppendL(0);
|
|
1632 |
iInts->AppendL(aCount);
|
|
1633 |
IncrementL( 1 ); // SetTextL
|
|
1634 |
}
|
|
1635 |
break;
|
|
1636 |
default:
|
|
1637 |
break;
|
|
1638 |
}
|
|
1639 |
}
|
|
1640 |
|
|
1641 |
// -----------------------------------------------------------------------------
|
|
1642 |
// CNotepadListDialog::CNotepadProgressDialog::IncrementL
|
|
1643 |
// -----------------------------------------------------------------------------
|
|
1644 |
//
|
|
1645 |
void CNotepadListDialog::CNotepadProgressDialog::IncrementL(
|
|
1646 |
const TInt aIncrement)
|
|
1647 |
{
|
|
1648 |
__ASSERT_DEBUG(iProgressInfo,
|
|
1649 |
Panic(ENotepadLibraryPanicProgressDialogNotReady));
|
|
1650 |
if ( iInts ) // IsTemplates
|
|
1651 |
{
|
|
1652 |
(*iInts)[0] = aIncrement + iProgressInfo->CurrentValue();
|
|
1653 |
HBufC* prompt = StringLoader::LoadLC(
|
|
1654 |
R_NOTEPAD_MCE_WAIT_NOTE_DELETE_TEMPLATES, *iInts, iCoeEnv );
|
|
1655 |
SetTextL(prompt->Des());
|
|
1656 |
CleanupStack::PopAndDestroy(); // prompt
|
|
1657 |
}
|
|
1658 |
iProgressInfo->IncrementAndDraw(aIncrement);
|
|
1659 |
}
|
|
1660 |
|
|
1661 |
// -----------------------------------------------------------------------------
|
|
1662 |
// CNotepadListDialog::CNotepadProgressDialog::ProcessFinishedL
|
|
1663 |
// -----------------------------------------------------------------------------
|
|
1664 |
//
|
|
1665 |
void CNotepadListDialog::CNotepadProgressDialog::ProcessFinishedL()
|
|
1666 |
{
|
|
1667 |
iProgressInfo->SetAndDraw(iProgressInfo->Info().iFinalValue);
|
|
1668 |
CAknProgressDialog::ProcessFinishedL();
|
|
1669 |
}
|
|
1670 |
|
|
1671 |
// -----------------------------------------------------------------------------
|
|
1672 |
// CNotepadListDialog::HandleListBoxPointerEventL
|
|
1673 |
// -----------------------------------------------------------------------------
|
|
1674 |
//
|
|
1675 |
void CNotepadListDialog::HandleListBoxPointerEventL(TNotepadListBoxEvent aEvent)
|
|
1676 |
{
|
|
1677 |
if(aEvent == EOpenListBoxContextMenu && !MenuShowing())
|
|
1678 |
{
|
|
1679 |
if (iListBox->CurrentItemIndex() == 0)
|
|
1680 |
{
|
|
1681 |
OnCmdAddL();
|
|
1682 |
}
|
|
1683 |
else if (iEditorFlag == EFalse)
|
|
1684 |
{
|
|
1685 |
iFlags |= ENotepadMenuByOkKey;
|
|
1686 |
iMskFlag=ETrue;
|
|
1687 |
DisplayMenuL();
|
|
1688 |
}
|
|
1689 |
}
|
|
1690 |
else if(aEvent == EOpenListBoxItem)
|
|
1691 |
{
|
|
1692 |
if ( iListBox->CurrentItemIndex() == 0 )
|
|
1693 |
{
|
|
1694 |
OnCmdAddL();
|
|
1695 |
}
|
|
1696 |
else if (!iEditorDialog && !IsTemplates())
|
|
1697 |
{
|
|
1698 |
OnCmdOpenL( iListBox->CurrentItemIndex() );
|
|
1699 |
}
|
|
1700 |
}
|
|
1701 |
}
|
|
1702 |
|
|
1703 |
// -----------------------------------------------------------------------------
|
|
1704 |
// CNotepadListDialog::MiddleSoftKeyL()
|
|
1705 |
// -----------------------------------------------------------------------------
|
|
1706 |
//
|
|
1707 |
|
|
1708 |
void CNotepadListDialog::MiddleSoftKeyL()
|
|
1709 |
{
|
|
1710 |
const TInt markCount( iListBox->SelectionIndexes()->Count() );
|
|
1711 |
|
|
1712 |
if( !IsTemplates() ) // Notepad ListView
|
|
1713 |
{
|
|
1714 |
if( (iModel->MdcaCount() == 1))
|
|
1715 |
{
|
|
1716 |
ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_EXIT_NEW );
|
|
1717 |
}
|
|
1718 |
else
|
|
1719 |
{
|
|
1720 |
if( markCount > 0 )
|
|
1721 |
{
|
|
1722 |
ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_EXIT_CONTEXTOPTIONS );
|
|
1723 |
}
|
|
1724 |
else
|
|
1725 |
{
|
|
1726 |
ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_OPEN_EXIT );
|
|
1727 |
}
|
|
1728 |
}
|
|
1729 |
}
|
|
1730 |
else // Messaging Templates Listview (Notepad view)
|
|
1731 |
{
|
|
1732 |
if( (iModel->MdcaCount() == 0))
|
|
1733 |
{
|
|
1734 |
|
|
1735 |
ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_BACK_NEW );
|
|
1736 |
}
|
|
1737 |
else
|
|
1738 |
{
|
|
1739 |
if(markCount > 0 )
|
|
1740 |
{
|
|
1741 |
ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_BACK_CONTEXTOPTIONS );
|
|
1742 |
}
|
|
1743 |
else
|
|
1744 |
{
|
|
1745 |
ButtonGroupContainer().SetCommandSetL( R_NOTEPAD_SOFTKEYS_OPTIONS_OPEN_BACK );
|
|
1746 |
}
|
|
1747 |
}
|
|
1748 |
}
|
|
1749 |
|
|
1750 |
ButtonGroupContainer().DrawNow();
|
|
1751 |
}
|
|
1752 |
|
|
1753 |
// ----------------------------------------------------------------------------
|
|
1754 |
// CNotepadListDialog::HandleNotifyL
|
|
1755 |
// (may leave)
|
|
1756 |
// ----------------------------------------------------------------------------
|
|
1757 |
//
|
|
1758 |
TInt CNotepadListDialog::HandleNotifyL( TInt /* aCmdId */,
|
|
1759 |
TInt /* aEventId */,
|
|
1760 |
CAiwGenericParamList& /* aEventParamList */,
|
|
1761 |
const CAiwGenericParamList& aInParamList
|
|
1762 |
)
|
|
1763 |
{
|
|
1764 |
#if 0
|
|
1765 |
// Extract service command
|
|
1766 |
const TAiwGenericParam* errorParam = NULL;
|
|
1767 |
TInt index = 0;
|
|
1768 |
errorParam = aInParamList.FindFirst( index,
|
|
1769 |
EGenericParamError,
|
|
1770 |
EVariantTypeTInt32
|
|
1771 |
);
|
|
1772 |
TInt error = KErrNone;
|
|
1773 |
if ( errorParam )
|
|
1774 |
{
|
|
1775 |
error = errorParam->Value().AsTInt32();
|
|
1776 |
}
|
|
1777 |
|
|
1778 |
if ( error != KErrNone )
|
|
1779 |
{
|
|
1780 |
// Error handling here
|
|
1781 |
}
|
|
1782 |
#endif // 0
|
|
1783 |
|
|
1784 |
return KErrNone;
|
|
1785 |
}
|
|
1786 |
|
|
1787 |
// -----------------------------------------------------------------------------
|
|
1788 |
// CNotepadListDialog::HandleMarkListDynInitMenuPane
|
|
1789 |
// -----------------------------------------------------------------------------
|
|
1790 |
//
|
|
1791 |
void CNotepadListDialog::HandleMarkListDynInitMenuPane( TInt aResourceId, CEikMenuPane *aMenu, CEikListBox *aListBox )
|
|
1792 |
{
|
|
1793 |
TInt numofNotes = aListBox->Model()->NumberOfItems() - KNumberOfFixedItem;
|
|
1794 |
|
|
1795 |
if ( aResourceId == R_MENUPANE_MARKABLE_LIST_IMPLEMENTATION )
|
|
1796 |
{
|
|
1797 |
TInt currentItemIndex = aListBox->View()->CurrentItemIndex();
|
|
1798 |
TBool markHidden = aListBox->View()->ItemIsSelected( currentItemIndex ) || currentItemIndex == 0;
|
|
1799 |
TBool unmarkHidden =
|
|
1800 |
!aListBox->View()->ItemIsSelected(currentItemIndex) || currentItemIndex == 0;
|
|
1801 |
TBool markAllHidden = ( numofNotes == 0 ) || ( aListBox->SelectionIndexes()->Count() == numofNotes );
|
|
1802 |
TBool unmarkAllHidden = ( numofNotes == 0 ) || ( aListBox->SelectionIndexes()->Count() == 0 );
|
|
1803 |
aMenu->SetItemDimmed(EAknCmdMark, markHidden);
|
|
1804 |
aMenu->SetItemDimmed(EAknCmdUnmark, unmarkHidden);
|
|
1805 |
aMenu->SetItemDimmed(EAknMarkAll, markAllHidden);
|
|
1806 |
aMenu->SetItemDimmed(EAknUnmarkAll, unmarkAllHidden);
|
|
1807 |
}
|
|
1808 |
if ( aResourceId == R_MENUPANE_MARKABLE_LIST_EDIT_LIST_IMPLEMENTATION )
|
|
1809 |
{
|
|
1810 |
TBool editListHidden = numofNotes == 0;
|
|
1811 |
|
|
1812 |
aMenu->SetItemDimmed(EAknCmdEditListMenu, editListHidden);
|
|
1813 |
}
|
|
1814 |
}
|
|
1815 |
// End of File
|
|
1816 |
|
|
1817 |
|