File: AppListView.qml

package info (click to toggle)
software-center 5.1.2debian3.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,708 kB
  • sloc: python: 28,999; xml: 379; sh: 127; makefile: 28
file content (209 lines) | stat: -rw-r--r-- 6,337 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
 * Copyright 2011 Canonical Ltd.
 *
 * Authors:
 *  Olivier Tilloy <olivier@tilloy.net>
 *  Michael Vogt <mvo@ubuntu.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 1.0

FocusScope {
    id: applistview

    property alias count: list.count
    property alias currentItem: list.currentItem
    property alias model: list.model

    signal moreInfoClicked

    clip: true

    Rectangle {
        color: activePalette.base
        anchors.fill: parent
    }

    ScrollBar {
        id: scrollbar
        width: 6
        height: parent.height
        orientation: Qt.Vertical

        anchors.right: parent.right
        position: list.visibleArea.yPosition
        pageSize: list.visibleArea.heightRatio
        visible: list.count > 0
    }

    ListView {
        id: list
        height: parent.height
        anchors.left: parent.left
        anchors.right: scrollbar.left
        spacing: 5
        focus: true

        SystemPalette {
            id: activePalette
            colorGroup: SystemPalette.Active
        }

        SystemPalette {
            id: inactivePalette
            colorGroup: SystemPalette.Inactive
        }

        delegate: Rectangle {
            property string appname: _appname
            property string pkgname: _pkgname
            property string icon: _icon
            property string summary: _summary
            property bool installed: _installed
            property string description: _description
            property double ratingsaverage: _ratings_average
            property int ratingstotal: _ratings_total
            property int installremoveprogress: _installremoveprogress
        
            width: parent.width
            height: ListView.isCurrentItem ? 75 : 40
            Behavior on height {
                NumberAnimation { duration: 40 }
            }

            color: {
                if (!ListView.isCurrentItem) return activePalette.base
                if (list.activeFocus) return activePalette.highlight
                else return inactivePalette.highlight
            }

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    list.forceActiveFocus()
                    list.currentIndex = index
                }
            }

            Image {
                id: iconimg
                height: 24
                width: height
                anchors.top: parent.top
                anchors.topMargin: 3
                anchors.left: parent.left
                anchors.leftMargin: 3
                sourceSize.height: height
                sourceSize.width: width
                source: icon
                asynchronous: true

                Image {
                    id: installedemblem
                    height: 16
                    width: height
                    sourceSize.height: height
                    sourceSize.width: width
                    source: "file:///usr/share/software-center/icons/software-center-installed.png"
                    anchors.horizontalCenter: parent.right
                    anchors.verticalCenter: parent.bottom
                    asynchronous: true
                    visible: installed
                }
            }

            Text {
                id: appnametxt
                height: 20
                anchors.top: parent.top
                anchors.topMargin: 3
                width: parent.width - iconimg.witdh - 15
                x: iconimg.x + iconimg.width + 10
                text: appname
            }

            Text {
                id: summarytxt
                height: 20
                anchors.top: appnametxt.bottom
                width: appnametxt.width
                x: appnametxt.x
                font.pointSize:  appnametxt.font.pointSize * 0.8
                text: summary
            }

            Item {
                id: ratings
                anchors.top: parent.top
                anchors.right: parent.right
                anchors.margins: 5
                visible: !progressbar.visible && (ratingstotal > 0)

                Stars {
                    id: ratingstars
                    anchors.top: parent.top
                    anchors.right: parent.right
                    height: 16
                    ratings_average: ratingsaverage
                }

                Text {
                    text: qsTr("%1 Ratings").arg(ratingstotal)
                    anchors.top: ratingstars.bottom
                    anchors.right: parent.right
                }
            }

            ProgressBar {
                id: progressbar
                width: 100
                anchors.top: appnametxt.top
                anchors.right: parent.right
                anchors.margins: 10
                height: appnametxt.height
                progress: installremoveprogress
                visible: parent.ListView.isCurrentItem && (progress != -1)
            }

            Button {
                id: moreinfobtn
                text: qsTr("More Info")

                anchors.top: summarytxt.bottom
                x: summarytxt.x
                visible: parent.ListView.isCurrentItem

                onClicked: applistview.moreInfoClicked()
            }

            Button {
                text: installed ? qsTr("Remove") : qsTr("Install")

                anchors.top: summarytxt.bottom
                anchors.right: parent.right
                anchors.rightMargin: 10
                visible: parent.ListView.isCurrentItem

                onClicked: {
                    if (installed) 
                        list.model.removePackage(pkgname)
                    else
                        list.model.installPackage(pkgname)
                }
            }
        }
    }
}