2
* Copyright 2012, 2013, 2014 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/>.
21
import Ubuntu.Components 1.1
22
import Ubuntu.Contacts 0.1
23
import Ubuntu.History 0.1
25
import "dateUtils.js" as DateUtils
27
MultipleSelectionListView {
30
property var _currentSwipedItem: null
31
property list<Action> _availableActions
33
function updateSwippedItem(item)
39
if (item.swipeState !== "Normal") {
40
if (_currentSwipedItem !== item) {
41
if (_currentSwipedItem) {
42
_currentSwipedItem.resetSwipe()
44
_currentSwipedItem = item
46
} else if (item.swipeState !== "Normal" && _currentSwipedItem === item) {
47
_currentSwipedItem = null
55
listModel: participants.length > 0 ? sortProxy : null
56
verticalLayoutDirection: ListView.BottomToTop
57
highlightFollowsCurrentItem: true
64
text: i18n.tr("Retry")
65
onTriggered: value.resendMessage()
72
onTriggered: value.copyMessage()
80
var messageData = listModel.get(value._index)
81
var messageType = messageData.textMessageAttachments.length > 0 ? i18n.tr("MMS") : i18n.tr("SMS")
82
var messageInfo = {"type": messageType,
83
"senderId": messageData.senderId,
84
"timestamp": messageData.timestamp,
85
"textReadTimestamp": messageData.textReadTimestamp,
86
"status": messageData.textMessageStatus,
87
"participants": messages.participants}
88
messageInfoDialog.showMessageInfo(messageInfo)
93
listDelegate: Column {
96
// WORKAROUND: we can not use sections because the verticalLayoutDirection is ListView.BottomToTop the sections will appear
99
text: visible ? DateUtils.friendlyDay(timestamp) : ""
103
leftMargin: units.gu(2)
104
rightMargin: units.gu(2)
106
visible: (index === root.count) || !DateUtils.areSameDay(sortProxy.get(index+1).timestamp, timestamp)
109
MessageDelegateFactory {
110
objectName: "message%1".arg(index)
112
incoming: senderId != "self"
113
// TODO: we have several items inside
114
selected: root.isSelected(messageDelegate)
115
selectionMode: root.isInSelectionMode
116
accountLabel: multipleAccounts ? telepathyHelper.accountForId(accountId).displayName : ""
119
if (textMessageStatus === HistoryThreadModel.MessageStatusPermanentlyFailed) {
120
actions.push(reloadAction)
122
actions.push(copyAction)
123
actions.push(infoAction)
127
// TODO: need select only the item
129
if (root.isInSelectionMode) {
130
if (!root.selectItem(messageDelegate)) {
131
root.deselectItem(messageDelegate)
135
onItemPressAndHold: {
136
root.startSelection()
137
root.selectItem(messageDelegate)
139
Component.onCompleted: {
141
messages.markMessageAsRead(accountId, threadId, eventId, type);
148
for (var i=0; i < items.count; i++) {
149
var event = items.get(i).model
150
eventModel.removeEvent(event.accountId, event.threadId, event.eventId, event.type)
155
// list is in the bootom we should scroll to the new message
156
if (Math.abs(height + contentY) < units.gu(3)) {
158
positionViewAtBeginning()
164
sourceModel: eventModel.filter ? eventModel : null
165
sortRole: HistoryEventModel.TimestampRole