2
* Copyright 2012-2015 Canonical Ltd.
4
* This file is part of messaging-app.
6
* messaging-app is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* messaging-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
import Ubuntu.Components 1.3
21
import Ubuntu.Contacts 0.1
26
readonly property int contactsCount:vcardParser.contacts ? vcardParser.contacts.length : 0
27
property string filePath
28
property alias vcard: vcardParser
29
property string contactDisplayName: {
30
if (contactsCount > 0) {
31
var contact = vcard.contacts[0]
32
if (contact.displayLabel.label && (contact.displayLabel.label != "")) {
33
return contact.displayLabel.label
34
} else if (contact.name) {
35
var contacFullName = contact.name.firstName
36
if (contact.name.midleName) {
37
contacFullName += " " + contact.name.midleName
39
if (contact.name.lastName) {
40
contacFullName += " " + contact.name.lastName
44
return i18n.tr("Unknown contact")
48
property string title: {
49
var result = attachment.contactDisplayName
50
if (attachment.contactsCount > 1) {
51
return result + " (+%1)".arg(attachment.contactsCount-1)
60
width: textEntry.width
70
contactElement: attachment.contactsCount === 1 ? attachment.vcard.contacts[0] : null
71
fallbackAvatarUrl: attachment.contactsCount === 1 ? "image://theme/contact" : "image://theme/contact-group"
72
fallbackDisplayName: attachment.contactsCount === 1 ? attachment.contactDisplayName : ""
80
leftMargin: units.gu(1)
84
rightMargin: units.gu(1)
87
verticalAlignment: Text.AlignVCenter
88
text: attachment.title
89
elide: Text.ElideMiddle
90
color: UbuntuColors.lightAubergine
96
attachment.pressAndHold()
102
vCardUrl: attachment ? Qt.resolvedUrl(attachment.filePath) : ""