Merge lp:~uonedb-qt/u1db-qt/advanced-game into lp:u1db-qt

Proposed by Cris Dywan
Status: Merged
Approved by: Cris Dywan
Approved revision: 117
Merged at revision: 126
Proposed branch: lp:~uonedb-qt/u1db-qt/advanced-game
Merge into: lp:u1db-qt
Diff against target: 419 lines (+378/-0)
8 files modified
examples/advanced-game/AdvancedGame.desktop (+7/-0)
examples/advanced-game/AdvancedGame.json (+6/-0)
examples/advanced-game/AdvancedGame.qml (+83/-0)
examples/advanced-game/AdvancedGame.qmlproject (+53/-0)
examples/advanced-game/CreatePlayerPage.qml (+74/-0)
examples/advanced-game/FilterPlayers.qml (+73/-0)
examples/advanced-game/ListPlayers.qml (+67/-0)
examples/advanced-game/manifest.json (+15/-0)
To merge this branch: bzr merge lp:~uonedb-qt/u1db-qt/advanced-game
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Nekhelesh Ramananthan Pending
Review via email: mp+209920@code.launchpad.net

Commit message

Add new advanced-game example

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Very lovely upgrade! Let's get this in!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'examples/advanced-game'
2=== added file 'examples/advanced-game/AdvancedGame.desktop'
3--- examples/advanced-game/AdvancedGame.desktop 1970-01-01 00:00:00 +0000
4+++ examples/advanced-game/AdvancedGame.desktop 2014-08-25 09:53:24 +0000
5@@ -0,0 +1,7 @@
6+[Desktop Entry]
7+Name=AdvancedGame
8+Exec=/usr/bin/qmlscene $@ /usr/share/AdvancedGame/AdvancedGame.qml
9+Icon=qmlscene
10+Terminal=false
11+Type=Application
12+X-Ubuntu-Touch=true
13
14=== added file 'examples/advanced-game/AdvancedGame.json'
15--- examples/advanced-game/AdvancedGame.json 1970-01-01 00:00:00 +0000
16+++ examples/advanced-game/AdvancedGame.json 2014-08-25 09:53:24 +0000
17@@ -0,0 +1,6 @@
18+{
19+ "policy_groups": [
20+ "networking"
21+ ],
22+ "policy_version": 1.2
23+}
24\ No newline at end of file
25
26=== added file 'examples/advanced-game/AdvancedGame.qml'
27--- examples/advanced-game/AdvancedGame.qml 1970-01-01 00:00:00 +0000
28+++ examples/advanced-game/AdvancedGame.qml 2014-08-25 09:53:24 +0000
29@@ -0,0 +1,83 @@
30+/*
31+ * Copyright (C) 2014 Canonical, Ltd.
32+ *
33+ * Authors:
34+ * Nekhelesh Ramananthan <nik90@ubuntu.com>
35+ *
36+ * This program is free software; you can redistribute it and/or modify
37+ * it under the terms of the GNU Lesser General Public License as published by
38+ * the Free Software Foundation; version 3.
39+ *
40+ * This program is distributed in the hope that it will be useful,
41+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
42+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43+ * GNU Lesser General Public License for more details.
44+ *
45+ * You should have received a copy of the GNU Lesser General Public License
46+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
47+ */
48+
49+import QtQuick 2.2
50+import Ubuntu.Components 1.1
51+
52+// Import U1db to access its functions
53+import U1db 1.0 as U1db
54+
55+MainView {
56+ id: mainView
57+
58+ objectName: "mainView"
59+ applicationName: "com.ubuntu.developer.nik90.AdvancedGame"
60+
61+ width: units.gu(50)
62+ height: units.gu(75)
63+
64+ useDeprecatedToolbar: false
65+
66+ // U1db database to store player profiles
67+ U1db.Database {
68+ id: appDb
69+ path: "playerDatabase"
70+ }
71+
72+ // Common Action available to all pages
73+ Action {
74+ id: addPlayerAction
75+ text: i18n.tr("Add Player")
76+ iconName: "add"
77+ onTriggered: pagestack.push(Qt.resolvedUrl("CreatePlayerPage.qml"))
78+ }
79+
80+ PageStack {
81+ id: pagestack
82+
83+ Component.onCompleted: push(homePage)
84+
85+ Page {
86+ id: homePage
87+ title: i18n.tr("Advanced Game")
88+
89+ head.actions: [
90+ addPlayerAction
91+ ]
92+
93+ Column {
94+ anchors.fill: parent
95+ anchors.margins: units.gu(5)
96+ spacing: units.gu(2)
97+
98+ Button {
99+ width: parent.width
100+ text: i18n.tr("List Players")
101+ onClicked: pagestack.push(Qt.resolvedUrl("ListPlayers.qml"))
102+ }
103+
104+ Button {
105+ width: parent.width
106+ text: i18n.tr("Filter Players")
107+ onClicked: pagestack.push(Qt.resolvedUrl("FilterPlayers.qml"))
108+ }
109+ }
110+ }
111+ }
112+}
113
114=== added file 'examples/advanced-game/AdvancedGame.qmlproject'
115--- examples/advanced-game/AdvancedGame.qmlproject 1970-01-01 00:00:00 +0000
116+++ examples/advanced-game/AdvancedGame.qmlproject 2014-08-25 09:53:24 +0000
117@@ -0,0 +1,53 @@
118+/* File generated by Qt Creator (with Ubuntu Plugin), version 2.8.1 */
119+
120+import QmlProject 1.1
121+
122+Project {
123+ mainFile: "AdvancedGame.qml"
124+
125+ /* Include .qml, .js, and image files from current directory and subdirectories */
126+ QmlFiles {
127+ directory: "."
128+ }
129+ JavaScriptFiles {
130+ directory: "."
131+ }
132+ ImageFiles {
133+ directory: "."
134+ }
135+ Files {
136+ filter: "*.desktop"
137+ }
138+ Files {
139+ filter: "www/*.html"
140+ }
141+ Files {
142+ filter: "Makefile"
143+ }
144+ Files {
145+ directory: "www"
146+ filter: "*"
147+ }
148+ Files {
149+ directory: "www/img/"
150+ filter: "*"
151+ }
152+ Files {
153+ directory: "www/css/"
154+ filter: "*"
155+ }
156+ Files {
157+ directory: "www/js/"
158+ filter: "*"
159+ }
160+ Files {
161+ directory: "tests/"
162+ filter: "*"
163+ }
164+ Files {
165+ directory: "debian"
166+ filter: "*"
167+ }
168+ /* List of plugin directories passed to QML runtime */
169+ importPaths: [ "." ,"/usr/bin","/usr/lib/x86_64-linux-gnu/qt5/qml" ]
170+}
171
172=== added file 'examples/advanced-game/CreatePlayerPage.qml'
173--- examples/advanced-game/CreatePlayerPage.qml 1970-01-01 00:00:00 +0000
174+++ examples/advanced-game/CreatePlayerPage.qml 2014-08-25 09:53:24 +0000
175@@ -0,0 +1,74 @@
176+/*
177+ * Copyright (C) 2014 Canonical, Ltd.
178+ *
179+ * Authors:
180+ * Nekhelesh Ramananthan <nik90@ubuntu.com>
181+ *
182+ * This program is free software; you can redistribute it and/or modify
183+ * it under the terms of the GNU Lesser General Public License as published by
184+ * the Free Software Foundation; version 3.
185+ *
186+ * This program is distributed in the hope that it will be useful,
187+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
188+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189+ * GNU Lesser General Public License for more details.
190+ *
191+ * You should have received a copy of the GNU Lesser General Public License
192+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
193+ */
194+
195+import QtQuick 2.2
196+import Ubuntu.Components 1.1
197+import U1db 1.0 as U1db
198+
199+Page {
200+ id: createUserPage
201+
202+ visible: false
203+ title: i18n.tr("Create Player")
204+
205+ head.actions: [
206+ Action {
207+ id: savePlayerAction
208+ text: i18n.tr("Save Player")
209+ iconName: "save"
210+ onTriggered: {
211+ appDb.putDoc({ "username": userName.text, "userlevel": userlevel.text, "userclass": userClass.selectedIndex})
212+ pageStack.pop()
213+ }
214+ }
215+ ]
216+
217+ Column {
218+ spacing: units.gu(3)
219+ anchors.fill: parent
220+ anchors.margins: units.gu(2)
221+
222+ Column {
223+ width: parent.width
224+ spacing: units.gu(1)
225+ Label { text: i18n.tr("Username") }
226+ TextField {
227+ id: userName
228+ placeholderText: "Username"
229+ width: parent.width
230+ }
231+ }
232+
233+ Column {
234+ width: parent.width
235+ spacing: units.gu(1)
236+ Label { text: i18n.tr("User Level") }
237+ TextField {
238+ id: userlevel
239+ placeholderText: "User Level"
240+ width: parent.width
241+ }
242+ }
243+
244+ OptionSelector {
245+ id: userClass
246+ model: ["Foot Soldier", "Archer", "Giant", "Wizard", "Demolisher"]
247+ }
248+ }
249+}
250
251=== added file 'examples/advanced-game/FilterPlayers.qml'
252--- examples/advanced-game/FilterPlayers.qml 1970-01-01 00:00:00 +0000
253+++ examples/advanced-game/FilterPlayers.qml 2014-08-25 09:53:24 +0000
254@@ -0,0 +1,73 @@
255+/*
256+ * Copyright (C) 2014 Canonical, Ltd.
257+ *
258+ * Authors:
259+ * Nekhelesh Ramananthan <nik90@ubuntu.com>
260+ *
261+ * This program is free software; you can redistribute it and/or modify
262+ * it under the terms of the GNU Lesser General Public License as published by
263+ * the Free Software Foundation; version 3.
264+ *
265+ * This program is distributed in the hope that it will be useful,
266+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
267+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
268+ * GNU Lesser General Public License for more details.
269+ *
270+ * You should have received a copy of the GNU Lesser General Public License
271+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
272+ */
273+
274+import QtQuick 2.2
275+import Ubuntu.Components 1.1
276+import Ubuntu.Components.ListItems 1.0 as ListItem
277+import U1db 1.0 as U1db
278+
279+Page {
280+ id: filterPlayers
281+
282+ visible: false
283+ title: "Filter Players"
284+
285+ U1db.Index {
286+ database: appDb
287+ id: by_player
288+ expression: ["username", "userlevel", "userclass"]
289+ }
290+
291+ U1db.Query {
292+ id: playerQuery
293+ index: by_player
294+ query: [{username:'*'}, {userlevel:'*'},{userclass:userClass.selectedIndex.toString()}]
295+ }
296+
297+ Column {
298+ spacing: units.gu(3)
299+ anchors.fill: parent
300+ anchors.margins: units.gu(2)
301+
302+ Label { text: "Filter by user class" }
303+
304+ OptionSelector {
305+ id: userClass
306+ model: ["Foot Soldier", "Archer", "Giant", "Wizard", "Demolisher"]
307+ }
308+
309+ ListView {
310+ id: players
311+
312+ width: parent.width
313+ height: units.gu(20)
314+
315+ clip: true
316+ model: playerQuery
317+
318+ delegate: ListItem.Subtitled {
319+ text: '%1 Lvl %2'.arg(model.contents.username).arg(model.contents.userlevel)
320+ subText: userClass.model[model.contents.userclass]
321+ removable: true
322+ confirmRemoval: true
323+ onItemRemoved: appDb.deleteDoc(model.docId)
324+ }
325+ }
326+ }
327+}
328
329=== added file 'examples/advanced-game/ListPlayers.qml'
330--- examples/advanced-game/ListPlayers.qml 1970-01-01 00:00:00 +0000
331+++ examples/advanced-game/ListPlayers.qml 2014-08-25 09:53:24 +0000
332@@ -0,0 +1,67 @@
333+/*
334+ * Copyright (C) 2014 Canonical, Ltd.
335+ *
336+ * Authors:
337+ * Nekhelesh Ramananthan <nik90@ubuntu.com>
338+ *
339+ * This program is free software; you can redistribute it and/or modify
340+ * it under the terms of the GNU Lesser General Public License as published by
341+ * the Free Software Foundation; version 3.
342+ *
343+ * This program is distributed in the hope that it will be useful,
344+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
345+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
346+ * GNU Lesser General Public License for more details.
347+ *
348+ * You should have received a copy of the GNU Lesser General Public License
349+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
350+ */
351+
352+import QtQuick 2.2
353+import Ubuntu.Components 1.1
354+import Ubuntu.Components.ListItems 1.0 as ListItem
355+import U1db 1.0 as U1db
356+
357+Page {
358+ id: homePage
359+
360+ visible: false
361+ title: i18n.tr("List Players")
362+
363+ head.actions: [
364+ addPlayerAction
365+ ]
366+
367+ U1db.Index {
368+ database: appDb
369+ id: by_player
370+ expression: ["username", "userlevel", "userclass"]
371+ }
372+
373+ U1db.Query {
374+ id: playerQuery
375+ index: by_player
376+ query: ["*", "*", "*"]
377+ }
378+
379+ Label {
380+ anchors.centerIn: parent
381+ visible: players.count === 0
382+ text: "No players? Add some!"
383+ }
384+
385+ ListView {
386+ id: players
387+ anchors.fill: parent
388+ clip: true
389+ model: playerQuery
390+
391+ delegate: ListItem.Subtitled {
392+ text: model.contents.username
393+ subText: "User Level: " + model.contents.userlevel
394+ removable: true
395+ confirmRemoval: true
396+ onItemRemoved: appDb.deleteDoc(model.docId)
397+ }
398+ }
399+}
400
401=== added file 'examples/advanced-game/manifest.json'
402--- examples/advanced-game/manifest.json 1970-01-01 00:00:00 +0000
403+++ examples/advanced-game/manifest.json 2014-08-25 09:53:24 +0000
404@@ -0,0 +1,15 @@
405+{
406+ "architecture": "all",
407+ "description": "description of AdvancedGame",
408+ "framework": "ubuntu-sdk-14.10-qml-dev3",
409+ "hooks": {
410+ "AdvancedGame": {
411+ "apparmor": "AdvancedGame.json",
412+ "desktop": "AdvancedGame.desktop"
413+ }
414+ },
415+ "maintainer": "Nekhelesh Ramananthan <krnekhelesh@gmail.com>",
416+ "name": "com.ubuntu.developer.nik90.advancedgame",
417+ "title": "AdvancedGame",
418+ "version": "0.1"
419+}

Subscribers

People subscribed via source and target branches

to all changes: