~ubuntu-branches/ubuntu/wily/u1db-qt/wily

« back to all changes in this revision

Viewing changes to qtcreator/contacts/main.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-07 10:28:13 UTC
  • Revision ID: package-import@ubuntu.com-20130807102813-uk4un76xcsoy3n12
Tags: upstream-0.1.5+13.10.20130807
ImportĀ upstreamĀ versionĀ 0.1.5+13.10.20130807

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Christian Dywan <christian.dywan@canonical.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
 
 
20
import QtQuick 2.0
 
21
import U1db 1.0 as U1db
 
22
import Ubuntu.Components 0.1
 
23
import Ubuntu.Components.ListItems 0.1 as ListItem
 
24
 
 
25
MainView {
 
26
    width: units.gu(45)
 
27
    height: units.gu(80)
 
28
 
 
29
    U1db.Database {
 
30
        id: contactsDatabase
 
31
        /*
 
32
            Uncomment to persistently store contacts on disk
 
33
        path: "contacts.db"
 
34
        */
 
35
    }
 
36
 
 
37
    U1db.Document {
 
38
        database: contactsDatabase
 
39
        docId: 'person0'
 
40
        create: true
 
41
        defaults: { 'name': 'John', 'city': 'Dublin', 'phone': 65849 }
 
42
    }
 
43
 
 
44
    U1db.Document {
 
45
        database: contactsDatabase
 
46
        docId: 'person1'
 
47
        create: true
 
48
        defaults: { 'name': 'Ivanka', 'city': 'Dublin', 'phone': 98765 }
 
49
    }
 
50
 
 
51
    U1db.Document {
 
52
        database: contactsDatabase
 
53
        docId: 'person2'
 
54
        create: true
 
55
        defaults: { 'name': 'Leonardo', 'city': 'Rome', 'phone': 12345 }
 
56
    }
 
57
 
 
58
    U1db.Index {
 
59
        database: contactsDatabase
 
60
        id: byCityName
 
61
        expression: [ "city" ]
 
62
    }
 
63
 
 
64
    U1db.Query {
 
65
        id: numberOne
 
66
        index: byCityName
 
67
        query: [ "Dublin" ]
 
68
    }
 
69
 
 
70
    Page {
 
71
        Tabs {
 
72
            Tab {
 
73
                title: i18n.tr("People living in Dublin")
 
74
                page: Page {
 
75
                    anchors.centerIn: parent
 
76
                    ListView {
 
77
                        width: units.gu(45)
 
78
                        height: units.gu(80)
 
79
                        model: numberOne
 
80
                        delegate: ListItem.Subtitled {
 
81
                            text: contents.name
 
82
                            subText: contents.city
 
83
                        }
 
84
                    }
 
85
                }
 
86
            }
 
87
         }
 
88
    }
 
89
}
 
90