2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-28 07:06:17 -04:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../components"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property alias channelListCount: chatGroupsListView.count
|
2020-06-18 14:06:02 -04:00
|
|
|
property string searchStr: ""
|
2020-05-28 07:06:17 -04:00
|
|
|
id: chatGroupsContainer
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: chatGroupsListView
|
2020-06-25 10:41:50 -04:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-05-28 07:06:17 -04:00
|
|
|
model: chatsModel.chats
|
2020-06-18 14:06:02 -04:00
|
|
|
delegate: Channel {
|
|
|
|
name: model.name
|
|
|
|
lastMessage: model.lastMessage
|
|
|
|
timestamp: model.timestamp
|
|
|
|
chatType: model.chatType
|
|
|
|
unviewedMessagesCount: model.unviewedMessagesCount
|
2020-07-09 13:46:25 +02:00
|
|
|
hasMentions: model.hasMentions
|
2020-07-17 15:44:25 -04:00
|
|
|
contentType: model.contentType
|
2020-06-18 14:06:02 -04:00
|
|
|
searchStr: chatGroupsContainer.searchStr
|
|
|
|
}
|
2020-05-28 10:58:25 -04:00
|
|
|
onCountChanged: {
|
2020-06-05 10:50:39 -04:00
|
|
|
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
|
|
|
// If a chat is added or removed, we set the current index to the first value
|
2020-05-29 14:24:48 -04:00
|
|
|
chatsModel.activeChannelIndex = 0;
|
2020-06-05 10:50:39 -04:00
|
|
|
currentIndex = 0;
|
|
|
|
} else {
|
|
|
|
if(chatsModel.activeChannelIndex > -1){
|
|
|
|
chatGroupsListView.currentIndex = 0;
|
|
|
|
} else {
|
|
|
|
// Initial state. No chat has been selected yet
|
|
|
|
chatGroupsListView.currentIndex = -1;
|
|
|
|
}
|
2020-05-29 14:24:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.chats
|
|
|
|
onDataChanged: {
|
|
|
|
// If the current active channel receives messages and changes its position,
|
|
|
|
// refresh the currentIndex accordingly
|
2020-06-02 16:10:48 -04:00
|
|
|
if(chatsModel.activeChannelIndex !== chatGroupsListView.currentIndex){
|
2020-05-29 14:24:48 -04:00
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-05-28 10:58:25 -04:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 07:06:17 -04:00
|
|
|
}
|
2020-06-22 13:24:01 -04:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel
|
|
|
|
onActiveChannelChanged: {
|
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-07-10 18:22:39 -04:00
|
|
|
SelectedMessage.reset();
|
|
|
|
chatColumn.isReply = false;
|
2020-06-22 13:24:01 -04:00
|
|
|
}
|
|
|
|
}
|
2020-06-17 15:18:31 -04:00
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|