~michael-sheldon/content-hub/qdoc-import-fix

« back to all changes in this revision

Viewing changes to examples/export-qml/export.qml

  • Committer: Guenter Schwann
  • Date: 2013-08-26 17:28:50 UTC
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: guenter.schwann@canonical.com-20130826172850-uu44q1nu3wl72s6e
Add examples for import and export

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
import Ubuntu.Components 0.1
 
3
import Ubuntu.Content 0.1
 
4
 
 
5
Rectangle {
 
6
    id: root
 
7
    width: 300
 
8
    height: 200
 
9
 
 
10
    property bool pickMode: true
 
11
    property list<ContentItem> selectedItems
 
12
    property var activeTransfer
 
13
 
 
14
    function __returnResult() {
 
15
        activeTransfer.items = selectedItems;
 
16
        activeTransfer.state = ContentTransfer.Charged;
 
17
    }
 
18
 
 
19
    Button {
 
20
        id: button1
 
21
        anchors.top: parent.top
 
22
        anchors.left: parent.left
 
23
        enabled: pickMode
 
24
        text: "Return URL1"
 
25
        onClicked: {
 
26
            var result = resultComponent.createObject(root);
 
27
            result.url = "file:///picture_1.jpg";
 
28
            selectedItems = [ result ];
 
29
            root.__returnResult();
 
30
        }
 
31
    }
 
32
    Button {
 
33
        id: button2
 
34
        anchors.top: parent.top
 
35
        anchors.right: parent.right
 
36
        enabled: pickMode
 
37
        text: "Return Url2"
 
38
        onClicked: {
 
39
            var results = [];
 
40
 
 
41
            var result = resultComponent.createObject(root);
 
42
            result.url = "file:///picture_1.jpg";
 
43
            results.push(result);
 
44
 
 
45
            result = resultComponent.createObject(root);
 
46
            result.url = "file:///picture_2.jpg";
 
47
            results.push(result);
 
48
 
 
49
            selectedItems = results;
 
50
            console.log(selectedItems[0].url + "/" + selectedItems[1].url)
 
51
            root.__returnResult();
 
52
        }
 
53
    }
 
54
 
 
55
    Button {
 
56
        id: buttonAbort
 
57
        anchors.bottom: parent.bottom
 
58
        anchors.horizontalCenter: parent.horizontalCenter
 
59
        enabled: pickMode
 
60
        text: "Cancel"
 
61
        onClicked: {
 
62
            root.activeTransfer.state = ContentTransfer.Aborted;
 
63
            root.pickMode = false;
 
64
        }
 
65
    }
 
66
 
 
67
    Component {
 
68
        id: resultComponent
 
69
        ContentItem {}
 
70
    }
 
71
 
 
72
    Connections {
 
73
        target: ContentHub
 
74
        onExportRequested: {
 
75
            root.activeTransfer = transfer
 
76
            root.pickMode = true;
 
77
        }
 
78
    }
 
79
}