Warning, /office/klevernotes/src/contents/ui/sideBar/SearchBar.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2023 Louis Schul <schul9louis@gmail.com>
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006 import QtQuick.Controls 2.15 as Controls
0007 
0008 import org.kde.kitemmodels 1.0
0009 import org.kde.kirigami 2.19 as Kirigami
0010 import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
0011 
0012 KirigamiComponents.SearchPopupField {
0013     id: root
0014 
0015     required property var listModel
0016 
0017     property var clickedIndex
0018 
0019     spaceAvailableLeft: false
0020     spaceAvailableRight: false
0021 
0022     popupContentItem: ListView {
0023         id: searchListView
0024 
0025         KSortFilterProxyModel {
0026             id: searchFilterProxyModel
0027 
0028             sourceModel: KDescendantsProxyModel {
0029                 id: descendants
0030                 model: root.listModel
0031             }
0032             filterRoleName: "noteName"
0033             filterCaseSensitivity: Qt.CaseInsensitive
0034         }
0035 
0036         model: (root.text === "") ? null : searchFilterProxyModel
0037 
0038         delegate: Controls.ItemDelegate {
0039             id: searchDelegate
0040 
0041             width: ListView.view.width
0042 
0043             highlighted: activeFocus
0044 
0045             leftInset: 1
0046             rightInset: 1
0047 
0048             contentItem: ColumnLayout {
0049                 Controls.Label {
0050                     text: i18n("From : ")+model.branchName
0051                     font: Kirigami.Theme.smallFont
0052                     elide: Text.ElideRight
0053                     Layout.fillWidth: true
0054                 }
0055                 Controls.Label {
0056                     text: model.displayName
0057                     wrapMode: Text.WordWrap
0058                     font.bold: true
0059                     Layout.fillWidth: true
0060                 }
0061             }
0062 
0063             onClicked: {
0064                 const searchModelIndex = searchFilterProxyModel.mapToSource(searchFilterProxyModel.index(index,0))
0065 
0066                 const descendantsModelIndex = descendants.mapToSource(descendants.index(searchModelIndex.row, 0))
0067                 root.clickedIndex = descendantsModelIndex
0068             }
0069         }
0070 
0071         Kirigami.PlaceholderMessage {
0072             width: parent.width - Kirigami.Units.gridUnit * 4
0073             anchors.centerIn: parent
0074 
0075             text: i18n("No search results")
0076             visible: searchListView.count === 0
0077             icon.name: "system-search"
0078         }
0079     }
0080 
0081     onTextChanged: {
0082         searchFilterProxyModel.setFilterFixedString(text)
0083     }
0084 }