1/**************************************************************************** 2** 3** Copyright (C) 2017 The Qt Company Ltd. 4** Contact: https://www.qt.io/licensing/ 5** 6** This file is part of the examples of the Qt Toolkit. 7** 8** $QT_BEGIN_LICENSE:BSD$ 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 https://www.qt.io/terms-conditions. For further 15** information use the contact form at https://www.qt.io/contact-us. 16** 17** BSD License Usage 18** Alternatively, you may use this file under the terms of the BSD license 19** as follows: 20** 21** "Redistribution and use in source and binary forms, with or without 22** modification, are permitted provided that the following conditions are 23** met: 24** * Redistributions of source code must retain the above copyright 25** notice, this list of conditions and the following disclaimer. 26** * Redistributions in binary form must reproduce the above copyright 27** notice, this list of conditions and the following disclaimer in 28** the documentation and/or other materials provided with the 29** distribution. 30** * Neither the name of The Qt Company Ltd nor the names of its 31** contributors may be used to endorse or promote products derived 32** from this software without specific prior written permission. 33** 34** 35** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46** 47** $QT_END_LICENSE$ 48** 49****************************************************************************/ 50 51import QtQuick 2.0 52import QtQuick.XmlListModel 2.0 53import "flickrcommon" as Common 54import "flickrmobile" as Mobile 55 56Item { 57 id: screen; width: 320; height: 480 58 property bool inListView : false 59 60 Rectangle { 61 id: background 62 anchors.fill: parent; color: "#343434"; 63 64 Image { source: "flickrmobile/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } 65 66 Common.RestModel { 67 id: restModel 68 coordinate: geoTab.coordinate 69 } 70 71 Item { 72 id: views 73 x: 2; width: parent.width - 4 74 anchors.top: titleBar.bottom; anchors.bottom: toolBar.top 75 76 Text { 77 text: qsTr("Network error") 78 font.pixelSize: 48 79 fontSizeMode: Text.HorizontalFit 80 anchors.centerIn: parent 81 width: parent.width * 0.9 82 visible: restModel.status === XmlListModel.Error 83 84 } 85 86 Mobile.GridDelegate { id: gridDelegate } 87 GridView { 88 x: (width/4-79)/2; y: x 89 id: photoGridView; model: restModel; delegate: gridDelegate; cacheBuffer: 100 90 cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height - 1; z: 6 91 } 92 Mobile.ListDelegate { id: listDelegate } 93 ListView { 94 id: photoListView; model: restModel; delegate: listDelegate; z: 6 95 width: parent.width; height: parent.height; x: -(parent.width * 1.5); cacheBuffer: 100; 96 } 97 states: State { 98 name: "ListView"; when: screen.inListView == true 99 PropertyChanges { target: photoListView; x: 0 } 100 PropertyChanges { target: photoGridView; x: -(parent.width * 1.5) } 101 } 102 103 transitions: Transition { 104 NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } 105 } 106 } 107 Mobile.ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height; z:1 } 108 Mobile.TitleBar { id: titleBar; z: 5; width: parent.width; height: 40; opacity: 0.9 } 109 Mobile.GeoTab { 110 id: geoTab; 111 x: 15; y:50; 112 } 113 Mobile.ToolBar { 114 id: toolBar; z: 5 115 height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 116 button1Label: "Update"; button2Label: "View mode" 117 onButton1Clicked: restModel.reload() 118 onButton2Clicked: if (screen.inListView == true) screen.inListView = false; else screen.inListView = true 119 } 120 Connections { 121 target: imageDetails 122 onClosed: { 123 if (background.state == "DetailedView") { 124 background.state = ''; 125 imageDetails.photoUrl = ""; 126 } 127 } 128 } 129 130 states: State { 131 name: "DetailedView" 132 PropertyChanges { target: views; x: -parent.width } 133 PropertyChanges { target: geoTab; x: -parent.width } 134 PropertyChanges { target: toolBar; button1Label: "More..." } 135 PropertyChanges { 136 target: toolBar 137 onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' 138 } 139 PropertyChanges { target: toolBar; button2Label: "Back" } 140 PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() } 141 } 142 143 transitions: Transition { 144 NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } 145 } 146 } 147} 148