<?xml version="1.0" encoding="UTF-8"?>

<!--START_USECASES: CU20 END_USECASES-->
<!-- Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). -->
<!-- All rights reserved. -->
<!-- This component and the accompanying materials are made available -->
<!-- under the terms of the License "Eclipse Public License v1.0" -->
<!-- which accompanies this distribution, and is available -->
<!-- at the URL "http://www.eclipse.org/legal/epl-v10.html". -->

<componentDefinition xmlns="http://www.nokia.com/sdt/emf/component"
					xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<enumPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.TSelectFileDialogEntryKeyFlags">
		<enumElement value="ESortByName" displayValue="%sortByName"/>
		<enumElement value="ESortByExt" displayValue="%sortByExt"/>
		<enumElement value="ESortBySize" displayValue="%sortBySize"/>
		<enumElement value="ESortByDate" displayValue="%sortByDate"/>
	</enumPropertyDeclaration>

	<enumPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.TSelectFileDialogSorting">
		<enumElement value="0" displayValue="%notSorted"/>
		<enumElement value="EQikSelectFileDialogSortAscending" displayValue="%sortAscending"/>
		<enumElement value="EQikSelectFileDialogSortDescending" displayValue="%sortDescending"/>
	</enumPropertyDeclaration>

	<enumPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.SelectFileDialogLockToDefaultFolder">
		<enumElement value="EQikSelectFileDialogLockToDefaultFolder" displayValue="%SelectFileDialogLockToDefaultFolder"/>
		<enumElement value="0" displayValue="%DontSelectFileDialogLockToDefaultFolder"/>
	</enumPropertyDeclaration>

	<enumPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.SelectFileDialogEnableMultipleSelect">
		<enumElement value="EQikSelectFileDialogEnableMultipleSelect" displayValue="%SelectFileDialogEnableMultipleSelect"/>
		<enumElement value="0" displayValue="%DontSelectFileDialogEnableMultipleSelect"/>
	</enumPropertyDeclaration>

	<enumPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.SelectFileDialogEnableAutomaticConsumeLock">
		<enumElement value="EQikSelectFileDialogEnableAutomaticConsumeLock" displayValue="%SelectFileDialogEnableAutomaticConsumeLock"/>
		<enumElement value="0" displayValue="%DontSelectFileDialogEnableAutomaticConsumeLock"/>
	</enumPropertyDeclaration>

	<enumPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.SelectFileDialogEnableForwardableLock">
		<enumElement value="EQikSelectFileDialogEnableForwardableLock" displayValue="%SelectFileDialogEnableForwardableLock"/>
		<enumElement value="0" displayValue="%DontSelectFileDialogEnableForwardableLock"/>
	</enumPropertyDeclaration>

	<compoundPropertyDeclaration qualifiedName="com.nokia.carbide.uiq.TSelectFileDialogFlags">
		<enumProperty name="sortType" type="com.nokia.carbide.uiq.TSelectFileDialogEntryKeyFlags"
				default="ESortByName"
				descriptionKey="sortTypeDescription"/>
		<enumProperty name="sortOrder" type="com.nokia.carbide.uiq.TSelectFileDialogSorting"
				default="0"
				descriptionKey="sortOrderDescription"/>
		<enumProperty name="lockToDefaultFolder" type="com.nokia.carbide.uiq.SelectFileDialogLockToDefaultFolder"  
				default="EQikSelectFileDialogLockToDefaultFolder" 
				descriptionKey="lockToDefaultFolderDescription"/>
		<enumProperty name="enableMultipleSelect" type="com.nokia.carbide.uiq.SelectFileDialogEnableMultipleSelect"  
				default="EQikSelectFileDialogEnableMultipleSelect" 
				descriptionKey="enableMultipleSelectDescription"/>
		<enumProperty name="enableAutomaticConsumeLock" type="com.nokia.carbide.uiq.SelectFileDialogEnableAutomaticConsumeLock"  
				default="EQikSelectFileDialogEnableAutomaticConsumeLock" 
				descriptionKey="enableAutomaticConsumeLockDescription"/>
		<enumProperty name="enableForwardableLock" type="com.nokia.carbide.uiq.SelectFileDialogEnableForwardableLock"  
				default="EQikSelectFileDialogEnableForwardableLock" 
				descriptionKey="enableForwardableLockDescription"/>
	</compoundPropertyDeclaration>
			
	<component friendlyName="%friendlyName"
			qualifiedName="com.nokia.carbide.uiq.CQikSelectFileDlg"
			baseComponent="com.nokia.carbide.uiq.TransientDialogBase"
			instanceNameRoot="selectFileDialog"			
			version="1.0"
			category="%category.dialog">
			
		<documentation>
			<information>%information</information>
		</documentation>
		
		<symbian sdkName="com.uiq"
			minSDKVersion="3.0"
			className="CQikSelectFileDlg"/>
		
		<designerImages smallIconFile="SelectFileDialog_sm.png"
			largeIconFile="SelectFileDialog.png"/>
				
		<properties>
			<property  name="title" 
				type="localizedString" 
				descriptionKey="titleDescription"
				category="%category.appearance"/>																				
			<arrayProperty name="mimeTypes" 
				type="string" 
				editorClass="com.nokia.sdt.symbian.ui.editors.StringListEditorFactory"
				descriptionKey="mimeTypesDescription"
				category="%category.data"/>
			<compoundProperty  name="defaultFolderDescription" 
				type="com.nokia.carbide.uiq.TQikDefaultFolderDescription" 
				descriptionKey="defaultFolderDescriptionDescription"
				category="%category.data"/>																				
			<compoundProperty  name="flags" 
				type="com.nokia.carbide.uiq.TSelectFileDialogFlags" 
				descriptionKey="flagsDescription"
				category="%category.behavior"/>																				
			<compoundProperty category="Hidden" name="location" 
				type="com.nokia.carbide.uiq.locationProperty"
				editorClass="com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory"/>
			<compoundProperty category="Hidden" name="size" 
				type="com.nokia.carbide.uiq.sizeProperty"
				editorClass="com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory"/>									
		</properties>

		<implementations>	
			<implementation>
				<interface id="com.nokia.sdt.datamodel.adapter.IVisualAppearance"/>			
				<interface id="com.nokia.sdt.datamodel.adapter.ILayout"/> 
				<interface id="com.nokia.sdt.datamodel.adapter.IDirectLabelEdit"/>
				<interface id="com.nokia.sdt.datamodel.adapter.IComponentValidator"/>
				<script file="SelectFileDialog.js" prototype="SelectFileDialog"/>
			</implementation>					
		</implementations>

		<sourceMapping>
			<mapResource struct="TBUF" headers="eikon.rh" id="title">
				<mapSimpleMember property="title" member="buf"/>
			</mapResource>
			
			<mapResource struct="ARRAY" headers="badef.rh" id="mimeTypes">
				<mapArrayMember property="mimeTypes" member="items">
					<mapResourceElement struct="LBUF" headers="badef.rh">
						<mapSimpleMember property="." member="txt"/>
					</mapResourceElement>
				</mapArrayMember>
			</mapResource>			
						
			<mapResource struct="TBUF1" headers="uikon.rh" id="driveLetter">
				<mapSimpleMember property="defaultFolderDescription.driveLetter" member="buf"/>
			</mapResource>
			<mapResource struct="TBUF" headers="badef.rh" id="relativePath">
				<mapSimpleMember property="defaultFolderDescription.relativePath" member="buf"/>
			</mapResource>			
			
		</sourceMapping>

		<sourceGen>
			<inline scope="file">
				function isMultipleSelectFileDialog(instance){
					return instance.properties.flags.enableMultipleSelect=="EQikSelectFileDialogEnableMultipleSelect";
				}
			</inline>
			<template id="selectFolderDlg" phase="MainSystemIncludes">
<![CDATA[#include <QikSelectFileDlg.h>]]>
			</template>			
			<expandMacro name="GenerateMethodWithOwnedBody"
				DeclPhase="HeaderClassPublic"
				FunctionName="Run${instanceMemberName}L"
				FunctionArgs="CDesCArray*&amp; aFileNameArray"
				ReturnType="TBool"
				FunctionLocationId="RUNMULTIPLESELECTFILEDLG"
				IsOwned="false"
				DefnLocation="VIEWDIALOGBASE_SOURCE_FILE"
				ClassName="${className}"
				OwnedRegionLocationId="RUNMULTIPLESELECTFILEDLG_BODY"
				ifExpr="isMultipleSelectFileDialog(instance)">
				<expandArgument name="FunctionComment">
/**
 * Run Multiple Select File Dialog
 * 
 * Allows user to select multiple files from a list of files in dialog.
 * Files displayed in dialog are filtered by MIME type defined in
 * resource file.
 * If selection was done, aFileNameArray contains selected files names
 * and it is pushed on to the cleanup stack, so developer should pop
 * and destroy this resources at some point, i.e.
 * 
 * CDesCArray* filenamearray = NULL;
 * if ( RunSelectFileDlg1LC( filenamearray ) != EFalse )
 * 	{
 *	//Do something with selection
 * 	//...
 *	if ( filenamearray != NULL )
 *	{
 *	CleanupStack::PopAndDestroy( filenamearray );
 *	}
 * 
 * Selection could also be kept for further use, so developer should pop
 * resource, use it and delete it when finished, i.e.
 * 
 * TBool response = RunSelectFileDlg1LC( filenamearray );
 * CleanupStack::Pop( filenamearray );
 * ...
 * ...
 * delete filenamearray;
 * filenamearray = NULL;
 * 
 * @param aFileNameArray The selected files names (if selection was done), otherwise empty.
 * @return EFalse if dialog was canceled (no selection), otherwise a value different from EFalse.
 */
				</expandArgument>
				<expandArgument name="FunctionBody">
<![CDATA[
	aFileNameArray = new ( ELeave ) CDesCArraySeg( 64 );
	CleanupStack::PushL( aFileNameArray );
	CDesCArray* mimetypes = iEikonEnv->ReadDesCArrayResourceL( ${Engine.getGeneratedResource(instance,"mimeTypes").toUpperCase()} );
	CleanupStack::PushL( mimetypes );
	TQikDefaultFolderDescription defaultfolderdesc;
	defaultfolderdesc.SetDefaultFolder( ${properties.defaultFolderDescription.defaultFolder} );
	HBufC* driveletter = iEikonEnv->AllocReadResourceLC( ${Engine.getGeneratedResource(instance, "driveLetter").toUpperCase()} );
	HBufC* relativepath = iEikonEnv->AllocReadResourceLC( ${Engine.getGeneratedResource(instance, "relativePath").toUpperCase()} );
	defaultfolderdesc.SetDriveLetter( driveletter->Des()[ 0 ] );
	defaultfolderdesc.SetRelativePath( relativepath->Des() );
	HBufC* dlgtitle = iEikonEnv->AllocReadResourceLC( ${Engine.getGeneratedResource(instance, "title").toUpperCase()} );
	
	TBool response = CQikSelectFileDlg::RunDlgLD( *mimetypes,
			*aFileNameArray,
			defaultfolderdesc,
			dlgtitle,
			${properties.flags.enableMultipleSelect} | 
			${properties.flags.enableAutomaticConsumeLock} |
			${properties.flags.enableForwardableLock} |
			${properties.flags.lockToDefaultFolder} |
			${properties.flags.sortType} |
			${properties.flags.sortOrder} );
	
	CleanupStack::PopAndDestroy( 4, mimetypes );
	if ( response == EFalse )
		{
		CleanupStack::PopAndDestroy( aFileNameArray );
		aFileNameArray = NULL;
		}
	
	return response;
]]>				
				</expandArgument>
			</expandMacro>	

			<expandMacro name="GenerateMethodWithOwnedBody"
				DeclPhase="HeaderClassPublic"
				FunctionName="Run${instanceMemberName}L"
				FunctionArgs="TFileName&amp; aFileName"
				ReturnType="TBool"
				FunctionLocationId="RUNSINGLESELECTFILEDLG"
				IsOwned="false"
				DefnLocation="VIEWDIALOGBASE_SOURCE_FILE"
				ClassName="${className}"
				OwnedRegionLocationId="RUNSINGLESELECTFILEDLG_BODY"
				ifExpr="!isMultipleSelectFileDialog(instance)">
				<expandArgument name="FunctionComment">
/**
 * Run Single Select File Dialog
 * 
 * Allows user to select a single file from a list of files in dialog.
 * Files displayed in dialog are filtered by MIME type defined in
 * resource file.
 * 
 * @param aFileName The selected file name (if selection was done), otherwise empty.
 * @return EFalse if dialog was canceled (no selection), otherwise a value different from EFalse.
 */

				</expandArgument>
				<expandArgument name="FunctionBody">
<![CDATA[
	CDesCArray* mimetypes = iEikonEnv->ReadDesCArrayResourceL( ${Engine.getGeneratedResource(instance,"mimeTypes").toUpperCase()} );
	CleanupStack::PushL( mimetypes );
	CDesCArray* filenamearray = new ( ELeave ) CDesCArraySeg( 64 );
	CleanupStack::PushL( filenamearray );
	TQikDefaultFolderDescription defaultfolderdesc;
	defaultfolderdesc.SetDefaultFolder( ${properties.defaultFolderDescription.defaultFolder} );
	HBufC* driveletter = iEikonEnv->AllocReadResourceLC( ${Engine.getGeneratedResource(instance, "driveLetter").toUpperCase()} );
	HBufC* relativepath = iEikonEnv->AllocReadResourceLC( ${Engine.getGeneratedResource(instance, "relativePath").toUpperCase()} );
	defaultfolderdesc.SetDriveLetter( driveletter->Des()[ 0 ] );
	defaultfolderdesc.SetRelativePath( relativepath->Des() );
	HBufC* dlgtitle = iEikonEnv->AllocReadResourceLC( ${Engine.getGeneratedResource(instance, "title").toUpperCase()} );
	
	TBool response = CQikSelectFileDlg::RunDlgLD( *mimetypes,
			*filenamearray,
			defaultfolderdesc,
			dlgtitle,
			${properties.flags.enableAutomaticConsumeLock} |
			${properties.flags.enableForwardableLock} |
			${properties.flags.lockToDefaultFolder} |
			${properties.flags.sortType} |
			${properties.flags.sortOrder} );
	
	if ( response == EFalse )
		{
		aFileName = KNullDesC;
		}
	else
		{
		aFileName = (*filenamearray)[ 0 ];
		}
	
	CleanupStack::PopAndDestroy( 5, mimetypes );
	
	return response;
]]>				
				</expandArgument>
			</expandMacro>	

			
		</sourceGen>				
	</component>

</componentDefinition>