Update copyright headers
[qt:qt.git] / demos / declarative / photoviewer / qml / photoviewer / PhotoViewerCore / AlbumDelegate.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 1.0
43
44 Component {
45     id: albumDelegate
46     Package {
47
48         Item {
49             Package.name: 'browser'
50             GridView {
51                 id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21
52                 x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false
53                 onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain)
54             }
55         }
56
57         Item {
58             Package.name: 'fullscreen'
59             ListView {
60                 id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal
61                 width: mainWindow.width; height: mainWindow.height; interactive: false
62                 onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
63                 highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
64             }
65         }
66
67         Item {
68             Package.name: 'album'
69             id: albumWrapper; width: 210; height: 220
70
71             VisualDataModel {
72                 id: visualModel; delegate: PhotoDelegate { }
73                 model: RssModel { id: rssModel; tags: tag }
74             }
75
76             BusyIndicator {
77                 id: busyIndicator
78                 anchors { centerIn: parent; verticalCenterOffset: -20 }
79                 on: rssModel.status != XmlListModel.Ready
80             }
81
82             PathView {
83                 id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
84                 visible: !busyIndicator.visible
85                 anchors.centerIn: parent; anchors.verticalCenterOffset: -30
86                 path: Path {
87                     PathAttribute { name: 'z'; value: 9999.0 }
88                     PathLine { x: 1; y: 1 }
89                     PathAttribute { name: 'z'; value: 0.0 }
90                 }
91             }
92
93             MouseArea {
94                 anchors.fill: parent
95                 onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
96             }
97
98             Tag {
99                 anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
100                 frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode
101                 onTagChanged: rssModel.tags = tag
102                 onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
103             }
104
105             states: [
106             State {
107                 name: 'inGrid'
108                 PropertyChanges { target: photosGridView; interactive: true }
109                 PropertyChanges { target: albumsShade; opacity: 1 }
110                 PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 }
111             },
112             State {
113                 name: 'fullscreen'; extend: 'inGrid'
114                 PropertyChanges { target: photosGridView; interactive: false }
115                 PropertyChanges { target: photosListView; interactive: true }
116                 PropertyChanges { target: photosShade; opacity: 1 }
117                 PropertyChanges { target: backButton; y: -backButton.height - 8 }
118             }
119             ]
120
121             GridView.onAdd: NumberAnimation {
122                 target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad
123             }
124             GridView.onRemove: SequentialAnimation {
125                 PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true }
126                 NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad }
127                 PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false }
128             }
129
130             transitions: [
131             Transition {
132                 from: '*'; to: 'inGrid'
133                 SequentialAnimation {
134                     NumberAnimation { properties: 'opacity'; duration: 250 }
135                     PauseAnimation { duration: 350 }
136                     NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad }
137                 }
138             },
139             Transition {
140                 from: 'inGrid'; to: '*'
141                 NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 }
142             }
143             ]
144         }
145     }
146 }