2020-05-28 11:06:17 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../components"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property alias channelListCount: chatGroupsListView.count
|
|
|
|
id: chatGroupsContainer
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: chatGroupsListView
|
|
|
|
anchors.topMargin: 24
|
|
|
|
anchors.fill: parent
|
|
|
|
model: chatsModel.chats
|
2020-05-28 11:10:12 +00:00
|
|
|
delegate: Channel {}
|
2020-05-28 14:58:25 +00:00
|
|
|
onCountChanged: {
|
2020-05-29 18:24:48 +00:00
|
|
|
// If a chat is added or removed, we set the current index to the first value
|
2020-05-28 14:58:25 +00:00
|
|
|
if (count > 0) {
|
2020-05-28 20:14:31 +00:00
|
|
|
currentIndex = 0;
|
2020-05-29 18:24:48 +00:00
|
|
|
chatsModel.activeChannelIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.chats
|
|
|
|
onDataChanged: {
|
|
|
|
// If the current active channel receives messages and changes its position,
|
|
|
|
// refresh the currentIndex accordingly
|
|
|
|
if(chatsModel.activeChannelIndex != chatGroupsListView.currentIndex){
|
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-05-28 14:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 11:06:17 +00:00
|
|
|
}
|
|
|
|
}
|