pragma ComponentBehavior: Bound import QtQuick import QtQuick.Templates as QQCT import Weave.Controls import Weave.Templates as T T.TreeView { id: view iconSize: Qt.size(Theme.component.treeitem.icon.width, Theme.component.treeitem.icon.height) iconColor: Theme.component.treeitem.icon.fill font.family: Theme.component.treeitem.fontFamily font.pixelSize: Theme.component.treeitem.fontSize font.weight: Theme.component.treeitem.fontWeight visibleBorders: T.TreeView.NoBorders borderWidth: Theme.component.table.cell.borderWidth minimumUnpinnedHeight: Theme.component.treeitem.height * 4 minimumColumnWidth: Theme.generic.px._50 // TODO: Theme.component.treeitem.minWidth rowMoveGripperMargin: Theme.component.table.rowOrderingColumn.width T.TableLayout.minimumWidth: Theme.component.table.filtering.modal.form.width + leftMargin + rightMargin // TODO: Theme.component.treeview.minWidth headerMenu: HeaderActionMenu { } defaultDelegate: TreeItemDelegate { required icon required text required property variant textAlignment T.TableLayout.horizontalAlignment: textAlignment !== undefined && (textAlignment & (T.TableLayout.AlignLeft | T.TableLayout.AlignHCenter | T.TableLayout.AlignRight)) ? textAlignment & (T.TableLayout.AlignLeft | T.TableLayout.AlignHCenter | T.TableLayout.AlignRight) : undefined T.TableLayout.verticalAlignment: textAlignment !== undefined && (textAlignment & (T.TableLayout.AlignTop | T.TableLayout.AlignVCenter | T.TableLayout.AlignBottom)) ? textAlignment & (T.TableLayout.AlignTop | T.TableLayout.AlignVCenter | T.TableLayout.AlignBottom) : undefined } defaultEditDelegate: EditDelegate { required icon required text Component.onCompleted: selectAll() onAccepted: { T.TableLayout.setData(view.editRole, text) T.TableLayout.endEdit() } } rowPinningHeaderDelegate: RowPinHeader { } rowSelectionHeaderDelegate: RowSelectionHeader { } rowDetailHeaderDelegate: RowDetailHeader { } defaultRowDelegate: TableViewRow { } cornerSelectionHeaderDelegate: CornerSelectionHeader { } cornerDetailHeaderDelegate: CornerDetailHeader { } cornerActionHeaderDelegate: TableCornerHeaderDelegate { } cornerPinningHeaderDelegate: CornerPinHeader { } defaultColumnHeaderDelegate: TreeHeaderDelegate { required icon required text required property variant textAlignment T.TableLayoutColumn.horizontalItemAlignment: textAlignment !== undefined && (textAlignment & (T.TableLayout.AlignLeft | T.TableLayout.AlignHCenter | T.TableLayout.AlignRight)) ? textAlignment & (T.TableLayout.AlignLeft | T.TableLayout.AlignHCenter | T.TableLayout.AlignRight) : undefined T.TableLayoutColumn.verticalItemAlignment: textAlignment !== undefined && (textAlignment & (T.TableLayout.AlignTop | T.TableLayout.AlignVCenter | T.TableLayout.AlignBottom)) ? textAlignment & (T.TableLayout.AlignTop | T.TableLayout.AlignVCenter | T.TableLayout.AlignBottom) : T.TableLayout.AlignVCenter } defaultColumnGroupHeaderDelegate: TreeHeaderDelegate { required icon required text T.TableLayoutColumn.horizontalItemAlignment: T.TableLayout.AlignHCenter } defaultTreeNodeDelegate: QQCT.AbstractButton { id: node readonly property real guideSpacing: Theme.component.treeitem.guidelineContainer.paddingLeft implicitWidth: Theme.component.treeitem.iconContainer.width implicitHeight: Theme.component.treeitem.iconContainer.height bottomPadding: Math.max(0, height - implicitHeight)/2 topPadding: Math.max(0, height - implicitHeight)/2 TableLayout.leftMargin: mirrored ? 0 : guideSpacing * node.T.TreeNode.parentCount TableLayout.rightMargin: mirrored ? guideSpacing * node.T.TreeNode.parentCount : 0 contentItem: T.IconImage { color: Theme.component.treeitem.icon.fill name: { if (!node.T.TreeNode.hasChildren) { return "" } else if (view.control === T.TreeView.Operator) { return node.T.TreeNode.expanded ? Theme.icon.small("operator-minus") : Theme.icon.small("operator-plus") } else if (node.mirrored) { return node.T.TreeNode.expanded ? Theme.icon.medium("caret-down") : Theme.icon.medium("caret-left") } else { return node.T.TreeNode.expanded ? Theme.icon.medium("caret-down") : Theme.icon.medium("caret-right") } } } background: Item { id: backgroundItem Repeater { model: view.guidelinesVisible ? node.T.TreeNode.parentGuides : undefined Image { required property int index required property bool modelData x: node.mirrored ? verticalGuide.x + verticalGuide.width + ((index + 1) * node.guideSpacing) : verticalGuide.x - ((index + 1) * node.guideSpacing) height: node.T.TreeNode.isLastRow && index == 0 ? horizontalGuide.y + horizontalGuide.height : node.height fillMode: Image.TileVertically verticalAlignment: Image.AlignBottom sourceSize.width: Theme.component.treeitem.guideline.borderWidth source: Guidelines.vertical + Theme.component.treeitem.guideline.borderColor.default visible: modelData } } Image { id: horizontalGuide x: node.mirrored ? backgroundItem.width - (node.guideSpacing/2) : -(node.guideSpacing/2) y: node.height / 2 width: node.T.TreeNode.hasChildren ? Theme.component.treeitem.directory.guideline.width : Theme.component.treeitem.root.guideline.width visible: view.guidelinesVisible && node.T.TreeNode.parentCount > 0 fillMode: Image.TileHorizontally horizontalAlignment: node.mirrored ? Image.AlignLeft : Image.AlignRight sourceSize.height: Theme.component.treeitem.guideline.borderWidth source: Guidelines.horizontal + Theme.component.treeitem.guideline.borderColor.default } Image { id: verticalGuide x: Math.floor((backgroundItem.width - width)/2) y: Theme.component.treeitem.height height: node.bottomPadding visible: view.guidelinesVisible && node.T.TreeNode.expanded && node.T.TreeNode.rowCount > 0 fillMode: Image.TileVertically verticalAlignment: Image.AlignBottom sourceSize.width: Theme.component.treeitem.guideline.borderWidth source: Guidelines.vertical + Theme.component.treeitem.guideline.borderColor.default } } } highlight: CellHighlight { } background: T.CellBackground { // TODO: need Theme.component.treeview.backgroundColor and Theme.component.treeview.borderColor tokens? color: Theme.component.table.backgroundColor borderColor: Theme.blendColor(color, Theme.component.table.cell.borderColor.default) borderWidth: (view.visibleBorders & T.TreeView.PerimeterBorders) ? Theme.component.table.cell.borderWidth : 0 } defaultBackgroundDelegate: ItemViewDelegateBackground { color: Theme.blendColor(baseColor, function() { if (T.TableLayout.pressed) { return T.TableLayout.selected ? Theme.component.table.cell.backgroundColor.selected.pressed : Theme.component.table.cell.backgroundColor.pressed } else if (T.TableLayout.hovered) { return T.TableLayout.selected ? Theme.component.treeitem.backgroundColor.selected.hover : Theme.component.treeitem.backgroundColor.hover } else if (T.TableLayout.focused) { return Theme.component.treeitem.backgroundColor.selected.focus } else if (T.TableLayout.selected) { return Theme.component.treeitem.backgroundColor.selected.default } else if (view.alternatingRowColors && T.TableLayout.alternateRow) { return Theme.component.treeitem.backgroundColor.default } else { return "transparent" } }()) } defaultHeaderBackgroundDelegate: ItemViewHeaderBackground { } rowMoveGripper: RowMoveGripper { } movePositionIndicator: MovePositionIndicator { draggedItemCount: view.draggedItemCount } topPinningBorder: TopPinningBorder { } bottomPinningBorder: BottomPinningBorder { } leftPinningBorder: LeftPinningBorder { } rightPinningBorder: RightPinningBorder { } resizeBorder: ResizeBorder { } defaultDecorationDelegate: { switch (decorationType) { case T.TableView.Icon: return iconDecorationDelegate case T.TableView.Avatar: return avatarDecorationDelegate case T.TableView.Thumbnail: return thumbnailDecorationDelegate default: return null } } defaultIndicatorDelegate: CheckBoxIndicator { } Component { id: iconDecorationDelegate ItemViewIconDecoration { } } Component { id: avatarDecorationDelegate ItemViewAvatarDecoration { } } Component { id: thumbnailDecorationDelegate ItemViewThumbnailDecoration { } } horizontalScrollBar: ScrollBar {} verticalScrollBar: ScrollBar {} }