main.qml Example File
filepicker/assets/main.qml
import bb.cascades 1.0
import bb.cascades.pickers 1.0
Page {
titleBar: TitleBar {
title: qsTr ("File Picker")
}
Container {
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
FilepickerScrollView {
Container {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
topPadding: 50
leftPadding: 30
rightPadding: 30
DropDown {
id: pickerMode
horizontalAlignment: HorizontalAlignment.Center
topMargin: 50
title: qsTr("Mode")
Option {
text: qsTr("Picker")
value: FilePickerMode.Picker
selected: true
}
Option {
text: qsTr("Saver")
value: FilePickerMode.Saver
}
Option {
text: qsTr("PickerMultiple")
value: FilePickerMode.PickerMultiple
}
Option {
text: qsTr("SaverMultiple")
value: FilePickerMode.SaverMultiple
}
}
DropDown {
id: pickerType
horizontalAlignment: HorizontalAlignment.Center
title: qsTr("Type")
Option {
text: qsTr("Picture")
value: FileType.Picture
}
Option {
text: qsTr("Document")
value: FileType.Document
}
Option {
text: qsTr("Music")
value: FileType.Music
}
Option {
text: qsTr("Video")
value: FileType.Video
}
Option {
text: qsTr("Other")
value: FileType.Other
selected: true
}
}
DropDown {
id: pickerViewMode
horizontalAlignment: HorizontalAlignment.Center
title: qsTr("View Mode")
Option {
text: qsTr("Default")
value: FilePickerViewMode.Default
selected: true
}
Option {
text: qsTr("List View")
value: FilePickerViewMode.ListView
}
Option {
text: qsTr("Grid View")
value: FilePickerViewMode.GridView
}
}
DropDown {
id: pickerSortBy
horizontalAlignment: HorizontalAlignment.Center
title: qsTr("Sort by")
Option {
text: qsTr("Default")
value: FilePickerSortFlag.Default
selected: true
}
Option {
text: qsTr("Name")
value: FilePickerSortFlag.Name
}
Option {
text: qsTr("Date")
value: FilePickerSortFlag.Date
}
Option {
text: qsTr("Suffix")
value: FilePickerSortFlag.Suffix
}
Option {
text: qsTr("Size")
value: FilePickerSortFlag.Size
}
}
DropDown {
id: pickerSortOrder
horizontalAlignment: HorizontalAlignment.Center
title: qsTr("Sort order")
Option {
text: qsTr("Default")
value: FilePickerSortOrder.Default
selected: true
}
Option {
text: qsTr("Ascending")
value: FilePickerSortOrder.Ascending
}
Option {
text: qsTr("Descending")
value: FilePickerSortOrder.Descending
}
}
Button {
horizontalAlignment: HorizontalAlignment.Center
topMargin: 100
text: qsTr("Show")
onClicked: picker.open()
}
Label {
id: resultLabel
horizontalAlignment: HorizontalAlignment.Center
topMargin: 30
text: qsTr("Selected file: %1").arg(picker.selectedFile)
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
}
multiline: true
visible: (picker.selectedFile != "")
}
}
}
}
attachedObjects: [
FilePicker {
id: picker
property string selectedFile
title: qsTr ("File Picker")
mode: pickerMode.selectedValue
type: pickerType.selectedValue
viewMode: pickerViewMode.selectedValue
sortBy: pickerSortBy.selectedValue
sortOrder: pickerSortOrder.selectedValue
onFileSelected: {
selectedFile = selectedFiles[0]
}
}
]
}