Warning, /maui/nota/src/views/RecentView.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.14
0002 import QtQuick.Controls 2.15
0003 import QtQuick.Layouts 1.3
0004 
0005 import org.mauikit.controls 1.3 as Maui
0006 
0007 import org.maui.nota 1.0 as Nota
0008 import "widgets"
0009 
0010 DocsBrowser
0011 {
0012     id: control
0013     property bool selectionMode : false
0014     altHeader: Maui.Handy.isMobile
0015 
0016     headBar.forceCenterMiddleContent: false
0017     floatingFooter: true
0018     holder.visible: historyList.count === 0
0019     holder.emoji: "qrc:/assets/dialog-information.svg"
0020     holder.title : i18n("No Recent Files!")
0021     holder.body: i18n("Here you will see your recently opened files")
0022 
0023 
0024     headBar.farLeftContent: ToolButton
0025     {
0026         icon.name: "go-previous"
0027         onClicked: control.StackView.view.pop()
0028     }  
0029 
0030     model: Maui.BaseModel
0031     {
0032         id: _historyModel
0033 
0034         list: historyList
0035 
0036         sort: "modified"
0037         sortOrder: Qt.DescendingOrder
0038         recursiveFilteringEnabled: true
0039         sortCaseSensitivity: Qt.CaseInsensitive
0040         filterCaseSensitivity: Qt.CaseInsensitive
0041     }
0042 
0043     property string typingQuery
0044 
0045     Maui.Chip
0046     {
0047         z: control.z + 99999
0048         Maui.Theme.colorSet:Maui.Theme.Complementary
0049         visible: _typingTimer.running
0050         label.text: typingQuery
0051         anchors.left: parent.left
0052         anchors.bottom: parent.bottom
0053         showCloseButton: false
0054         anchors.margins: Maui.Style.space.medium
0055     }
0056 
0057     Timer
0058     {
0059         id: _typingTimer
0060         interval: 250
0061         onTriggered:
0062         {
0063             const index = historyList.indexOfName(typingQuery)
0064             if(index > -1)
0065             {
0066                 control.currentIndex = _historyModel.mappedFromSource(index)
0067             }
0068 
0069             typingQuery = ""
0070         }
0071     }
0072 
0073     Connections
0074     {
0075         target: control.currentView
0076 
0077         function onKeyPress(event)
0078         {
0079             const index = control.currentIndex
0080             const item = control.model.get(index)
0081 
0082             var pat = /^([a-zA-Z0-9 _-]+)$/
0083             if(event.count === 1 && pat.test(event.text))
0084             {
0085                 typingQuery += event.text
0086                 _typingTimer.restart()
0087             }
0088         }
0089     }
0090 
0091     footer: Maui.SelectionBar
0092     {
0093         id: _selectionbar
0094 
0095         anchors.horizontalCenter: parent.horizontalCenter
0096         width: Math.min(parent.width-(Maui.Style.space.medium*2), implicitWidth)
0097         maxListHeight: root.height - (Maui.Style.contentMargins*2)
0098 
0099         onItemClicked: (index) => console.log(index)
0100 
0101         onExitClicked:
0102         {
0103             control.selectionMode = false
0104             clear()
0105         }
0106 
0107         listDelegate: Maui.ListBrowserDelegate
0108         {
0109             width: ListView.view.width
0110             iconSource: model.icon
0111             label1.text: model.label
0112             label2.text: model.url
0113 
0114             checkable: true
0115             checked: true
0116             onToggled: _selectionbar.removeAtIndex(index)
0117 
0118             background: null
0119         }
0120 
0121         Action
0122         {
0123             text: i18n("Open")
0124             icon.name: "document-open"
0125             onTriggered:
0126             {
0127                 const paths =  _selectionbar.uris
0128                 for(var i in paths)
0129                     editorView.openTab(paths[i])
0130 
0131                 _selectionbar.clear()
0132             }
0133         }
0134 
0135         Action
0136         {
0137             text: i18n("Share")
0138             icon.name: "document-share"
0139             onTriggered: Maui.Platform.shareFiles(_selectionbar.uris)
0140         }
0141 
0142         Action
0143         {
0144             text: i18n("Export")
0145             icon.name: "document-export"
0146             onTriggered:
0147             {
0148                 _dialogLoader.sourceComponent= _fileDialogComponent
0149                 dialog.mode = dialog.modes.OPEN
0150                 dialog.settings.onlyDirs = true
0151                 dialog.callback = function(paths)
0152                 {
0153                     for(var url of _selectionbar.uris)
0154                     {
0155                         for(var i in paths)
0156                         {
0157                             FB.FM.copy(url, paths[i])
0158                         }
0159                     }
0160                 };
0161 
0162                 dialog.open()
0163             }
0164         }
0165     }
0166 
0167     function addToSelection(item)
0168     {
0169         _selectionbar.append(item.path, item)
0170     }
0171 }