From 0fc4fc7f9b19499fe5922eddd84fce8f01badea2 Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Mon, 11 Sep 2017 14:43:47 +0200 Subject: add maillist filter field --- framework/qml/MailListView.qml | 334 +++++++++++++++++++++-------------------- 1 file changed, 174 insertions(+), 160 deletions(-) (limited to 'framework/qml/MailListView.qml') diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml index 1a1bdb6c..94e591e7 100644 --- a/framework/qml/MailListView.qml +++ b/framework/qml/MailListView.qml @@ -63,199 +63,213 @@ FocusScope { text: qsTr("Nothing here...") } - Kube.ListView { - id: listView - + ColumnLayout { anchors.fill: parent - clip: true - focus: true - //BEGIN keyboard nav - onActiveFocusChanged: { - if (activeFocus && currentIndex < 0) { - currentIndex = 0 - } - } + spacing: 0 - Keys.onDownPressed: { - incrementCurrentIndex() - } - Keys.onUpPressed: { - decrementCurrentIndex() - } - //END keyboard nav - - onCurrentItemChanged: { - if (currentItem) { - root.currentMail = currentItem.currentData.mail; - root.isDraft = currentItem.currentData.draft; - root.isTrash = currentItem.currentData.trash; - root.isImportant = currentItem.currentData.important; - root.isUnread = currentItem.currentData.unread; - } + Kube.TextField { + Layout.fillWidth: true + placeholderText: "Filter..." + onTextChanged: mailListModel.filter = text } - model: Kube.MailListModel { - id: mailListModel - parentFolder: root.parentFolder - } - - delegate: Kube.ListDelegate { - id: delegateRoot - //Required for D&D - property var mail: model.mail + Kube.ListView { + id: listView - width: listView.width - Kube.Units.smallSpacing - height: Kube.Units.gridUnit * 5 + Layout.fillWidth: true + Layout.fillHeight: true - color: Kube.Colors.viewBackgroundColor - border.color: Kube.Colors.backgroundColor - border.width: 1 + clip: true + focus: true - states: [ - State { - name: "dnd" - when: mouseArea.drag.active + //BEGIN keyboard nav + onActiveFocusChanged: { + if (activeFocus && currentIndex < 0) { + currentIndex = 0 + } + } - PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor} - PropertyChanges {target: delegateRoot; x: x; y: y} - PropertyChanges {target: delegateRoot; parent: root} - PropertyChanges {target: delegateRoot; opacity: 0.7} - PropertyChanges {target: delegateRoot; highlighted: true} + Keys.onDownPressed: { + incrementCurrentIndex() + } + Keys.onUpPressed: { + decrementCurrentIndex() } - ] - - Drag.active: mouseArea.drag.active - Drag.hotSpot.x: mouseArea.mouseX - Drag.hotSpot.y: mouseArea.mouseY - Drag.source: delegateRoot - - MouseArea { - id: mouseArea - anchors.fill: parent - drag.target: parent - onReleased: parent.Drag.drop() - onClicked: delegateRoot.clicked() + //END keyboard nav + + onCurrentItemChanged: { + if (currentItem) { + root.currentMail = currentItem.currentData.mail; + root.isDraft = currentItem.currentData.draft; + root.isTrash = currentItem.currentData.trash; + root.isImportant = currentItem.currentData.important; + root.isUnread = currentItem.currentData.unread; + } + } + + model: Kube.MailListModel { + id: mailListModel + parentFolder: root.parentFolder } - Item { - id: content + delegate: Kube.ListDelegate { + id: delegateRoot + //Required for D&D + property var mail: model.mail + + width: listView.width - Kube.Units.smallSpacing + height: Kube.Units.gridUnit * 5 + + color: Kube.Colors.viewBackgroundColor + border.color: Kube.Colors.backgroundColor + border.width: 1 + + states: [ + State { + name: "dnd" + when: mouseArea.drag.active - anchors { - fill: parent - margins: Kube.Units.smallSpacing + PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor} + PropertyChanges {target: delegateRoot; x: x; y: y} + PropertyChanges {target: delegateRoot; parent: root} + PropertyChanges {target: delegateRoot; opacity: 0.7} + PropertyChanges {target: delegateRoot; highlighted: true} } - property color unreadColor: (model.unread && !delegateRoot.highlighted) ? Kube.Colors.highlightColor : delegateRoot.textColor - -//TODO batch editing -// Kube.CheckBox { -// id: checkBox -// -// anchors.verticalCenter: parent.verticalCenter -// visible: (checked || delegateRoot.hovered) && !mouseArea.drag.active -// opacity: 0.9 -// } - - Column { + ] + + Drag.active: mouseArea.drag.active + Drag.hotSpot.x: mouseArea.mouseX + Drag.hotSpot.y: mouseArea.mouseY + Drag.source: delegateRoot + + MouseArea { + id: mouseArea + anchors.fill: parent + drag.target: parent + onReleased: parent.Drag.drop() + onClicked: delegateRoot.clicked() + } + + Item { + id: content + anchors { - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: Kube.Units.largeSpacing // + checkBox.width + fill: parent + margins: Kube.Units.smallSpacing } - - Kube.Label{ - id: subject - width: content.width - Kube.Units.gridUnit * 3 - text: model.subject - color: content.unreadColor - maximumLineCount: 2 - wrapMode: Text.WordWrap - elide: Text.ElideRight + property color unreadColor: (model.unread && !delegateRoot.highlighted) ? Kube.Colors.highlightColor : delegateRoot.textColor + + //TODO batch editing + // Kube.CheckBox { + // id: checkBox + // + // anchors.verticalCenter: parent.verticalCenter + // visible: (checked || delegateRoot.hovered) && !mouseArea.drag.active + // opacity: 0.9 + // } + + Column { + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: Kube.Units.largeSpacing // + checkBox.width + } + + Kube.Label{ + id: subject + width: content.width - Kube.Units.gridUnit * 3 + text: model.subject + color: content.unreadColor + maximumLineCount: 2 + wrapMode: Text.WordWrap + elide: Text.ElideRight + } + + Kube.Label { + id: sender + text: model.senderName + color: delegateRoot.textColor + font.italic: true + width: delegateRoot.width - Kube.Units.gridUnit * 3 + elide: Text.ElideRight + } } Kube.Label { - id: sender - text: model.senderName - color: delegateRoot.textColor + id: date + anchors { + right: parent.right + bottom: parent.bottom + } + visible: !delegateRoot.hovered + text: Qt.formatDateTime(model.date, "dd MMM yyyy") font.italic: true - width: delegateRoot.width - Kube.Units.gridUnit * 3 - elide: Text.ElideRight + color: Kube.Colors.disabledTextColor + font.pointSize: Kube.Units.tinyFontSize + } + + Kube.Label { + id: threadCounter + anchors.right: parent.right + text: model.threadSize + color: content.unreadColor + visible: model.threadSize > 1 } } - Kube.Label { - id: date + Row { + id: buttons + anchors { right: parent.right bottom: parent.bottom + margins: Kube.Units.smallSpacing } - visible: !delegateRoot.hovered - text: Qt.formatDateTime(model.date, "dd MMM yyyy") - font.italic: true - color: Kube.Colors.disabledTextColor - font.pointSize: Kube.Units.tinyFontSize - } - Kube.Label { - id: threadCounter - anchors.right: parent.right - text: model.threadSize - color: content.unreadColor - visible: model.threadSize > 1 - } - } - - Row { - id: buttons - - anchors { - right: parent.right - bottom: parent.bottom - margins: Kube.Units.smallSpacing - } + visible: delegateRoot.hovered && !mouseArea.drag.active - visible: delegateRoot.hovered && !mouseArea.drag.active + spacing: Kube.Units.smallSpacing + opacity: 0.7 - spacing: Kube.Units.smallSpacing - opacity: 0.7 - - Kube.IconButton { - id: readButton - iconName: Kube.Icons.markAsRead - visible: model.unread - onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": model.mail}) - activeFocusOnTab: false - } - Kube.IconButton { - id: unreadButton - iconName: Kube.Icons.markAsUnread - visible: !model.unread - onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsUnread, {"mail": model.mail}) - activeFocusOnTab: false - } + Kube.IconButton { + id: readButton + iconName: Kube.Icons.markAsRead + visible: model.unread + onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": model.mail}) + activeFocusOnTab: false + } + Kube.IconButton { + id: unreadButton + iconName: Kube.Icons.markAsUnread + visible: !model.unread + onClicked: Kube.Fabric.postMessage(Kube.Messages.markAsUnread, {"mail": model.mail}) + activeFocusOnTab: false + } - Kube.IconButton { - id: importantButton - iconName: Kube.Icons.markImportant - visible: !!model.mail - onClicked: Kube.Fabric.postMessage(Kube.Messages.toggleImportant, {"mail": model.mail, "important": model.important}) - activeFocusOnTab: false - } + Kube.IconButton { + id: importantButton + iconName: Kube.Icons.markImportant + visible: !!model.mail + onClicked: Kube.Fabric.postMessage(Kube.Messages.toggleImportant, {"mail": model.mail, "important": model.important}) + activeFocusOnTab: false + } - Kube.IconButton { - id: deleteButton - iconName: Kube.Icons.moveToTrash - visible: !!model.mail - onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail}) - activeFocusOnTab: false - } + Kube.IconButton { + id: deleteButton + iconName: Kube.Icons.moveToTrash + visible: !!model.mail + onClicked: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": model.mail}) + activeFocusOnTab: false + } - Kube.IconButton { - id: restoreButton - iconName: Kube.Icons.undo - visible: !!model.trash - onClicked: Kube.Fabric.postMessage(Kube.Messages.restoreFromTrash, {"mail": model.mail}) - activeFocusOnTab: false + Kube.IconButton { + id: restoreButton + iconName: Kube.Icons.undo + visible: !!model.trash + onClicked: Kube.Fabric.postMessage(Kube.Messages.restoreFromTrash, {"mail": model.mail}) + activeFocusOnTab: false + } } } } -- cgit v1.2.3