Before:   After:   @martremotes/origin/work/commitevent
parent
e6483c98fc
commit
c9e09be0a9
12 changed files with 306 additions and 147 deletions
@ -1,70 +0,0 @@ |
|||||||
/* |
|
||||||
SPDX-FileCopyrightText: 2012 Marco Martin <mart@kde.org> |
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later |
|
||||||
*/ |
|
||||||
|
|
||||||
import QtQuick 2.1 |
|
||||||
import QtQuick.Controls 2.0 as QQC2 |
|
||||||
import QtQuick.Layouts 1.2 |
|
||||||
import org.kde.kirigami 2.0 as Kirigami |
|
||||||
|
|
||||||
Column { |
|
||||||
id: treeDelegate |
|
||||||
property variant sourceModel |
|
||||||
property int rowIndex: index |
|
||||||
width: parent.width |
|
||||||
|
|
||||||
property bool matches: display.toLowerCase().indexOf(searchField.text.toLowerCase()) !== -1 |
|
||||||
|
|
||||||
Kirigami.BasicListItem { |
|
||||||
id: delegateArea |
|
||||||
height: matches ? implicitHeight : 0 |
|
||||||
opacity: matches ? 1 : 0 |
|
||||||
Behavior on opacity { |
|
||||||
NumberAnimation { duration: 250 } |
|
||||||
} |
|
||||||
Behavior on height { |
|
||||||
NumberAnimation { duration: 250 } |
|
||||||
} |
|
||||||
|
|
||||||
onClicked: { |
|
||||||
documentItem.currentPage = page-1 |
|
||||||
contextDrawer.drawerOpen = false |
|
||||||
} |
|
||||||
|
|
||||||
label: display |
|
||||||
highlighted: highlight |
|
||||||
icon: highlight || highlightedParent ? (LayoutMirroring.enabled ? "arrow-left" : "arrow-right") : "" |
|
||||||
|
|
||||||
QQC2.Label { |
|
||||||
text: pageLabel ? pageLabel : page |
|
||||||
verticalAlignment: Text.AlignBottom |
|
||||||
Layout.rightMargin: Kirigami.Units.largeSpacing |
|
||||||
} |
|
||||||
} |
|
||||||
Column { |
|
||||||
id: col |
|
||||||
x: 20 |
|
||||||
width: parent.width - 20 |
|
||||||
property variant model: childrenModel |
|
||||||
Repeater { |
|
||||||
id: rep |
|
||||||
model: VisualDataModel { |
|
||||||
id: childrenModel |
|
||||||
model: documentItem.tableOfContents |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
onParentChanged: { |
|
||||||
if (treeDelegate.parent && treeDelegate.parent.model) { |
|
||||||
sourceModel = treeDelegate.parent.model |
|
||||||
} |
|
||||||
|
|
||||||
childrenModel.rootIndex = sourceModel.modelIndex(index) |
|
||||||
|
|
||||||
if (model.hasModelChildren) { |
|
||||||
childrenModel.delegate = Qt.createComponent("TreeDelegate.qml") |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,77 @@ |
|||||||
|
/* |
||||||
|
* SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> |
||||||
|
* |
||||||
|
* SPDX-License-Identifier: LGPL-2.0-or-later |
||||||
|
*/ |
||||||
|
|
||||||
|
import QtQuick 2.12 |
||||||
|
import QtQuick.Layouts 1.4 |
||||||
|
import QtQuick.Controls 2.14 as QQC2 |
||||||
|
import org.kde.kirigami 2.13 as Kirigami |
||||||
|
import org.kde.kitemmodels 1.0 |
||||||
|
|
||||||
|
/** |
||||||
|
* An item delegate for the TreeListView and TreeTableView components. |
||||||
|
* |
||||||
|
* It has the tree expander decoration but no content otherwise, |
||||||
|
* which has to be set as contentItem |
||||||
|
* |
||||||
|
*/ |
||||||
|
QQC2.ItemDelegate { |
||||||
|
id: listItem |
||||||
|
|
||||||
|
property alias decoration: decoration |
||||||
|
|
||||||
|
width: ListView.view.width |
||||||
|
|
||||||
|
data: [ |
||||||
|
TreeViewDecoration { |
||||||
|
id: decoration |
||||||
|
anchors { |
||||||
|
left: parent.left |
||||||
|
top:parent.top |
||||||
|
bottom: parent.bottom |
||||||
|
leftMargin: listItem.padding |
||||||
|
} |
||||||
|
parent: listItem |
||||||
|
parentDelegate: listItem |
||||||
|
model: listItem.ListView.view ? listItem.ListView.view.model :null |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
Keys.onLeftPressed: if (kDescendantExpandable && kDescendantExpanded) { |
||||||
|
decoration.model.collapseChildren(index); |
||||||
|
} else if (!kDescendantExpandable && kDescendantLevel > 0) { |
||||||
|
if (listItem.ListView.view) { |
||||||
|
const sourceIndex = decoration.model.mapToSource(decoration.model.index(index, 0)); |
||||||
|
const newIndex = decoration.model.mapFromSource(sourceIndex.parent); |
||||||
|
listItem.listItem.ListView.view.currentIndex = newIndex.row; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Keys.onRightPressed: if (kDescendantExpandable) { |
||||||
|
if (kDescendantExpanded && listItem.ListView.view) { |
||||||
|
ListView.view.incrementCurrentIndex(); |
||||||
|
} else { |
||||||
|
decoration.model.expandChildren(index); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
onDoubleClicked: if (kDescendantExpandable) { |
||||||
|
decoration.model.toggleChildren(index); |
||||||
|
} |
||||||
|
|
||||||
|
contentItem: Kirigami.Heading { |
||||||
|
wrapMode: Text.Wrap |
||||||
|
text: listItem.text |
||||||
|
level: 5 |
||||||
|
width: listItem.ListView.view.width - (decoration.width + listItem.padding * 3 + Kirigami.Units.smallSpacing) |
||||||
|
} |
||||||
|
|
||||||
|
leftInset: Qt.application.layoutDirection !== Qt.RightToLeft ? decoration.width + listItem.padding * 2 : 0 |
||||||
|
leftPadding: Qt.application.layoutDirection !== Qt.RightToLeft ? decoration.width + listItem.padding * 2 : 0 |
||||||
|
|
||||||
|
rightPadding: Qt.application.layoutDirection === Qt.RightToLeft ? decoration.width + listItem.padding * 2 : 0 |
||||||
|
rightInset: Qt.application.layoutDirection === Qt.RightToLeft ? decoration.width + listItem.padding * 2 : 0 |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,113 @@ |
|||||||
|
/* |
||||||
|
* SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org> |
||||||
|
* |
||||||
|
* SPDX-License-Identifier: LGPL-2.0-or-later |
||||||
|
*/ |
||||||
|
|
||||||
|
import QtQuick 2.6 |
||||||
|
import QtQuick.Layouts 1.4 |
||||||
|
import QtQuick.Controls 2.2 as QQC2 |
||||||
|
import QtQuick.Templates 2.2 as T |
||||||
|
import org.kde.kitemmodels 1.0 |
||||||
|
import org.kde.kirigami 2.14 as Kirigami |
||||||
|
|
||||||
|
/** |
||||||
|
* The tree expander decorator for item views. |
||||||
|
* |
||||||
|
* It will have a "> v" expander button graphics, and will have indentation on the left |
||||||
|
* depending on the level of the tree the item is in |
||||||
|
*/ |
||||||
|
RowLayout { |
||||||
|
id: decorationLayout |
||||||
|
/** |
||||||
|
* The delegate this decoration will live in. |
||||||
|
* It needs to be assigned explicitly by the developer. |
||||||
|
*/ |
||||||
|
property T.ItemDelegate parentDelegate |
||||||
|
|
||||||
|
/** |
||||||
|
* The KDescendantsProxyModel the view is showing. |
||||||
|
* It needs to be assigned explicitly by the developer. |
||||||
|
*/ |
||||||
|
property KDescendantsProxyModel model |
||||||
|
|
||||||
|
property color decorationHighlightColor |
||||||
|
|
||||||
|
Layout.topMargin: -parentDelegate.topPadding |
||||||
|
Layout.bottomMargin: -parentDelegate.bottomPadding |
||||||
|
Repeater { |
||||||
|
model: kDescendantLevel-1 |
||||||
|
delegate: Item { |
||||||
|
Layout.preferredWidth: controlRoot.width |
||||||
|
Layout.fillHeight: true |
||||||
|
|
||||||
|
Rectangle { |
||||||
|
anchors { |
||||||
|
horizontalCenter: parent.horizontalCenter |
||||||
|
top: parent.top |
||||||
|
bottom: parent.bottom |
||||||
|
} |
||||||
|
visible: kDescendantHasSiblings[modelData] |
||||||
|
color: Kirigami.Theme.textColor |
||||||
|
opacity: 0.5 |
||||||
|
width: 1 |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
T.Button { |
||||||
|
id: controlRoot |
||||||
|
Layout.preferredWidth: Kirigami.Units.gridUnit |
||||||
|
Layout.fillHeight: true |
||||||
|
enabled: kDescendantExpandable |
||||||
|
hoverEnabled: enabled |
||||||
|
onClicked: model.toggleChildren(index) |
||||||
|
contentItem: Item { |
||||||
|
id: styleitem |
||||||
|
implicitWidth: Kirigami.Units.gridUnit |
||||||
|
Rectangle { |
||||||
|
anchors { |
||||||
|
horizontalCenter: parent.horizontalCenter |
||||||
|
top: parent.top |
||||||
|
bottom: expander.visible ? expander.top : parent.verticalCenter |
||||||
|
} |
||||||
|
color: Kirigami.Theme.textColor |
||||||
|
opacity: 0.5 |
||||||
|
width: 1 |
||||||
|
} |
||||||
|
Kirigami.Icon { |
||||||
|
id: expander |
||||||
|
anchors.centerIn: parent |
||||||
|
width: Kirigami.Units.iconSizes.small |
||||||
|
height: width |
||||||
|
source: kDescendantExpanded ? "go-down-symbolic" : (Qt.application.layoutDirection == Qt.RightToLeft ? "go-previous-symbolic" : "go-next-symbolic") |
||||||
|
isMask: true |
||||||
|
color: controlRoot.hovered ? decorationLayout.decorationHighlightColor ? decorationLayout.decorationHighlightColor : |
||||||
|
Kirigami.Theme.highlightColor : Kirigami.Theme.textColor |
||||||
|
Behavior on color { ColorAnimation { duration: Kirigami.Units.shortDuration; easing.type: Easing.InOutQuad } } |
||||||
|
visible: kDescendantExpandable |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
anchors { |
||||||
|
horizontalCenter: parent.horizontalCenter |
||||||
|
top: expander.visible ? expander.bottom : parent.verticalCenter |
||||||
|
bottom: parent.bottom |
||||||
|
} |
||||||
|
visible: kDescendantHasSiblings[kDescendantHasSiblings.length - 1] |
||||||
|
color: Kirigami.Theme.textColor |
||||||
|
opacity: 0.5 |
||||||
|
width: 1 |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
anchors { |
||||||
|
verticalCenter: parent.verticalCenter |
||||||
|
left: expander.visible ? expander.right : parent.horizontalCenter |
||||||
|
right: parent.right |
||||||
|
} |
||||||
|
color: Kirigami.Theme.textColor |
||||||
|
opacity: 0.5 |
||||||
|
height: 1 |
||||||
|
} |
||||||
|
} |
||||||
|
background: Item {} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue