~gang65/messaging-app/messaging-app-chevron-down

« back to all changes in this revision

Viewing changes to src/qml/Messages.qml

  • Committer: CI Train Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2015-11-23 19:52:38 UTC
  • mfrom: (467.1.26 new-vcard-preview)
  • Revision ID: ci-train-bot@canonical.com-20151123195238-90m6ql5y4b4d7h09
Extend contact preview page to show all details from contact vcard.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1150
1150
                    Item {
1151
1151
                        id: attachment
1152
1152
 
 
1153
                        readonly property int contactsCount:vcardParser.contacts ? vcardParser.contacts.length : 0
1153
1154
                        property int index
1154
1155
                        property string filePath
1155
 
                        property var vcardInfo: application.contactNameFromVCard(attachment.filePath)
 
1156
                        property alias vcard: vcardParser
 
1157
                        property string contactDisplayName: {
 
1158
                            if (contactsCount > 0)  {
 
1159
                                var contact = vcard.contacts[0]
 
1160
                                if (contact.displayLabel.label && (contact.displayLabel.label != "")) {
 
1161
                                    return contact.displayLabel.label
 
1162
                                } else if (contact.name) {
 
1163
                                    var contacFullName  = contact.name.firstName
 
1164
                                    if (contact.name.midleName) {
 
1165
                                        contacFullName += " " + contact.name.midleName
 
1166
                                    }
 
1167
                                    if (contact.name.lastName) {
 
1168
                                        contacFullName += " " + contact.name.lastName
 
1169
                                    }
 
1170
                                    return contacFullName
 
1171
                                }
 
1172
                                return i18n.tr("Unknown contact")
 
1173
                            }
 
1174
                            return ""
 
1175
                        }
 
1176
                        property string title: {
 
1177
                            var result = attachment.contactDisplayName
 
1178
                            if (attachment.contactsCount > 1) {
 
1179
                                return result + " (+%1)".arg(attachment.contactsCount-1)
 
1180
                            } else {
 
1181
                                return result
 
1182
                            }
 
1183
                        }
1156
1184
 
1157
1185
                        height: units.gu(6)
1158
1186
                        width: textEntry.width
1165
1193
                                bottom: parent.bottom
1166
1194
                                left: parent.left
1167
1195
                            }
1168
 
                            fallbackAvatarUrl: "image://theme/contact"
1169
 
                            fallbackDisplayName: label.name
 
1196
                            contactElement: attachment.contactsCount === 1 ? attachment.vcard.contacts[0] : null
 
1197
                            fallbackAvatarUrl: attachment.contactsCount === 1 ? "image://theme/contact" : "image://theme/contact-group"
 
1198
                            fallbackDisplayName: attachment.contactsCount === 1 ? attachment.contactDisplayName : ""
1170
1199
                            width: height
1171
1200
                        }
1172
1201
                        Label {
1173
1202
                            id: label
1174
1203
 
1175
 
                            property string name: attachment.vcardInfo["name"] !== "" ?
1176
 
                                                      attachment.vcardInfo["name"] :
1177
 
                                                      i18n.tr("Unknown contact")
1178
 
 
1179
1204
                            anchors {
1180
1205
                                left: avatar.right
1181
1206
                                leftMargin: units.gu(1)
1186
1211
                            }
1187
1212
 
1188
1213
                            verticalAlignment: Text.AlignVCenter
1189
 
                            text: {
1190
 
                                if (attachment.vcardInfo["count"] > 1) {
1191
 
                                    return label.name + " (+%1)".arg(attachment.vcardInfo["count"]-1)
1192
 
                                } else {
1193
 
                                    return label.name
1194
 
                                }
1195
 
                            }
 
1214
                            text: attachment.title
1196
1215
                            elide: Text.ElideMiddle
1197
1216
                            color: UbuntuColors.lightAubergine
1198
1217
                        }
1205
1224
                                PopupUtils.open(attachmentPopover, parent)
1206
1225
                            }
1207
1226
                        }
 
1227
                        VCardParser {
 
1228
                            id: vcardParser
 
1229
 
 
1230
                            vCardUrl: attachment ? Qt.resolvedUrl(attachment.filePath) : ""
 
1231
                        }
1208
1232
                    }
1209
1233
                }
1210
1234