~mhr3/unity8/fix-1297246

« back to all changes in this revision

Viewing changes to Dash/People/Data.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 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 Dee 3.0
 
19
 
 
20
DeeVariantText {
 
21
    property string uri
 
22
    property string name
 
23
    property url avatar
 
24
    property var emails: ListModel {}
 
25
    property var phones: ListModel {}
 
26
    property string presenceStatus
 
27
    property string presenceMessage
 
28
    property url remoteSourceIcon
 
29
    property string remotePost
 
30
    property bool favorite
 
31
    property bool recent
 
32
    property url statusIcon
 
33
    property string status: remotePost ? remotePost : presenceMessage
 
34
    property url recentIcon
 
35
    property string recentTime
 
36
 
 
37
    statusIcon: switch(presenceStatus) {
 
38
        case "offline": "graphics/icon_offline.png"; break
 
39
        // FIXME random for now, as we don't get actual presence data on the phone
 
40
        case "":
 
41
            var r = Math.random();
 
42
            if (r >= 0.7) "graphics/icon_online.png"
 
43
            else if (r >= 0.4) "graphics/icon_offline.png"
 
44
            else "graphics/icon_unknown.png"
 
45
            break;
 
46
        default: "graphics/icon_online.png"
 
47
    }
 
48
 
 
49
    onValueChanged: {
 
50
        for (var i in value) switch (value[i][0]) {
 
51
            case "presence-message": presenceMessage = value[i][1]; break
 
52
            case "presence-status": presenceStatus = value[i][1]; break
 
53
            case "remote-source-icon": remoteSourceIcon = value[i][1]; break
 
54
            case "remote-post": remotePost = value[i][1]; break
 
55
            case "recent-icon": recentIcon = value[i][1]; break
 
56
            case "recent-time": recentTime = value[i][1]; break
 
57
            case "phone": phones.append({"type": generateType(), "number": value[i][1]}); break
 
58
            case "email": emails.append({"type": generateType(), "address": value[i][1]}); break
 
59
        }
 
60
    }
 
61
 
 
62
    // FIXME: random for now, as we don't have multiple phone numbers in the backend yet
 
63
    function generateType() {
 
64
        var phoneType = "";
 
65
        var r = Math.random();
 
66
        if (r >= 0.7) phoneType = "Private";
 
67
        else if (r >= 0.4) phoneType = "Mobile";
 
68
        else phoneType = "Work";
 
69
        return phoneType;
 
70
    }
 
71
}