status-desktop/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml

111 lines
3.3 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
2020-05-28 11:06:17 +00:00
import "../../../../shared"
import "../../../../imports"
import "../components"
import "./"
2020-05-28 11:06:17 +00:00
Item {
2020-12-11 20:29:46 +00:00
property var channelModel
2020-05-28 11:06:17 +00:00
property alias channelListCount: chatGroupsListView.count
property string searchStr: ""
2021-05-16 15:16:42 +00:00
property string categoryId: ""
2020-12-11 20:29:46 +00:00
id: channelListContent
width: parent.width
height: childrenRect.height
Timer {
id: timer
}
2020-12-11 20:29:46 +00:00
ListView {
id: chatGroupsListView
spacing: 0
anchors.top: parent.top
2020-12-11 20:29:46 +00:00
height: childrenRect.height
2021-02-10 20:41:00 +00:00
visible: height > (appSettings.useCompactMode ? 30 : 50)
anchors.right: parent.right
anchors.left: parent.left
2020-12-11 20:29:46 +00:00
interactive: false
2021-06-22 18:30:51 +00:00
model: channelListContent.channelModel
2020-12-11 20:29:46 +00:00
delegate: Channel {
name: model.name
muted: model.muted
lastMessage: model.lastMessage
timestamp: model.timestamp
chatType: model.chatType
identicon: model.identicon
unviewedMessagesCount: model.unviewedMessagesCount
hasMentions: model.hasMentions
contentType: model.contentType
2021-06-22 18:30:51 +00:00
searchStr: channelListContent.searchStr
2021-05-16 15:16:42 +00:00
categoryId: model.categoryId
filterCategory: channelListContent.categoryId
2020-12-11 20:29:46 +00:00
chatId: model.id
}
onCountChanged: {
if (count > 0 && chatsModel.channelView.activeChannelIndex > -1) {
currentIndex = chatsModel.channelView.activeChannelIndex;
2020-12-11 20:29:46 +00:00
} else {
if (chatsModel.channelView.activeChannelIndex > -1) {
2020-12-11 20:29:46 +00:00
chatGroupsListView.currentIndex = 0;
} else {
2020-12-11 20:29:46 +00:00
// Initial state. No chat has been selected yet
chatGroupsListView.currentIndex = -1;
}
}
}
2020-12-11 20:29:46 +00:00
}
Item {
2020-12-11 20:29:46 +00:00
id: noSearchResults
anchors.top: parent.top
height: visible ? 300 : 0
visible: !chatGroupsListView.visible && channelListContent.searchStr !== ""
anchors.left: parent.left
anchors.right: parent.right
2020-12-11 20:29:46 +00:00
StyledText {
font.pixelSize: 15
color: Style.current.secondaryText
2020-12-11 20:29:46 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
2021-02-18 16:36:05 +00:00
//% "No search results"
text: qsTrId("no-search-results")
2020-09-23 19:11:27 +00:00
}
}
ChannelContextMenu {
2020-08-03 19:05:49 +00:00
id: channelContextMenu
}
Connections {
target: chatsModel.channelView.chats
onDataChanged: {
// If the current active channel receives messages and changes its position,
// refresh the currentIndex accordingly
if(chatsModel.channelView.activeChannelIndex !== chatGroupsListView.currentIndex){
chatGroupsListView.currentIndex = chatsModel.channelView.activeChannelIndex
2020-05-28 14:58:25 +00:00
}
}
2020-05-28 11:06:17 +00:00
}
Connections {
target: chatsModel.channelView
onActiveChannelChanged: {
chatsModel.messageView.hideLoadingIndicator()
chatGroupsListView.currentIndex = chatsModel.channelView.activeChannelIndex
2020-07-10 22:22:39 +00:00
SelectedMessage.reset();
chatColumn.isReply = false;
}
}
2020-06-17 19:18:31 +00:00
}
2020-12-11 20:29:46 +00:00
2020-06-17 19:18:31 +00:00
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/