pragma ComponentBehavior: Bound import QtQuick import Weave.Controls import Weave.Templates as T import Weave.Views as Views T.TableHeaderDelegate { id: delegate T.TableLayoutColumn.filter.name: text T.TableLayoutColumn.minimumWidth: Math.max( leftPadding + rightPadding + (contentItem ? contentItem.T.TableLayout.minimumWidth : implicitContentWidth), T.TableLayoutColumn.minimumItemWidth) T.TableLayoutColumn.leftItemPadding: Theme.component.table.cell.paddingLeft T.TableLayoutColumn.rightItemPadding: Theme.component.table.cell.paddingRight T.TableLayout.leftPadding: Math.max(T.TableLayout.leftLayoutPadding, Theme.component.table.cell.paddingLeft) T.TableLayout.rightPadding: Math.max(T.TableLayout.rightLayoutPadding, Theme.component.table.cell.paddingRight) T.TableLayout.topPadding: Math.max(T.TableLayout.topLayoutPadding, Theme.component.table.cell.paddingTop) T.TableLayout.bottomPadding: Math.max(T.TableLayout.bottomLayoutPadding, Theme.component.table.cell.paddingBottom) implicitWidth: Math.max( T.TableLayout.leftPadding + T.TableLayout.rightPadding + implicitContentWidth, T.TableLayoutColumn.preferredItemWidth) implicitHeight: Math.max(Theme.component.table.cell.height, implicitContentHeight + topPadding + bottomPadding) topPadding: T.TableLayout.topPadding bottomPadding: T.TableLayout.bottomPadding font.family: Theme.component.table.fontFamily font.pixelSize: Theme.component.table.fontSize font.weight: Theme.component.table.fontWeight lineHeight: Theme.component.table.lineHeight icon.color: Theme.component.table.icon.fill.default icon.width: Theme.component.table.scaledIcon.width icon.height: Theme.component.table.scaledIcon.height visible: !T.TableLayoutColumn.hidden decoration: T.DecorationItemLoader { delegateItem: delegate sourceComponent: T.IconImage { T.TableLayout.itemStatus: status name: delegate.icon.name url: delegate.icon.source color: delegate.icon.color sourceSize: Qt.size(delegate.icon.width, delegate.icon.height) } } contentItem: T.TableLayoutRow { id: stackedItems readonly property bool sortingButtonPersistent: delegate.sortOrder !== T.TableView.Unsorted readonly property bool sortingButtonEnabled: delegate.sortingEnabled || delegate.sortOrder !== T.TableView.Unsorted readonly property bool filterButtonPersistent: delegate.TableLayoutColumn.filter.expressionCount > 0 readonly property bool filterButtonEnabled: !!delegate.T.TableLayoutColumn.view?.multiFilter?.enabled readonly property real persistentButtonWidth: headerActionRow.rightMargin + (sortingButtonPersistent ? sortingButton.implicitWidth : 0) + (filterButtonPersistent ? filterButton.implicitWidth : 0) readonly property real enabledButtonWidth: headerActionRow.rightMargin + (sortingButtonEnabled ? sortingButton.implicitWidth : 0) + (filterButtonEnabled ? filterButton.implicitWidth : 0) + ((sortingButtonEnabled || filterButtonEnabled) ? moreButton.implicitWidth : 0) leftMargin: delegate.T.TableLayout.leftPadding opacity: enabled && !delegate.T.TableLayout.moving ? 1.0 : Theme.component.menu.opacity.disabled verticalItemAlignment: Text.AlignVCenter T.TableLayoutProxyItem { target: delegate.indicator } T.TableLayoutColumn { T.TableLayout.minimumWidth: Math.max(minimumWidth, stackedItems.enabledButtonWidth) T.TableLayout.preferredWidth: Math.max(preferredWidth, stackedItems.minimumWidth) T.TableLayout.horizontalFillMode: T.TableLayout.Preferred T.TableLayout.verticalFillMode: T.TableLayout.Preferred rightMargin: delegate.T.TableLayoutColumn.horizontalItemAlignment === T.TableLayout.AlignRight ? Math.max(delegate.T.TableLayout.rightPadding, stackedItems.persistentButtonWidth) : delegate.T.TableLayout.rightPadding horizontalItemFillMode: T.TableLayout.Maximum horizontalItemAlignment: delegate.T.TableLayout.hovered || delegate.T.TableLayoutColumn.menuOpened.opened ? T.TableLayout.AlignLeft : delegate.T.TableLayoutColumn.horizontalItemAlignment verticalItemFillMode: T.TableLayout.Preferred T.TableLayoutRow { topMargin: delegate.T.TableLayout.topPadding bottomMargin: delegate.T.TableLayout.bottomPadding verticalItemAlignment: Text.AlignVCenter T.TableLayoutLoader { sourceComponent: delegate.decoration leftMargin: Theme.component.menu.icon.marginLeft rightMargin: Theme.component.menu.icon.marginRight topMargin: Theme.component.menu.icon.marginTop bottomMargin: Theme.component.menu.icon.marginBottom } Text { id: label T.TableLayout.minimumWidth: Math.min(Theme.component.table.cell.paddingRight + Theme.component.table.cell.paddingLeft, implicitWidth) T.TableLayout.preferredWidth: Math.max(implicitWidth + stackedItems.enabledButtonWidth, delegate.T.TableLayout.largestTextWidth) text: delegate.text font: delegate.font color: Theme.component.table.textColor lineHeight: delegate.lineHeight lineHeightMode: Text.FixedHeight elide: Text.ElideRight } } } Item { width: stackedItems.width height: stackedItems.height T.TableLayout.exclude: true T.TableLayoutRow { id: headerActionRow x: stackedItems.width - width height: stackedItems.height rightMargin: Theme.component.table.header.iconbutton.marginRight verticalItemAlignment: T.TableLayout.AlignVCenter IconButton { id: filterButton visible: delegate.TableLayoutColumn.filter.expressionCount > 0 icon.name: "filter" icon.width: Theme.component.table.fixedIcon.width icon.height: Theme.component.table.fixedIcon.height onClicked: delegate.TableLayoutColumn.openFilterMenu() Text { x: Theme.component.table.filtering.badge.marginRight + Theme.component.iconbutton.icon.paddingLeft - width y: Theme.component.table.filtering.badge.marginTop + Theme.component.iconbutton.icon.paddingTop font.family: Theme.component.table.fontFamily font.pixelSize: Theme.component.table.badge.fontSize font.weight: Theme.component.table.badge.fontWeight lineHeight: Theme.component.table.lineHeight lineHeightMode: Text.FixedHeight verticalAlignment: Text.AlignVCenter color: Theme.component.table.textColor visible: delegate.TableLayoutColumn.filter.expressionCount > 1 text: delegate.TableLayoutColumn.filter.expressionCount } } IconButton { id: sortingButton visible: (delegate.sortingEnabled && (delegate.T.TableLayout.hovered || delegate.T.TableLayoutColumn.menuOpened)) || delegate.sortOrder !== T.TableLayout.Unsorted icon.name: delegate.sortOrder === T.TableLayout.Descending ? "pin-row-bottom" : "pin-row-top" icon.width: Theme.component.table.fixedIcon.width icon.height: Theme.component.table.fixedIcon.height onClicked: { delegate.sortOrder = delegate.sortOrder !== T.TableLayout.Descending ? T.TableLayout.Descending : T.TableLayout.Ascending } } IconButton { id: moreButton visible: delegate.TableLayoutColumn.menuOpened || (delegate.T.TableLayout.hovered && delegate.T.TableLayoutColumn.hasMenu) icon.name: "more-vertical" icon.width: Theme.component.table.fixedIcon.width icon.height: Theme.component.table.fixedIcon.height onClicked: delegate.TableLayoutColumn.openMenu(moreButton, 0, height + Theme.component.table.cell.paddingBottom) } } } } background: T.BackgroundItemLoader { delegateItem: delegate sourceComponent: Rectangle { opacity: enabled ? 1.0 : Theme.component.menu.opacity.disabled color: Theme.blendColor(Theme.component.table.backgroundColor, function() { if (delegate.pressed) { return Theme.component.table.header.backgroundColor.pressed } else if (delegate.hovered) { return Theme.component.table.header.backgroundColor.hover } else { return Theme.component.table.header.backgroundColor.default } }()) } } }