~renatofilho/address-book-app/fix-1199122-phase2

« back to all changes in this revision

Viewing changes to src/imports/ContactList/ContactListPage.qml

  • Committer: Tarmac
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2013-07-25 17:04:42 UTC
  • mfrom: (20.1.10 favorite-list)
  • Revision ID: tarmac-20130725170442-qq8dd0rcb6kn82t0
Implemented ContactFavoriteListView.

Approved by Bill Filler, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012-2013 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import Ubuntu.Components 0.1
 
19
import Ubuntu.Components.ListItems 0.1 as ListItem
 
20
import Ubuntu.Components.Popups 0.1 as Popups
 
21
import Ubuntu.Contacts 0.1 as ContactsUI
 
22
 
 
23
Page {
 
24
    id: mainPage
 
25
    objectName: "ContactList"
 
26
 
 
27
    title: i18n.tr("Contacts")
 
28
 
 
29
    Component {
 
30
        id: dialog
 
31
 
 
32
        Popups.Dialog {
 
33
            id: dialogue
 
34
 
 
35
            title: i18n.tr("Error")
 
36
            text: i18n.tr("Fail to Load contacts")
 
37
 
 
38
            Button {
 
39
                text: "Cancel"
 
40
                gradient: UbuntuColors.greyGradient
 
41
                onClicked: PopupUtils.close(dialogue)
 
42
            }
 
43
        }
 
44
    }
 
45
 
 
46
    ContactsUI.ContactListView {
 
47
        id: contactList
 
48
 
 
49
        anchors.fill: parent
 
50
        onError: PopupUtils.open(dialog, null)
 
51
 
 
52
        ActivityIndicator {
 
53
            id: activity
 
54
 
 
55
            anchors.centerIn: parent
 
56
            running: contactListView.loading
 
57
            visible: running
 
58
        }
 
59
 
 
60
        onContactClicked: {
 
61
            pageStack.push(Qt.resolvedUrl("../ContactView/ContactView.qml"),
 
62
                           {model: contactList.model, contactId: contactId})
 
63
        }
 
64
    }
 
65
 
 
66
    tools: ToolbarItems {
 
67
        ToolbarButton {
 
68
            action: Action {
 
69
                text: i18n.tr("Add")
 
70
                iconSource: "artwork:/add.png"
 
71
                onTriggered: {
 
72
                    var newContact =  Qt.createQmlObject("import QtContacts 5.0; Contact{ }", mainPage)
 
73
                    pageStack.push(Qt.resolvedUrl("../ContactEdit/ContactEditor.qml"),
 
74
                                   {model: contactList.model, contact: newContact})
 
75
                }
 
76
 
 
77
            }
 
78
        }
 
79
    }
 
80
}