2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Dialog used to select target file or directory
19 #ifndef CAKNFILESELECTIONDIALOG_H
20 #define CAKNFILESELECTIONDIALOG_H
23 #include <CAknCommonDialogsBase.h>
25 // FORWARD DECLARATIONS
26 class CAknFileSelectionModel;
27 class CAknFileSelectionEventHandler;
28 class MAknFileSelectionObserver;
33 * A class that launches a popup dialog for file selection or directory browsing.
35 * @lib CommonDialogs.lib
38 NONSHARABLE_CLASS(CAknFileSelectionDialog) : public CAknCommonDialogsBase
40 public: // Constructors and destructors
43 * @param aDialogType Type of the dialog for reading correct default values.
44 * @return Returns a pointer to an instance of itself.
46 IMPORT_C static CAknFileSelectionDialog* NewL(
47 TCommonDialogType aDialogType );
51 * @param aDialogType Type of the dialog for reading correct default values.
52 * @param aResourceId A resource id (FILESELECTIONDIALOG).
53 * @return Returns a pointer to an instance of itself.
55 IMPORT_C static CAknFileSelectionDialog* NewL(
56 TCommonDialogType aDialogType, TInt aResourceId );
58 IMPORT_C ~CAknFileSelectionDialog();
60 public: // New functions
63 * Sets an observer which is asked if the selected item can be selected.
64 * @param aObserver A pointer to an observer.
66 IMPORT_C void SetObserver( MAknFileSelectionObserver* aObserver );
69 * Adds a filter to list of filters owned by the engine.
70 * Note! The ownership of the filter is transferred to the engine.
71 * @param aFilter A pointer to a filter that is derived from MAknFileFilter.
73 IMPORT_C void AddFilterL( MAknFileFilter* aFilter );
76 * Sets the default folder that browsing is started from.
77 * @param aDefaultFolder A folder that is relative to the root path,
78 * e.g. root path = "C:\" so the default folder could be
81 IMPORT_C void SetDefaultFolderL( const TDesC& aDefaultFolder );
84 * Sets title to the pop-up dialog.
85 * @param aText Title text.
87 IMPORT_C void SetTitleL( const TDesC& aText );
90 * Sets the text used for left softkey when a file is focused.
91 * @param aText The text for softkey.
93 IMPORT_C void SetLeftSoftkeyFileL( const TDesC& aText );
96 * Sets the text used for left softkey when a folder is focused.
97 * @param aText The text for softkey.
99 IMPORT_C void SetLeftSoftkeyFolderL( const TDesC& aText );
102 * Sets the text used for right softkey when user is in the root folder.
103 * @param aText The text used for right softkey when user is in the root folder.
105 IMPORT_C void SetRightSoftkeyRootFolderL( const TDesC& aText );
108 * Sets the text used for right softkey when user is in a subfolder.
109 * @param aText The text used for right softkey when user is in a subfolder.
111 IMPORT_C void SetRightSoftkeySubfolderL( const TDesC& aText );
114 * Executes the file selection dialog.
115 * @param aFileName Contains the root path.
116 * If an item is selected, the selected item will be set to the
117 * parameter with full path.
118 * @return Returns ETrue if user has selected an item and EFalse
119 * if user hits cancel.
121 IMPORT_C TBool ExecuteL( TDes& aFileName );
124 * A static method that launches a file selection dialog.
127 IMPORT_C static TBool RunDlgLD( TDes& aFileName,
128 const TDesC& aDefaultFolder,
129 MAknFileSelectionObserver* aObserver = NULL );
132 * A static method that launches a file selection dialog.
135 IMPORT_C static TBool RunDlgLD( TDes& aFileName,
136 const TDesC& aDefaultFolder,
138 MAknFileSelectionObserver* aObserver = NULL );
141 * A static method that launches a file selection dialog.
144 IMPORT_C static TBool RunDlgLD( TDes& aFileName,
145 const TDesC& aDefaultFolder,
147 MAknFileSelectionObserver* aObserver = NULL );
149 private: // New functions
152 * A static method for launching a file selection dialog.
153 * Creates, constructs, runs and deletes a file selection dialog with
154 * different parameters.
155 * @param aResourceId An id of a resource. If zero, default resource is used.
156 * @param aFileName A reference to a filename. Must contain the root path
157 * to start browsing from (if the root path is not defined in
158 * resource). If user accepts a selection, the whole path + current
159 * filename is set to aFileName.
160 * @param aDefaultFolder A descriptor that contains one or more folders
161 * that are relative to the root path. Browsing is started from
162 * the default folder and user can browse folders up all the way
163 * to the root folder.
164 * @param aTitle A title for file selection dialog.
165 * @param aObserver An observer which is asked if the selected item
166 * can be selected. Implemented in application.
167 * @return Returns true if user has selected an item and false
168 * if user hits cancel.
173 const TDesC& aDefaultFolder,
175 MAknFileSelectionObserver* aObserver );
178 * Initialization method that must be called before executing the dialog.
179 * Initializes the engine and event handler with correct values.
180 * Decides if the dialog should be shown or not.
181 * Called in ExecuteL.
182 * @param aFileName The root path.
183 * @return Returns EFalse if the dialog cannot be executed.
185 TBool PrepareL( const TDesC& aFileName );
188 * Sets id to a default CFD resource depending on dialog type.
189 * @param aResourceId Resource id variable to be modified.
190 * @param aType Dialog type.
192 void SetResourceId( TInt& aResourceId, TCommonDialogType aType ) const;
195 * Reads settings from resource.
196 * @param aResourceId Resource id.
198 void ReadFromResourceL( TInt aResourceId );
200 private: // Constructors and destructors
202 CAknFileSelectionDialog( TCommonDialogType aDialogType );
205 * Second phase construct. Constructs itself from a resource.
206 * @param aResourceId A resource id (FILESELECTIONDIALOG).
208 void ConstructFromResourceL( TInt aResourceId );
213 TCommonDialogType iDialogType;
216 CAknFileSelectionModel* iModel;
218 // Own: Event handler
219 CAknFileSelectionEventHandler* iEventHandler;
222 MAknFileSelectionObserver* iObserver;
227 // Own: Left softkey when file focused
228 HBufC* iLeftSoftkeyFile;
230 // Own: Left softkey when folder focused
231 HBufC* iLeftSoftkeyFolder;
233 // Own: Right softkey when in root folder
234 HBufC* iRightSoftkeyRootFolder;
236 // Own: Right softkey when in subfolder
237 HBufC* iRightSoftkeySubfolder;
242 // Own: Default folder
243 HBufC* iDefaultFolder;
245 // Own: Boolean value that tells if the dialog has been executed already.
249 #endif // CAKNFILESELECTIONDIALOG_H