MauiKit File Browsing

TagList.qml
1import QtQuick
2import QtQuick.Controls
3
4import org.mauikit.controls as Maui
5import org.mauikit.filebrowsing as FB
6
7import "."
8
9/**
10 * @inherit org::mauikit::controls::ListBrowser
11 * @brief The flickable element for listing horizontally the tag buttons in the TagsBar control. This control is a graphical representation and consumes the TagsList model.
12 *
13 * @warning This control only exists as an implementation detail of TagsBar, and it is exposed to access its own properties.
14 */
15Maui.ListBrowser
16{
17 id: control
18
19 clip: false
20
21 orientation: ListView.Horizontal
22 spacing: Maui.Style.defaultSpacing
24 implicitHeight: Maui.Style.toolBarHeight
25 horizontalScrollBarPolicy: ScrollBar.AlwaysOff
26 snapMode: ListView.SnapOneItem
27 verticalScrollBarPolicy: ScrollBar.AlwaysOff
28
29 /**
30 * @brief Text to be displayed in the bar when the list is empty.
31 */
32 property string placeholderText: i18nd("mauikitfilebrowsing", "Add tags...")
33
34 /**
35 * @brief An alias to the tags model and controller. This is exposed to fine tune all the listing properties of the tags.
36 * @property TagsList TagList::list
37 */
38 readonly property alias list : _tagsList
39
40 /**
41 * @brief Whether to display the placeholder text.
42 * By default this is set to `true`
43 */
44 property bool showPlaceHolder: true
45
46 /**
47 * @brief Whether the tag elements should have a clos/dismiss button.
48 * When this button is made visible and is clicked the `tagRemoved` signal is triggered.
49 * @see tagRemoved
50 */
51 property bool showDeleteIcon: true
53 /**
54 * @brief Emitted when the close/dismiss button in the tag button is clicked.
55 * @see showDeleteIcon
56 * @param index the index position of the tag element in the list
57 */
58 signal tagRemoved(int index)
59
60 /**
61 * @brief Emitted when a tag button has been clicked.
62 * @param index the index position of the tag element in the list
63 * @param tag the tag name
64 */
65 signal tagClicked(int index, string tag)
66
67 model: Maui.BaseModel
68 {
69 id: _tagsModel
70 list: FB.TagsListModel
71 {
72 id: _tagsList
73 }
74 }
75
76 Loader
77 {
78 anchors.fill: parent
79 anchors.leftMargin: Maui.Style.space.medium
80 asynchronous: true
81 active: count === 0 && control.showPlaceHolder
82 visible: active
83
84 sourceComponent: Label
85 {
86 verticalAlignment: Qt.AlignVCenter
87 text: control.placeholderText
88 opacity: 0.7
89 color: Maui.Theme.textColor
90 }
91 }
92
93 delegate: TagDelegate
94 {
95 showCloseButton: control.showDeleteIcon
96 Maui.Theme.textColor: control.Maui.Theme.textColor
97
98 ListView.onAdd:
99 {
100 control.flickable.positionViewAtEnd()
101 }
102
103 onRemoveTag: (index) => tagRemoved(index)
104 onClicked: tagClicked(index, model.tag)
105 }
106}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:50:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.