Warning, /network/tokodon/src/content/ui/SearchView.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Controls 2.15 as QQC2 0006 import QtQuick.Layouts 1.15 0007 import Qt.labs.qmlmodels 1.0 0008 import org.kde.kirigami 2.20 as Kirigami 0009 import org.kde.kirigamiaddons.delegates 1.0 as Delegates 0010 import org.kde.kmasto 1.0 0011 import './StatusDelegate' 0012 0013 ListView { 0014 id: root 0015 0016 required property string text 0017 0018 onTextChanged: if (text.length === 0) { 0019 searchModel.clear(); 0020 } 0021 0022 model: SearchModel { 0023 id: searchModel 0024 } 0025 0026 section { 0027 property: "type" 0028 delegate: Kirigami.ListSectionHeader { 0029 text: searchModel.labelForType(section) 0030 } 0031 } 0032 0033 Kirigami.PlaceholderMessage { 0034 text: i18n("Loading...") 0035 visible: searchModel.loading 0036 icon.name: "system-search" 0037 anchors.centerIn: parent 0038 width: parent.width - Kirigami.Units.gridUnit * 4 0039 } 0040 0041 Kirigami.PlaceholderMessage { 0042 text: i18n("No search results") 0043 visible: root.count === 0 && root.text.length > 2 && !searchModel.loading && searchModel.loaded 0044 icon.name: "system-search" 0045 anchors.centerIn: parent 0046 width: parent.width - Kirigami.Units.gridUnit * 4 0047 } 0048 0049 Kirigami.PlaceholderMessage { 0050 text: i18n("Search for peoples, tags and posts") 0051 visible: root.count === 0 && !searchModel.loading && !searchModel.loaded 0052 icon.name: "system-search" 0053 anchors.centerIn: parent 0054 width: parent.width - Kirigami.Units.gridUnit * 4 0055 } 0056 0057 delegate: DelegateChooser { 0058 role: "type" 0059 DelegateChoice { 0060 roleValue: SearchModel.Account 0061 0062 Delegates.RoundedItemDelegate { 0063 id: accountDelegate 0064 0065 required property var authorIdentity 0066 0067 width: ListView.view.width 0068 text: accountDelegate.authorIdentity.displayName 0069 0070 onClicked: Navigation.openAccount(accountDelegate.authorIdentity.id) 0071 0072 contentItem: RowLayout { 0073 Kirigami.Avatar { 0074 Layout.alignment: Qt.AlignTop 0075 Layout.rowSpan: 5 0076 source: accountDelegate.authorIdentity.avatarUrl 0077 cache: true 0078 name: accountDelegate.authorIdentity.displayName 0079 } 0080 0081 ColumnLayout { 0082 spacing: 0 0083 0084 Layout.fillWidth: true 0085 Layout.bottomMargin: Kirigami.Units.smallSpacing 0086 Layout.leftMargin: Kirigami.Units.largeSpacing 0087 0088 Kirigami.Heading { 0089 id: heading 0090 0091 level: 5 0092 text: accountDelegate.text 0093 textFormat: Text.RichText 0094 type: Kirigami.Heading.Type.Primary 0095 color: Kirigami.Theme.textColor 0096 verticalAlignment: Text.AlignTop 0097 0098 Layout.fillWidth: true 0099 } 0100 0101 Kirigami.Heading { 0102 level: 5 0103 elide: Text.ElideRight 0104 color: Kirigami.Theme.disabledTextColor 0105 text: `@${accountDelegate.authorIdentity.account}` 0106 verticalAlignment: Text.AlignTop 0107 0108 Layout.fillWidth: true 0109 } 0110 } 0111 } 0112 } 0113 } 0114 0115 DelegateChoice { 0116 roleValue: SearchModel.Status 0117 StatusDelegate { 0118 width: ListView.view.width 0119 secondary: true 0120 showSeparator: true 0121 showInteractionButton: false 0122 0123 leftPadding: 0 0124 rightPadding: 0 0125 topPadding: Kirigami.Units.smallSpacing 0126 bottomPadding: Kirigami.Units.smallSpacing 0127 } 0128 } 0129 0130 DelegateChoice { 0131 roleValue: SearchModel.Hashtag 0132 0133 Delegates.RoundedItemDelegate { 0134 id: delegate 0135 0136 required property string id 0137 0138 text: "#" + id 0139 Accessible.description: i18n("Hashtag") 0140 0141 onClicked: Navigation.openTag(id) 0142 0143 contentItem: ColumnLayout { 0144 Layout.fillWidth: true 0145 Layout.bottomMargin: Kirigami.Units.smallSpacing 0146 Layout.leftMargin: Kirigami.Units.largeSpacing 0147 spacing: 0 0148 Kirigami.Heading { 0149 id: heading 0150 level: 5 0151 text: delegate.text 0152 type: Kirigami.Heading.Type.Primary 0153 color: Kirigami.Theme.textColor 0154 verticalAlignment: Text.AlignTop 0155 } 0156 } 0157 } 0158 } 0159 } 0160 }