blob: d519ebfac5f8e49d0543f9e73d29f7e1a1f6b406 (
plain)
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
|
/****************************************************************************
**
** Copyright (C) 2015 Pelagicore AG
** Contact: http://www.pelagicore.com/
**
** This file is part of Neptune IVI UI.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Neptune IVI UI licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Pelagicore. For licensing terms
** and conditions see http://www.pelagicore.com.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3 requirements will be
** met: http://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.1
import QtQuick.Layouts 1.0
import controls 1.0
import utils 1.0
import service.apps 1.0
import "JSONBackend.js" as JSONBackend
import com.pelagicore.ApplicationInstaller 0.1
Item {
id: root
property int categoryid: 1
property string filter: ""
function download(id) {
var url = appstore.server + "/app/purchase"
var data = {"id": id, "device_id" : "00-11-22-33-44-55" }
JSONBackend.serverCall(url, data, function(data) {
if (data !== 0) {
if (data.status === "ok") {
print("start downloading")
var icon = appstore.server + "/app/icon?id=" + id
var installID = ApplicationInstaller.startPackageInstallation("internal-0", data.url);
ApplicationInstaller.acknowledgePackageInstallation(installID);
} else if (data.status === "fail" && data.error === "not-logged-in"){
print(":::AppStoreController::: not logged in")
} else {
print(":::AppStoreController::: download failed: " + data.error)
}
}
})
}
AppStore {
id: appstore
onLoginSuccessful: categoriesModel.refresh()
}
JSONModel {
id: categoriesModel
url: appstore.server + "/category/list"
}
JSONModel {
id: appModel
url: appstore.server + "/app/list"
data: root.categoryid >= 0 ? { "filter" : root.filter , "category_id" : root.categoryid} : { "filter" : root.filter}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
Column {
width: Style.hspan(4)
ListViewManager {
id: categoryView
anchors.left: parent.left; anchors.right: parent.right
vspan: 14
model: categoriesModel
header: Label {
// The graphics for the category list is not align to the grid, have to specify hardcoded values.
height: Style.vspan(5/3)
anchors.left: parent.left; anchors.right: parent.right
anchors.margins: Style.paddingXL
text: "CATEGORY"
font.pixelSize: Style.fontSizeM
}
delegate: CategoryListItem {
width: ListView.view.width
height: Style.vspan(5/3)
text: model.name //.title
onClicked: ListView.view.currentIndex = index
}
onCurrentIndexChanged: {
appGrid.appCategory = model.get(currentIndex) ? model.get(currentIndex).name : ""
categoryid = model.get(currentIndex) ? model.get(currentIndex).id : 1
appModel.refresh()
}
}
}
AppGridView {
id: appGrid
// The graphics for the category list is not align to the grid, have to specify hardcoded values.
width: Style.hspan(3)*4
height: root.height
loading: categoriesModel.status !== "ready" || appModel.status !== "ready"
cellWidth: Style.hspan(3)
cellHeight:Style.vspan(5)
appCategory: ""
model: appModel
delegate: AppGridItemDelegate {
width: GridView.view.cellWidth
height: GridView.view.cellHeight
icon: appstore.server + "/app/icon?id=" + model.id //model.icon
titleText: model.name //model.title
subtitleText: model.category //model.subtitle
onClicked: download(model.id)
}
}
}
Image {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
source: Style.icon('appstore_bottom_shadow')
asynchronous: true
visible: false
}
}
|