20
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "FBFileDlgs.h"
|
|
21 |
#include "FBFileUtils.h"
|
|
22 |
#include "FB.hrh"
|
|
23 |
#include "FBStd.h"
|
|
24 |
#include <filebrowser.rsg>
|
|
25 |
|
|
26 |
#include <aknlistquerydialog.h>
|
|
27 |
#include <AknIconArray.h>
|
|
28 |
#include <aknlists.h>
|
|
29 |
#include <eikbtgpc.h>
|
|
30 |
#include <akntitle.h>
|
|
31 |
#include <AknPopupFieldText.h>
|
|
32 |
#include <aknnotewrappers.h>
|
|
33 |
#include <eikfutil.h>
|
|
34 |
#include <eikclbd.h>
|
|
35 |
|
|
36 |
const TInt KAttOn = 1;
|
|
37 |
const TInt KAttOff = 2;
|
|
38 |
const TInt KAttEnableRecursion = 0;
|
|
39 |
const TInt KAttDisableRecursion = 1;
|
|
40 |
const TInt64 KAlmostaDayInMicroSeconds = 86399999999;
|
|
41 |
|
|
42 |
|
|
43 |
// ===================================== MEMBER FUNCTIONS =====================================
|
|
44 |
|
|
45 |
CFileBrowserDestinationFolderSelectionDlg* CFileBrowserDestinationFolderSelectionDlg::NewL(
|
|
46 |
TDes& aReturnPath, CDriveEntryList* aDriveEntryList, CAknIconArray* aIconArray)
|
|
47 |
{
|
|
48 |
CFileBrowserDestinationFolderSelectionDlg* self = new(ELeave) CFileBrowserDestinationFolderSelectionDlg(aReturnPath, aIconArray);
|
|
49 |
CleanupStack::PushL(self);
|
|
50 |
self->ConstructL(aDriveEntryList);
|
|
51 |
CleanupStack::Pop(self);
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
// --------------------------------------------------------------------------------------------
|
|
56 |
|
|
57 |
CFileBrowserDestinationFolderSelectionDlg::~CFileBrowserDestinationFolderSelectionDlg()
|
|
58 |
{
|
|
59 |
delete iFileEntryList;
|
|
60 |
delete iDriveEntryList;
|
|
61 |
|
|
62 |
iFs.Close();
|
|
63 |
|
|
64 |
iEikonEnv->InfoMsgCancel();
|
|
65 |
}
|
|
66 |
|
|
67 |
// --------------------------------------------------------------------------------------------
|
|
68 |
|
|
69 |
CFileBrowserDestinationFolderSelectionDlg::CFileBrowserDestinationFolderSelectionDlg(
|
|
70 |
TDes& aReturnPath, CAknIconArray* aIconArray) : CAknListQueryDialog(&iSelectedIndex),
|
|
71 |
iReturnPath(aReturnPath), iIconArray(aIconArray)
|
|
72 |
{
|
|
73 |
}
|
|
74 |
|
|
75 |
// --------------------------------------------------------------------------------------------
|
|
76 |
|
|
77 |
void CFileBrowserDestinationFolderSelectionDlg::ConstructL(CDriveEntryList* aDriveEntryList)
|
|
78 |
{
|
|
79 |
User::LeaveIfError( iFs.Connect() );
|
|
80 |
iDriveEntryList = new(ELeave) CDriveEntryList(8);
|
|
81 |
iFileEntryList = new(ELeave) CFileEntryList(32);
|
|
82 |
iCurrentPath = KNullDesC;
|
|
83 |
|
|
84 |
//iIsDragging = EFalse;
|
|
85 |
//EnableDragEvents();
|
|
86 |
|
|
87 |
// get only writeable drives
|
|
88 |
for (TInt i=0; i<aDriveEntryList->Count(); i++)
|
|
89 |
{
|
|
90 |
TDriveEntry driveEntry = aDriveEntryList->At(i);
|
|
91 |
|
|
92 |
if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent)
|
|
93 |
{
|
|
94 |
iDriveEntryList->AppendL(driveEntry);
|
|
95 |
}
|
|
96 |
}
|
|
97 |
}
|
|
98 |
|
|
99 |
// --------------------------------------------------------------------------------------------
|
|
100 |
|
|
101 |
/*
|
|
102 |
void CFileBrowserDestinationFolderSelectionDlg::HandlePointerEventL(const TPointerEvent &aPointerEvent)
|
|
103 |
{
|
|
104 |
// detect direction of dragging by comparing the start and finish points
|
|
105 |
|
|
106 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
107 |
{
|
|
108 |
iDragStartPoint = aPointerEvent.iPosition;
|
|
109 |
iIsDragging = EFalse;
|
|
110 |
}
|
|
111 |
else if (aPointerEvent.iType == TPointerEvent::EDrag)
|
|
112 |
{
|
|
113 |
iIsDragging = ETrue;
|
|
114 |
|
|
115 |
return;
|
|
116 |
}
|
|
117 |
else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
|
|
118 |
{
|
|
119 |
if (iIsDragging)
|
|
120 |
{
|
|
121 |
const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX;
|
|
122 |
const TInt KThreshold = 30;
|
|
123 |
|
|
124 |
if (KDelta < -KThreshold) // dragging to right
|
|
125 |
{
|
|
126 |
// "emulate" right key press
|
|
127 |
|
|
128 |
TKeyEvent keyEvent;
|
|
129 |
keyEvent.iCode = EKeyRightArrow;
|
|
130 |
keyEvent.iModifiers = 0;
|
|
131 |
|
|
132 |
TEventCode type = EEventKey;
|
|
133 |
|
|
134 |
OfferKeyEventL(keyEvent, type);
|
|
135 |
|
|
136 |
return;
|
|
137 |
}
|
|
138 |
else if (KDelta > KThreshold) // dragging to left
|
|
139 |
{
|
|
140 |
// "emulate" left key press
|
|
141 |
|
|
142 |
TKeyEvent keyEvent;
|
|
143 |
keyEvent.iCode = EKeyLeftArrow;
|
|
144 |
keyEvent.iModifiers = 0;
|
|
145 |
|
|
146 |
TEventCode type = EEventKey;
|
|
147 |
|
|
148 |
OfferKeyEventL(keyEvent, type);
|
|
149 |
|
|
150 |
return;
|
|
151 |
}
|
|
152 |
}
|
|
153 |
iIsDragging = EFalse;
|
|
154 |
}
|
|
155 |
else
|
|
156 |
{
|
|
157 |
iIsDragging = EFalse;
|
|
158 |
}
|
|
159 |
|
|
160 |
CAknListQueryDialog::HandlePointerEventL(aPointerEvent);
|
|
161 |
}
|
|
162 |
*/
|
|
163 |
|
|
164 |
// --------------------------------------------------------------------------------------------
|
|
165 |
|
|
166 |
TKeyResponse CFileBrowserDestinationFolderSelectionDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
167 |
{
|
|
168 |
if(aType != EEventKey)
|
|
169 |
return EKeyWasNotConsumed;
|
|
170 |
|
|
171 |
if (aKeyEvent.iCode == EKeyLeftArrow && !IsDriveListViewActive())
|
|
172 |
{
|
|
173 |
MoveUpOneLevelL();
|
|
174 |
return EKeyWasConsumed;
|
|
175 |
}
|
|
176 |
else if (aKeyEvent.iCode == EKeyRightArrow && ((ListBox()->CurrentItemIndex() > 0 && !IsDriveListViewActive()) || IsDriveListViewActive()))
|
|
177 |
{
|
|
178 |
MoveDownToDirectoryL();
|
|
179 |
return EKeyWasConsumed;
|
|
180 |
}
|
|
181 |
else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)
|
|
182 |
{
|
|
183 |
if (IsDriveListViewActive())
|
|
184 |
{
|
|
185 |
MoveDownToDirectoryL();
|
|
186 |
return EKeyWasConsumed;
|
|
187 |
}
|
|
188 |
else if (ListBox()->CurrentItemIndex() == 0)
|
|
189 |
{
|
|
190 |
TryExitL(EAknSoftkeyOk);
|
|
191 |
return EKeyWasConsumed;
|
|
192 |
}
|
|
193 |
else if (ListBox()->CurrentItemIndex() > 0)
|
|
194 |
{
|
|
195 |
MoveDownToDirectoryL();
|
|
196 |
return EKeyWasConsumed;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
TKeyResponse result = CAknDialog::OfferKeyEventL(aKeyEvent, aType);
|
|
201 |
|
|
202 |
// update LSK label
|
|
203 |
if (!IsDriveListViewActive())
|
|
204 |
{
|
|
205 |
if (ListBox()->CurrentItemIndex() == 0)
|
|
206 |
{
|
|
207 |
ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText);
|
|
208 |
ButtonGroupContainer().DrawNow();
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
|
212 |
ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open dir"));
|
|
213 |
ButtonGroupContainer().DrawNow();
|
|
214 |
}
|
|
215 |
}
|
|
216 |
|
|
217 |
return result;
|
|
218 |
}
|
|
219 |
|
|
220 |
// --------------------------------------------------------------------------------------------
|
|
221 |
|
|
222 |
void CFileBrowserDestinationFolderSelectionDlg::PreLayoutDynInitL()
|
|
223 |
{
|
|
224 |
CAknListQueryDialog::PreLayoutDynInitL();
|
|
225 |
|
|
226 |
static_cast<CEikFormattedCellListBox*>(ListBox())->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
|
|
227 |
}
|
|
228 |
|
|
229 |
// --------------------------------------------------------------------------------------------
|
|
230 |
|
|
231 |
void CFileBrowserDestinationFolderSelectionDlg::PostLayoutDynInitL()
|
|
232 |
{
|
|
233 |
CAknListQueryDialog::PostLayoutDynInitL();
|
|
234 |
|
|
235 |
SetIconArrayL(static_cast<CArrayPtr<CGulIcon>*>(iIconArray));
|
|
236 |
|
|
237 |
RefreshViewL();
|
|
238 |
}
|
|
239 |
|
|
240 |
// --------------------------------------------------------------------------------------------
|
|
241 |
|
|
242 |
TBool CFileBrowserDestinationFolderSelectionDlg::OkToExitL(TInt aButtonId)
|
|
243 |
{
|
|
244 |
if (aButtonId == GetLeftCBAShortKeyPress())
|
|
245 |
{
|
|
246 |
if (IsDriveListViewActive())
|
|
247 |
{
|
|
248 |
MoveDownToDirectoryL();
|
|
249 |
return EFalse;
|
|
250 |
}
|
|
251 |
else if (ListBox()->CurrentItemIndex() == 0)
|
|
252 |
{
|
|
253 |
// close the dialog
|
|
254 |
iReturnPath = iCurrentPath;
|
|
255 |
return ETrue;
|
|
256 |
}
|
|
257 |
else if (ListBox()->CurrentItemIndex() > 0)
|
|
258 |
{
|
|
259 |
MoveDownToDirectoryL();
|
|
260 |
return EFalse;
|
|
261 |
}
|
|
262 |
else
|
|
263 |
return EFalse;
|
|
264 |
}
|
|
265 |
else if (aButtonId == GetRightCBAShortKeyPress())
|
|
266 |
{
|
|
267 |
return ETrue;
|
|
268 |
}
|
|
269 |
else
|
|
270 |
{
|
|
271 |
return EFalse;
|
|
272 |
}
|
|
273 |
}
|
|
274 |
|
|
275 |
// --------------------------------------------------------------------------------------------
|
|
276 |
|
|
277 |
void CFileBrowserDestinationFolderSelectionDlg::MoveUpOneLevelL()
|
|
278 |
{
|
|
279 |
if (iCurrentPath.Length() <= 3)
|
|
280 |
{
|
|
281 |
// move to drive list view is the current path is already short enough
|
|
282 |
iCurrentPath = KNullDesC;
|
|
283 |
}
|
|
284 |
else
|
|
285 |
{
|
|
286 |
// move one directory up
|
|
287 |
TInt marker(iCurrentPath.Length());
|
|
288 |
|
|
289 |
// find second last dir marker
|
|
290 |
for (TInt i=iCurrentPath.Length()-2; i>=0; i--)
|
|
291 |
{
|
|
292 |
if (iCurrentPath[i] == '\\')
|
|
293 |
{
|
|
294 |
marker = i;
|
|
295 |
break;
|
|
296 |
}
|
|
297 |
|
|
298 |
}
|
|
299 |
iCurrentPath = iCurrentPath.LeftTPtr(marker+1);
|
|
300 |
}
|
|
301 |
|
|
302 |
// update view
|
|
303 |
RefreshViewL();
|
|
304 |
}
|
|
305 |
|
|
306 |
// --------------------------------------------------------------------------------------------
|
|
307 |
|
|
308 |
void CFileBrowserDestinationFolderSelectionDlg::MoveDownToDirectoryL()
|
|
309 |
{
|
|
310 |
TInt index = ListBox()->CurrentItemIndex();
|
|
311 |
|
|
312 |
if (index >= 0)
|
|
313 |
{
|
|
314 |
if (IsDriveListViewActive())
|
|
315 |
{
|
|
316 |
// currently in a drive list view, move to root of selected drive
|
|
317 |
if (iDriveEntryList->Count() > index)
|
|
318 |
{
|
|
319 |
TDriveEntry driveEntry = iDriveEntryList->At(index);
|
|
320 |
|
|
321 |
iCurrentPath.Append(driveEntry.iLetter);
|
|
322 |
iCurrentPath.Append(_L(":\\"));
|
|
323 |
}
|
|
324 |
}
|
|
325 |
else
|
|
326 |
{
|
|
327 |
// this needed because we have an extra item in the listbox
|
|
328 |
index--;
|
|
329 |
|
|
330 |
// append the new directory
|
|
331 |
if (iFileEntryList->Count() > index)
|
|
332 |
{
|
|
333 |
TFileEntry fileEntry = iFileEntryList->At(index);
|
|
334 |
|
|
335 |
if (fileEntry.iEntry.IsDir())
|
|
336 |
{
|
|
337 |
iCurrentPath.Append(fileEntry.iEntry.iName);
|
|
338 |
iCurrentPath.Append(_L("\\"));
|
|
339 |
}
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
// update view
|
|
344 |
RefreshViewL();
|
|
345 |
}
|
|
346 |
}
|
|
347 |
|
|
348 |
// --------------------------------------------------------------------------------------------
|
|
349 |
|
|
350 |
void CFileBrowserDestinationFolderSelectionDlg::RefreshViewL()
|
|
351 |
{
|
|
352 |
CDesCArray* textArray = new(ELeave) CDesCArrayFlat(16);
|
|
353 |
|
|
354 |
if (IsDriveListViewActive())
|
|
355 |
{
|
|
356 |
_LIT(KSimpleDriveEntry, "%d\t%c: <%S>\t\t");
|
|
357 |
|
|
358 |
for (TInt i=0; i<iDriveEntryList->Count(); i++)
|
|
359 |
{
|
|
360 |
TFileName textEntry;
|
|
361 |
TDriveEntry driveEntry = iDriveEntryList->At(i);
|
|
362 |
|
|
363 |
textEntry.Format(KSimpleDriveEntry, driveEntry.iIconId, TUint(driveEntry.iLetter), &driveEntry.iMediaTypeDesc);
|
|
364 |
|
|
365 |
textArray->AppendL(textEntry);
|
|
366 |
}
|
|
367 |
|
|
368 |
// set default LSK label
|
|
369 |
ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open drive"));
|
|
370 |
ButtonGroupContainer().DrawNow();
|
|
371 |
}
|
|
372 |
|
|
373 |
else
|
|
374 |
{
|
|
375 |
// first get the directory list
|
|
376 |
iFileEntryList->Reset();
|
|
377 |
|
|
378 |
CDir* dir = NULL;
|
|
379 |
if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone)
|
|
380 |
{
|
|
381 |
CleanupStack::PushL(dir);
|
|
382 |
|
|
383 |
for (TInt i=0; i<dir->Count(); i++)
|
|
384 |
{
|
|
385 |
TFileEntry fileEntry;
|
|
386 |
fileEntry.iPath = iCurrentPath;
|
|
387 |
fileEntry.iEntry = (*dir)[i];
|
|
388 |
fileEntry.iDirEntries = KErrNotFound;
|
|
389 |
fileEntry.iIconId = EFixedIconEmpty;
|
|
390 |
|
|
391 |
// check for directory entries
|
|
392 |
if (fileEntry.iEntry.IsDir())
|
|
393 |
{
|
|
394 |
fileEntry.iIconId = EFixedIconFolder;
|
|
395 |
|
|
396 |
TFileName subPath = fileEntry.iPath;
|
|
397 |
subPath.Append(fileEntry.iEntry.iName);
|
|
398 |
subPath.Append(_L("\\"));
|
|
399 |
|
|
400 |
// check if any sub directories
|
|
401 |
CDir* subDir = NULL;
|
|
402 |
if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
|
|
403 |
{
|
|
404 |
fileEntry.iDirEntries = subDir->Count();
|
|
405 |
|
|
406 |
for (TInt j=0; j<subDir->Count(); j++)
|
|
407 |
{
|
|
408 |
TEntry entry = (*subDir)[j];
|
|
409 |
|
|
410 |
if (entry.IsDir())
|
|
411 |
{
|
|
412 |
fileEntry.iIconId = EFixedIconFolderSub;
|
|
413 |
break;
|
|
414 |
}
|
|
415 |
}
|
|
416 |
|
|
417 |
delete subDir;
|
|
418 |
}
|
|
419 |
}
|
|
420 |
|
|
421 |
iFileEntryList->AppendL(fileEntry);
|
|
422 |
}
|
|
423 |
|
|
424 |
CleanupStack::PopAndDestroy(); //dir
|
|
425 |
}
|
|
426 |
|
|
427 |
|
|
428 |
_LIT(KSimpleFileEntry, "%d\t%S\t\t");
|
|
429 |
|
|
430 |
|
|
431 |
// append current folder item
|
|
432 |
TParse nameParser;
|
|
433 |
TInt err = nameParser.SetNoWild(iCurrentPath.LeftTPtr(iCurrentPath.Length()-1), NULL, NULL);
|
|
434 |
TFileName currentFolderName = nameParser.Name();
|
|
435 |
if (currentFolderName == KNullDesC)
|
|
436 |
currentFolderName.Copy(_L("[root level]"));
|
|
437 |
|
|
438 |
TFileName currentDirTextEntry;
|
|
439 |
currentDirTextEntry.Format(KSimpleFileEntry, EFixedIconFolderCurrent, ¤tFolderName);
|
|
440 |
textArray->AppendL(currentDirTextEntry);
|
|
441 |
|
|
442 |
|
|
443 |
for (TInt i=0; i<iFileEntryList->Count(); i++)
|
|
444 |
{
|
|
445 |
TFileName textEntry;
|
|
446 |
TFileEntry fileEntry = iFileEntryList->At(i);
|
|
447 |
|
|
448 |
textEntry.Format(KSimpleFileEntry, fileEntry.iIconId, &fileEntry.iEntry.iName);
|
|
449 |
|
|
450 |
textArray->AppendL(textEntry);
|
|
451 |
}
|
|
452 |
|
|
453 |
// set default LSK label
|
|
454 |
ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText);
|
|
455 |
ButtonGroupContainer().DrawNow();
|
|
456 |
}
|
|
457 |
|
|
458 |
if (iCurrentPath == KNullDesC)
|
|
459 |
iEikonEnv->InfoMsgWithDuration(_L("<- up dir down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt));
|
|
460 |
else
|
|
461 |
iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt));
|
|
462 |
|
|
463 |
SetItemTextArray(textArray);
|
|
464 |
SetOwnershipType(ELbmOwnsItemArray);
|
|
465 |
ListBox()->HandleItemAdditionL();
|
|
466 |
Layout();
|
|
467 |
ListBox()->SetCurrentItemIndex(0);
|
|
468 |
DrawDeferred();
|
|
469 |
}
|
|
470 |
|
|
471 |
// --------------------------------------------------------------------------------------------
|
|
472 |
|
|
473 |
TBool CFileBrowserDestinationFolderSelectionDlg::RunCopyDlgLD()
|
|
474 |
{
|
|
475 |
iLSKActionText.Copy(_L("Copy"));
|
|
476 |
return ExecuteLD(R_COPY_TO_FOLDER_SELECTION_QUERY);
|
|
477 |
}
|
|
478 |
|
|
479 |
// --------------------------------------------------------------------------------------------
|
|
480 |
|
|
481 |
TBool CFileBrowserDestinationFolderSelectionDlg::RunMoveDlgLD()
|
|
482 |
{
|
|
483 |
iLSKActionText.Copy(_L("Move"));
|
|
484 |
return ExecuteLD(R_MOVE_TO_FOLDER_SELECTION_QUERY);
|
|
485 |
}
|
|
486 |
|
|
487 |
// --------------------------------------------------------------------------------------------
|
|
488 |
|
|
489 |
TInt CAknQueryDialog::GetLeftCBAShortKeyPress()
|
|
490 |
{
|
|
491 |
return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0)));
|
|
492 |
}
|
|
493 |
|
|
494 |
// --------------------------------------------------------------------------------------------
|
|
495 |
|
|
496 |
TInt CAknQueryDialog::GetRightCBAShortKeyPress()
|
|
497 |
{
|
|
498 |
return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2)));
|
|
499 |
}
|
|
500 |
|
|
501 |
|
|
502 |
// --------------------------------------------------------------------------------------------
|
|
503 |
// --------------------------------------------------------------------------------------------
|
|
504 |
|
|
505 |
|
|
506 |
CFileBrowserAttributeEditorDlg* CFileBrowserAttributeEditorDlg::NewL(TUint& aSetAttMask, TUint& aClearAttMask, TBool& aRecurse)
|
|
507 |
{
|
|
508 |
CFileBrowserAttributeEditorDlg* self = new(ELeave) CFileBrowserAttributeEditorDlg(aSetAttMask, aClearAttMask, aRecurse);
|
|
509 |
CleanupStack::PushL(self);
|
|
510 |
self->ConstructL();
|
|
511 |
CleanupStack::Pop(self);
|
|
512 |
return self;
|
|
513 |
}
|
|
514 |
|
|
515 |
// --------------------------------------------------------------------------------------------
|
|
516 |
|
|
517 |
CFileBrowserAttributeEditorDlg::~CFileBrowserAttributeEditorDlg()
|
|
518 |
{
|
|
519 |
}
|
|
520 |
|
|
521 |
// --------------------------------------------------------------------------------------------
|
|
522 |
|
|
523 |
CFileBrowserAttributeEditorDlg::CFileBrowserAttributeEditorDlg(TUint& aSetAttMask, TUint& aClearAttMask, TBool& aRecurse) :
|
|
524 |
iSetAttMask(aSetAttMask), iClearAttMask(aClearAttMask), iRecurse(aRecurse)
|
|
525 |
{
|
|
526 |
}
|
|
527 |
|
|
528 |
// --------------------------------------------------------------------------------------------
|
|
529 |
|
|
530 |
void CFileBrowserAttributeEditorDlg::ConstructL()
|
|
531 |
{
|
|
532 |
CAknForm::ConstructL();
|
|
533 |
|
|
534 |
// set title text
|
|
535 |
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
|
|
536 |
CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
537 |
tp->SetTextL( _L("Set attributes") );
|
|
538 |
}
|
|
539 |
|
|
540 |
// --------------------------------------------------------------------------------------------
|
|
541 |
|
|
542 |
void CFileBrowserAttributeEditorDlg::PreLayoutDynInitL()
|
|
543 |
{
|
|
544 |
CAknForm::PreLayoutDynInitL();
|
|
545 |
|
|
546 |
// set default LSK label
|
|
547 |
ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Save"));
|
|
548 |
|
|
549 |
// load values
|
|
550 |
CAknPopupFieldText* archivePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetArchive));
|
|
551 |
CAknPopupFieldText* hiddenPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetHidden));
|
|
552 |
CAknPopupFieldText* readOnlyPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetReadOnly));
|
|
553 |
CAknPopupFieldText* systemPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetSystem));
|
|
554 |
CAknPopupFieldText* recursePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetRecurse));
|
|
555 |
|
|
556 |
if (iSetAttMask & KEntryAttArchive)
|
|
557 |
archivePopup->SetCurrentValueIndex(KAttOn);
|
|
558 |
else if (iClearAttMask & KEntryAttArchive)
|
|
559 |
archivePopup->SetCurrentValueIndex(KAttOff);
|
|
560 |
|
|
561 |
if (iSetAttMask & KEntryAttHidden)
|
|
562 |
hiddenPopup->SetCurrentValueIndex(KAttOn);
|
|
563 |
else if (iClearAttMask & KEntryAttHidden)
|
|
564 |
hiddenPopup->SetCurrentValueIndex(KAttOff);
|
|
565 |
|
|
566 |
if (iSetAttMask & KEntryAttReadOnly)
|
|
567 |
readOnlyPopup->SetCurrentValueIndex(KAttOn);
|
|
568 |
else if (iClearAttMask & KEntryAttReadOnly)
|
|
569 |
readOnlyPopup->SetCurrentValueIndex(KAttOff);
|
|
570 |
|
|
571 |
if (iSetAttMask & KEntryAttSystem)
|
|
572 |
systemPopup->SetCurrentValueIndex(KAttOn);
|
|
573 |
else if (iClearAttMask & KEntryAttSystem)
|
|
574 |
systemPopup->SetCurrentValueIndex(KAttOff);
|
|
575 |
|
|
576 |
if (iRecurse)
|
|
577 |
recursePopup->SetCurrentValueIndex(KAttEnableRecursion);
|
|
578 |
else
|
|
579 |
recursePopup->SetCurrentValueIndex(KAttDisableRecursion);
|
|
580 |
}
|
|
581 |
|
|
582 |
// --------------------------------------------------------------------------------------------
|
|
583 |
|
|
584 |
TBool CFileBrowserAttributeEditorDlg::OkToExitL(TInt aButtonId)
|
|
585 |
{
|
|
586 |
if (aButtonId == EAknSoftkeyOk)
|
|
587 |
{
|
|
588 |
// save changes
|
|
589 |
CAknPopupFieldText* archivePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetArchive));
|
|
590 |
CAknPopupFieldText* hiddenPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetHidden));
|
|
591 |
CAknPopupFieldText* readOnlyPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetReadOnly));
|
|
592 |
CAknPopupFieldText* systemPopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetSystem));
|
|
593 |
CAknPopupFieldText* recursePopup = static_cast<CAknPopupFieldText*>(Control(EFileBrowserAttributeEditorSetRecurse));
|
|
594 |
|
|
595 |
iSetAttMask = 0;
|
|
596 |
iClearAttMask = 0;
|
|
597 |
|
|
598 |
if (archivePopup->CurrentValueIndex() == KAttOn)
|
|
599 |
iSetAttMask |= KEntryAttArchive;
|
|
600 |
else if (archivePopup->CurrentValueIndex() == KAttOff)
|
|
601 |
iClearAttMask |= KEntryAttArchive;
|
|
602 |
|
|
603 |
if (hiddenPopup->CurrentValueIndex() == KAttOn)
|
|
604 |
iSetAttMask |= KEntryAttHidden;
|
|
605 |
else if (hiddenPopup->CurrentValueIndex() == KAttOff)
|
|
606 |
iClearAttMask |= KEntryAttHidden;
|
|
607 |
|
|
608 |
if (readOnlyPopup->CurrentValueIndex() == KAttOn)
|
|
609 |
iSetAttMask |= KEntryAttReadOnly;
|
|
610 |
else if (readOnlyPopup->CurrentValueIndex() == KAttOff)
|
|
611 |
iClearAttMask |= KEntryAttReadOnly;
|
|
612 |
|
|
613 |
if (systemPopup->CurrentValueIndex() == KAttOn)
|
|
614 |
iSetAttMask |= KEntryAttSystem;
|
|
615 |
else if (systemPopup->CurrentValueIndex() == KAttOff)
|
|
616 |
iClearAttMask |= KEntryAttSystem;
|
|
617 |
|
|
618 |
if (recursePopup->CurrentValueIndex() == KAttEnableRecursion)
|
|
619 |
iRecurse = ETrue;
|
|
620 |
else if (recursePopup->CurrentValueIndex() == KAttDisableRecursion)
|
|
621 |
iRecurse = EFalse;
|
|
622 |
}
|
|
623 |
|
|
624 |
return ETrue;
|
|
625 |
}
|
|
626 |
// --------------------------------------------------------------------------------------------
|
|
627 |
|
|
628 |
TBool CFileBrowserAttributeEditorDlg::RunEditorLD()
|
|
629 |
{
|
|
630 |
return ExecuteLD(R_ATTRIBUTE_EDITOR_FORM_DIALOG);
|
|
631 |
}
|
|
632 |
|
|
633 |
|
|
634 |
// --------------------------------------------------------------------------------------------
|
|
635 |
// --------------------------------------------------------------------------------------------
|
|
636 |
|
|
637 |
|
|
638 |
CFileBrowserSearchQueryDlg* CFileBrowserSearchQueryDlg::NewL(TSearchAttributes& aSearchAttributes)
|
|
639 |
{
|
|
640 |
CFileBrowserSearchQueryDlg* self = new(ELeave) CFileBrowserSearchQueryDlg(aSearchAttributes);
|
|
641 |
CleanupStack::PushL(self);
|
|
642 |
self->ConstructL();
|
|
643 |
CleanupStack::Pop(self);
|
|
644 |
return self;
|
|
645 |
}
|
|
646 |
|
|
647 |
// --------------------------------------------------------------------------------------------
|
|
648 |
|
|
649 |
CFileBrowserSearchQueryDlg::~CFileBrowserSearchQueryDlg()
|
|
650 |
{
|
|
651 |
}
|
|
652 |
|
|
653 |
// --------------------------------------------------------------------------------------------
|
|
654 |
|
|
655 |
CFileBrowserSearchQueryDlg::CFileBrowserSearchQueryDlg(TSearchAttributes& aSearchAttributes) :
|
|
656 |
iSearchAttributes(aSearchAttributes)
|
|
657 |
{
|
|
658 |
}
|
|
659 |
|
|
660 |
// --------------------------------------------------------------------------------------------
|
|
661 |
|
|
662 |
void CFileBrowserSearchQueryDlg::ConstructL()
|
|
663 |
{
|
|
664 |
CAknForm::ConstructL();
|
|
665 |
|
|
666 |
// set title text
|
|
667 |
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
|
|
668 |
CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
669 |
tp->SetTextL( _L("Search") );
|
|
670 |
}
|
|
671 |
|
|
672 |
// --------------------------------------------------------------------------------------------
|
|
673 |
|
|
674 |
void CFileBrowserSearchQueryDlg::PreLayoutDynInitL()
|
|
675 |
{
|
|
676 |
CAknForm::PreLayoutDynInitL();
|
|
677 |
|
|
678 |
// set default LSK label
|
|
679 |
ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Search"));
|
|
680 |
|
|
681 |
// load values
|
|
682 |
CEikEdwin* searchDir = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQuerySearchDir));
|
|
683 |
CEikEdwin* wildCards = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryWildCards));
|
|
684 |
CEikEdwin* textInFile = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryTextInFile));
|
|
685 |
CEikNumberEditor* minSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMinSize));
|
|
686 |
CEikNumberEditor* maxSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMaxSize));
|
|
687 |
CEikDateEditor* minDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMinDate));
|
|
688 |
CEikDateEditor* maxDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMaxDate));
|
|
689 |
CAknPopupFieldText* recurse = static_cast<CAknPopupFieldText*>(Control(EFileBrowserSearchQueryRecurse));
|
|
690 |
|
|
691 |
searchDir->SetTextL(&iSearchAttributes.iSearchDir);
|
|
692 |
wildCards->SetTextL(&iSearchAttributes.iWildCards);
|
|
693 |
textInFile->SetTextL(&iSearchAttributes.iTextInFile);
|
|
694 |
minSize->SetNumber(iSearchAttributes.iMinSize);
|
|
695 |
maxSize->SetNumber(iSearchAttributes.iMaxSize);
|
|
696 |
minDate->SetDate(iSearchAttributes.iMinDate);
|
|
697 |
maxDate->SetDate(iSearchAttributes.iMaxDate);
|
|
698 |
recurse->SetCurrentValueIndex(iSearchAttributes.iRecurse);
|
|
699 |
}
|
|
700 |
// --------------------------------------------------------------------------------------------
|
|
701 |
|
|
702 |
TBool CFileBrowserSearchQueryDlg::OkToExitL(TInt aButtonId)
|
|
703 |
{
|
|
704 |
if (aButtonId == EAknSoftkeyOk)
|
|
705 |
{
|
|
706 |
// save changes
|
|
707 |
CEikEdwin* searchDir = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQuerySearchDir));
|
|
708 |
CEikEdwin* wildCards = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryWildCards));
|
|
709 |
CEikEdwin* textInFile = static_cast<CEikEdwin*>(Control(EFileBrowserSearchQueryTextInFile));
|
|
710 |
CEikNumberEditor* minSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMinSize));
|
|
711 |
CEikNumberEditor* maxSize = static_cast<CEikNumberEditor*>(Control(EFileBrowserSearchQueryMaxSize));
|
|
712 |
CEikDateEditor* minDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMinDate));
|
|
713 |
CEikDateEditor* maxDate = static_cast<CEikDateEditor*>(Control(EFileBrowserSearchQueryMaxDate));
|
|
714 |
CAknPopupFieldText* recurse = static_cast<CAknPopupFieldText*>(Control(EFileBrowserSearchQueryRecurse));
|
|
715 |
|
|
716 |
// get the current value of search dir and make sure it has a trailing backslash
|
|
717 |
TFileName searchDirBuf;
|
|
718 |
searchDir->GetText(searchDirBuf);
|
|
719 |
if (searchDirBuf.Length() && searchDirBuf[searchDirBuf.Length()-1] != '\\')
|
|
720 |
searchDirBuf.Append('\\');
|
|
721 |
|
|
722 |
// check that the path is valid
|
|
723 |
if (searchDirBuf.Length() && !EikFileUtils::PathExists(searchDirBuf))
|
|
724 |
{
|
|
725 |
CAknInformationNote* note = new(ELeave) CAknInformationNote;
|
|
726 |
note->ExecuteLD(_L("Given search directory does not exists"));
|
|
727 |
|
|
728 |
return EFalse;
|
|
729 |
}
|
|
730 |
|
|
731 |
iSearchAttributes.iSearchDir = searchDirBuf;
|
|
732 |
wildCards->GetText(iSearchAttributes.iWildCards);
|
|
733 |
textInFile->GetText(iSearchAttributes.iTextInFile);
|
|
734 |
iSearchAttributes.iMinSize = minSize->Number();
|
|
735 |
iSearchAttributes.iMaxSize = maxSize->Number();
|
|
736 |
iSearchAttributes.iMinDate = minDate->Date();
|
|
737 |
iSearchAttributes.iMaxDate = maxDate->Date();
|
|
738 |
// Adjust the MaxDate to the end of the day:
|
|
739 |
iSearchAttributes.iMaxDate += TTimeIntervalMicroSeconds( KAlmostaDayInMicroSeconds );
|
|
740 |
iSearchAttributes.iRecurse = recurse->CurrentValueIndex();
|
|
741 |
}
|
|
742 |
|
|
743 |
return ETrue;
|
|
744 |
}
|
|
745 |
// --------------------------------------------------------------------------------------------
|
|
746 |
|
|
747 |
TBool CFileBrowserSearchQueryDlg::RunQueryLD()
|
|
748 |
{
|
|
749 |
return ExecuteLD(R_SEARCH_QUERY_FORM_DIALOG);
|
|
750 |
}
|
|
751 |
|
|
752 |
|
|
753 |
// --------------------------------------------------------------------------------------------
|
|
754 |
// --------------------------------------------------------------------------------------------
|
|
755 |
|
|
756 |
|
|
757 |
CFileBrowserDataTypesDlg* CFileBrowserDataTypesDlg::NewL()
|
|
758 |
{
|
|
759 |
CFileBrowserDataTypesDlg* self = new(ELeave) CFileBrowserDataTypesDlg();
|
|
760 |
CleanupStack::PushL(self);
|
|
761 |
self->ConstructL();
|
|
762 |
CleanupStack::Pop(self);
|
|
763 |
return self;
|
|
764 |
}
|
|
765 |
|
|
766 |
// --------------------------------------------------------------------------------------------
|
|
767 |
|
|
768 |
CFileBrowserDataTypesDlg::~CFileBrowserDataTypesDlg()
|
|
769 |
{
|
|
770 |
delete iDTArray;
|
|
771 |
|
|
772 |
iLs.Close();
|
|
773 |
}
|
|
774 |
|
|
775 |
// --------------------------------------------------------------------------------------------
|
|
776 |
|
|
777 |
CFileBrowserDataTypesDlg::CFileBrowserDataTypesDlg()
|
|
778 |
{
|
|
779 |
}
|
|
780 |
|
|
781 |
// --------------------------------------------------------------------------------------------
|
|
782 |
|
|
783 |
void CFileBrowserDataTypesDlg::ConstructL()
|
|
784 |
{
|
|
785 |
// construct a menu bar
|
|
786 |
CAknDialog::ConstructL(R_FILEBROWSER_DATA_TYPES_MENUBAR);
|
|
787 |
|
|
788 |
// set title text
|
|
789 |
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
|
|
790 |
CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
791 |
tp->SetTextL( _L("Data types") );
|
|
792 |
|
|
793 |
User::LeaveIfError(iLs.Connect());
|
|
794 |
|
|
795 |
iDTArray = new(ELeave) CDataTypeArray(32);
|
|
796 |
}
|
|
797 |
|
|
798 |
// --------------------------------------------------------------------------------------------
|
|
799 |
|
|
800 |
void CFileBrowserDataTypesDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
|
|
801 |
{
|
|
802 |
switch (aEventType)
|
|
803 |
{
|
|
804 |
case EEventEnterKeyPressed:
|
|
805 |
case EEventItemDoubleClicked:
|
|
806 |
// reserved for future extensions;
|
|
807 |
break;
|
|
808 |
default:
|
|
809 |
break;
|
|
810 |
}
|
|
811 |
}
|
|
812 |
|
|
813 |
// --------------------------------------------------------------------------------------------
|
|
814 |
|
|
815 |
void CFileBrowserDataTypesDlg::ProcessCommandL(TInt aCommandId)
|
|
816 |
{
|
|
817 |
CAknDialog::ProcessCommandL(aCommandId);
|
|
818 |
|
|
819 |
switch (aCommandId)
|
|
820 |
{
|
|
821 |
case EFileBrowserCmdDataTypesChangeMapping:
|
|
822 |
ChangeMappingL();
|
|
823 |
break;
|
|
824 |
case EFileBrowserCmdDataTypesSetDefaultMapping:
|
|
825 |
SetDefaultMappingL();
|
|
826 |
break;
|
|
827 |
case EFileBrowserCmdDataTypesRefresh:
|
|
828 |
GetDataTypesL();
|
|
829 |
break;
|
|
830 |
case EFileBrowserCmdDataTypesExit:
|
|
831 |
TryExitL(EAknCmdExit);
|
|
832 |
break;
|
|
833 |
default:
|
|
834 |
break;
|
|
835 |
}
|
|
836 |
}
|
|
837 |
|
|
838 |
// --------------------------------------------------------------------------------------------
|
|
839 |
|
|
840 |
void CFileBrowserDataTypesDlg::PreLayoutDynInitL()
|
|
841 |
{
|
|
842 |
CAknDialog::PreLayoutDynInitL();
|
|
843 |
|
|
844 |
iListBox = static_cast<CAknSingleGraphicStyleListBox*>( Control(EFileBrowserDataTypesList) );
|
|
845 |
iListBox->SetContainerWindowL(*this);
|
|
846 |
iListBox->View()->SetListEmptyTextL(_L("No data types"));
|
|
847 |
|
|
848 |
iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
|
|
849 |
|
|
850 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
851 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
852 |
iListBox->SetListBoxObserver(this);
|
|
853 |
|
|
854 |
iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
|
|
855 |
|
|
856 |
GetDataTypesL();
|
|
857 |
}
|
|
858 |
|
|
859 |
// --------------------------------------------------------------------------------------------
|
|
860 |
|
|
861 |
void CFileBrowserDataTypesDlg::GetDataTypesL()
|
|
862 |
{
|
|
863 |
// get an instance of the listbox's item array
|
|
864 |
MDesCArray* tempArray = iListBox->Model()->ItemTextArray();
|
|
865 |
CDesCArray* listBoxArray = (CDesCArray*)tempArray;
|
|
866 |
listBoxArray->Reset();
|
|
867 |
|
|
868 |
// create an icon array
|
|
869 |
CAknIconArray* iconArray = new(ELeave) CAknIconArray(32);
|
|
870 |
CleanupStack::PushL(iconArray);
|
|
871 |
|
|
872 |
// get data types
|
|
873 |
iDTArray->Reset();
|
|
874 |
User::LeaveIfError(iLs.GetSupportedDataTypesL(*iDTArray));
|
|
875 |
|
|
876 |
// sort the array
|
|
877 |
TKeyArrayFix key(0, ECmpFolded8); // iDataType is located in offset 0 and contain 8-bit descriptor
|
|
878 |
iDTArray->Sort(key);
|
|
879 |
|
|
880 |
|
|
881 |
// loop each data type
|
|
882 |
for (TInt i=0; i<iDTArray->Count(); i++)
|
|
883 |
{
|
|
884 |
TDataType& dt = iDTArray->At(i);
|
|
885 |
|
|
886 |
// get app uid which handles this data type
|
|
887 |
TUid appUid;
|
|
888 |
TInt err = iLs.AppForDataType(dt, appUid);
|
|
889 |
|
|
890 |
// generate icon which is the app icon which handles this mime type
|
|
891 |
CFbsBitmap* bitmap = NULL;
|
|
892 |
CFbsBitmap* mask = NULL;
|
|
893 |
CGulIcon* appIcon = NULL;
|
|
894 |
|
|
895 |
TRAPD(err2,
|
|
896 |
AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask);
|
|
897 |
appIcon = CGulIcon::NewL(bitmap, mask);
|
|
898 |
CleanupStack::Pop(2); //bitmap, mask
|
|
899 |
);
|
|
900 |
|
|
901 |
// append to the icon array
|
|
902 |
appIcon->SetBitmapsOwnedExternally(EFalse);
|
|
903 |
iconArray->AppendL(appIcon);
|
|
904 |
|
|
905 |
TFileName entry;
|
|
906 |
entry.AppendNum(i);
|
|
907 |
entry.Append(_L("\t"));
|
|
908 |
entry.Append(dt.Des());
|
|
909 |
entry.Append(_L(" <<"));
|
|
910 |
|
|
911 |
|
|
912 |
// get caption of the handling app
|
|
913 |
TFileName appCaption;
|
|
914 |
|
|
915 |
if (err || err2 || appUid == KNullUid)
|
|
916 |
entry.Append(_L("none"));
|
|
917 |
else
|
|
918 |
{
|
|
919 |
TApaAppInfo appInfo;
|
|
920 |
|
|
921 |
if (iLs.GetAppInfo(appInfo, appUid) == KErrNone)
|
|
922 |
entry.Append(appInfo.iCaption);
|
|
923 |
else
|
|
924 |
entry.Append(_L("none"));
|
|
925 |
}
|
|
926 |
|
|
927 |
entry.Append(_L(">>"));
|
|
928 |
|
|
929 |
listBoxArray->AppendL( entry );
|
|
930 |
}
|
|
931 |
|
|
932 |
|
|
933 |
// clear any previous icon array
|
|
934 |
CAknIconArray* oldIconArray = static_cast<CAknIconArray*>(iListBox->ItemDrawer()->ColumnData()->IconArray());
|
|
935 |
if (oldIconArray)
|
|
936 |
delete oldIconArray;
|
|
937 |
|
|
938 |
|
|
939 |
CleanupStack::Pop(); //iconArray
|
|
940 |
|
|
941 |
// updates the listbox
|
|
942 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
|
|
943 |
iListBox->HandleItemAdditionL();
|
|
944 |
}
|
|
945 |
|
|
946 |
// --------------------------------------------------------------------------------------------
|
|
947 |
|
|
948 |
void CFileBrowserDataTypesDlg::ChangeMappingL()
|
|
949 |
{
|
|
950 |
TInt currentItemIndex = iListBox->CurrentItemIndex();
|
|
951 |
|
|
952 |
if (iDTArray->Count() > currentItemIndex && currentItemIndex >= 0)
|
|
953 |
{
|
|
954 |
// create list of TApaAppInfo
|
|
955 |
CArrayFixFlat<TApaAppInfo>* appInfoArray = new(ELeave) CArrayFixFlat<TApaAppInfo>(64);
|
|
956 |
CleanupStack::PushL(appInfoArray);
|
|
957 |
|
|
958 |
// get list of applications
|
|
959 |
TApaAppInfo appInfo;
|
|
960 |
User::LeaveIfError(iLs.GetAllApps());
|
|
961 |
|
|
962 |
while (iLs.GetNextApp(appInfo) == KErrNone)
|
|
963 |
{
|
|
964 |
appInfoArray->AppendL(appInfo);
|
|
965 |
}
|
|
966 |
|
|
967 |
// sort the array
|
|
968 |
TKeyArrayFix key(_FOFF(TApaAppInfo,iCaption), ECmpFolded16);
|
|
969 |
appInfoArray->Sort(key);
|
|
970 |
|
|
971 |
// create a popup with listbox
|
|
972 |
CAknSingleGraphicPopupMenuStyleListBox* listBox = new(ELeave) CAknSingleGraphicPopupMenuStyleListBox();
|
|
973 |
CleanupStack::PushL(listBox);
|
|
974 |
CAknPopupList* popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuGraphicWindow );
|
|
975 |
CleanupStack::PushL(popupList);
|
|
976 |
listBox->ConstructL( popupList, 0 );
|
|
977 |
listBox->CreateScrollBarFrameL(ETrue);
|
|
978 |
listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
979 |
listBox->View()->SetListEmptyTextL(_L("No apps"));
|
|
980 |
listBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
|
|
981 |
listBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
|
|
982 |
popupList->SetTitleL(_L("Select app"));
|
|
983 |
popupList->EnableFind();
|
|
984 |
|
|
985 |
|
|
986 |
// get an instance of the listbox's item array
|
|
987 |
MDesCArray* tempArray = listBox->Model()->ItemTextArray();
|
|
988 |
CDesCArray* listBoxArray = (CDesCArray*)tempArray;
|
|
989 |
|
|
990 |
// create an icon array
|
|
991 |
CAknIconArray* iconArray = new(ELeave) CAknIconArray(32);
|
|
992 |
CleanupStack::PushL(iconArray);
|
|
993 |
|
|
994 |
// loop each app info
|
|
995 |
for (TInt i=0; i<appInfoArray->Count(); i++)
|
|
996 |
{
|
|
997 |
|
|
998 |
// get icon of this app
|
|
999 |
CFbsBitmap* bitmap = NULL;
|
|
1000 |
CFbsBitmap* mask = NULL;
|
|
1001 |
CGulIcon* appIcon = NULL;
|
|
1002 |
|
|
1003 |
TRAP_IGNORE(
|
|
1004 |
AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appInfoArray->At(i).iUid, EAknsAppIconTypeList, bitmap, mask);
|
|
1005 |
appIcon = CGulIcon::NewL(bitmap, mask);
|
|
1006 |
CleanupStack::Pop(2); //bitmap, mask
|
|
1007 |
);
|
|
1008 |
|
|
1009 |
// append to the icon array
|
|
1010 |
appIcon->SetBitmapsOwnedExternally(EFalse);
|
|
1011 |
iconArray->AppendL(appIcon);
|
|
1012 |
|
|
1013 |
TFileName entry;
|
|
1014 |
entry.AppendNum(i);
|
|
1015 |
entry.Append(_L("\t"));
|
|
1016 |
entry.Append(appInfoArray->At(i).iCaption);
|
|
1017 |
|
|
1018 |
listBoxArray->AppendL(entry);
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
|
|
1022 |
CleanupStack::Pop(); //iconArray
|
|
1023 |
|
|
1024 |
// updates the listbox
|
|
1025 |
listBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray);
|
|
1026 |
listBox->HandleItemAdditionL();
|
|
1027 |
|
|
1028 |
|
|
1029 |
// execute the popup to query the application
|
|
1030 |
if (popupList->ExecuteLD())
|
|
1031 |
{
|
|
1032 |
|
|
1033 |
// query priority
|
|
1034 |
TInt queryIndex(0);
|
|
1035 |
CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex);
|
|
1036 |
|
|
1037 |
if (listQueryDlg->ExecuteLD(R_DATA_TYPE_PRIORITY_QUERY))
|
|
1038 |
{
|
|
1039 |
TInt32 selectedPriority(0);
|
|
1040 |
|
|
1041 |
if (queryIndex == EDataTypePriorityMaximum)
|
|
1042 |
selectedPriority = KDataTypeUnTrustedPriorityThreshold;
|
|
1043 |
else if (queryIndex == EDataTypePriorityHigh)
|
|
1044 |
selectedPriority = KDataTypePriorityHigh;
|
|
1045 |
else if (queryIndex == EDataTypePriorityNormal)
|
|
1046 |
selectedPriority = KDataTypePriorityNormal;
|
|
1047 |
else if (queryIndex == EDataTypePriorityLow)
|
|
1048 |
selectedPriority = KDataTypePriorityLow;
|
|
1049 |
else
|
|
1050 |
selectedPriority = KDataTypePriorityLastResort;
|
|
1051 |
|
|
1052 |
|
|
1053 |
TApaAppInfo& selectedAppInfo = appInfoArray->At(listBox->CurrentItemIndex());
|
|
1054 |
|
|
1055 |
if (iLs.InsertDataMapping(iDTArray->At(currentItemIndex), selectedPriority, selectedAppInfo.iUid) == KErrNone)
|
|
1056 |
{
|
|
1057 |
GetDataTypesL();
|
|
1058 |
|
|
1059 |
CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
|
|
1060 |
note->ExecuteLD(_L("Mapping changed"));
|
|
1061 |
}
|
|
1062 |
else
|
|
1063 |
{
|
|
1064 |
CAknErrorNote* note = new(ELeave) CAknErrorNote;
|
|
1065 |
note->ExecuteLD(_L("Unable to change mapping"));
|
|
1066 |
}
|
|
1067 |
}
|
|
1068 |
}
|
|
1069 |
|
|
1070 |
CleanupStack::Pop(); // popupList
|
|
1071 |
CleanupStack::PopAndDestroy(2); // listBox, appInfoArray
|
|
1072 |
}
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
// --------------------------------------------------------------------------------------------
|
|
1076 |
|
|
1077 |
void CFileBrowserDataTypesDlg::SetDefaultMappingL()
|
|
1078 |
{
|
|
1079 |
TInt currentItemIndex = iListBox->CurrentItemIndex();
|
|
1080 |
|
|
1081 |
if (iDTArray->Count() > currentItemIndex && currentItemIndex >= 0)
|
|
1082 |
{
|
|
1083 |
if (iLs.DeleteDataMapping(iDTArray->At(currentItemIndex)) == KErrNone)
|
|
1084 |
{
|
|
1085 |
GetDataTypesL();
|
|
1086 |
|
|
1087 |
CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
|
|
1088 |
note->ExecuteLD(_L("Restored default"));
|
|
1089 |
}
|
|
1090 |
else
|
|
1091 |
{
|
|
1092 |
CAknInformationNote* note = new(ELeave) CAknInformationNote;
|
|
1093 |
note->ExecuteLD(_L("Nothing to restore"));
|
|
1094 |
}
|
|
1095 |
}
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
// --------------------------------------------------------------------------------------------
|
|
1099 |
|
|
1100 |
TBool CFileBrowserDataTypesDlg::OkToExitL(TInt aButtonId)
|
|
1101 |
{
|
|
1102 |
return CAknDialog::OkToExitL(aButtonId);
|
|
1103 |
}
|
|
1104 |
|
|
1105 |
// --------------------------------------------------------------------------------------------
|
|
1106 |
|
|
1107 |
TBool CFileBrowserDataTypesDlg::RunQueryLD()
|
|
1108 |
{
|
|
1109 |
return ExecuteLD(R_DATA_TYPES_DIALOG);
|
|
1110 |
}
|
|
1111 |
|
|
1112 |
// --------------------------------------------------------------------------------------------
|
|
1113 |
|
|
1114 |
// End of File
|
|
1115 |
|