~ubuntu-branches/ubuntu/natty/plasma-mobile/natty

« back to all changes in this revision

Viewing changes to bindings/mobilecomponents/IconGrid.qml

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Belem
  • Date: 2011-01-01 16:58:27 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110101165827-vij700zj247uxcdr
Tags: 0.0~svn20110101-0ubuntu1
* New svn snapshot
* Remove kubuntu_01_library_version.diff and
  debian-changes-0.0~svn20100830-0ubuntu4, they don't apply and aren't
  needed in the current snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2010 Marco Martin <notmart@gmail.com>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
import Qt 4.7
 
21
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
 
22
import org.kde.plasma.core 0.1 as PlasmaCore
 
23
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
 
24
 
 
25
 
 
26
Item {
 
27
    id: main
 
28
 
 
29
    property Component delegate
 
30
    property QtObject model
 
31
    property string searchQuery
 
32
 
 
33
    PlasmaCore.Theme {
 
34
        id:theme
 
35
    }
 
36
 
 
37
    Flickable {
 
38
        id: mainFlickable
 
39
        interactive:true
 
40
        contentWidth: container.width; contentHeight: container.height
 
41
        anchors.fill: parent
 
42
        clip: true
 
43
        
 
44
 
 
45
        Column {
 
46
            id: container
 
47
            width: mainFlickable.width
 
48
            Component.onCompleted: {
 
49
                mainFlickable.contentY = searchFieldContainer.height
 
50
            }
 
51
 
 
52
            Item {
 
53
                id: searchFieldContainer
 
54
                width: parent.width
 
55
                height: 128
 
56
                PlasmaCore.FrameSvgItem {
 
57
                    id : background
 
58
                    imagePath: "widgets/lineedit"
 
59
                    prefix: "base"
 
60
 
 
61
                    width: 300
 
62
                    height: 35
 
63
                    anchors.horizontalCenter: parent.horizontalCenter
 
64
                    anchors.verticalCenter: parent.verticalCenter
 
65
                    TextInput {
 
66
                        id: searchField
 
67
                        anchors.fill:parent
 
68
                        anchors.leftMargin: background.margins.left
 
69
                        anchors.rightMargin: background.margins.right
 
70
                        anchors.topMargin: background.margins.top
 
71
                        anchors.bottomMargin: background.margins.bottom
 
72
                        onTextChanged: {
 
73
                            searchTimer.running = true
 
74
                        }
 
75
                    }
 
76
                    PropertyAnimation {
 
77
                        id: hideSearchFieldAnim
 
78
                        target: mainFlickable
 
79
                        properties: "contentY"
 
80
                        duration: 300
 
81
                    }
 
82
                    Timer {
 
83
                        id: searchTimer
 
84
                        interval: 500;
 
85
                        running: false
 
86
                        repeat: false
 
87
                        onTriggered: {
 
88
                            if (searchField.text == "") {
 
89
                                clearButton.visible = false
 
90
                            } else {
 
91
                                clearButton.visible = true
 
92
                            }
 
93
                            searchQuery = searchField.text
 
94
                            hideSearchFieldAnim.to = searchFieldContainer.height;
 
95
                            hideSearchFieldAnim.running = true;
 
96
                        }
 
97
                    }
 
98
                    PlasmaWidgets.IconWidget {
 
99
                        id: clearButton
 
100
                        anchors.verticalCenter: parent.verticalCenter
 
101
                        anchors.right: parent.right
 
102
                        anchors.rightMargin: -10
 
103
                        visible: false
 
104
                        size: "64x64"
 
105
                        Component.onCompleted: {
 
106
                            setIcon("edit-clear-locationbar-rtl")
 
107
                        }
 
108
                        onClicked: {
 
109
                            searchField.text = ""
 
110
                        }
 
111
                    }
 
112
                }
 
113
            }
 
114
            ListView {
 
115
                id: appsView
 
116
                objectName: "appsView"
 
117
                width: mainFlickable.width
 
118
                height: mainFlickable.height
 
119
 
 
120
                model: main.model?Math.ceil(main.model.count/18.0):0
 
121
                highlightRangeMode: ListView.StrictlyEnforceRange
 
122
                orientation: ListView.Horizontal
 
123
                snapMode: ListView.SnapOneItem
 
124
 
 
125
                clip: true
 
126
                signal clicked(string url)
 
127
 
 
128
 
 
129
                delegate: Item {
 
130
                    width: appsView.width
 
131
                    height: appsView.height
 
132
                    Grid {
 
133
                        anchors.horizontalCenter: parent.horizontalCenter
 
134
                        rows: appsView.width > 600 ? 3 : 5
 
135
                        Repeater {
 
136
                            model: MobileComponents.PagedProxyModel {
 
137
                                sourceModel: main.model
 
138
                                currentPage: index
 
139
                                pageSize: 18
 
140
                            }
 
141
                            delegate: main.delegate
 
142
                        }
 
143
                    }
 
144
                }
 
145
            }
 
146
        }
 
147
    }
 
148
    Item {
 
149
        anchors.left: parent.left
 
150
        anchors.right: parent.right
 
151
        anchors.top: mainFlickable.bottom
 
152
        anchors.topMargin: 10
 
153
        Row {
 
154
            anchors.centerIn: parent
 
155
            spacing: 20
 
156
 
 
157
            Repeater {
 
158
                model: main.model?Math.ceil(main.model.count/18.0):0
 
159
 
 
160
                Rectangle {
 
161
                    y: appsView.currentIndex == index ? -2 : 0
 
162
                    width: appsView.currentIndex == index ? 10 : 6
 
163
                    height: appsView.currentIndex == index ? 10 : 6
 
164
                    radius: 4
 
165
                    smooth: true
 
166
                    color: appsView.currentIndex == index ? Qt.rgba(1,1,1,1) : Qt.rgba(1,1,1,0.6)
 
167
 
 
168
                    MouseArea {
 
169
                        width: 20; height: 20
 
170
                        anchors.centerIn: parent
 
171
                        onClicked: appsView.currentIndex = index
 
172
                    }
 
173
                }
 
174
            }
 
175
        }
 
176
    }
 
177
}