MauiKit File Browsing

PlacesListBrowser.qml
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import org.mauikit.controls as Maui
6import org.mauikit.filebrowsing as FB
7
8/**
9 * @inherit org::mauikit::controls::ListBrowser
10 * @brief A browsing list of the system locations, such as common standard places, bookmarks and others as removable devices and networks.
11 *
12 * This control inherits from MauiKit ListBrowser, to checkout its inherited properties refer to docs.
13 *
14 * Most of the properties to control the behaviour is handled via the PlacesList model, which is exposed via the `list` property.
15 * @see list
16 *
17 * @image html placeslistbrowser.png
18 *
19 * @code
20 * Maui.SideBarView
21 * {
22 * anchors.fill: parent
23 *
24 * sideBar.content: Pane
25 * {
26 * Maui.Theme.colorSet: Maui.Theme.Window
27 * anchors.fill: parent
28 * FB.PlacesListBrowser
29 * {
30 * anchors.fill: parent
31 * }
32 * }
33 *
34 * Maui.Page
35 * {
36 * Maui.Controls.showCSD: true
37 * anchors.fill: parent
38 * }
39 * }
40 * @endcode
41 *
42 * <a href="https://invent.kde.org/maui/mauikit-filebrowser/examples/PlacesListBrowser.qml">You can find a more complete example at this link.</a>
43 */
44Maui.ListBrowser
45{
46 id: control
47
48 /**
49 * @brief The model list of the places.
50 * @property PlacesList PlacesListBrowser::list
51 */
52 readonly property alias list : placesList
53
54 /**
55 * @brief The contextual menu for the entries.
56 * @note The menu has an extra property `index`, which refers to the index position of the entry where the menu was invoked at.
57 *
58 * To add more entries, use the `itemMenu.data` property, or append/push methods.
59 * @property Menu PlacesListBrowser::itemMenu
60 */
61 readonly property alias itemMenu : _menu
62
63 /**
64 * @brief The preferred size of the icon for the places delegates.
65 * By default this is set to `Style.iconSizes.small`
66 * @see Style::iconSizes
67 */
68 property int iconSize : Maui.Style.iconSizes.small
69
70 /**
71 * @brief The path of the current place selected.
72 */
73 property string currentPath
74
75 /**
76 * @brief Emitted when a entry has been clicked.
77 * @param path the URL path of the entry
78 */
79 signal placeClicked (string path)
80
81 Maui.Theme.colorSet: Maui.Theme.View
82 Maui.Theme.inherit: false
83
84 focus: true
85 model: Maui.BaseModel
86 {
87 list: FB.PlacesList
88 {
89 id: placesList
90 groups: [
91 FB.FMList.BOOKMARKS_PATH,
92 FB.FMList.DRIVES_PATH]
93 }
94 }
95
96 currentIndex: placesList.indexOfPath(control.currentPath)
97
98 section.property: "type"
99 section.criteria: ViewSection.FullString
100 section.delegate: Maui.LabelDelegate
101 {
102 id: delegate
103 text: section
104
105 isSection: true
106 width: parent.width
107 height: Maui.Style.toolBarHeightAlt
108 }
109
110 Maui.ContextualMenu
111 {
112 id: _menu
113 property int index
114
115 MenuItem
116 {
117 text: i18nd("mauikitfilebrowsing", "Edit")
118 }
119
120 MenuItem
121 {
122 text: i18nd("mauikitfilebrowsing", "Hide")
123 }
124
125 MenuItem
126 {
127 text: i18nd("mauikitfilebrowsing", "Remove")
128 Maui.Theme.textColor: Maui.Theme.negativeTextColor
129 onTriggered: list.removePlace(control.currentIndex)
130 }
131 }
132
133 flickable.header: GridLayout
134 {
135 id: _quickSection
136
137 width: Math.min(parent.width, 180)
138 rows: 3
139 columns: 3
140 columnSpacing: Maui.Style.space.small
141 rowSpacing: Maui.Style.space.small
142
143 Repeater
144 {
145 model: Maui.BaseModel
146 {
147 list: FB.PlacesList
148 {
149 id: _quickPacesList
150 groups: [FB.FMList.QUICK_PATH, FB.FMList.PLACES_PATH]
151 }
152 }
153
154 delegate: Maui.GridBrowserDelegate
155 {
156 Layout.preferredHeight: Math.min(50, width)
157 Layout.preferredWidth: 50
158 Layout.fillWidth: true
159 Layout.fillHeight: true
160 flat: false
161 isCurrentItem: control.currentPath === model.path
162 iconSource: model.icon + (Qt.platform.os == "android" || Qt.platform.os == "osx" ? ("-sidebar") : "")
163 iconSizeHint: Maui.Style.iconSize
164 template.isMask: true
165 label1.text: model.label
166 labelsVisible: false
167 tooltipText: model.label
168 onClicked:
169 {
170 placeClicked(model.path)
171 }
172 }
173 }
174 }
175
176 delegate: Maui.ListDelegate
177 {
178 width: ListView.view.width
179 iconSize: control.iconSize
180 labelVisible: true
181 iconVisible: true
182 label: model.label
183 iconName: model.icon
184
185 onClicked:
186 {
187 placeClicked(model.path)
188 }
189
190 onRightClicked:
191 {
192 _menu.index = index
193 _menu.popup()
194 }
195
196 onPressAndHold:
197 {
198 _menu.index = index
199 _menu.popup()
200 }
201 }
202}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.