From 03e8aabf1754f5061f207d2c9c082ba6199db0e5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 2 Mar 2018 12:00:54 +0100 Subject: Visualize that a folder has new mails. We listen for new mail notifications, and highlight the folder accordingly. --- framework/qml/FolderListView.qml | 34 +++++++++++++++++++++++++++------- framework/qml/TreeView.qml | 33 ++++++--------------------------- 2 files changed, 33 insertions(+), 34 deletions(-) (limited to 'framework/qml') diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml index 25c6cbe5..a24a9ff6 100644 --- a/framework/qml/FolderListView.qml +++ b/framework/qml/FolderListView.qml @@ -30,6 +30,33 @@ Kube.TreeView { Controls1.TableViewColumn { title: "Name" role: "name" + delegate: Item { + DropArea { + anchors.fill: parent + Rectangle { + anchors.fill: parent + color: Kube.Colors.viewBackgroundColor + opacity: 0.3 + visible: parent.containsDrag + } + onDropped: { + Kube.Fabric.postMessage(Kube.Messages.moveToFolder, {"mail": drop.source.mail, "folder": model.domainObject}) + drop.accept(Qt.MoveAction) + drop.source.visible = false + } + } + + Kube.Label { + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + right: parent.right + } + text: styleData.value + elide: Qt.ElideRight + color: model.hasNewData ? Kube.Colors.highlightColor : Kube.Colors.viewBackgroundColor + } + } } model: Kube.FolderListModel { @@ -43,11 +70,4 @@ Kube.TreeView { Kube.Fabric.postMessage(Kube.Messages.folderSelection, {"folder": model.data(index, Kube.FolderListModel.DomainObject), "trash": model.data(index, Kube.FolderListModel.Trash)}); } - - - onDropped: { - Kube.Fabric.postMessage(Kube.Messages.moveToFolder, {"mail": drop.source.mail, "folder": model.domainObject}) - drop.accept(Qt.MoveAction) - drop.source.visible = false - } } diff --git a/framework/qml/TreeView.qml b/framework/qml/TreeView.qml index eb140514..7b9a1103 100644 --- a/framework/qml/TreeView.qml +++ b/framework/qml/TreeView.qml @@ -36,12 +36,16 @@ FocusScope { * FIXME: This is what QItemSelectionModel selection vs current selection are for. Try to use that instead. */ property var activeIndex: null - signal dropped(var drop, var model) signal activated(var index) onActivated: { activeIndex = index } + function indexFromRow(row) { + //FIXME Uses internal API to get to the model index + return treeView.__model.mapRowToModelIndex(row) + } + Flickable { id: flickableItem @@ -115,8 +119,7 @@ FocusScope { style: TreeViewStyle { rowDelegate: Controls2.Control { id: delegateRoot - //FIXME Uses internal API to get to the model index - property bool isActive: root.activeIndex === treeView.__model.mapRowToModelIndex(styleData.row) + property bool isActive: root.activeIndex === indexFromRow(styleData.row) height: Kube.Units.gridUnit * 1.5 //FIXME This is the only way I could find to get the correct width. parent.width is way to wide width: parent.parent.parent ? parent.parent.parent.width : 0 @@ -145,30 +148,6 @@ FocusScope { text: styleData.isExpanded ? "-" : "+" } - itemDelegate: Item { - DropArea { - anchors.fill: parent - Rectangle { - anchors.fill: parent - color: Kube.Colors.viewBackgroundColor - opacity: 0.3 - visible: parent.containsDrag - } - onDropped: root.dropped(drop, model) - } - - Kube.Label { - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - right: parent.right - } - text: styleData.value - elide: Qt.ElideRight - color: Kube.Colors.viewBackgroundColor - } - } - backgroundColor: Kube.Colors.textColor highlightedTextColor: Kube.Colors.highlightedTextColor } -- cgit v1.2.3