Commit 53a51bb0 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Add vendored TreeView components

parent 30a03067
Pipeline #88965 passed with stage
in 1 minute and 47 seconds
......@@ -9,7 +9,6 @@ import QtQuick.Dialogs 1.0
import org.kde.kalendar 1.0
import Qt.labs.qmlmodels 1.0
import org.kde.kitemmodels 1.0
import org.kde.kirigamiaddons.treeview 1.0 as TreeView
Kirigami.Page {
title: i18n("Calendars")
......
......@@ -6,13 +6,13 @@ import QtQuick 2.15
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.14 as Kirigami
import org.kde.kirigamiaddons.treeview 1.0 as KirigamiAddonsTreeView
//import org.kde.kirigamiaddons.treeview 1.0 as KirigamiAddonsTreeView
import org.kde.kalendar 1.0 as Kalendar
import "dateutils.js" as DateUtils
import "labelutils.js" as LabelUtils
KirigamiAddonsTreeView.TreeListView {
TreeListView {
id: root
signal addTodo(int collectionId)
......@@ -68,7 +68,7 @@ KirigamiAddonsTreeView.TreeListView {
sortBy: root.sortBy
sortAscending: root.ascendingOrder
}
delegate: KirigamiAddonsTreeView.BasicTreeItem {
delegate: BasicTreeItem {
id: listItem
Layout.fillWidth: true
......
/*
* SPDX-FileCopyrightText: 2020 Marco Martin <notmart@gmail.com>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.1
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.0 as QQC2
import org.kde.kirigami 2.14
import org.kde.kirigamiaddons.treeview 1.0 as TreeView
/**
* An item delegate for the TreeListView and TreeTableView components.
*
* It's intended to make all tree views look coherent.
* It has a default icon and a label
*
*/
TreeView.AbstractTreeItem {
id: listItem
/**
* string: bool
* A single text label the list item will contain
*/
property alias label: listItem.text
/**
* A subtitle that goes below the main label
* Optional; if not defined, the list item will only have a main label
* @since 5.70
* @since org.kde.kirigami 2.12
*/
property alias subtitle: subtitleItem.text
/**
* bold: bool
* Control whether the text (in both primary text and subtitle) should be rendered as bold
* @since 5.71
* @since org.kde.kirigami 2.13
*/
property bool bold: false
/**
* icon: var
* A single icon that will be displayed in the list item.
* The icon can be a grouped property with name,size,color etc, as QtQuickControls2 icons are defined.
* The icon can also be either a QIcon, a string name of a fdo compatible name,
* or any url accepted by the Image element.
*/
property var icon
/**
* iconSize: int
* The preferred size for the icon
* @since 2.5
*/
property alias iconSize: iconItem.size
/**
* iconColor: color
* The color the icon should be colorized to.
* By default it will be the text color.
* If the icon shouldn't be colorized in any way, set it to "transparent"
* @since 2.7
*/
property alias iconColor: iconItem.color
/**
* reserveSpaceForIcon: bool
* If true, even when there is no icon the space will be reserved for it
* It's useful in layouts where only some entries have an icon,
* having the text all horizontally aligned
*/
property alias reserveSpaceForIcon: iconItem.visible
/**
* reserveSpaceForLabel: bool
* If false, the label will not try to be as wide as possible
* It's useful in layouts containing entries without text
*/
property alias reserveSpaceForLabel: labelItem.visible
default property alias _basicDefault: layout.data
icon: action ? action.icon.name || action.icon.source : undefined
contentItem: RowLayout {
id: layout
spacing: LayoutMirroring.enabled ? listItem.rightPadding : listItem.leftPadding
Icon {
id: iconItem
source: {
if (!listItem.icon) {
return undefined
}
if (listItem.icon.hasOwnProperty) {
if (listItem.icon.hasOwnProperty("name") && listItem.icon.name !== "")
return listItem.icon.name;
if (listItem.icon.hasOwnProperty("source"))
return listItem.icon.source;
}
return listItem.icon;
}
property int size: Units.iconSizes.smallMedium
Layout.minimumHeight: size
Layout.maximumHeight: size
Layout.minimumWidth: size
selected: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents))
opacity: 1
visible: source != undefined
}
ColumnLayout {
spacing: 0
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
QQC2.Label {
id: labelItem
text: listItem.text
Layout.fillWidth: true
color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor
elide: Text.ElideRight
font.weight: listItem.bold ? Font.Bold : Font.Normal
opacity: 1
}
QQC2.Label {
id: subtitleItem
Layout.fillWidth: true
color: (listItem.highlighted || listItem.checked || (listItem.pressed && listItem.supportsMouseEvents)) ? listItem.activeTextColor : listItem.textColor
elide: Text.ElideRight
font: Theme.smallFont
opacity: listItem.bold ? 0.9 : 0.7
visible: text.length > 0
}
}
}
}
/*
* 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 org.kde.kirigami 2.13 as Kirigami
import org.kde.kitemmodels 1.0
import org.kde.kirigamiaddons.treeview 1.0 as TreeView
ListView {
id: root
spacing: 0
property QtObject sourceModel
property alias descendantsModel: descendantsModel
property alias expandsByDefault: descendantsModel.expandsByDefault
add: Transition {
// NumberAnimation behaves better than animators here
NumberAnimation {
property: "opacity"
from: 0
to: 1
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
addDisplaced: Transition {
NumberAnimation {
property: "y"
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
remove: Transition {
NumberAnimation {
property: "opacity"
from: 1
to: 0
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
removeDisplaced: Transition {
NumberAnimation {
property: "y"
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
}
model: KDescendantsProxyModel {
id: descendantsModel
expandsByDefault: false
model: root.sourceModel
}
}
/*
* SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.12
/**
* A ListView with an internal KDescendantsProxyModel already in place.
* It also features tree node open and close animations.
*
* In order to use it, just assign the actual tree model you need.
* Additional properties:
* * sourceModel: the tree model we want to show
* * descendantsModel: The used KDescendantsProxyModel instance
* * expandsByDefault: If true, the tree view will be loaded completely expanded (default false)
*/
InternalTreeListView {
id: root
property alias model: root.sourceModel
}
......@@ -49,5 +49,8 @@ SPDX-License-Identifier: CC0-1.0
<file alias="KQuickCommandbar.qml">contents/ui/KQuickCommandBar.qml</file>
<file alias="WeekView.qml">contents/ui/WeekView.qml</file>
<file alias="FilterHeader.qml">contents/ui/FilterHeader.qml</file>
<file alias="InternalTreeListView.qml">contents/ui/TreeView/InternalTreeListView.qml</file>
<file alias="TreeListView.qml">contents/ui/TreeView/TreeListView.qml</file>
<file alias="BasicTreeItem.qml">contents/ui/TreeView/BasicTreeItem.qml</file>
</qresource>
</RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment