~renatofilho/messaging-app/fix-1489330

« back to all changes in this revision

Viewing changes to src/qml/MMSDelegate.qml

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2016-05-16 15:53:28 UTC
  • mfrom: (458.1.101 messaging-app)
  • Revision ID: renato.filho@canonical.com-20160516155328-3lkc6f6cob6jgi8k
Trunk merged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    property var dataAttachments: []
28
28
    property var textAttachements: []
29
29
    property string messageText: ""
 
30
    swipeLocked: {
 
31
        for (var i=0; i < attachmentsView.children.length; i++) {
 
32
            if (attachmentsView.children[i].item && !attachmentsView.children[i].item.swipeLocked) {
 
33
                return false
 
34
            }
 
35
        }
 
36
        return true
 
37
    }
 
38
 
30
39
 
31
40
    function clicked(mouse)
32
41
    {
36
45
            var properties = {}
37
46
            properties["attachment"] = attachment.item.attachment
38
47
            properties["thumbnail"] = attachment.item
39
 
            mainStack.push(Qt.resolvedUrl(attachment.item.previewer), properties)
 
48
            mainStack.addFileToCurrentColumnSync(messages.basePage, Qt.resolvedUrl(attachment.item.previewer), properties)
40
49
        }
41
50
    }
42
51
 
65
74
            attachment.push(item.filePath)
66
75
            newAttachments.push(attachment)
67
76
        }
68
 
        messages.sendMessage(textMessage, messages.participantIds, newAttachments, {"x-canonical-tmp-files": true})
69
 
        deleteMessage();
 
77
        if (messages.sendMessage(textMessage, messages.participantIds, newAttachments, {"x-canonical-tmp-files": true})) {
 
78
            deleteMessage()
 
79
        }
70
80
    }
71
81
 
72
82
    function copyMessage()
82
92
            var attachment = attachments[i]
83
93
            if (startsWith(attachment.contentType, "text/plain") ) {
84
94
                root.textAttachements.push(attachment)
 
95
            } else if (startsWith(attachment.contentType, "audio/")) {
 
96
                root.dataAttachments.push({"type": "audio",
 
97
                                      "data": attachment,
 
98
                                      "delegateSource": "MMS/MMSAudio.qml",
 
99
                                    })
85
100
            } else if (startsWith(attachment.contentType, "image/")) {
86
101
                root.dataAttachments.push({"type": "image",
87
102
                                      "data": attachment,
88
103
                                      "delegateSource": "MMS/MMSImage.qml",
89
104
                                    })
90
 
            //} else if (startsWith(attachment.contentType, "video/")) {
91
 
                        // TODO: implement proper video attachment support
92
 
                        //                dataAttachments.push({type: "video",
93
 
                        //                                  data: attachment,
94
 
                        //                                  delegateSource: "MMS/MMSVideo.qml",
95
 
                        //                                 })
96
105
            } else if (startsWith(attachment.contentType, "application/smil") ||
97
106
                       startsWith(attachment.contentType, "application/x-smil")) {
98
107
                // smil files will always be ignored here
102
111
                                      "data": attachment,
103
112
                                      "delegateSource": "MMS/MMSContact.qml"
104
113
                                    })
 
114
            } else if (startsWith(attachment.contentType, "video/")) {
 
115
                root.dataAttachments.push({"type": "video",
 
116
                                      "data": attachment,
 
117
                                      "delegateSource": "MMS/MMSVideo.qml",
 
118
                                    })
105
119
            } else {
106
120
                root.dataAttachments.push({"type": "default",
107
121
                                      "data": attachment,
150
164
                            target: attachmentLoader
151
165
                            anchors.left: parent ? parent.left : undefined
152
166
                        }
153
 
                        PropertyChanges {
154
 
                            target: attachmentLoader
155
 
                            anchors.leftMargin: units.gu(1)
156
 
                            anchors.rightMargin: 0
157
 
                        }
158
167
                    },
159
168
                    State {
160
169
                        when: !root.incoming
163
172
                            target: attachmentLoader
164
173
                            anchors.right: parent ? parent.right : undefined
165
174
                        }
166
 
                        PropertyChanges {
167
 
                            target: attachmentLoader
168
 
                            anchors.leftMargin: 0
169
 
                            anchors.rightMargin: units.gu(1)
170
 
                        }
171
175
                    }
172
176
                ]
173
177
                source: modelData.delegateSource
221
225
                target: bubbleLoader.item
222
226
                property: "sender"
223
227
                value: messageData.sender.alias !== "" ? messageData.sender.alias : messageData.senderId
224
 
                when: participants.length > 1 && bubbleLoader.status === Loader.Ready && messageData.senderId !== "self"
 
228
                when: messageData.participants.length > 1 && bubbleLoader.status === Loader.Ready && messageData.senderId !== "self"
225
229
            }
226
230
        }
227
231
    }