2
* Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18
import Ubuntu.Components 0.1
19
import "../../Components"
20
import "../../Components/Time.js" as Time
25
property var dataModel
27
property int __spacing: units.gu(1)
29
/* Select what is shown in the subtitle
30
data: phone number or email address
31
status: social media presence status
33
property string subtitleType: "data"
34
height: subtitleType == "data" && detailsLabel.lineCount < 2 ? units.gu(10) : units.gu(11.5)
41
leftMargin: units.gu(2)
42
rightMargin: units.gu(4)
44
topMargin: units.gu(2)
50
anchors { top: parent.top }
55
source: peopleView.dataModel.avatar
56
sourceSize { width: avatar.width; height: avatar.height }
57
fillMode: Image.PreserveAspectCrop
65
spacing: units.gu(0.5)
66
width: parent.width - x
75
source: peopleView.dataModel.statusIcon
78
fillMode: Image.PreserveAspectFit
80
anchors.verticalCenter: parent.verticalCenter
86
elide: Text.ElideRight
87
text: peopleView.dataModel.name
91
font.weight: Font.DemiBold;
96
source: switch(peopleView.subtitleType) {
98
return peopleView.dataModel.remoteSourceIcon;
100
return peopleView.dataModel.recent ? peopleView.dataModel.recentIcon : "";
104
height: units.gu(1.5)
105
fillMode: Image.PreserveAspectFit
111
width: parent.width - x
112
elide: Text.ElideRight
113
text: switch (peopleView.subtitleType) {
115
if (peopleView.dataModel.phones && peopleView.dataModel.phones.count > 0) {
116
return peopleView.dataModel.phones.get(0).number;
117
} else if (peopleView.dataModel.emails && peopleView.dataModel.emails.count > 0) {
118
return peopleView.dataModel.emails.get(0).address;
122
return peopleView.dataModel.status;
129
wrapMode: Text.WordWrap;
141
width: parent.width - x
142
elide: Text.ElideRight
143
text: switch (peopleView.subtitleType) {
145
if (peopleView.dataModel.phones && peopleView.dataModel.phones.count > 0) {
146
return peopleView.dataModel.phones.get(0).type;
147
} else if (peopleView.dataModel.emails && peopleView.dataModel.emails.count > 0) {
148
return peopleView.dataModel.emails.get(0).type;
152
if (peopleView.dataModel.recent) {
153
var time = Time.readableFromNow(peopleView.dataModel.recentTime);
154
return time ? time : peopleView.dataModel.recentTime;
156
return peopleView.dataModel.status