Make sure sort indicator is attached to the right of title

This commit is contained in:
vladest 2018-02-23 10:06:16 +01:00
parent 37645022f6
commit b8102cfbd7

View file

@ -22,6 +22,7 @@ TableView {
readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light
property bool expandSelectedRow: false property bool expandSelectedRow: false
property bool centerHeaderText: false property bool centerHeaderText: false
readonly property real headerSpacing: 3 //spacing between sort indicator and table header title
model: ListModel { } model: ListModel { }
@ -69,20 +70,18 @@ TableView {
height: hifi.dimensions.tableHeaderHeight height: hifi.dimensions.tableHeaderHeight
color: isLightColorScheme ? hifi.colors.tableBackgroundLight : hifi.colors.tableBackgroundDark color: isLightColorScheme ? hifi.colors.tableBackgroundLight : hifi.colors.tableBackgroundDark
RalewayRegular { RalewayRegular {
id: titleText id: titleText
x: centerHeaderText ? parent.width/2 -
(paintedWidth/2 + (sortIndicatorVisible ? titleSort.paintedWidth/12 : 0)) :
hifi.dimensions.tablePadding
text: styleData.value text: styleData.value
size: hifi.fontSizes.tableHeading size: hifi.fontSizes.tableHeading
font.capitalization: Font.AllUppercase font.capitalization: Font.AllUppercase
color: hifi.colors.baseGrayHighlight color: hifi.colors.baseGrayHighlight
horizontalAlignment: (centerHeaderText ? Text.AlignHCenter : Text.AlignLeft) horizontalAlignment: (centerHeaderText ? Text.AlignHCenter : Text.AlignLeft)
anchors { anchors.verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: hifi.dimensions.tablePadding
right: parent.right
rightMargin: hifi.dimensions.tablePadding
verticalCenter: parent.verticalCenter
}
} }
HiFiGlyphs { HiFiGlyphs {
@ -91,13 +90,9 @@ TableView {
color: hifi.colors.darkGray color: hifi.colors.darkGray
opacity: 0.6; opacity: 0.6;
size: hifi.fontSizes.tableHeadingIcon size: hifi.fontSizes.tableHeadingIcon
anchors { anchors.verticalCenter: titleText.verticalCenter
left: titleText.right anchors.left: titleText.right
leftMargin: -hifi.fontSizes.tableHeadingIcon / 3 - (centerHeaderText ? 15 : 10) anchors.leftMargin: -(hifi.fontSizes.tableHeadingIcon / 3 + tableView.headerSpacing)
right: parent.right
rightMargin: hifi.dimensions.tablePadding
verticalCenter: titleText.verticalCenter
}
visible: sortIndicatorVisible && sortIndicatorColumn === styleData.column visible: sortIndicatorVisible && sortIndicatorColumn === styleData.column
} }
@ -152,7 +147,7 @@ TableView {
color: styleData.selected color: styleData.selected
? hifi.colors.primaryHighlight ? hifi.colors.primaryHighlight
: tableView.isLightColorScheme : tableView.isLightColorScheme
? (styleData.alternate ? hifi.colors.tableRowLightEven : hifi.colors.tableRowLightOdd) ? (styleData.alternate ? hifi.colors.tableRowLightEven : hifi.colors.tableRowLightOdd)
: (styleData.alternate ? hifi.colors.tableRowDarkEven : hifi.colors.tableRowDarkOdd) : (styleData.alternate ? hifi.colors.tableRowDarkEven : hifi.colors.tableRowDarkOdd)
} }
} }