5import org.mauikit.controls as Maui
6import org.mauikit.filebrowsing as FB
19 headBar.visible: false
21 title: currentFMList.pathName
23 enableLassoSelection: true
25 gridView.itemSize : control.gridItemSize
26 gridView.itemHeight: gridView.cellWidth
33 property Component delegateInjector : null
39 readonly property alias dialog :_dialogLoader.item
48 property int gridIconSize: Maui.Style.mapToIconSizes(control.gridItemSize)
49 property int listIconSize: Maui.Style.mapToIconSizes(control.listItemSize)
52 Binding on currentIndex
54 when: control.currentView
55 value: control.currentView.currentIndex
58 viewType: settings.viewType === FB.FMList.ICON_VIEW ? Maui.AltBrowser.ViewType.Grid : Maui.AltBrowser.ViewType.List
62 control.currentIndex = 0
63 control.currentView.forceActiveFocus()
73 onSortByChanged: if(settings.group) groupBy()
74 onlyDirs: settings.onlyDirs
75 filterType: settings.filterType
76 filters: settings.filters
77 sortBy: settings.sortBy
78 hidden: settings.showHiddenFiles
79 foldersFirst: settings.foldersFirst
82 recursiveFilteringEnabled: true
83 sortCaseSensitivity: Qt.CaseInsensitive
84 filterCaseSensitivity: Qt.CaseInsensitive
92 property alias path : _commonFMList.path
99 property int gridItemSize : 140
105 property int listItemSize : Maui.Style.rowHeight
112 readonly property alias settings : _settings
118 readonly property bool loading : currentFMList.status.code === FB.PathStatus.LOADING
124 property alias readOnly: _commonFMList.readOnly
133 readonly property alias currentFMList : _commonFMList
139 readonly property alias currentFMModel : _browserModel
145 property alias filter : _browserModel.filter
151 property alias filters: _browserModel.filters
158 signal itemClicked(int index)
164 signal itemDoubleClicked(int index)
170 signal itemRightClicked(int index)
177 signal itemToggled(int index, bool state)
183 signal itemsSelected(var indexes)
189 signal keyPress(var event)
195 signal areaClicked(var mouse)
201 signal areaRightClicked(var mouse)
205 target: control.currentView
206 ignoreUnknownSignals: true
208 function onKeyPress(event)
210 control.keyPress(event)
213 function onItemsSelected(indexes)
215 control.itemsSelected(indexes)
218 function onAreaClicked(mouse)
220 console.log("Area clicked")
221 control.currentView.forceActiveFocus()
222 control.areaClicked(mouse)
225 function onAreRightClicked(mouse)
227 console.log(
"Area right clicked")
229 control.currentView.forceActiveFocus()
230 control.areaRightClicked(mouse)
245 currentView.section.property =
""
253 browser: _commonFMList
256 Maui.ProgressIndicator
258 id: _scanningProgress
260 anchors.bottom: parent.bottom
261 visible: control.loading
264 holder.visible: _holder.visible
265 holder.emoji: _holder.emoji
266 holder.title: _holder.title
267 holder.body: _holder.body
279 id: _mergeDialogComponent
286 readonly
property bool dirExists : FB.FM.fileExists(control.path+
"/"+textEntry.text)
290 console.log(
"DIR EXISTS?", dirExists)
294 _mergeDialog.alert(
i18nd(
"mauikitfilebrowsing",
"Directory already exists."), 2)
297 _mergeDialog.alert(
i18nd(
"mauikitfilebrowsing",
"Looks good."), 0)
301 title:
i18nd(
"mauikitfilebrowsing",
"Merge %1 files", urls.length)
302 message:i18nd("mauikitfilebrowsing", "Give a name to the new directory where all files will be merge.")
304 textEntry.placeholderText: i18nd("mauikitfilebrowsing", "Directory name")
308 FB.FM.group(_mergeDialog.urls, control.path, text)
313 enabled: !FB.FM.isDir(_dropMenu.target) && !control.readOnly
314 text:
i18nd(
"mauikitfilebrowsing",
"Merge Here")
315 icon.name: "edit-group"
318 var urls = _dropMenu.urls.
split(
",")
319 urls.push(_dropMenu.target)
320 _dialogLoader.sourceComponent = _mergeDialogComponent
328 enabled: FB.FM.isDir(_dropMenu.target) && !control.readOnly
329 text:
i18nd(
"mauikitfilebrowsing",
"Copy Here")
330 icon.name: "edit-copy"
333 const urls = _dropMenu.urls.split(
",")
334 FB.FM.copy(urls, _dropMenu.target)
340 enabled: FB.FM.isDir(_dropMenu.target) && !control.readOnly
341 text:
i18nd(
"mauikitfilebrowsing",
"Move Here")
342 icon.name: "edit-move"
345 const urls = _dropMenu.urls.split(
",")
346 FB.FM.cut(urls, _dropMenu.target)
352 enabled: FB.FM.isDir(_dropMenu.target) && !control.readOnly
353 text:
i18nd(
"mauikitfilebrowsing",
"Link Here")
354 icon.name: "edit-link"
357 const urls = _dropMenu.urls.split(
",")
359 FB.FM.createSymlink(url[i], _dropMenu.target)
367 text:
i18nd(
"mauikitfilebrowsing",
"Cancel")
368 icon.name: "dialog-cancel"
369 onTriggered: _dropMenu.close()
376 width: ListView.view.width
377 height:
Maui.Style.toolBarHeightAlt
378 text: control.listView.section.property ==
"date" || control.listView.section.property ===
"modified" ?
Qt.formatDateTime(
new Date(section),
"d MMM yyyy") : section
382 listDelegate:
Maui.ListBrowserDelegate
385 readonly
property string path : model.path
387 width: ListView.view.width
389 iconSource: model.icon
391 label1.text: model.label ? model.label :
""
392 label2.text: control.objectName ===
"searchView" ? model.path :
""
393 label3.text : model.mime ? (model.mime ===
"inode/directory" ? (model.count ? model.count +
i18nd(
"mauikitfilebrowsing",
" items") :
"") :
Maui.
Handy.formatSize(model.size)) :
""
394 label4.text: model.modified ?
Maui.
Handy.formatDate(model.modified,
"MM/dd/yyyy") :
""
396 template.isMask: iconSizeHint <= 22
397 iconSizeHint: _private.listIconSize
399 tooltipText: model.
path
401 checkable: control.selectionMode || checked
402 imageSource: settings.showThumbnails && height > 32 ? model.thumbnail :
""
403 checked: selectionBar ? selectionBar.contains(model.
path) : false
404 template.iconContainer.opacity: model.hidden ==
"true" ? 0.5 : 1
407 Drag.keys: [
"text/uri-list"]
409 "text/uri-list": filterSelection(control.path, model.path)
414 Layout.fillHeight:
true
415 Layout.preferredWidth: height
416 visible: (model.issymlink ==
true) || (model.issymlink ==
"true")
421 height:
Maui.Style.iconSizes.small
422 width:
Maui.Style.iconSizes.small
423 anchors.centerIn: parent
433 property var itemData : model
434 sourceComponent: control.delegateInjector
435 Layout.fillHeight:
true
436 Layout.preferredWidth: visible ? height : 0
437 active: control.delegateInjector
441 onClicked: (mouse) =>
443 control.currentIndex = index
445 if ((mouse.button ==
Qt.LeftButton) && (mouse.modifiers &
Qt.ControlModifier))
447 control.itemsSelected([index])
448 }
else if((mouse.button ==
Qt.LeftButton) && (mouse.modifiers &
Qt.ShiftModifier))
450 var lastSelectedIndex = findLastSelectedIndex(control.listView.flickable, index)
452 if(lastSelectedIndex < 0)
456 control.itemsSelected(control.range(lastSelectedIndex, index))
460 control.itemClicked(index)
466 control.currentIndex = index
467 control.itemDoubleClicked(index)
472 if(!
Maui.Handy.isTouch)
475 control.currentIndex = index
476 control.itemRightClicked(index)
481 control.currentIndex = index
482 control.itemRightClicked(index)
485 onToggled: (state) =>
487 control.currentIndex = index
488 control.itemToggled(index, state)
491 onContentDropped: (
drop) =>
493 _dropMenu.urls =
drop.urls.join(
",")
494 _dropMenu.target = model.path
502 selectionBar.removeAtUri(delegate.path)
510 function onUriRemoved(uri)
512 if(uri === model.path)
513 delegate.checked =
false
516 function onUriAdded(uri)
518 if(uri === model.path)
519 delegate.checked =
true
524 delegate.checked =
false
533 readonly
property alias checked : delegate.checked
539 selectionBar.removeAtUri(delegate.path)
543 Maui.GridBrowserDelegate
546 readonly
property string path : model.path
548 template.imageWidth: control.gridView.itemSize
549 template.imageHeight: control.gridView.itemSize
552 anchors.margins:
Maui.Handy.isMobile ?
Maui.Style.space.tiny :
Maui.Style.space.medium
554 template.labelSizeHint: 42
555 iconSizeHint: _private.gridIconSize
556 imageSource: settings.showThumbnails ? model.thumbnail :
""
557 template.fillMode:
Image.PreserveAspectFit
558 template.maskRadius: 0
559 iconSource: model.icon
560 label1.text: model.label
561 label2.visible: delegate.height > 160 && model.mime
562 label2.font.pointSize:
Maui.Style.fontSizes.tiny
563 label2.text: model.mime ? (model.mime ===
"inode/directory" ? (model.count ? model.count +
i18nd(
"mauikitfilebrowsing",
" items") :
"") :
Maui.
Handy.formatSize(model.size)) :
""
565 isCurrentItem: parent.
GridView.isCurrentItem || checked
566 tooltipText: model.
label
567 checkable: control.selectionMode || checked
568 checked: (selectionBar ? selectionBar.contains(model.
path) : false)
570 template.iconContainer.opacity: model.hidden ==
"true" ? 0.5 : 1
572 Drag.keys: [
"text/uri-list"]
574 "text/uri-list": filterSelection(control.path, model.path)
579 anchors.right: parent.right
580 anchors.top: parent.top
581 anchors.margins:
Maui.Style.space.medium
583 visible: (model.issymlink ==
true) || (model.issymlink ==
"true")
586 color:
Maui.Theme.textColor
588 height:
Maui.Style.iconSizes.small
595 property var itemData : model
596 sourceComponent: control.delegateInjector
598 active: control.delegateInjector
601 onClicked: (mouse) =>
603 if ((mouse.button ==
Qt.LeftButton) && (mouse.modifiers &
Qt.ControlModifier))
605 control.itemsSelected([index])
606 }
else if((mouse.button ==
Qt.LeftButton) && (mouse.modifiers &
Qt.ShiftModifier))
608 var lastSelectedIndex = findLastSelectedIndex(control.gridView.flickable, index)
610 if(lastSelectedIndex < 0)
614 control.itemsSelected(control.range(lastSelectedIndex, index))
618 control.itemClicked(index)
620 control.currentIndex = index
625 control.currentIndex = index
626 control.itemDoubleClicked(index)
631 if(!
Maui.Handy.isTouch)
634 control.currentIndex = index
635 control.itemRightClicked(index)
640 control.currentIndex = index
641 control.itemRightClicked(index)
644 onToggled: (state) =>
646 control.currentIndex = index
648 control.itemToggled(index, state)
651 onContentDropped: (
drop) =>
653 _dropMenu.urls =
drop.urls.join(
",")
654 _dropMenu.target = model.path
662 function onUriRemoved(uri)
664 if(uri === model.path)
665 delegate.checked =
false
668 function onUriAdded(uri)
670 if(uri === model.path)
671 delegate.checked =
true
674 function onCleared(uri)
676 delegate.checked =
false
689 var criteria = ViewSection.FullString
691 switch(control.currentFMList.sortBy)
693 case FB.FMList.LABEL:
695 criteria = ViewSection.FirstCharacter
706 case FB.FMList.MODIFIED:
713 control.currentView.section.property =
""
717 control.settings.viewType = FB.FMList.LIST_VIEW
718 control.currentView.section.
property = prop
719 control.currentView.section.criteria = criteria
725 function findLastSelectedIndex(view, limit)
728 for(var i = 0; i < limit; i++)
730 if(view.itemAtIndex(i).checked)
742 function range(
start, end)
746 const arr =
new Array(targetLength);
747 const b = Array.apply(null, arr);
748 const result = b.map((discard, n) => {
749 return (isReverse) ? n +
end : n +
start;
752 return (isReverse) ? result.reverse() : result;
758 function forceActiveFocus()
760 control.currentView.forceActiveFocus()
A group of properties to tweak the browser in the FileBrowser component.
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
KIOWIDGETS_EXPORT DropJob * drop(const QDropEvent *dropEvent, const QUrl &destUrl, DropJobFlags dropjobFlags, JobFlags flags=DefaultFlags)
QString path(const QString &relativePath)
QString label(StandardShortcut id)
const QList< QKeySequence > & end()
QVariant property(const char *name) const const
QString & fill(QChar ch, qsizetype size)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const