blob: eb7cd0d30a4108ee13e9b519745abf4823342031 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
2/*
3 * Copyright (C) 2020 by Savoir-faire Linux
4 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
5 *
6 * This program 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; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19import QtQuick 2.14
20import QtQuick.Controls 2.14
21import QtQuick.Layouts 1.14
22import net.jami.Models 1.0
23
24ListView {
25 id: conversationSmartListView
26
27 signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr)
ababi0b686642020-08-18 17:21:28 +020028 signal needToSelectItems(string conversationUid)
Sébastien Blin1f915762020-08-03 13:27:42 -040029 signal needToDeselectItems
30 signal needToBackToWelcomePage
31 signal needToGrabFocus
32
33 signal needToShowChatView(string accountId, string convUid)
34 signal currentIndexIsChanged
35 signal forceUpdatePotentialInvalidItem
36
37
38 /*
39 * When model is sorted, we need to reset to focus (currentIndex)
40 * to the real conversation that we focused.
41 */
42 function modelSorted(contactURIToCompare) {
43 var conversationSmartListViewModel = conversationSmartListView.model
44 conversationSmartListView.currentIndex = -1
45 updateConversationSmartListView()
46 for (var i = 0; i < count; i++) {
47 if (conversationSmartListViewModel.data(
48 conversationSmartListViewModel.index(i, 0),
49 261) === contactURIToCompare) {
50 conversationSmartListView.currentIndex = i
51 break
52 }
53 }
54 }
55
56
57 /*
58 * Refresh all item within model.
59 */
60 function updateConversationSmartListView() {
61 var conversationSmartListViewModel = conversationSmartListView.model
62 conversationSmartListViewModel.dataChanged(
63 conversationSmartListViewModel.index(0, 0),
64 conversationSmartListViewModel.index(
65 conversationSmartListViewModel.rowCount() - 1, 0))
66 conversationSmartListView.forceUpdatePotentialInvalidItem()
67 }
68
69 function setModel(model) {
70 conversationSmartListView.model = model
71 }
72
73 function backToWelcomePage() {
74 conversationSmartListView.needToBackToWelcomePage()
75 }
76
Ming Rui Zhang96808872020-08-27 12:59:09 -040077 ConversationSmartListContextMenu {
78 id: smartListContextMenu
79 }
80
Sébastien Blin1f915762020-08-03 13:27:42 -040081 Connections {
82 target: CallAdapter
83
84 function onUpdateConversationSmartList() {
85 updateConversationSmartListView()
86 }
87 }
88
89 onCurrentIndexChanged: {
90 conversationSmartListView.currentIndexIsChanged()
91 }
92
93 clip: true
94
95 delegate: ConversationSmartListViewItemDelegate {
96 id: smartListItemDelegate
97 }
98
99 ScrollIndicator.vertical: ScrollIndicator {}
100}