~ubuntu-branches/ubuntu/saucy/plasma-mobile/saucy

« back to all changes in this revision

Viewing changes to applications/filebrowser/package/contents/ui/main.qml

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-09-17 14:08:58 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20130917140858-wv7n3z6t95iy1fs9
Tags: 1:0.5-0ubuntu1
* New upstream release LP: #1227602
* Use epoch to sync with upstream version number
* Build-dep on libxcursor-dev
* Add kubuntu_no_contourd.diff to disable contourd from building,
  does not compile with 4.11 and not used by default
* Depend on renamed package ksplash-theme-active
* Add kubuntu_no_dirmodel.diff to prevert compile of dirmodel,
  included in kde-runtime 4.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import org.kde.plasma.components 0.1 as PlasmaComponents
25
25
import org.kde.plasma.extras 0.1 as PlasmaExtras
26
26
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
27
 
import org.kde.plasma.slccomponents 0.1 as SlcComponents
28
27
 
29
28
 
30
29
Image {
31
30
    id: fileBrowserRoot
 
31
 
 
32
    //BEGIN properties
 
33
    width: 360
 
34
    height: 360
 
35
    
 
36
    property QtObject model: metadataModel
 
37
    
32
38
    objectName: "fileBrowserRoot"
33
39
    source: "image://appbackgrounds/contextarea"
34
40
    fillMode: Image.Tile
35
41
    state: "browsing"
36
 
    property QtObject model: metadataModel
37
 
 
38
 
    width: 360
39
 
    height: 360
40
 
 
41
 
    MobileComponents.Package {
42
 
        id: partPackage
43
 
    }
44
 
 
45
 
    PlasmaExtras.ResourceInstance {
46
 
        id: resourceInstance
47
 
    }
48
 
 
49
 
    MetadataModels.MetadataUserTypes {
50
 
        id: userTypes
51
 
    }
 
42
    //END properties
 
43
 
 
44
    //BEGIN model
 
45
    PlasmaCore.DataSource {
 
46
        id: metadataSource
 
47
        engine: "org.kde.active.metadata"
 
48
        //connectedSources: []
 
49
    }
 
50
 
52
51
    MetadataModels.MetadataModel {
53
52
        id: metadataModel
54
 
        sortBy: [userTypes.sortFields[metadataModel.resourceType]]
55
 
        //sortOrder: Qt.DescendingOrder
56
 
        //queryString: "pdf"
57
 
        resourceType: exclusiveResourceType
58
 
        mimeTypes: exclusiveMimeTypes
 
53
        queryProvider: MetadataModels.ResourceQueryProvider {
 
54
            sortBy: [userTypes.sortFields[metadataModel.queryProvider.resourceType]]
 
55
            //This query string part is set by the user in the search field
 
56
            property string userQueryString
 
57
            //this query string part may be set by Browser addons
 
58
            property string extraQueryString
 
59
            queryString: userQueryString + (extraQueryString ? (" " + extraQueryString) : "")
 
60
            resourceType: exclusiveResourceType
 
61
            mimeTypes: exclusiveMimeTypes
 
62
        }
59
63
    }
 
64
 
60
65
    PlasmaCore.DataSource {
61
66
        id: activitySource
62
67
        engine: "org.kde.activities"
63
68
        connectedSources: ["Status"]
64
69
    }
 
70
 
65
71
    DirModel {
66
72
        id: dirModel
67
73
    }
68
 
    function goBack()
69
 
    {
70
 
        toolBar.y = 0
 
74
    PlasmaCore.DataSource {
 
75
        id: hotplugSource
 
76
        engine: "hotplug"
 
77
        connectedSources: sources
 
78
    }
 
79
    PlasmaCore.DataSource {
 
80
        id: devicesSource
 
81
        engine: "soliddevice"
 
82
        connectedSources: hotplugSource.sources
 
83
        onDataChanged: {
 
84
            //access it here due to the async nature of the dataengine
 
85
            if (resultsGrid.model == dirModel) {
 
86
                var udi
 
87
                var path
 
88
 
 
89
                for (var i in devicesSource.connectedSources) {
 
90
                    udi = devicesSource.connectedSources[i]
 
91
                    path = devicesSource.data[udi]["File Path"]
 
92
                    print(udi+dirModel.url.indexOf(udi))
 
93
                    if (dirModel.url.indexOf(path) > 2) {
 
94
                        resourceBrowser.currentUdi = udi
 
95
                        break
 
96
                    }
 
97
                }
 
98
            } else if (resultsGrid.model != dirModel && devicesSource.data[resourceBrowser.currentUdi]["File Path"] != "") {
 
99
                dirModel.url = devicesSource.data[resourceBrowser.currentUdi]["File Path"]
 
100
 
 
101
                fileBrowserRoot.model = dirModel
 
102
            }
 
103
        }
 
104
    }
 
105
    //END model
 
106
 
 
107
    //BEGIN functions    
 
108
    function goBack() {
 
109
        toolBar.y = 0;
 
110
 
71
111
        //don't go more back than the browser
72
112
        if (mainStack.currentPage.objectName == "resourceBrowser") {
73
 
            return
 
113
            return;
74
114
        }
 
115
 
75
116
        if (mainStack.depth == 1) {
76
 
            if (exclusiveResourceType || exclusiveMimeTypes.length > 0) {
77
 
                mainStack.replace(Qt.createComponent("Browser.qml"))
78
 
            } else {
79
 
                mainStack.replace(Qt.createComponent("Intro.qml"))
80
 
            }
 
117
            mainStack.replace(Qt.createComponent("Browser.qml"))
81
118
        } else {
82
 
            mainStack.pop()
 
119
            mainStack.pop();
83
120
        }
84
121
    }
85
122
 
86
 
    PlasmaComponents.BusyIndicator {
87
 
        anchors.centerIn: mainStack
88
 
        visible: metadataModel.running
89
 
        running: visible
 
123
    Image {
 
124
        anchors {
 
125
            centerIn: parent
 
126
            verticalCenterOffset: Math.round(toolBar.height/2)
 
127
            horizontalCenterOffset: - Math.round(parent.width / 8)
 
128
        }
 
129
        x: y
 
130
        source: "background-logo.png"
90
131
    }
91
132
 
92
133
    PlasmaComponents.ToolBar {
93
134
        id: toolBar
94
 
        height: tools ? theme.hugeIconSize : 0
 
135
        height: tools && tools.item !== null ? theme.hugeIconSize : 0
95
136
    }
96
137
 
97
 
    function openFile(url, mimeType)
 
138
    function openResource(data)
98
139
    {
99
 
        if (mimeType == "inode/directory") {
100
 
            dirModel.url = url
 
140
        if (data.mimeType == "inode/directory") {
 
141
            dirModel.url = data.url
101
142
            fileBrowserRoot.model = dirModel
102
143
        } else if (!mainStack.busy) {
103
 
            var packageName = application.packageForMimeType(mimeType)
104
 
            print("Package for mimetype " + mimeType + " " + packageName)
 
144
            var packageName = application.viewerPackageForType(data.mimeType)
 
145
            print("Package for mimetype " + data.mimeType + " " + packageName)
105
146
            if (packageName) {
106
147
                partPackage.name = packageName
107
148
                if (partPackage.visibleName && partPackage.visibleName != '') {
110
151
                    application.caption = i18n('Files')
111
152
                }
112
153
                var part = mainStack.push(partPackage.filePath("mainscript"))
113
 
                part.loadFile(url)
 
154
                part.loadResource(data)
114
155
            } else {
115
 
                Qt.openUrlExternally(url)
 
156
                Qt.openUrlExternally(data.url)
116
157
            }
117
158
        }
118
159
    }
119
 
 
120
 
    PlasmaComponents.PageStack {
121
 
        id: mainStack
122
 
        clip: false
123
 
        toolBar: toolBar
124
 
        //initialPage: Qt.createComponent("Browser.qml")
125
 
        anchors {
126
 
            top: parent.top
127
 
            bottom: parent.bottom
128
 
            left: parent.left
129
 
        }
 
160
    //END functions
 
161
 
 
162
    //BEGIN non-UI components
 
163
    PlasmaExtras.ResourceInstance {
 
164
        id: resourceInstance
 
165
    }
 
166
 
 
167
    MobileComponents.Package {
 
168
        id: partPackage
 
169
    }
 
170
 
 
171
    MetadataModels.MetadataUserTypes {
 
172
        id: userTypes
130
173
    }
131
174
 
132
175
    Timer {
136
179
            if (mainStack.depth > 0) {
137
180
                return
138
181
            }
139
 
            if (exclusiveResourceType || exclusiveMimeTypes.length > 0) {
140
 
                mainStack.push(Qt.createComponent("Browser.qml"))
141
 
            } else {
142
 
                mainStack.push(Qt.createComponent("Intro.qml"))
143
 
            }
 
182
            mainStack.push(Qt.createComponent("Browser.qml"))
144
183
        }
145
184
    }
 
185
    
146
186
    //FIXME: this is due to global vars being binded after the parse is done, do the 2 steps parsing
147
187
    Timer {
148
188
        interval: 100
156
196
                        mainStack.push(Qt.createComponent("Browser.qml"))
157
197
                    }
158
198
                }
159
 
                openFile(path, startupMimeType)
 
199
                openResource({"url": path, "mimeType": startupMimeType})
160
200
            }
161
201
        }
162
202
    }
163
 
    /*SlcComponents.SlcMenu {
164
 
        id: contextMenu
165
 
    }*/
 
203
    //END non-UI components
 
204
 
 
205
 
 
206
    //BEGIN: UI components
 
207
 
 
208
    PlasmaComponents.PageStack {
 
209
        id: mainStack
 
210
        clip: false
 
211
        toolBar: toolBar
 
212
        //initialPage: Qt.createComponent("Browser.qml")
 
213
        anchors {
 
214
            top: parent.top
 
215
            bottom: parent.bottom
 
216
            left: parent.left
 
217
        }
 
218
    }
 
219
 
 
220
    PlasmaComponents.BusyIndicator {
 
221
        anchors.centerIn: mainStack
 
222
        visible: metadataModel.running
 
223
        running: visible
 
224
    }
 
225
 
 
226
    //END UI components
166
227
}