Warning, /office/klevernotes/src/contents/ui/dialogs/LinkNoteDialog.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2024 Louis Schul <schul9louis@gmail.com>
0003
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006
0007 import org.kde.kitemmodels 1.0
0008 import org.kde.kirigami 2.19 as Kirigami
0009 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0010
0011 import "qrc:/contents/ui/sharedComponents"
0012
0013 Kirigami.PromptDialog {
0014 id: linkNoteDialog
0015
0016 property alias linkText: linkTextField.text
0017 readonly property string path: noteComboBox.currentValue
0018 property string headerString: ""
0019 required property var listModel
0020
0021 title: i18nc("@title:dialog", "Create your link")
0022
0023 width: Kirigami.Units.gridUnit * 20
0024
0025 standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
0026
0027 onClosed: {
0028 linkText = ""
0029 headerSwitch.checked = false
0030 noteComboBox.currentIndex = 0
0031 }
0032
0033 ColumnLayout {
0034 FormCard.FormComboBoxDelegate {
0035 id: noteComboBox
0036
0037 text: i18nc("@label:combobox, 'a note' (the noun)", "Note:")
0038 model: KSortFilterProxyModel {
0039 id: searchFilterProxyModel
0040
0041 sourceModel: KDescendantsProxyModel {
0042 id: descendants
0043 model: linkNoteDialog.listModel
0044 }
0045 filterRoleName: "useCase"
0046 filterString: "Note"
0047 }
0048 textRole: "fullName"
0049 valueRole: "path"
0050 displayMode: FormCard.FormComboBoxDelegate.Dialog
0051
0052 onCurrentValueChanged: if (headerSwitch.checked) {
0053 headerComboBox.model = applicationWindow().noteMapper.getNoteHeaders(noteComboBox.currentValue)
0054 }
0055 Component.onCompleted: {
0056 currentIndex = 0
0057 }
0058 }
0059
0060 ExpendingFormSwitch {
0061 id: headerSwitch
0062
0063 text: i18nc("@label:switch", "Search headers")
0064 checked: false
0065
0066 onCheckedChanged: if (checked) {
0067 headerComboBox.model = applicationWindow().noteMapper.getNoteHeaders(noteComboBox.currentValue)
0068 } else {
0069 linkNoteDialog.headerString = ""
0070 }
0071
0072 FormCard.FormComboBoxDelegate {
0073 id: headerComboBox
0074
0075 text: i18nc("@label:textbox", "Header:")
0076
0077 textRole: "text"
0078 valueRole: "value"
0079 displayMode: FormCard.FormComboBoxDelegate.Dialog
0080
0081 onCurrentValueChanged: {
0082 linkNoteDialog.headerString = currentValue
0083 }
0084 }
0085 }
0086
0087 FormCard.FormTextFieldDelegate {
0088 id: linkTextField
0089
0090 label: i18nc("@label:textbox, the displayed text of a link, in html: <a>This text</a> ", "Link text:")
0091 Layout.fillWidth: true
0092 }
0093 }
0094 }