123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- import QtQuick 1.1
- //import QtMobility.gallery 1.1
- import com.nokia.meego 1.0
- import Qt.labs.folderlistmodel 1.0
- /* idea from ereader. */
- Page {
- id: pageFileListView
- tools: ToolBarLayout {
- opacity: userTheme.opacityToolbar
- ToolIcon {
- //iconId: "toolbar-back"
- iconSource: "images/toolbar/back.png"
- onClicked: {
- pageStack.pop()
- }
- }
- ToolIcon {
- //iconId: "toolbar-up"
- iconSource: "images/toolbar/folder_back.png"
- onClicked: {
- if (stripFilePrefix(folderModel.folder) !== "/") {
- setCurrentFolder(stripFilePrefix(stripSuffix(folderModel.folder)))
- }
- }
- }
- }
- BackgroundPage { }
- function stripFilePrefix(path) {
- var filePath = new String(path)
- return filePath.replace("file://", "")
- }
- function stripSuffix(path) {
- var filePath = new String(path)
- return filePath.substring(0, filePath.lastIndexOf("/"))
- }
- function setCurrentFolder(folder) {
- folderModel.folder = folder
- }
- QNMTitle {
- id: titlePage
- text: stripFilePrefix(folderModel.folder)
- image: "images/folder_docs.png"
- sizFont: 22
- busy: false
- }
- Component {
- id: delegateFolder
- Rectangle {
- id:wrapper
- height: 70
- width: list.width
- color: "transparent"
- radius: 10
- Behavior on opacity { NumberAnimation{ duration: 400 } }
- Image {
- id: imgFolder
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- anchors.leftMargin: 20
- source: folderModel.isFolder(index) ? "images/folder.png" : "images/doc.png"
- }
- Text {
- text: decodeURI(fileName)
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: imgFolder.right
- anchors.leftMargin: 20
- font.pixelSize: 30
- color: folderModel.isFolder(index) ? "black" : "blue"
- }
- MouseArea {
- id: maFolder
- anchors.fill: parent
- onClicked: {
- if (folderModel.isFolder(index)) {
- setCurrentFolder(filePath)
- }
- else {
- setCurrentFolder(folderModel.folder)
- //console.log("Selected file: "+stripFilePrefix(decodeURI(filePath)) )
- pageImportWords.xmlfile = stripFilePrefix(decodeURI(filePath))
- //pageImportWords._txtTF.text = stripFilePrefix(decodeURI(filePath))
- pageStack.pop()
- }
- }
- onExited: {
- wrapper.color = "transparent"
- wrapper.opacity = 1
- }
- onPressedChanged: {
- if( pressed ) {
- wrapper.color = "black"
- wrapper.opacity = 0.5
- } else {
- wrapper.color = "transparent"
- wrapper.opacity = 1
- }
- }
- } //MouseArea
- }
- }
- ListView {
- id: list
- clip: true
- anchors.top: titlePage.bottom
- anchors.bottom: parent.bottom
- width: parent.width
- model: folderModel
- spacing: 2
- section.property: "path"
- delegate: delegateFolder
- }
- SectionScroller {
- listView: list
- }
- ScrollDecorator { flickableItem: list }
- FolderListModel {
- id: folderModel
- nameFilters: [ "*.xml", "*.XML" ]
- sortField: "Type"
- }
- onStatusChanged: {
- if (status == PageStatus.Active) {
- /*
- if (engine.pathExist(lastPath)) {
- setCurrentFolder(lastPath)
- }
- else {
- setCurrentFolder("/home/user/MyDocs")
- }*/
- }/* else if (status == PageStatus.Activating) {
- }*/
- }
- }
|