Don't show rounded corners
[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: Seems losing resources in post capture will not be recovered from.
34
35 CameraPage {
36         id: page
37
38         controlsVisible: false
39         policyMode: CameraResources.PostCapture
40         needsPipeline: false
41
42         property Item currentItem: null
43
44         function parseDate(str) {
45                 var parts = str.split('T');
46                 var dates = parts[0].split('-');
47                 var times = parts[1].split(':');
48                 return new Date(dates[0], dates[1], dates[2], times[0], times[1], times[2]);
49         }
50
51         Rectangle {
52                 color: "black"
53                 anchors.fill: parent
54         }
55
56         PathView {
57                 id: view
58                 anchors.fill: parent
59
60                 path: Path {
61                         startX: - view.width
62                         startY: view.height / 2
63                         PathLine { x: view.width * 2; y: view.height / 2 }
64                 }
65
66                 flickDeceleration: 999999 // Insanely high value to prevent panning multiple images
67                 preferredHighlightBegin: 0.5
68                 preferredHighlightEnd: 0.5
69                 highlightRangeMode: PathView.StrictlyEnforceRange
70                 pathItemCount: 3
71
72                 model: SparqlListModel {
73                         query: "SELECT nie:url(?urn) AS ?url nie:title(?urn) AS ?title nfo:fileName(?urn) AS ?filename ?created nie:mimeType(?urn) AS ?mimetype ( EXISTS { ?urn nao:hasTag nao:predefined-tag-favorite . } ) AS ?favorite nfo:fileLastModified(?urn) as ?lastmod 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)"
74
75                         connection: SparqlConnection {
76                                 id: connection
77                                 driver: "QTRACKER_DIRECT"
78                                 onStatusChanged: checkStatus(status)
79
80                                 function checkStatus(status) {
81                                         if (status == SparqlConnection.Error) {
82                                                 // TODO: report 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         ToolBar {
106                 opacity: toolBar.opacity
107                 anchors.top: parent.top
108                 visible: toolBar.visible
109
110                 tools: ToolBarLayout {
111                         Label {
112                                 text: currentItem ? currentItem.itemTitle : ""
113                                 anchors.top: parent.top
114                                 anchors.bottom: parent.bottom
115                                 anchors.left: parent.left
116                                 font.bold: true
117                                 verticalAlignment: Text.AlignVCenter
118                         }
119
120                         Label {
121                                 text: currentItem ? Qt.formatDateTime(parseDate(currentItem.creationDate)) : ""
122                                 font.bold: true
123                                 anchors.top: parent.top
124                                 anchors.bottom: parent.bottom
125                                 anchors.right: parent.right
126                                 verticalAlignment: Text.AlignVCenter
127                         }
128                 }
129         }
130 }