From b1e49b5bad02f6dbab9578d2cdd0ad73b18e1c4a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 25 Jul 2017 01:39:22 +0200 Subject: A ListDelegate --- components/kube/contents/ui/LogView.qml | 19 +-------------- framework/qml/ListDelegate.qml | 41 +++++++++++++++++++++++++++++++++ framework/qmldir | 1 + 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 framework/qml/ListDelegate.qml diff --git a/components/kube/contents/ui/LogView.qml b/components/kube/contents/ui/LogView.qml index b278c2e9..b71d3692 100644 --- a/components/kube/contents/ui/LogView.qml +++ b/components/kube/contents/ui/LogView.qml @@ -54,16 +54,7 @@ Controls.SplitView { details.message = currentItem.currentData.message details.timestamp = currentItem.currentData.timestamp } - - delegate: Rectangle { - property variant currentData: model - height: Kube.Units.gridUnit * 3 - width: listView.width - - border.color: Kube.Colors.buttonColor - border.width: 1 - color: listView.currentIndex == index ? Kube.Colors.highlightColor : Kube.Colors.viewBackgroundColor - + delegate: Kube.ListDelegate { Kube.Label { id: description anchors { @@ -106,14 +97,6 @@ Controls.SplitView { color: Kube.Colors.disabledTextColor font.pointSize: 9 } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - listView.currentIndex = index - } - } } } } diff --git a/framework/qml/ListDelegate.qml b/framework/qml/ListDelegate.qml new file mode 100644 index 00000000..3c63ccbe --- /dev/null +++ b/framework/qml/ListDelegate.qml @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 Michael Bohlender, + * Copyright (C) 2017 Christian Mollekopf, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.7 +import org.kube.framework 1.0 as Kube + +Rectangle { + id: root + property variant currentData: model + property var listView: root.parent + default property alias contentItem: root.children + + height: Kube.Units.gridUnit * 3 + width: listView.width + + border.color: Kube.Colors.buttonColor + border.width: 1 + color: listView.currentIndex == root.index ? Kube.Colors.highlightColor : Kube.Colors.viewBackgroundColor + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: listView.currentIndex = root.index + } +} diff --git a/framework/qmldir b/framework/qmldir index 156cdb07..83fc8d61 100644 --- a/framework/qmldir +++ b/framework/qmldir @@ -31,6 +31,7 @@ View 1.0 View.qml AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml AttachmentDelegate 1.0 AttachmentDelegate.qml ListView 1.0 ListView.qml +ListDelegate 1.0 ListDelegate.qml TreeView 1.0 TreeView.qml GridView 1.0 GridView.qml ScrollHelper 1.0 ScrollHelper.qml -- cgit v1.2.3