williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: Dialog used to select target file or directory
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef CAKNFILESELECTIONDIALOG_H
|
williamr@2
|
20 |
#define CAKNFILESELECTIONDIALOG_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
// INCLUDES
|
williamr@2
|
23 |
#include <CAknCommonDialogsBase.h>
|
williamr@2
|
24 |
|
williamr@2
|
25 |
// FORWARD DECLARATIONS
|
williamr@2
|
26 |
class CAknFileSelectionModel;
|
williamr@2
|
27 |
class CAknFileSelectionEventHandler;
|
williamr@2
|
28 |
class MAknFileSelectionObserver;
|
williamr@2
|
29 |
class MAknFileFilter;
|
williamr@2
|
30 |
|
williamr@2
|
31 |
// CLASS DEFINITION
|
williamr@2
|
32 |
/**
|
williamr@2
|
33 |
* A class that launches a popup dialog for file selection or directory browsing.
|
williamr@2
|
34 |
*
|
williamr@2
|
35 |
* @lib CommonDialogs.lib
|
williamr@2
|
36 |
* @since 1.2
|
williamr@2
|
37 |
*/
|
williamr@2
|
38 |
NONSHARABLE_CLASS(CAknFileSelectionDialog) : public CAknCommonDialogsBase
|
williamr@2
|
39 |
{
|
williamr@2
|
40 |
public: // Constructors and destructors
|
williamr@2
|
41 |
/**
|
williamr@2
|
42 |
* Static constructor.
|
williamr@2
|
43 |
* @param aDialogType Type of the dialog for reading correct default values.
|
williamr@2
|
44 |
* @return Returns a pointer to an instance of itself.
|
williamr@2
|
45 |
*/
|
williamr@2
|
46 |
IMPORT_C static CAknFileSelectionDialog* NewL(
|
williamr@2
|
47 |
TCommonDialogType aDialogType );
|
williamr@2
|
48 |
|
williamr@2
|
49 |
/**
|
williamr@2
|
50 |
* Static constructor.
|
williamr@2
|
51 |
* @param aDialogType Type of the dialog for reading correct default values.
|
williamr@2
|
52 |
* @param aResourceId A resource id (FILESELECTIONDIALOG).
|
williamr@2
|
53 |
* @return Returns a pointer to an instance of itself.
|
williamr@2
|
54 |
*/
|
williamr@2
|
55 |
IMPORT_C static CAknFileSelectionDialog* NewL(
|
williamr@2
|
56 |
TCommonDialogType aDialogType, TInt aResourceId );
|
williamr@2
|
57 |
|
williamr@2
|
58 |
IMPORT_C ~CAknFileSelectionDialog();
|
williamr@2
|
59 |
|
williamr@2
|
60 |
public: // New functions
|
williamr@2
|
61 |
|
williamr@2
|
62 |
/**
|
williamr@2
|
63 |
* Sets an observer which is asked if the selected item can be selected.
|
williamr@2
|
64 |
* @param aObserver A pointer to an observer.
|
williamr@2
|
65 |
*/
|
williamr@2
|
66 |
IMPORT_C void SetObserver( MAknFileSelectionObserver* aObserver );
|
williamr@2
|
67 |
|
williamr@2
|
68 |
/**
|
williamr@2
|
69 |
* Adds a filter to list of filters owned by the engine.
|
williamr@2
|
70 |
* Note! The ownership of the filter is transferred to the engine.
|
williamr@2
|
71 |
* @param aFilter A pointer to a filter that is derived from MAknFileFilter.
|
williamr@2
|
72 |
*/
|
williamr@2
|
73 |
IMPORT_C void AddFilterL( MAknFileFilter* aFilter );
|
williamr@2
|
74 |
|
williamr@2
|
75 |
/**
|
williamr@2
|
76 |
* Sets the default folder that browsing is started from.
|
williamr@2
|
77 |
* @param aDefaultFolder A folder that is relative to the root path,
|
williamr@2
|
78 |
* e.g. root path = "C:\" so the default folder could be
|
williamr@2
|
79 |
* "Nokia\Images\".
|
williamr@2
|
80 |
*/
|
williamr@2
|
81 |
IMPORT_C void SetDefaultFolderL( const TDesC& aDefaultFolder );
|
williamr@2
|
82 |
|
williamr@2
|
83 |
/**
|
williamr@2
|
84 |
* Sets title to the pop-up dialog.
|
williamr@2
|
85 |
* @param aText Title text.
|
williamr@2
|
86 |
*/
|
williamr@2
|
87 |
IMPORT_C void SetTitleL( const TDesC& aText );
|
williamr@2
|
88 |
|
williamr@2
|
89 |
/**
|
williamr@2
|
90 |
* Sets the text used for left softkey when a file is focused.
|
williamr@2
|
91 |
* @param aText The text for softkey.
|
williamr@2
|
92 |
*/
|
williamr@2
|
93 |
IMPORT_C void SetLeftSoftkeyFileL( const TDesC& aText );
|
williamr@2
|
94 |
|
williamr@2
|
95 |
/**
|
williamr@2
|
96 |
* Sets the text used for left softkey when a folder is focused.
|
williamr@2
|
97 |
* @param aText The text for softkey.
|
williamr@2
|
98 |
*/
|
williamr@2
|
99 |
IMPORT_C void SetLeftSoftkeyFolderL( const TDesC& aText );
|
williamr@2
|
100 |
|
williamr@2
|
101 |
/**
|
williamr@2
|
102 |
* Sets the text used for right softkey when user is in the root folder.
|
williamr@2
|
103 |
* @param aText The text used for right softkey when user is in the root folder.
|
williamr@2
|
104 |
*/
|
williamr@2
|
105 |
IMPORT_C void SetRightSoftkeyRootFolderL( const TDesC& aText );
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/**
|
williamr@2
|
108 |
* Sets the text used for right softkey when user is in a subfolder.
|
williamr@2
|
109 |
* @param aText The text used for right softkey when user is in a subfolder.
|
williamr@2
|
110 |
*/
|
williamr@2
|
111 |
IMPORT_C void SetRightSoftkeySubfolderL( const TDesC& aText );
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
* Executes the file selection dialog.
|
williamr@2
|
115 |
* @param aFileName Contains the root path.
|
williamr@2
|
116 |
* If an item is selected, the selected item will be set to the
|
williamr@2
|
117 |
* parameter with full path.
|
williamr@2
|
118 |
* @return Returns ETrue if user has selected an item and EFalse
|
williamr@2
|
119 |
* if user hits cancel.
|
williamr@2
|
120 |
*/
|
williamr@2
|
121 |
IMPORT_C TBool ExecuteL( TDes& aFileName );
|
williamr@2
|
122 |
|
williamr@2
|
123 |
/**
|
williamr@2
|
124 |
* A static method that launches a file selection dialog.
|
williamr@2
|
125 |
* @see RunL()
|
williamr@2
|
126 |
*/
|
williamr@2
|
127 |
IMPORT_C static TBool RunDlgLD( TDes& aFileName,
|
williamr@2
|
128 |
const TDesC& aDefaultFolder,
|
williamr@2
|
129 |
MAknFileSelectionObserver* aObserver = NULL );
|
williamr@2
|
130 |
|
williamr@2
|
131 |
/**
|
williamr@2
|
132 |
* A static method that launches a file selection dialog.
|
williamr@2
|
133 |
* @see RunL()
|
williamr@2
|
134 |
*/
|
williamr@2
|
135 |
IMPORT_C static TBool RunDlgLD( TDes& aFileName,
|
williamr@2
|
136 |
const TDesC& aDefaultFolder,
|
williamr@2
|
137 |
const TDesC& aTitle,
|
williamr@2
|
138 |
MAknFileSelectionObserver* aObserver = NULL );
|
williamr@2
|
139 |
|
williamr@2
|
140 |
/**
|
williamr@2
|
141 |
* A static method that launches a file selection dialog.
|
williamr@2
|
142 |
* @see RunL()
|
williamr@2
|
143 |
*/
|
williamr@2
|
144 |
IMPORT_C static TBool RunDlgLD( TDes& aFileName,
|
williamr@2
|
145 |
const TDesC& aDefaultFolder,
|
williamr@2
|
146 |
TInt aResourceId,
|
williamr@2
|
147 |
MAknFileSelectionObserver* aObserver = NULL );
|
williamr@2
|
148 |
|
williamr@2
|
149 |
private: // New functions
|
williamr@2
|
150 |
|
williamr@2
|
151 |
/**
|
williamr@2
|
152 |
* A static method for launching a file selection dialog.
|
williamr@2
|
153 |
* Creates, constructs, runs and deletes a file selection dialog with
|
williamr@2
|
154 |
* different parameters.
|
williamr@2
|
155 |
* @param aResourceId An id of a resource. If zero, default resource is used.
|
williamr@2
|
156 |
* @param aFileName A reference to a filename. Must contain the root path
|
williamr@2
|
157 |
* to start browsing from (if the root path is not defined in
|
williamr@2
|
158 |
* resource). If user accepts a selection, the whole path + current
|
williamr@2
|
159 |
* filename is set to aFileName.
|
williamr@2
|
160 |
* @param aDefaultFolder A descriptor that contains one or more folders
|
williamr@2
|
161 |
* that are relative to the root path. Browsing is started from
|
williamr@2
|
162 |
* the default folder and user can browse folders up all the way
|
williamr@2
|
163 |
* to the root folder.
|
williamr@2
|
164 |
* @param aTitle A title for file selection dialog.
|
williamr@2
|
165 |
* @param aObserver An observer which is asked if the selected item
|
williamr@2
|
166 |
* can be selected. Implemented in application.
|
williamr@2
|
167 |
* @return Returns true if user has selected an item and false
|
williamr@2
|
168 |
* if user hits cancel.
|
williamr@2
|
169 |
*/
|
williamr@2
|
170 |
static TBool RunL(
|
williamr@2
|
171 |
TInt aResourceId,
|
williamr@2
|
172 |
TDes& aFileName,
|
williamr@2
|
173 |
const TDesC& aDefaultFolder,
|
williamr@2
|
174 |
const TDesC& aTitle,
|
williamr@2
|
175 |
MAknFileSelectionObserver* aObserver );
|
williamr@2
|
176 |
|
williamr@2
|
177 |
/**
|
williamr@2
|
178 |
* Initialization method that must be called before executing the dialog.
|
williamr@2
|
179 |
* Initializes the engine and event handler with correct values.
|
williamr@2
|
180 |
* Decides if the dialog should be shown or not.
|
williamr@2
|
181 |
* Called in ExecuteL.
|
williamr@2
|
182 |
* @param aFileName The root path.
|
williamr@2
|
183 |
* @return Returns EFalse if the dialog cannot be executed.
|
williamr@2
|
184 |
*/
|
williamr@2
|
185 |
TBool PrepareL( const TDesC& aFileName );
|
williamr@2
|
186 |
|
williamr@2
|
187 |
/**
|
williamr@2
|
188 |
* Sets id to a default CFD resource depending on dialog type.
|
williamr@2
|
189 |
* @param aResourceId Resource id variable to be modified.
|
williamr@2
|
190 |
* @param aType Dialog type.
|
williamr@2
|
191 |
*/
|
williamr@2
|
192 |
void SetResourceId( TInt& aResourceId, TCommonDialogType aType ) const;
|
williamr@2
|
193 |
|
williamr@2
|
194 |
/**
|
williamr@2
|
195 |
* Reads settings from resource.
|
williamr@2
|
196 |
* @param aResourceId Resource id.
|
williamr@2
|
197 |
*/
|
williamr@2
|
198 |
void ReadFromResourceL( TInt aResourceId );
|
williamr@2
|
199 |
|
williamr@2
|
200 |
private: // Constructors and destructors
|
williamr@2
|
201 |
|
williamr@2
|
202 |
CAknFileSelectionDialog( TCommonDialogType aDialogType );
|
williamr@2
|
203 |
|
williamr@2
|
204 |
/**
|
williamr@2
|
205 |
* Second phase construct. Constructs itself from a resource.
|
williamr@2
|
206 |
* @param aResourceId A resource id (FILESELECTIONDIALOG).
|
williamr@2
|
207 |
*/
|
williamr@2
|
208 |
void ConstructFromResourceL( TInt aResourceId );
|
williamr@2
|
209 |
|
williamr@2
|
210 |
private: // Data
|
williamr@2
|
211 |
|
williamr@2
|
212 |
// Own: Dialog type
|
williamr@2
|
213 |
TCommonDialogType iDialogType;
|
williamr@2
|
214 |
|
williamr@2
|
215 |
// Own: Model
|
williamr@2
|
216 |
CAknFileSelectionModel* iModel;
|
williamr@2
|
217 |
|
williamr@2
|
218 |
// Own: Event handler
|
williamr@2
|
219 |
CAknFileSelectionEventHandler* iEventHandler;
|
williamr@2
|
220 |
|
williamr@2
|
221 |
// Ref: Observer
|
williamr@2
|
222 |
MAknFileSelectionObserver* iObserver;
|
williamr@2
|
223 |
|
williamr@2
|
224 |
// Own: Title
|
williamr@2
|
225 |
HBufC* iTitle;
|
williamr@2
|
226 |
|
williamr@2
|
227 |
// Own: Left softkey when file focused
|
williamr@2
|
228 |
HBufC* iLeftSoftkeyFile;
|
williamr@2
|
229 |
|
williamr@2
|
230 |
// Own: Left softkey when folder focused
|
williamr@2
|
231 |
HBufC* iLeftSoftkeyFolder;
|
williamr@2
|
232 |
|
williamr@2
|
233 |
// Own: Right softkey when in root folder
|
williamr@2
|
234 |
HBufC* iRightSoftkeyRootFolder;
|
williamr@2
|
235 |
|
williamr@2
|
236 |
// Own: Right softkey when in subfolder
|
williamr@2
|
237 |
HBufC* iRightSoftkeySubfolder;
|
williamr@2
|
238 |
|
williamr@2
|
239 |
// Own: Root path
|
williamr@2
|
240 |
HBufC* iRootPath;
|
williamr@2
|
241 |
|
williamr@2
|
242 |
// Own: Default folder
|
williamr@2
|
243 |
HBufC* iDefaultFolder;
|
williamr@2
|
244 |
|
williamr@2
|
245 |
// Own: Boolean value that tells if the dialog has been executed already.
|
williamr@2
|
246 |
TBool iExecuted;
|
williamr@2
|
247 |
};
|
williamr@2
|
248 |
|
williamr@2
|
249 |
#endif // CAKNFILESELECTIONDIALOG_H
|
williamr@2
|
250 |
|
williamr@2
|
251 |
// End of File
|