examples/QtQuick/qmlaudioplayer/qml/qmlaudioplayer/FilePickerPage.qml

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the Qt Components project on Qt Labs.
00008 **
00009 ** No Commercial Usage
00010 ** This file contains pre-release code and may not be distributed.
00011 ** You may use this file in accordance with the terms and conditions contained
00012 ** in the Technology Preview License Agreement accompanying this package.
00013 **
00014 ** GNU Lesser General Public License Usage
00015 ** Alternatively, this file may be used under the terms of the GNU Lesser
00016 ** General Public License version 2.1 as published by the Free Software
00017 ** Foundation and appearing in the file LICENSE.LGPL included in the
00018 ** packaging of this file.  Please review the following information to
00019 ** ensure the GNU Lesser General Public License version 2.1 requirements
00020 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00021 **
00022 ** If you have questions regarding the use of this file, please contact
00023 ** Nokia at qt-info@nokia.com.
00024 **
00025 ****************************************************************************/
00026 
00027 import QtQuick 1.0
00028 import com.nokia.symbian 1.0
00029 import Qt.labs.folderlistmodel 1.0
00030 
00031 Page {
00032     tools: filePickerTools
00033     property alias backgroundImage:  background.source
00034     Image {
00035         id: background
00036 
00037         anchors.fill: parent
00038     }
00039 
00040     Component {
00041         id: heading
00042 
00043         PageHeading {
00044             width: parent.width
00045             text: folderListModel.folder
00046         }
00047     }
00048 
00049     Component {
00050         id: filePickerDelegate
00051 
00052         Item {
00053             height: 75
00054             width: folderListView.width
00055 
00056             Rectangle {
00057                 width: 4
00058                 height: parent.height
00059                 color: "#2d2875"
00060                 visible: index % 2
00061             }
00062 
00063             Image {
00064                 id: folderIcon
00065 
00066                 anchors { left: parent.left; verticalCenter: parent.verticalCenter }
00067                 source: "folder.svg"
00068                 visible: folderListModel.isFolder(index)
00069             }
00070 
00071             Text {
00072                 anchors {
00073                     left: folderIcon.right
00074                     right: parent.right
00075                     leftMargin: 5
00076                     verticalCenter: parent.verticalCenter
00077                 }
00078                 elide: Text.ElideRight
00079                 font.pixelSize: 22
00080                 font.letterSpacing: -1
00081                 color: "white"
00082                 text: fileName
00083             }
00084 
00085             MouseArea {
00086                 anchors.fill: parent
00087 
00088                 onClicked: {
00089                     if (folderListModel.isFolder(index)) {
00090                         if (fileName == "..")
00091                             folderListModel.folder = folderListModel.parentFolder
00092                         else
00093                             folderListModel.folder += "/" + fileName
00094                     } else {
00095                         var file = folderListModel.folder + "/" + fileName
00096                         //file:///
00097                         audioPlayerPage.myaudio.source = file;
00098                         pageStack.pop()
00099                     }
00100                 }
00101             }
00102         }
00103     }
00104 
00106     FolderListModel {
00107         id: folderListModel
00108 
00109         nameFilters: ["*.mp3"]
00110         showDotAndDotDot: true
00111         showOnlyReadable: true
00112         sortField: FolderListModel.Type
00113         //folder: ""
00114     }
00116 
00117     ListView {
00118         id: folderListView
00119 
00120         anchors.fill: parent
00121         header: heading
00122         model: folderListModel
00123         delegate: filePickerDelegate
00124         cacheBuffer: height
00125         clip: true
00126 
00127         ScrollDecorator {
00128             flickableItem: parent
00129         }
00130     }
00131 
00132     ToolBarLayout {
00133         id: filePickerTools
00134 
00135         ToolButton {
00136             flat: true
00137             iconSource: "toolbar_back.svg"
00138             onClicked: pageStack.pop()
00139         }
00140     }
00141 }

Generated by  doxygen 1.6.2