~aacid/unity8/moreAsyncAudioCard

« back to all changes in this revision

Viewing changes to qml/Dash/PreviewView.qml

  • Committer: Albert Astals Cid
  • Date: 2016-03-10 08:32:16 UTC
  • mfrom: (2136.2.83 unity8)
  • Revision ID: albert.astals@canonical.com-20160310083216-8nnplxl85qx13xd0
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
Item {
24
24
    id: root
25
25
 
26
 
    property int initialIndex: -1
27
 
    property var initialIndexPreviewStack: null
 
26
    property bool open: false
28
27
    property var scope: null
29
28
    property var scopeStyle: null
30
 
    property string categoryId
31
 
    property bool usedInitialIndex: false
32
 
 
33
29
    property alias showSignatureLine: header.showSignatureLine
34
 
 
35
 
    property alias open: previewListView.open
36
 
    property alias model: previewListView.model
37
 
    property alias currentIndex: previewListView.currentIndex
38
 
    property alias currentItem: previewListView.currentItem
39
 
    property alias count: previewListView.count
40
 
 
41
 
    readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
42
 
                                                       || currentItem.previewModel.processingAction)
 
30
    property alias previewModel: preview.previewModel
 
31
    readonly property bool processing: previewModel && (!previewModel.loaded || previewModel.processingAction)
43
32
 
44
33
    signal backClicked()
45
34
 
55
44
        onBackClicked: root.backClicked()
56
45
    }
57
46
 
58
 
    ListView  {
59
 
        id: previewListView
60
 
        objectName: "listView"
 
47
    onOpenChanged: {
 
48
        if (!open) {
 
49
            root.scope.cancelActivation();
 
50
        }
 
51
    }
 
52
 
 
53
    Previews.Preview {
 
54
        id: preview
 
55
        objectName: "preview"
61
56
        anchors {
62
57
            top: header.bottom
63
58
            bottom: parent.bottom
64
59
            left: parent.left
65
60
            right: parent.right
66
61
        }
67
 
        orientation: ListView.Horizontal
68
 
        highlightRangeMode: ListView.StrictlyEnforceRange
69
 
        snapMode: ListView.SnapOneItem
70
 
        boundsBehavior: Flickable.DragAndOvershootBounds
71
 
        highlightMoveDuration: 250
72
 
        flickDeceleration: units.gu(625)
73
 
        maximumFlickVelocity: width * 5
74
 
        cacheBuffer: 0
75
 
 
76
 
        property bool open: false
77
 
 
78
 
        onOpenChanged: {
79
 
            if (!open) {
80
 
                // Cancel any pending preview requests or actions
81
 
                if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
82
 
                    previewListView.currentItem.previewData.cancelAction();
83
 
                }
84
 
                root.scope.cancelActivation();
85
 
                model = undefined;
86
 
            }
87
 
        }
88
 
 
89
 
        onModelChanged: {
90
 
            if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
91
 
                usedInitialIndex = true;
92
 
                previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
93
 
            }
94
 
        }
95
 
 
96
 
        delegate: Previews.Preview {
97
 
            id: preview
98
 
            objectName: "preview" + index
99
 
            height: previewListView.height
100
 
            width: previewListView.width
101
 
 
102
 
            isCurrent: ListView.isCurrentItem
103
 
 
104
 
            readonly property var previewStack: {
105
 
                if (root.open) {
106
 
                    if (index === root.initialIndex) {
107
 
                        return root.initialIndexPreviewStack;
108
 
                    } else {
109
 
                        return root.scope.preview(result, root.categoryId);
110
 
                    }
111
 
                } else {
112
 
                    return null;
113
 
                }
114
 
            }
115
 
 
116
 
            previewModel: {
117
 
                if (previewStack) {
118
 
                    return previewStack.getPreviewModel(0);
119
 
                } else {
120
 
                    return null;
121
 
                }
122
 
            }
123
 
 
124
 
            scopeStyle: root.scopeStyle
125
 
        }
 
62
        scopeStyle: root.scopeStyle
126
63
    }
127
64
 
128
65
    MouseArea {
129
66
        id: processingMouseArea
130
67
        objectName: "processingMouseArea"
131
68
        anchors {
 
69
            top: header.bottom
 
70
            bottom: parent.bottom
132
71
            left: parent.left
133
72
            right: parent.right
134
 
            top: header.bottom
135
 
            bottom: parent.bottom
136
73
        }
137
 
 
138
74
        enabled: root.processing
139
75
    }
140
76
}