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
52
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 */
64 signal tagClicked(int index)
65
66 model: Maui.BaseModel
67 {
68 id: _tagsModel
69 list: FB.TagsListModel
70 {
71 id: _tagsList
72 }
73 }
74
75 Loader
76 {
77 anchors.fill: parent
78 anchors.leftMargin: Maui.Style.space.medium
79 asynchronous: true
80 active: count === 0 && control.showPlaceHolder
81 visible: active
82
83 sourceComponent: Label
84 {
85 verticalAlignment: Qt.AlignVCenter
86 text: control.placeholderText
87 opacity: 0.7
88 color: Maui.Theme.textColor
89 }
90 }
91
92 delegate: TagDelegate
93 {
94 showCloseButton: control.showDeleteIcon
95 Maui.Theme.textColor: control.Maui.Theme.textColor
96
97 ListView.onAdd:
98 {
99 control.flickable.positionViewAtEnd()
100 }
101
102 onRemoveTag: tagRemoved(index)
103 onClicked: tagClicked(index)
104 }
105}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.