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
=== added directory 'examples/advanced-game'
=== added file 'examples/advanced-game/AdvancedGame.desktop'
--- examples/advanced-game/AdvancedGame.desktop 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/AdvancedGame.desktop 2014-08-25 09:53:24 +0000
@@ -0,0 +1,7 @@
1[Desktop Entry]
2Name=AdvancedGame
3Exec=/usr/bin/qmlscene $@ /usr/share/AdvancedGame/AdvancedGame.qml
4Icon=qmlscene
5Terminal=false
6Type=Application
7X-Ubuntu-Touch=true
08
=== added file 'examples/advanced-game/AdvancedGame.json'
--- examples/advanced-game/AdvancedGame.json 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/AdvancedGame.json 2014-08-25 09:53:24 +0000
@@ -0,0 +1,6 @@
1{
2 "policy_groups": [
3 "networking"
4 ],
5 "policy_version": 1.2
6}
0\ No newline at end of file7\ No newline at end of file
18
=== added file 'examples/advanced-game/AdvancedGame.qml'
--- examples/advanced-game/AdvancedGame.qml 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/AdvancedGame.qml 2014-08-25 09:53:24 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Nekhelesh Ramananthan <nik90@ubuntu.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import QtQuick 2.2
21import Ubuntu.Components 1.1
22
23// Import U1db to access its functions
24import U1db 1.0 as U1db
25
26MainView {
27 id: mainView
28
29 objectName: "mainView"
30 applicationName: "com.ubuntu.developer.nik90.AdvancedGame"
31
32 width: units.gu(50)
33 height: units.gu(75)
34
35 useDeprecatedToolbar: false
36
37 // U1db database to store player profiles
38 U1db.Database {
39 id: appDb
40 path: "playerDatabase"
41 }
42
43 // Common Action available to all pages
44 Action {
45 id: addPlayerAction
46 text: i18n.tr("Add Player")
47 iconName: "add"
48 onTriggered: pagestack.push(Qt.resolvedUrl("CreatePlayerPage.qml"))
49 }
50
51 PageStack {
52 id: pagestack
53
54 Component.onCompleted: push(homePage)
55
56 Page {
57 id: homePage
58 title: i18n.tr("Advanced Game")
59
60 head.actions: [
61 addPlayerAction
62 ]
63
64 Column {
65 anchors.fill: parent
66 anchors.margins: units.gu(5)
67 spacing: units.gu(2)
68
69 Button {
70 width: parent.width
71 text: i18n.tr("List Players")
72 onClicked: pagestack.push(Qt.resolvedUrl("ListPlayers.qml"))
73 }
74
75 Button {
76 width: parent.width
77 text: i18n.tr("Filter Players")
78 onClicked: pagestack.push(Qt.resolvedUrl("FilterPlayers.qml"))
79 }
80 }
81 }
82 }
83}
084
=== added file 'examples/advanced-game/AdvancedGame.qmlproject'
--- examples/advanced-game/AdvancedGame.qmlproject 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/AdvancedGame.qmlproject 2014-08-25 09:53:24 +0000
@@ -0,0 +1,53 @@
1/* File generated by Qt Creator (with Ubuntu Plugin), version 2.8.1 */
2
3import QmlProject 1.1
4
5Project {
6 mainFile: "AdvancedGame.qml"
7
8 /* Include .qml, .js, and image files from current directory and subdirectories */
9 QmlFiles {
10 directory: "."
11 }
12 JavaScriptFiles {
13 directory: "."
14 }
15 ImageFiles {
16 directory: "."
17 }
18 Files {
19 filter: "*.desktop"
20 }
21 Files {
22 filter: "www/*.html"
23 }
24 Files {
25 filter: "Makefile"
26 }
27 Files {
28 directory: "www"
29 filter: "*"
30 }
31 Files {
32 directory: "www/img/"
33 filter: "*"
34 }
35 Files {
36 directory: "www/css/"
37 filter: "*"
38 }
39 Files {
40 directory: "www/js/"
41 filter: "*"
42 }
43 Files {
44 directory: "tests/"
45 filter: "*"
46 }
47 Files {
48 directory: "debian"
49 filter: "*"
50 }
51 /* List of plugin directories passed to QML runtime */
52 importPaths: [ "." ,"/usr/bin","/usr/lib/x86_64-linux-gnu/qt5/qml" ]
53}
054
=== added file 'examples/advanced-game/CreatePlayerPage.qml'
--- examples/advanced-game/CreatePlayerPage.qml 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/CreatePlayerPage.qml 2014-08-25 09:53:24 +0000
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Nekhelesh Ramananthan <nik90@ubuntu.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import QtQuick 2.2
21import Ubuntu.Components 1.1
22import U1db 1.0 as U1db
23
24Page {
25 id: createUserPage
26
27 visible: false
28 title: i18n.tr("Create Player")
29
30 head.actions: [
31 Action {
32 id: savePlayerAction
33 text: i18n.tr("Save Player")
34 iconName: "save"
35 onTriggered: {
36 appDb.putDoc({ "username": userName.text, "userlevel": userlevel.text, "userclass": userClass.selectedIndex})
37 pageStack.pop()
38 }
39 }
40 ]
41
42 Column {
43 spacing: units.gu(3)
44 anchors.fill: parent
45 anchors.margins: units.gu(2)
46
47 Column {
48 width: parent.width
49 spacing: units.gu(1)
50 Label { text: i18n.tr("Username") }
51 TextField {
52 id: userName
53 placeholderText: "Username"
54 width: parent.width
55 }
56 }
57
58 Column {
59 width: parent.width
60 spacing: units.gu(1)
61 Label { text: i18n.tr("User Level") }
62 TextField {
63 id: userlevel
64 placeholderText: "User Level"
65 width: parent.width
66 }
67 }
68
69 OptionSelector {
70 id: userClass
71 model: ["Foot Soldier", "Archer", "Giant", "Wizard", "Demolisher"]
72 }
73 }
74}
075
=== added file 'examples/advanced-game/FilterPlayers.qml'
--- examples/advanced-game/FilterPlayers.qml 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/FilterPlayers.qml 2014-08-25 09:53:24 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Nekhelesh Ramananthan <nik90@ubuntu.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import QtQuick 2.2
21import Ubuntu.Components 1.1
22import Ubuntu.Components.ListItems 1.0 as ListItem
23import U1db 1.0 as U1db
24
25Page {
26 id: filterPlayers
27
28 visible: false
29 title: "Filter Players"
30
31 U1db.Index {
32 database: appDb
33 id: by_player
34 expression: ["username", "userlevel", "userclass"]
35 }
36
37 U1db.Query {
38 id: playerQuery
39 index: by_player
40 query: [{username:'*'}, {userlevel:'*'},{userclass:userClass.selectedIndex.toString()}]
41 }
42
43 Column {
44 spacing: units.gu(3)
45 anchors.fill: parent
46 anchors.margins: units.gu(2)
47
48 Label { text: "Filter by user class" }
49
50 OptionSelector {
51 id: userClass
52 model: ["Foot Soldier", "Archer", "Giant", "Wizard", "Demolisher"]
53 }
54
55 ListView {
56 id: players
57
58 width: parent.width
59 height: units.gu(20)
60
61 clip: true
62 model: playerQuery
63
64 delegate: ListItem.Subtitled {
65 text: '%1 Lvl %2'.arg(model.contents.username).arg(model.contents.userlevel)
66 subText: userClass.model[model.contents.userclass]
67 removable: true
68 confirmRemoval: true
69 onItemRemoved: appDb.deleteDoc(model.docId)
70 }
71 }
72 }
73}
074
=== added file 'examples/advanced-game/ListPlayers.qml'
--- examples/advanced-game/ListPlayers.qml 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/ListPlayers.qml 2014-08-25 09:53:24 +0000
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Nekhelesh Ramananthan <nik90@ubuntu.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import QtQuick 2.2
21import Ubuntu.Components 1.1
22import Ubuntu.Components.ListItems 1.0 as ListItem
23import U1db 1.0 as U1db
24
25Page {
26 id: homePage
27
28 visible: false
29 title: i18n.tr("List Players")
30
31 head.actions: [
32 addPlayerAction
33 ]
34
35 U1db.Index {
36 database: appDb
37 id: by_player
38 expression: ["username", "userlevel", "userclass"]
39 }
40
41 U1db.Query {
42 id: playerQuery
43 index: by_player
44 query: ["*", "*", "*"]
45 }
46
47 Label {
48 anchors.centerIn: parent
49 visible: players.count === 0
50 text: "No players? Add some!"
51 }
52
53 ListView {
54 id: players
55 anchors.fill: parent
56 clip: true
57 model: playerQuery
58
59 delegate: ListItem.Subtitled {
60 text: model.contents.username
61 subText: "User Level: " + model.contents.userlevel
62 removable: true
63 confirmRemoval: true
64 onItemRemoved: appDb.deleteDoc(model.docId)
65 }
66 }
67}
068
=== added file 'examples/advanced-game/manifest.json'
--- examples/advanced-game/manifest.json 1970-01-01 00:00:00 +0000
+++ examples/advanced-game/manifest.json 2014-08-25 09:53:24 +0000
@@ -0,0 +1,15 @@
1{
2 "architecture": "all",
3 "description": "description of AdvancedGame",
4 "framework": "ubuntu-sdk-14.10-qml-dev3",
5 "hooks": {
6 "AdvancedGame": {
7 "apparmor": "AdvancedGame.json",
8 "desktop": "AdvancedGame.desktop"
9 }
10 },
11 "maintainer": "Nekhelesh Ramananthan <krnekhelesh@gmail.com>",
12 "name": "com.ubuntu.developer.nik90.advancedgame",
13 "title": "AdvancedGame",
14 "version": "0.1"
15}

Subscribers

People subscribed via source and target branches

to all changes: