williamr@2: /* williamr@2: * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Dialog used to select target file or directory williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef CAKNFILESELECTIONDIALOG_H williamr@2: #define CAKNFILESELECTIONDIALOG_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CAknFileSelectionModel; williamr@2: class CAknFileSelectionEventHandler; williamr@2: class MAknFileSelectionObserver; williamr@2: class MAknFileFilter; williamr@2: williamr@2: // CLASS DEFINITION williamr@2: /** williamr@2: * A class that launches a popup dialog for file selection or directory browsing. williamr@2: * williamr@2: * @lib CommonDialogs.lib williamr@2: * @since 1.2 williamr@2: */ williamr@2: NONSHARABLE_CLASS(CAknFileSelectionDialog) : public CAknCommonDialogsBase williamr@2: { williamr@2: public: // Constructors and destructors williamr@2: /** williamr@2: * Static constructor. williamr@2: * @param aDialogType Type of the dialog for reading correct default values. williamr@2: * @return Returns a pointer to an instance of itself. williamr@2: */ williamr@2: IMPORT_C static CAknFileSelectionDialog* NewL( williamr@2: TCommonDialogType aDialogType ); williamr@2: williamr@2: /** williamr@2: * Static constructor. williamr@2: * @param aDialogType Type of the dialog for reading correct default values. williamr@2: * @param aResourceId A resource id (FILESELECTIONDIALOG). williamr@2: * @return Returns a pointer to an instance of itself. williamr@2: */ williamr@2: IMPORT_C static CAknFileSelectionDialog* NewL( williamr@2: TCommonDialogType aDialogType, TInt aResourceId ); williamr@2: williamr@2: IMPORT_C ~CAknFileSelectionDialog(); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Sets an observer which is asked if the selected item can be selected. williamr@2: * @param aObserver A pointer to an observer. williamr@2: */ williamr@2: IMPORT_C void SetObserver( MAknFileSelectionObserver* aObserver ); williamr@2: williamr@2: /** williamr@2: * Adds a filter to list of filters owned by the engine. williamr@2: * Note! The ownership of the filter is transferred to the engine. williamr@2: * @param aFilter A pointer to a filter that is derived from MAknFileFilter. williamr@2: */ williamr@2: IMPORT_C void AddFilterL( MAknFileFilter* aFilter ); williamr@2: williamr@2: /** williamr@2: * Sets the default folder that browsing is started from. williamr@2: * @param aDefaultFolder A folder that is relative to the root path, williamr@2: * e.g. root path = "C:\" so the default folder could be williamr@2: * "Nokia\Images\". williamr@2: */ williamr@2: IMPORT_C void SetDefaultFolderL( const TDesC& aDefaultFolder ); williamr@2: williamr@2: /** williamr@2: * Sets title to the pop-up dialog. williamr@2: * @param aText Title text. williamr@2: */ williamr@2: IMPORT_C void SetTitleL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text used for left softkey when a file is focused. williamr@2: * @param aText The text for softkey. williamr@2: */ williamr@2: IMPORT_C void SetLeftSoftkeyFileL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text used for left softkey when a folder is focused. williamr@2: * @param aText The text for softkey. williamr@2: */ williamr@2: IMPORT_C void SetLeftSoftkeyFolderL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text used for right softkey when user is in the root folder. williamr@2: * @param aText The text used for right softkey when user is in the root folder. williamr@2: */ williamr@2: IMPORT_C void SetRightSoftkeyRootFolderL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text used for right softkey when user is in a subfolder. williamr@2: * @param aText The text used for right softkey when user is in a subfolder. williamr@2: */ williamr@2: IMPORT_C void SetRightSoftkeySubfolderL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Executes the file selection dialog. williamr@2: * @param aFileName Contains the root path. williamr@2: * If an item is selected, the selected item will be set to the williamr@2: * parameter with full path. williamr@2: * @return Returns ETrue if user has selected an item and EFalse williamr@2: * if user hits cancel. williamr@2: */ williamr@2: IMPORT_C TBool ExecuteL( TDes& aFileName ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a file selection dialog. williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( TDes& aFileName, williamr@2: const TDesC& aDefaultFolder, williamr@2: MAknFileSelectionObserver* aObserver = NULL ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a file selection dialog. williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( TDes& aFileName, williamr@2: const TDesC& aDefaultFolder, williamr@2: const TDesC& aTitle, williamr@2: MAknFileSelectionObserver* aObserver = NULL ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a file selection dialog. williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( TDes& aFileName, williamr@2: const TDesC& aDefaultFolder, williamr@2: TInt aResourceId, williamr@2: MAknFileSelectionObserver* aObserver = NULL ); williamr@2: williamr@2: private: // New functions williamr@2: williamr@2: /** williamr@2: * A static method for launching a file selection dialog. williamr@2: * Creates, constructs, runs and deletes a file selection dialog with williamr@2: * different parameters. williamr@2: * @param aResourceId An id of a resource. If zero, default resource is used. williamr@2: * @param aFileName A reference to a filename. Must contain the root path williamr@2: * to start browsing from (if the root path is not defined in williamr@2: * resource). If user accepts a selection, the whole path + current williamr@2: * filename is set to aFileName. williamr@2: * @param aDefaultFolder A descriptor that contains one or more folders williamr@2: * that are relative to the root path. Browsing is started from williamr@2: * the default folder and user can browse folders up all the way williamr@2: * to the root folder. williamr@2: * @param aTitle A title for file selection dialog. williamr@2: * @param aObserver An observer which is asked if the selected item williamr@2: * can be selected. Implemented in application. williamr@2: * @return Returns true if user has selected an item and false williamr@2: * if user hits cancel. williamr@2: */ williamr@2: static TBool RunL( williamr@2: TInt aResourceId, williamr@2: TDes& aFileName, williamr@2: const TDesC& aDefaultFolder, williamr@2: const TDesC& aTitle, williamr@2: MAknFileSelectionObserver* aObserver ); williamr@2: williamr@2: /** williamr@2: * Initialization method that must be called before executing the dialog. williamr@2: * Initializes the engine and event handler with correct values. williamr@2: * Decides if the dialog should be shown or not. williamr@2: * Called in ExecuteL. williamr@2: * @param aFileName The root path. williamr@2: * @return Returns EFalse if the dialog cannot be executed. williamr@2: */ williamr@2: TBool PrepareL( const TDesC& aFileName ); williamr@2: williamr@2: /** williamr@2: * Sets id to a default CFD resource depending on dialog type. williamr@2: * @param aResourceId Resource id variable to be modified. williamr@2: * @param aType Dialog type. williamr@2: */ williamr@2: void SetResourceId( TInt& aResourceId, TCommonDialogType aType ) const; williamr@2: williamr@2: /** williamr@2: * Reads settings from resource. williamr@2: * @param aResourceId Resource id. williamr@2: */ williamr@2: void ReadFromResourceL( TInt aResourceId ); williamr@2: williamr@2: private: // Constructors and destructors williamr@2: williamr@2: CAknFileSelectionDialog( TCommonDialogType aDialogType ); williamr@2: williamr@2: /** williamr@2: * Second phase construct. Constructs itself from a resource. williamr@2: * @param aResourceId A resource id (FILESELECTIONDIALOG). williamr@2: */ williamr@2: void ConstructFromResourceL( TInt aResourceId ); williamr@2: williamr@2: private: // Data williamr@2: williamr@2: // Own: Dialog type williamr@2: TCommonDialogType iDialogType; williamr@2: williamr@2: // Own: Model williamr@2: CAknFileSelectionModel* iModel; williamr@2: williamr@2: // Own: Event handler williamr@2: CAknFileSelectionEventHandler* iEventHandler; williamr@2: williamr@2: // Ref: Observer williamr@2: MAknFileSelectionObserver* iObserver; williamr@2: williamr@2: // Own: Title williamr@2: HBufC* iTitle; williamr@2: williamr@2: // Own: Left softkey when file focused williamr@2: HBufC* iLeftSoftkeyFile; williamr@2: williamr@2: // Own: Left softkey when folder focused williamr@2: HBufC* iLeftSoftkeyFolder; williamr@2: williamr@2: // Own: Right softkey when in root folder williamr@2: HBufC* iRightSoftkeyRootFolder; williamr@2: williamr@2: // Own: Right softkey when in subfolder williamr@2: HBufC* iRightSoftkeySubfolder; williamr@2: williamr@2: // Own: Root path williamr@2: HBufC* iRootPath; williamr@2: williamr@2: // Own: Default folder williamr@2: HBufC* iDefaultFolder; williamr@2: williamr@2: // Own: Boolean value that tells if the dialog has been executed already. williamr@2: TBool iExecuted; williamr@2: }; williamr@2: williamr@2: #endif // CAKNFILESELECTIONDIALOG_H williamr@2: williamr@2: // End of File