ea5d0e8f6688a6df9de6fd9adb20939d3569c36d
[harmattan/cameraplus] / qml / PostCapturePage.qml
1 // -*- qml -*-
2 import QtQuick 1.1
3 import com.nokia.meego 1.1
4 import QtCamera 1.0
5 import QtSparql 1.0
6 import CameraPlus 1.0
7
8 // QML QtGallery stuff is crap.
9 // Most of the ideas (and some code) for loading and displaying images are stolen from
10 // N9QmlPhotoPicker https://github.com/petrumotrescu/N9QmlPhotoPicker
11
12 // TODO: this is really basic.
13
14 Page {
15         id: page
16         property Camera cam: null
17
18         Rectangle {
19                 color: "black"
20                 anchors.fill: parent
21         }
22
23         PathView {
24                 id: view
25                 anchors.fill: parent
26
27                 path: Path {
28                         startX: - view.width
29                         startY: view.height / 2
30                         PathLine { x: view.width * 2; y: view.height / 2 }
31                 }
32
33                 flickDeceleration: 999999 // Insanely high value to prevent panning multiple images
34                 preferredHighlightBegin: 0.5
35                 preferredHighlightEnd: 0.5
36                 highlightRangeMode: PathView.StrictlyEnforceRange
37                 pathItemCount: 3
38
39                 model: SparqlListModel {
40                         query: "SELECT nie:url(?urn) AS ?url tracker:id(?urn) AS ?trackerid nie:mimeType(?urn) AS ?mime WHERE { ?urn rdf:type nfo:Media .  ?urn nfo:equipment \"urn:equipment:" + deviceInfo.manufacturer + ":" + deviceInfo.model + ":\" ; tracker:available \"true\"^^xsd:boolean  OPTIONAL { ?urn nie:contentCreated ?created }   }  ORDER BY DESC (?created)"
41
42                         connection: SparqlConnection {
43                                 id: connection
44                                 driver: "QTRACKER_DIRECT"
45                                 onStatusChanged: checkStatus(status)
46
47                                 function checkStatus(status) {
48                                         if (status == SparqlConnection.Error)
49                                         console.log("Error = "+connection.errorString());
50                                 }
51                         }
52                 }
53
54                 delegate: Item {
55                         width: view.width
56                         height: view.height
57
58                         Label {
59                                 width: view.width - 10
60                                 height: view.height
61                                 anchors.centerIn: parent
62                                 visible: item.error
63                                 text: qsTr("Failed to load preview");
64                                 verticalAlignment: Text.AlignVCenter
65                                 horizontalAlignment: Text.AlignHCenter
66                                 font.pixelSize: 32
67                         }
68
69                         QuillItem {
70                                 id: item
71                                 source: url
72                                 mimeType: mime
73                                 width: view.width - 10
74                                 height: view.height
75                                 anchors.centerIn: parent
76                         }
77                 }
78         }
79
80         ToolBar {
81                 id: toolBar
82                 opacity: 0.8
83                 anchors.bottom: parent.bottom
84                 tools: ToolBarLayout {
85                         id: layout
86                         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
87                 }
88         }
89 }