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