[Merge] lp:~tiagosh/messaging-app/information-messageType into lp:messaging-app

Gustavo Pichorim Boiko gustavo.boiko at canonical.com
Tue Sep 30 21:53:12 UTC 2014


Review: Needs Fixing



Diff comments:

> === added file 'src/qml/AccountSectionDelegate.qml'
> --- src/qml/AccountSectionDelegate.qml	1970-01-01 00:00:00 +0000
> +++ src/qml/AccountSectionDelegate.qml	2014-09-30 21:34:12 +0000
> @@ -0,0 +1,71 @@
> +/*
> + * Copyright 2012, 2013, 2014 Canonical Ltd.
> + *
> + * This file is part of messaging-app.
> + *
> + * messaging-app is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 3.
> + *
> + * messaging-app is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +import QtQuick 2.2
> +
> +import Ubuntu.Components 1.1
> +import Ubuntu.Components.ListItems 0.1 as ListItem
> +import Ubuntu.Contacts 0.1
> +
> +import "dateUtils.js" as DateUtils
> +
> +ListItemWithActions {
> +    property var messageData: null
> +    property int index: -1
> +    property Item delegateItem
> +
> +    height: sectionLabel.height + units.gu(2)
> +    anchors.left: parent.left
> +    anchors.right: parent.right
> +    ListItem.ThinDivider {
> +        id: leftDivider
> +        anchors.verticalCenter: sectionLabel.verticalCenter
> +        anchors.left: parent.left
> +        anchors.right: sectionLabel.left
> +        anchors.rightMargin: 0
> +        anchors.leftMargin: 0
> +    }
> +
> +    ListItem.ThinDivider {
> +        id: rightDivider
> +        anchors.verticalCenter: sectionLabel.verticalCenter
> +        anchors.left: sectionLabel.right
> +        anchors.right: parent.right
> +        anchors.rightMargin: 0
> +        anchors.leftMargin: 0
> +    }
> +
> +    onItemClicked: {
> +        if (root.isInSelectionMode) {
> +            if (!root.selectItem(delegateItem)) {
> +                root.deselectItem(delegateItem)
> +            }
> +        }
> +    }
> +
> +    Label {
> +        id: sectionLabel
> +        anchors.horizontalCenter: parent.horizontalCenter
> +        height: paintedHeight
> +        clip: true
> +        text: i18n.tr("You switched to %1").arg(telepathyHelper.accountForId(messageData.accountId).displayName) + " @ " + DateUtils.formatLogDate(messageData.timestamp)

Can you replace this by:
// TRANSLATORS: %1 is the SIM card name and %2 is the timestamp
text: i18n.tr("You switched to %1 @ %2")
              .arg(telepathyHelper.accountForId(messageData.accountId).displayName)
              .arg(DateUtils.formatLogDate(messageData.timestamp))

This way translators can replace the "@" if it is appropriate to do so.

> +        fontSize: "x-small"
> +        horizontalAlignment: Text.AlignHCenter
> +    }
> +}
> +
> 
> === modified file 'src/qml/MessageBubble.qml'
> --- src/qml/MessageBubble.qml	2014-09-18 12:17:16 +0000
> +++ src/qml/MessageBubble.qml	2014-09-30 21:34:12 +0000
> @@ -130,7 +130,7 @@
>                  return ""
>  
>              var str = Qt.formatTime(messageTimeStamp).toLowerCase()
> -            if (root.accountName.length === 0) {
> +            if (root.accountName.length === 0 || !root.messageIncoming) {
>                  return str
>              }
>              str += " @ %1".arg(root.accountName)
> 
> === modified file 'src/qml/MessageDateSection.qml'
> --- src/qml/MessageDateSection.qml	2014-08-11 22:59:14 +0000
> +++ src/qml/MessageDateSection.qml	2014-09-30 21:34:12 +0000
> @@ -34,5 +34,7 @@
>      }
>      ListItem.ThinDivider {
>          anchors.bottom: parent.bottom
> +        anchors.rightMargin: 0
> +        anchors.leftMargin: 0
>      }
>  }
> 
> === modified file 'src/qml/MessageDelegateFactory.qml'
> --- src/qml/MessageDelegateFactory.qml	2014-09-16 20:21:27 +0000
> +++ src/qml/MessageDelegateFactory.qml	2014-09-30 21:34:12 +0000
> @@ -76,7 +76,7 @@
>          Binding {
>              target: loader.item
>              property: "messageData"
> -            value: model
> +            value: messageData
>              when: (loader.status === Loader.Ready)
>          }
>          Binding {
> 
> === modified file 'src/qml/Messages.qml'
> --- src/qml/Messages.qml	2014-09-17 15:48:56 +0000
> +++ src/qml/Messages.qml	2014-09-30 21:34:12 +0000
> @@ -857,12 +857,26 @@
>                      participants = multiRecipient.recipients
>                  }
>                  // create the new thread and update the threadId list
> -                eventModel.threadIdForParticipants(messages.account.accountId,
> +                var threadId = eventModel.threadIdForParticipants(messages.account.accountId,
>                                                     HistoryThreadModel.EventTypeText,
>                                                     participants,
>                                                     HistoryThreadModel.MatchPhoneNumber,
>                                                     true)
> -
> +                for (var i=0; i < eventModel.count; i++) {
> +                    var event = eventModel.get(i)
> +                    if (event.senderId == "self" && event.accountId != messages.account.accountId) {
> +                        // if the last outgoing message used a different accountId, add an
> +                        // information event and quit the loop
> +                        eventModel.writeTextInformationEvent(messages.account.accountId,
> +                                                             threadId,
> +                                                             participants,
> +                                                             "")
> +                        break;
> +                    } else if (event.senderId == "self" && event.accountId == messages.account.accountId) {
> +                        // in case last ougoing event used the same accountId, just skip
> +                        break;
> +                    }
> +                }
>                  updateFilters()
>                  if (attachments.count > 0) {
>                      var newAttachments = []
> 
> === modified file 'src/qml/MessagesListView.qml'
> --- src/qml/MessagesListView.qml	2014-09-16 20:21:27 +0000
> +++ src/qml/MessagesListView.qml	2014-09-30 21:34:12 +0000
> @@ -19,6 +19,7 @@
>  import QtQuick 2.2
>  
>  import Ubuntu.Components 1.1
> +import Ubuntu.Components.ListItems 0.1 as ListItem
>  import Ubuntu.Contacts 0.1
>  import Ubuntu.History 0.1
>  
> @@ -92,69 +93,46 @@
>          }
>      ]
>  
> -    listDelegate: Column {
> -        id: messageDelegate
> -
> -        // WORKAROUND: we can not use sections because the verticalLayoutDirection is ListView.BottomToTop the sections will appear
> -        // bellow the item
> -        MessageDateSection {
> -            text: visible ? DateUtils.friendlyDay(timestamp) : ""
> -            anchors {
> -                left: parent.left
> -                right: parent.right
> -                leftMargin: units.gu(2)
> -                rightMargin: units.gu(2)
> -            }
> -            visible: (index === root.count) || !DateUtils.areSameDay(eventModel.get(index+1).timestamp, timestamp)
> -        }
> -
> -        MessageDelegateFactory {
> -            objectName: "message%1".arg(index)
> -
> -            incoming: senderId != "self"
> -            // TODO: we have several items inside
> -            selected: root.isSelected(messageDelegate)
> -            selectionMode: root.isInSelectionMode
> -            accountLabel: multipleAccounts ? telepathyHelper.accountForId(accountId).displayName : ""
> -            rightSideActions: {
> -                var actions = []
> -                if (textMessageStatus === HistoryThreadModel.MessageStatusPermanentlyFailed) {
> -                    actions.push(reloadAction)
> -                }
> -                actions.push(copyAction)
> -                actions.push(infoAction)
> -                return actions
> -            }
> -
> -            // TODO: need select only the item
> -            onItemClicked: {
> -                if (root.isInSelectionMode) {
> -                    if (!root.selectItem(messageDelegate)) {
> -                        root.deselectItem(messageDelegate)
> -                    }
> -                }
> -            }
> -            onItemPressAndHold: {
> -                root.startSelection()
> -                root.selectItem(messageDelegate)
> -            }
> -            Component.onCompleted: {
> -                if (newEvent) {
> -                    messages.markMessageAsRead(accountId, threadId, eventId, type);
> -                }
> -            }
> +    listDelegate: Loader {
> +        id: loader
> +        anchors.left: parent.left
> +        anchors.right: parent.right
> +        height: status == Loader.Ready ? item.height : 0
> +        
> +        Component.onCompleted: {
> +            var properties = {"messageData": model}
> +            var sourceFile = textMessageType == HistoryThreadModel.MessageTypeInformation ? "AccountSectionDelegate.qml" : "RegularMessageDelegate.qml"
> +            loader.setSource(sourceFile, properties)
> +        }
> +
> +        Binding {
> +            target: loader.item
> +            property: "index"
> +            value: index
> +            when: (loader.status === Loader.Ready)
> +        }
> +
> +        Binding {
> +            target: loader.item
> +            property: "delegateItem"
> +            value: loader
> +            when: (loader.status === Loader.Ready)
>          }
>      }
>  
>      onSelectionDone: {
> +        var removeDividers = (items.count == eventModel.count)
>          for (var i=0; i < items.count; i++) {
>              var event = items.get(i).model
> +            if (!removeDividers && event.textMessageType == HistoryThreadModel.MessageTypeInformation) {
> +                continue;
> +            }
>              eventModel.removeEvent(event.accountId, event.threadId, event.eventId, event.type)
>          }
>      }
>  
>      onCountChanged: {
> -        // list is in the bootom we should scroll to the new message
> +        // list is in the bottom we should scroll to the new message
>          if (Math.abs(height + contentY) < units.gu(3)) {
>              currentIndex = 0
>              positionViewAtBeginning()
> 
> === added file 'src/qml/RegularMessageDelegate.qml'
> --- src/qml/RegularMessageDelegate.qml	1970-01-01 00:00:00 +0000
> +++ src/qml/RegularMessageDelegate.qml	2014-09-30 21:34:12 +0000
> @@ -0,0 +1,86 @@
> +/*
> + * Copyright 2012, 2013, 2014 Canonical Ltd.
> + *
> + * This file is part of messaging-app.
> + *
> + * messaging-app is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 3.
> + *
> + * messaging-app is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +import QtQuick 2.2
> +import Ubuntu.History 0.1
> +import "dateUtils.js" as DateUtils
> +
> +Column {
> +    height: childrenRect.height
> +    property var messageData: null
> +    property Item delegateItem
> +    property var timestamp: messageData.timestamp
> +    property string senderId: messageData.senderId
> +    property var textReadTimestamp: messageData.textReadTimestamp
> +    property int textMessageStatus: messageData.textMessageStatus
> +    property var textMessageAttachments: messageData.textMessageAttachments
> +    property bool newEvent: messageData.newEvent
> +    property var textMessage: messageData.textMessage
> +    property string accountId: messageData.accountId
> +    property int index: -1
> +
> +    // WORKAROUND: we can not use sections because the verticalLayoutDirection is ListView.BottomToTop the sections will appear
> +    // bellow the item
> +    MessageDateSection {
> +        text: visible ? DateUtils.friendlyDay(timestamp) : ""
> +        anchors {
> +            left: parent.left
> +            right: parent.right
> +            leftMargin: units.gu(2)
> +            rightMargin: units.gu(2)
> +        }
> +        visible: (index === root.count) || !DateUtils.areSameDay(eventModel.get(index+1).timestamp, timestamp)
> +    }
> +
> +    MessageDelegateFactory {
> +        objectName: "message%1".arg(index)
> +
> +        incoming: senderId != "self"
> +        // TODO: we have several items inside
> +        selected: root.isSelected(delegateItem)
> +        selectionMode: root.isInSelectionMode
> +        accountLabel: multipleAccounts ? telepathyHelper.accountForId(accountId).displayName : ""
> +        rightSideActions: {
> +            var actions = []
> +            if (textMessageStatus === HistoryThreadModel.MessageStatusPermanentlyFailed) {
> +                actions.push(reloadAction)
> +            }
> +            actions.push(copyAction)
> +            actions.push(infoAction)
> +            return actions
> +        }
> +
> +        // TODO: need select only the item
> +        onItemClicked: {
> +            if (root.isInSelectionMode) {
> +                if (!root.selectItem(delegateItem)) {
> +                    root.deselectItem(delegateItem)
> +                }
> +            }
> +        }
> +        onItemPressAndHold: {
> +            root.startSelection()
> +            root.selectItem(delegateItem)
> +        }
> +        Component.onCompleted: {
> +            if (newEvent) {
> +                messages.markMessageAsRead(accountId, threadId, eventId, type);
> +            }
> +        }
> +    }
> +}
> 


-- 
https://code.launchpad.net/~tiagosh/messaging-app/information-messageType/+merge/235860
Your team Ubuntu Phablet Team is subscribed to branch lp:messaging-app.



More information about the Ubuntu-reviews mailing list