19import QtQuick.Controls.Suru 2.2
20import Lomiri.Components 1.3
21import Dekko.Mail.Accounts 1.0
23import Dekko.Mail.API 1.0
24import Dekko.Mail.Stores.Mail 1.0
25import Dekko.Components 1.0
26import Dekko.Mail.Settings 1.0
27import Dekko.Lomiri.Components 1.0
28import Dekko.Lomiri.Constants 1.0
39 property alias mboxSearch: loader_mboxSearch.item
42 title: MailStore.folderTitle
44 composeButtonEnabled: !dekko.isLargeFF
45 backAction: dekko.isSmallFF || MailStore.isInSelectionMode ? drawerAction : null
46 filterSections: isSearchMode ? MailStore.searchFilters : MailStore.defaultFilters
47 multiSelectActionList: multiSelectRegistry.actions
50 onSelectedIndexChanged: {
52 if (selectedIndex === 0) {
53 mboxSearch.location = MailboxSearch.Local
55 mboxSearch.location = MailboxSearch.Remote
59 var filter = MessageList.All;
60 switch (selectedIndex) {
62 filter = MessageList.All;
65 filter = MessageList.Unread;
68 filter = MessageList.Important;
71 filter = MessageList.Replied;
74 filter = MessageList.Forwarded;
77 filter = MessageList.Attachments;
80 filter = MessageList.Calendar;
83 MessageActions.setMessageListFilter(filter)
86 onMultiSelectCanceled: MessageActions.endMultiSelection()
87 onIsSearchModeChanged: {
89 listView.currentIndex = -1
90 listView.model = mboxSearch.results
92 MessageActions.resetMessageList()
96 onSearchActivated: mboxSearch.search(searchString)
98 pageHeader.searchInProgress =
false;
99 mboxSearch.cancelSearch()
103 category:
"ui-property-cache"
104 property alias msgListFilterIndex: msgListPage.selectedIndex
109 id: multiSelectRegistry
110 location: MailStore.listenerId ?
"Dekko::Mail::MultiSelectAction" :
""
113 iconSource: !MailStore.msgList.canSelectAll ? Paths.actionIconUrl(Paths.NoneSelectedIcon) :
114 Paths.actionIconUrl(Paths.SelectIcon)
115 text: MailStore.msgList.canSelectAll ? qsTr(
"Unselect all") : qsTr(
"Select all")
117 if (MailStore.msgList.canSelectAll) {
118 MessageActions.selectAllMessages()
120 MessageActions.unselectAllMessages()
125 iconSource: MailStore.msgList.canMarkSelectionImportant ? Paths.actionIconUrl(Paths.StarredIcon) :
126 Paths.actionIconUrl(Paths.UnStarredIcon)
127 text: MailStore.msgList.canMarkSelectionImportant ? qsTr(
"Star") : qsTr(
"Remove star")
128 onTriggered: MessageActions.markSelectedMessagesImportant()
131 text: MailStore.msgList.canMarkSelectionRead ? qsTr(
"Mark as un-read") : qsTr(
"Mark as read")
132 iconSource: !MailStore.msgList.canMarkSelectionRead ? Paths.actionIconUrl(Paths.MailUnreadIcon) :
133 Paths.actionIconUrl(Paths.MailReadIcon)
134 onTriggered: MessageActions.markSelectedMessagesRead()
137 iconSource: Paths.actionIconUrl(Paths.DeleteIcon)
139 onTriggered: MessageActions.deleteSelectedMessages()
146 iconName:
"navigation-menu"
147 onTriggered: ViewActions.toggleNavDrawer()
151 id: loader_mboxSearch
153 sourceComponent: Component {
154 id: component_mboxSearch
156 messageKey: MailStore.msgListKey
157 location: MailboxSearch.Local
159 sortBy: MailboxSearch.TimeStamp
160 sortOrder: Qt.DescendingOrder
162 if (status === SearchService.InProgress) {
163 pageHeader.searchInProgress =
true
165 pageHeader.searchInProgress =
false
178 expansion.height: units.gu(6)
179 expansion.expanded: MailStore.hasUndoableActions
180 divider.visible: MailStore.hasUndoableActions
187 color: Suru.secondaryBackgroundColor
192 leftMargin:
Style.defaultSpacing
193 verticalCenter: parent.verticalCenter
194 right: undoButton.left
195 rightMargin: units.gu(1.5)
197 elide: Text.ElideRight
199 visible: MailStore.hasUndoableActions
200 text: MailStore.undoableActionDescription
205 height:
Style.largeSpacing
206 width: undoAction.text.width > units.gu(15) ? units.gu(15) : undoAction.text.width
209 rightMargin:
Style.defaultSpacing
210 verticalCenter: parent.verticalCenter
212 Suru.highlightType: Suru.PositiveHighlight
213 color: Suru.highlightColor
217 onTriggered: MessageActions.undoRecentActions()
226 top: undoNotification.bottom
228 bottom: parent.bottom
231 Keys.forwardTo: [listView]
235 property int selectionIndex: 0
238 property bool dontLoadNextCurrentItem:
false
243 onCurrentIndexChanged: {
244 MailStore.currentSelectedIndex = currentIndex
247 onCurrentItemChanged: {
248 if (!currentItem || currentIndex === -1) {
251 if (dontLoadNextCurrentItem) {
253 dontLoadNextCurrentItem =
false
257 MessageActions.openMessage(currentItem.msg.messageId)
258 if (currentIndex == MailStore.msgListModel.count - 1) {
259 MessageActions.showMoreMessages()
268 highlight: !dekko.isSmallFF ?
Style.highlightBar : null
269 highlightFollowsCurrentItem:
true
270 highlightMoveDuration: 200
271 cacheBuffer: units.gu(120)
272 model: MailStore.msgListModel
275 width: ListView.view.width
281 leftSideAction: Action {
284 MessageActions.deleteMessage(msgListDelegate.msg.messageId)
288 rightSideActions: [flagAction, readAction, contextAction]
292 if (MailStore.isInSelectionMode) {
294 MessageActions.setMessageCheck(model.index, Qt.Unchecked)
296 MessageActions.setMessageCheck(model.index, Qt.Checked)
302 ComposerActions.openDraft(msg.messageId)
306 if (mouse.button === Qt.RightButton) {
307 rightClickActions.trigger()
311 listView.currentIndex = model.index
313 onItemPressAndHold: {
318 if (!MailStore.isInSelectionMode) {
319 listView.selectionIndex = model.index
320 MessageActions.startMultiSelection()
321 MessageActions.setMessageCheck(model.index, Qt.Checked)
322 msgListPage.startMultiSelect()
330 footer: (!isSearchMode && !MailStore.msgListLoading && MailStore.canLoadMore) ? footerComponent : null
336 anchors.centerIn: parent
337 text: qsTr(
"Load more messages ...")
339 onClicked: MessageActions.showMoreMessages()
344 refreshing: MailboxStore.folderSyncActive
345 onRefresh: MailboxActions.syncStandardFolders(Folder.StandardFolder)
353 horizontalCenter: parent.horizontalCenter
354 topMargin: units.gu(20)
356 visible: MailStore.msgListLoading
357 running: MailStore.msgListLoading
363 property:
"currentIndex";
364 value: MailStore.currentSelectedIndex
371 type: MessageKeys.resetMessageList
373 listView.currentIndex = -1
374 listView.positionViewAtBeginning()
376 if (listView.model !== MailStore.msgListModel) {
377 listView.dontLoadNextCurrentItem =
true
378 listView.model = MailStore.msgListModel
384 type: MailboxKeys.resetSelectedMsgIndex
386 listView.currentIndex = -1