1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the examples of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 ** the names of its contributors may be used to endorse or promote
22 ** products derived from this software without specific prior written
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
42 import "../../../modelviews/listview/content"
44 // This example illustrates expanding a list item to show a more detailed view.
46 // Delegate for the recipes. This delegate has two modes:
47 // 1. List mode (default), which just shows the picture and title of the recipe.
48 // 2. Details mode, which also shows the ingredients and method.
55 // Create a property to contain the visibility of the details.
56 // We can bind multiple element's opacity to this one property,
57 // rather than having a "PropertyChanges" line for each element we
59 property real detailsOpacity : 0
61 //this bit changed for aesthetics
64 // A simple rounded rectangle for the background
67 x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
69 border.color: "orange"
79 // This mouse region covers the entire delegate.
80 // When clicked it changes mode to 'Details'. If we are already
81 // in Details mode, then no change will happen.
84 onClicked: recipe.state = 'Details';
87 // Lay out the page: picture, title and ingredients at the top, and method at the
88 // bottom. Note that elements that should not be visible in the list
89 // mode have their opacity set to recipe.detailsOpacity.
92 x: 10; y: 10; height: recipeImage.height; width: parent.width
98 source: "../../modelviews/listview/" + picture
102 width: background.width - recipeImage.width - 20; height: recipeImage.height
107 font.bold: true; font.pointSize: 16
112 font.pointSize: 12; font.bold: true
113 opacity: recipe.detailsOpacity
118 wrapMode: Text.WordWrap
120 opacity: recipe.detailsOpacity
127 x: 10; width: parent.width - 20
128 anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 }
129 opacity: recipe.detailsOpacity
133 anchors.top: parent.top
135 font.pointSize: 12; font.bold: true
141 anchors { top: methodTitle.bottom; bottom: parent.bottom }
142 contentHeight: methodText.height
145 Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width }
149 anchors { right: flick.right; top: flick.top }
150 source: "../../modelviews/listview/" + "content/pics/moreUp.png"
151 opacity: flick.atYBeginning ? 0 : 1
155 anchors { right: flick.right; bottom: flick.bottom }
156 source: "../../modelviews/listview/" + "content/pics/moreDown.png"
157 opacity: flick.atYEnd ? 0 : 1
161 // A button to close the detailed view, i.e. set the state back to default ('').
164 anchors { right: background.right; rightMargin: 10 }
165 opacity: recipe.detailsOpacity
168 onClicked: recipe.state = '';
174 PropertyChanges { target: background; color: "white" }
175 PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger
176 PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible
177 PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view
179 // Move the list so that this item is at the top.
180 //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y }
182 // Disallow flicking while we're in detailed view
183 //PropertyChanges { target: recipe.ListView.view; interactive: false }
186 transitions: Transition {
187 //The only strictly necessary particle specific lines
190 ScriptAction {script: {
191 if(state == "Details")
197 // Make the state changes smooth
199 ColorAnimation { property: "color"; duration: 500 }
200 NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" }