demos/declarative/flickr/flickr.qml
changeset 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 import Qt 4.7
       
    43 import "common" as Common
       
    44 import "mobile" as Mobile
       
    45 
       
    46 Item {
       
    47     id: screen; width: 320; height: 480
       
    48     property bool inListView : false
       
    49 
       
    50     Rectangle {
       
    51         id: background
       
    52         anchors.fill: parent; color: "#343434";
       
    53 
       
    54         Image { source: "mobile/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
       
    55 
       
    56         Common.RssModel { id: rssModel }
       
    57 
       
    58         Item {
       
    59             id: views
       
    60             x: 2; width: parent.width - 4
       
    61             anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
       
    62 
       
    63             Mobile.GridDelegate { id: gridDelegate }
       
    64             GridView {
       
    65                 x: (width/4-79)/2; y: x
       
    66                 id: photoGridView; model: rssModel; delegate: gridDelegate; cacheBuffer: 100
       
    67                 cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height - 1; z: 6
       
    68             }
       
    69 
       
    70             Mobile.ListDelegate { id: listDelegate }
       
    71             ListView {
       
    72                 id: photoListView; model: rssModel; delegate: listDelegate; z: 6
       
    73                 width: parent.width; height: parent.height; x: -(parent.width * 1.5); cacheBuffer: 100;
       
    74             }
       
    75             states: State {
       
    76                 name: "ListView"; when: screen.inListView == true
       
    77                 PropertyChanges { target: photoListView; x: 0 }
       
    78                 PropertyChanges { target: photoGridView; x: -(parent.width * 1.5) }
       
    79             }
       
    80 
       
    81             transitions: Transition {
       
    82                 NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
       
    83             }
       
    84         }
       
    85 
       
    86         Mobile.ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height; z:1 }
       
    87         Mobile.TitleBar { id: titleBar; z: 5; width: parent.width; height: 40; opacity: 0.9 }
       
    88 
       
    89         Mobile.ToolBar {
       
    90             id: toolBar; z: 5
       
    91             height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
       
    92             button1Label: "Update"; button2Label: "View mode"
       
    93             onButton1Clicked: rssModel.reload()
       
    94             onButton2Clicked: if (screen.inListView == true) screen.inListView = false; else screen.inListView = true
       
    95         }
       
    96 
       
    97         Connections {
       
    98             target: imageDetails
       
    99             onClosed: {
       
   100                 if (background.state == "DetailedView") {
       
   101                     background.state = '';
       
   102                     imageDetails.photoUrl = "";
       
   103                 }
       
   104             }
       
   105         }
       
   106 
       
   107         states: State {
       
   108             name: "DetailedView"
       
   109             PropertyChanges { target: views; x: -parent.width }
       
   110             PropertyChanges { target: toolBar; button1Label: "More..." }
       
   111             PropertyChanges {
       
   112                 target: toolBar
       
   113                 onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state=''
       
   114             }
       
   115             PropertyChanges { target: toolBar; button2Label: "Back" }
       
   116             PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() }
       
   117         }
       
   118 
       
   119         transitions: Transition {
       
   120             NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
       
   121         }
       
   122     }
       
   123 }