From 7eddc26d24defb3444e21adfbd43f8e568be576d Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 22 Jul 2017 04:30:45 +0200 Subject: ModelIndexRetriever to abuse Repeater less publicly Simliar to Retriever, but we'd have to alias all properties/roles automatically somehow. --- components/kube/contents/ui/LogView.qml | 19 ++++++------------- framework/qml/ModelIndexRetriever.qml | 32 ++++++++++++++++++++++++++++++++ framework/qmldir | 1 + 3 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 framework/qml/ModelIndexRetriever.qml diff --git a/components/kube/contents/ui/LogView.qml b/components/kube/contents/ui/LogView.qml index 0d01ed6f..918597df 100644 --- a/components/kube/contents/ui/LogView.qml +++ b/components/kube/contents/ui/LogView.qml @@ -122,24 +122,17 @@ Controls.SplitView { property date timestamp property string message property string resourceId: "" - property string accountId: "" - property string accountName: "" + property string accountId: retriever.currentData.accountId + property string accountName: retriever.currentData.name color: Kube.Colors.backgroundColor - Repeater { + + Kube.ModelIndexRetriever { + id: retriever model: Kube.AccountsModel { - id: accountsModel resourceId: details.resourceId } - Item { - property string account: model.accountId - property string accountName: model.name - onAccountChanged: { - details.accountId = account - details.accountName = name - } - visible: false - } } + Rectangle { anchors { fill: parent diff --git a/framework/qml/ModelIndexRetriever.qml b/framework/qml/ModelIndexRetriever.qml new file mode 100644 index 00000000..fa3fb64b --- /dev/null +++ b/framework/qml/ModelIndexRetriever.qml @@ -0,0 +1,32 @@ +/* + * 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.4 + +Repeater { + id: root + property var currentData + Item { + id: delegate + property var currentData: model + onCurrentDataChanged: { + root.currentData = model + } + visible: false + } +} diff --git a/framework/qmldir b/framework/qmldir index b7e455b3..0a71b6c8 100644 --- a/framework/qmldir +++ b/framework/qmldir @@ -33,6 +33,7 @@ ListView 1.0 ListView.qml TreeView 1.0 TreeView.qml GridView 1.0 GridView.qml ScrollHelper 1.0 ScrollHelper.qml +ModelIndexRetriever 1.0 ModelIndexRetriever.qml singleton Messages 1.0 Messages.qml singleton Colors 1.0 Colors.qml singleton Icons 1.0 Icons.qml -- cgit v1.2.3