Reworked
[harmattan/cameraplus] / qml / PostCapturePage.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 import QtQuick 1.1
24 import com.nokia.meego 1.1
25 import QtCamera 1.0
26 import QtSparql 1.0
27 import CameraPlus 1.0
28
29 // QML QtGallery stuff is crap.
30 // Most of the ideas (and some code) for loading and displaying images are stolen from
31 // N9QmlPhotoPicker https://github.com/petrumotrescu/N9QmlPhotoPicker
32
33 // TODO: this is really basic.
34 // TODO: Seems losing resources in post capture will not be recovered from.
35
36 CameraPage {
37         id: page
38
39         controlsVisible: false
40         policyMode: CameraResources.PostCapture
41         needsPipeline: false
42
43         Rectangle {
44                 color: "black"
45                 anchors.fill: parent
46         }
47
48         function stop() {
49                 if (currentItem) {
50                         currentItem.stop();
51                 }
52         }
53
54         PathView {
55                 id: view
56                 anchors.fill: parent
57
58                 path: Path {
59                         startX: - view.width
60                         startY: view.height / 2
61                         PathLine { x: view.width * 2; y: view.height / 2 }
62                 }
63
64                 flickDeceleration: 999999 // Insanely high value to prevent panning multiple images
65                 preferredHighlightBegin: 0.5
66                 preferredHighlightEnd: 0.5
67                 highlightRangeMode: PathView.StrictlyEnforceRange
68                 pathItemCount: 3
69
70                 model: SparqlListModel {
71                         // This is the exact query used by Harmattan gallery.
72                         // Gallery prints it as part of its debugging when
73                         // passing -output-level debug ;-)
74                         query: "SELECT nie:url(?urn) AS ?url nfo:fileName(?urn) AS ?filename ?created nie:mimeType(?urn) AS ?mimetype ( EXISTS { ?urn nao:hasTag nao:predefined-tag-favorite . } ) AS ?favorite nfo:duration(?urn) AS ?duration ?urn \"false\"^^xsd:boolean AS ?isVirtual nfo:fileLastModified(?urn) as ?lastmod nfo:hasRegionOfInterest(?urn) as ?roi tracker:id(?urn) AS ?trackerid WHERE { ?urn rdf:type nfo:Visual ; tracker:available \"true\"^^xsd:boolean . OPTIONAL { ?urn nie:contentCreated ?created } . ?urn nfo:equipment \"urn:equipment:" + deviceInfo.manufacturer + ":" + deviceInfo.model + ":\" . } ORDER BY DESC (?created)"
75
76                         connection: SparqlConnection {
77                                 id: connection
78                                 driver: "QTRACKER_DIRECT"
79                                 onStatusChanged: checkStatus(status)
80
81                                 function checkStatus(status) {
82                                         if (status == SparqlConnection.Error) {
83                                                 console.log("Error = "+connection.errorString());
84                                         }
85                                 }
86                         }
87                 }
88
89                 delegate: PostCaptureItem {
90                         width: view.width - 10
91                         height: view.height
92                 }
93         }
94
95         ToolBar {
96                 id: toolBar
97                 opacity: 0.8
98                 anchors.bottom: parent.bottom
99                 tools: ToolBarLayout {
100                         id: layout
101                         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: { pageStack.pop(); } }
102                 }
103         }
104
105         Rectangle {
106                 // TODO: transitions
107                 id: rect
108                 anchors.top: parent.top
109                 height: toolBar.height
110                 width: parent.width
111                 color: "black"
112                 opacity: toolBar.opacity
113                 visible: toolBar.visible
114                 Row {
115                         anchors.fill: parent
116
117                         Label {
118
119                         }
120
121                         Label {
122
123                         }
124                 }
125         }
126 }