-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileListContainer.cpp
More file actions
184 lines (158 loc) · 5.75 KB
/
FileListContainer.cpp
File metadata and controls
184 lines (158 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* ============================================================================
* Name : CFileListContainer from FileListContainer.h
* Part of : FileList
* Created : 18.12.2002 by Forum Nokia
* Implementation notes:
* Initial content was generated by Nokia Series 60 AppWizard.
* Version : 1.0
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include "FileListContainer.h"
#include "FileListEngine.h"
#include "Filelist.hrh"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CFileListContainer::ConstructL(const TRect& aRect)
// Symbian two phased constructor
// ---------------------------------------------------------
//
void CFileListContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iListBox = new (ELeave) CAknDoubleNumberStyleListBox;
iListBox->SetContainerWindowL( *this );
iListBox->ConstructL( this, EAknListBoxMarkableList);
// Create the scroll indicator
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
iListBox->ActivateL();
// Create the FileListEngine
iAppEngine = new (ELeave) CFileListEngine;
SetFileList(EFileListPictures, EFileListDate);
SetRect(aRect);
ActivateL();
}
// Destructor
CFileListContainer::~CFileListContainer()
{
delete iAppEngine;
delete iListBox;
}
// ---------------------------------------------------------
// CFileListContainer::SetFileList(TInt aDirectory, TInt aSizeDate)
// This will set up filelist.
// Directory and Size can be changed. See Filelist.hrh for possible values
// This function is located in the container and not in the engine, because it
// activates the listbox.
// ---------------------------------------------------------
//
void CFileListContainer::SetFileList(TInt aDirectory, TInt aSizeDate)
{
// Set the listbox to use the the file list model
CDesCArray* items = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
// If there are items, they will be removed here
if (iAppEngine->RemoveItems(items))
{
// This makes changes to the actual listbox
iListBox->HandleItemRemovalL();
}
// Let's show directory
iAppEngine->SetDirectory(aDirectory);
// Let's decide whether to show file size or modification date
iAppEngine->SetSizeDate(aSizeDate);
// Do preparations for the FileList
if(iAppEngine->StartFileList() == KErrNone)
{
// Create FileList Items in the ListBox
iAppEngine->GetFileListItems(items);
}
// Close FileList session
iAppEngine->EndFileList();
// Refresh the listbox due to model change
iListBox->HandleItemAdditionL();
iListBox->SetCurrentItemIndex(0);
iListBox->DrawNow();
}
// ---------------------------------------------------------
// CFileListContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CFileListContainer::SizeChanged()
{
// control resizing
iListBox->SetExtent(TPoint(0,0),TSize(176,160));
}
// ---------------------------------------------------------
// CFileListContainer::OffeKeyEventL()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
TKeyResponse CFileListContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
// See if we have a selection
TInt code = aKeyEvent.iCode;
switch(code)
{
// is navigator button pressed
case EKeyOK:
iAppEngine->LaunchCurrent(iListBox->CurrentItemIndex());
return (EKeyWasConsumed);
break;
default:
// Let Listbox take care of its key handling
return iListBox->OfferKeyEventL(aKeyEvent, aType);
break;
}
}
// ---------------------------------------------------------
// CFileListContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CFileListContainer::CountComponentControls() const
{
// return number of controls inside this container
return 1;
}
// ---------------------------------------------------------
// CFileListContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CFileListContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CFileListContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CFileListContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// drawing code
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CFileListContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CFileListContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// End of File