<commit_before>/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import Qt 4.7
import MeeGo.App.Contacts 0.1
import TelepathyQML 0.1

Item {
    id: contactCardLandscape

    // TODO need clip off rounded edges from avatar image

    height: contactWithNoAvatar.height; width: contactWithNoAvatar.width // size from theme image
    property PeopleModel dataPeople : theModel
    property ProxyModel sortPeople : sortModel
    property int sourceIndex
    property int proxyIndex

    property string dataAvatar: dataPeople.data(sourceIndex, PeopleModel.AvatarRole)
    property string dataFirst: dataPeople.data(sourceIndex, PeopleModel.FirstNameRole)
    property string dataLast:  dataPeople.data(sourceIndex, PeopleModel.LastNameRole)
    property bool dataFavorite: dataPeople.data(sourceIndex, PeopleModel.FavoriteRole)
    property string dataUuid: dataPeople.data(sourceIndex, PeopleModel.UuidRole);
    property int iconsMargin: 6
    property int borderMargins: 3 
    property int itemMargins: 15

    signal clicked
    signal pressAndHold(int mouseX, int mouseY, string uuid, string name)

    function getOnlineStatusIcon(presence) {
        var icon = "";
        switch (presence) {
            case TelepathyTypes.ConnectionPresenceTypeAvailable:
                icon = "image://themedimage/icons/status/status-available"
                break;
            case TelepathyTypes.ConnectionPresenceTypeBusy:
                icon = "image://themedimage/icons/status/status-busy"
                break;
            case TelepathyTypes.ConnectionPresenceTypeAway:
            case TelepathyTypes.ConnectionPresenceTypeExtendedAway:
                icon = "image://themedimage/icons/status/status-idle";
                break;
            case TelepathyTypes.ConnectionPresenceTypeHidden:
            case TelepathyTypes.ConnectionPresenceTypeUnknown:
            case TelepathyTypes.ConnectionPresenceTypeError:
            case TelepathyTypes.ConnectionPresenceTypeOffline:
            default:
                icon = "image://themedimage/icons/status/status-idle";
        }
        return icon;
    }

    Connections {
        target: accountsModel
        ignoreUnknownSignals: true
        onComponentsLoaded: {
            var uri = dataPeople.data(sourceIndex,
                                      PeopleModel.OnlineAccountUriRole);
            var provider = dataPeople.data(sourceIndex,
                                           PeopleModel.OnlineServiceProviderRole);

            if ((uri.length < 1) || (provider.length < 1))
               return;

            var account = provider[0].split("\n");
            if (account.length != 2)
                return;
            account = account[1];

            var buddy = uri[0].split(") ");
            if (buddy.length != 2)
                return;
            buddy = buddy[1];

            var contactItem = accountsModel.contactItemForId(account, buddy);
            var presence = contactItem.data(AccountsModel.PresenceTypeRole);

            statusIcon.source = getOnlineStatusIcon(presence);
        }
    }

    Image {
        id: contactWithAvatar
        width: theme_listBackgroundPixelHeightTwo + itemMargins
        height: width
        anchors.centerIn: parent
        asynchronous: true
        visible: avatar.status == Image.Ready

        BorderImage {
            id: borderImg
            anchors.fill:parent
            z: -10
            asynchronous: true
            source: "image://themedimage/widgets/apps/media/photo-border"
            border.top: borderMargins
            border.bottom: borderMargins
            border.left: borderMargins
            border.right: borderMargins

            Item {
                id: wrapper
                anchors.fill: parent
                anchors.topMargin: borderImg.border.top
                anchors.bottomMargin: borderImg.border.bottom
                anchors.leftMargin: borderImg.border.left
                anchors.rightMargin: borderImg.border.right

                Image {
                    id: avatar
                    smooth: true
                    asynchronous: true
                    anchors { fill: parent; }
                    fillMode: Image.PreserveAspectCrop
                    source: dataAvatar
                    clip: true
                    z: 0
                }

                Image {
                    id: nameOverlay
                    width: parent.width
                    anchors.bottom: parent.bottom
                    anchors.horizontalCenter: parent.horizontalCenter
                    source: "image://theme/contacts/contact_thumb_bg"
                    fillMode: Image.PreserveAspectCrop
                    clip: true
                }
            }
        }
    }

    Image {
        id: contactWithNoAvatar
        width: theme_listBackgroundPixelHeightTwo + itemMargins
        height: theme_listBackgroundPixelHeightTwo + itemMargins
        source: "image://themedimage/widgets/common/avatar/avatar-default"
        visible: avatar.status != Image.Ready
    }

    Text {
        id: contactNameText
        anchors {
            left: parent.left
            right: parent.right
            bottom: parent.bottom<commit_msg>BMC#20799: Use overlays on all avatars even when using the default avatar<commit_after>/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import Qt 4.7
import MeeGo.App.Contacts 0.1
import TelepathyQML 0.1

Item {
    id: contactCardLandscape

    // TODO need clip off rounded edges from avatar image

    height: contactWithAvatar.height; width: contactWithAvatar.width // size from theme image
    property PeopleModel dataPeople : theModel
    property ProxyModel sortPeople : sortModel
    property int sourceIndex
    property int proxyIndex

    property string dataAvatar: dataPeople.data(sourceIndex, PeopleModel.AvatarRole)
    property string dataFirst: dataPeople.data(sourceIndex, PeopleModel.FirstNameRole)
    property string dataLast:  dataPeople.data(sourceIndex, PeopleModel.LastNameRole)
    property bool dataFavorite: dataPeople.data(sourceIndex, PeopleModel.FavoriteRole)
    property string dataUuid: dataPeople.data(sourceIndex, PeopleModel.UuidRole);
    property int iconsMargin: 6
    property int borderMargins: 3 
    property int itemMargins: 15

    signal clicked
    signal pressAndHold(int mouseX, int mouseY, string uuid, string name)

    function getOnlineStatusIcon(presence) {
        var icon = "";
        switch (presence) {
            case TelepathyTypes.ConnectionPresenceTypeAvailable:
                icon = "image://themedimage/icons/status/status-available"
                break;
            case TelepathyTypes.ConnectionPresenceTypeBusy:
                icon = "image://themedimage/icons/status/status-busy"
                break;
            case TelepathyTypes.ConnectionPresenceTypeAway:
            case TelepathyTypes.ConnectionPresenceTypeExtendedAway:
                icon = "image://themedimage/icons/status/status-idle";
                break;
            case TelepathyTypes.ConnectionPresenceTypeHidden:
            case TelepathyTypes.ConnectionPresenceTypeUnknown:
            case TelepathyTypes.ConnectionPresenceTypeError:
            case TelepathyTypes.ConnectionPresenceTypeOffline:
            default:
                icon = "image://themedimage/icons/status/status-idle";
        }
        return icon;
    }

    Connections {
        target: accountsModel
        ignoreUnknownSignals: true
        onComponentsLoaded: {
            var uri = dataPeople.data(sourceIndex,
                                      PeopleModel.OnlineAccountUriRole);
            var provider = dataPeople.data(sourceIndex,
                                           PeopleModel.OnlineServiceProviderRole);

            if ((uri.length < 1) || (provider.length < 1))
               return;

            var account = provider[0].split("\n");
            if (account.length != 2)
                return;
            account = account[1];

            var buddy = uri[0].split(") ");
            if (buddy.length != 2)
                return;
            buddy = buddy[1];

            var contactItem = accountsModel.contactItemForId(account, buddy);
            var presence = contactItem.data(AccountsModel.PresenceTypeRole);

            statusIcon.source = getOnlineStatusIcon(presence);
        }
    }

    Image {
        id: contactWithAvatar
        width: theme_listBackgroundPixelHeightTwo + itemMargins
        height: width
        anchors.centerIn: parent
        asynchronous: true

        BorderImage {
            id: borderImg
            anchors.fill:parent
            z: -10
            asynchronous: true
            source: "image://themedimage/widgets/apps/media/photo-border"
            border.top: borderMargins
            border.bottom: borderMargins
            border.left: borderMargins
            border.right: borderMargins

            Item {
                id: wrapper
                anchors.fill: parent
                anchors.topMargin: borderImg.border.top
                anchors.bottomMargin: borderImg.border.bottom
                anchors.leftMargin: borderImg.border.left
                anchors.rightMargin: borderImg.border.right

                Image {
                    id: avatar
                    smooth: true
                    asynchronous: true
                    anchors { fill: parent; }
                    fillMode: Image.PreserveAspectCrop
                    source: (dataAvatar) ? dataAvatar : "image://themedimage/widgets/common/avatar/avatar-default"
                    clip: true
                    z: 0
                }

                Image {
                    id: nameOverlay
                    width: parent.width
                    anchors.bottom: parent.bottom
                    anchors.horizontalCenter: parent.horizontalCenter
                    source: "image://theme/contacts/contact_thumb_bg"
                    fillMode: Image.PreserveAspectCrop
                    clip: true
                }
            }
        }
    }

    Text {
        id: contactNameText
        anchors {
            left: parent.left
            right: parent.right
            bottom: parent.bottom
{'fraction_non_alphanumeric': 0.06991824076684522, 'fraction_numerical': 0.005920496193966732, 'mean_word_length': 1.7961114030478191, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6309607', 'n_tokens_mistral': 2738, 'n_tokens_neox': 2568, 'n_words': 609}