// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL import QtQuick import QtQuick.Layouts // One folder of the conversation list: its heading, and the rows of it that the // heading says are there. // // A file of its own because the list builds one of these per folder and each of // them is seventy lines: written inline, the one thing a folder is - a heading // and what is under it - is seventy lines to read past to find the next thing. // // It is handed the row it draws rather than given one: the row is defined by the // page, which is where the model it reads from lives, and a component cannot // reach into its user for a delegate. ColumnLayout { id: folderGroup // the folder this section is: its name, its id, how many conversations are // in it, and whether it can be renamed. required property var folder // whether the heading is unfolded. property bool sectionShown: false // whether the heading is drawn at all: a list with nothing in it has no // headings, so the whole column is the folder with nothing in it. property bool bare: false // the conversation list every folder draws from, because the model is // ordered by activity and the folders are not. property var chatModel: null // the row, from the page. property Component rowComponent: null signal toggleRequested(string folderId) signal menuRequested(string folderId, string folderName) readonly property string folderId: folderGroup.folder.id Layout.fillWidth: true spacing: 0 // A folder with nothing in it is not drawn, except for the pair that always // is: an empty "Group chats" is where a new room goes, and hiding it would // leave nowhere for the first room to land. visible: folderGroup.folder.count > 0 || folderGroup.folder.editable ChatSection { Layout.fillWidth: true text: folderGroup.folder.name itemCount: folderGroup.folder.count visible: !folderGroup.bare menuAvailable: folderGroup.folder.editable expanded: folderGroup.sectionShown onToggleRequested: folderGroup.toggleRequested(folderGroup.folderId) onMenuRequested: folderGroup.menuRequested(folderGroup.folderId, folderGroup.folder.name) } ColumnLayout { id: folderBody // The rows below hang off this item, not off folderGroup, so the two // things a row has to know about its folder are repeated here: reaching // folderGroup from a delegate defined in another file is not something // an id can do, and a row that asked its parent for these got nothing, // which is a folder that unfolds onto nothing. readonly property string folderId: folderGroup.folderId readonly property bool sectionShown: folderGroup.sectionShown Layout.fillWidth: true spacing: 0 visible: folderGroup.sectionShown Repeater { // A folder that is closed has no rows rather than rows that are // hidden: this repeater builds the whole list once per folder, and // a row that is only there to draw nothing is still a delegate with // an avatar in it, so a few hundred conversations cost a few // thousand of them to draw the two sections that are open. model: folderGroup.sectionShown ? folderGroup.chatModel : null delegate: folderGroup.rowComponent } } }