mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Bring changes from TableView to Digital Library version
The classes should be approximately the same. There's 2 differences now though: * The ScrollBar is re-implemented in the Digital Library because the re-useable component is not available in all Cura editions that the Digital Library needs to support. * The sections are not working. It was removing big parts of the table for some reason and I don't think it's worth debugging since this version of the table doesn't use it at all. It's also a bit faster this way. Contributes to issue CURA-8686.
This commit is contained in:
parent
7a1c3e1bd5
commit
43d4075309
1 changed files with 27 additions and 9 deletions
|
@ -35,7 +35,7 @@ Item
|
|||
model: columnHeaders
|
||||
Rectangle
|
||||
{
|
||||
width: Math.round(tableBase.width / headerRepeater.count)
|
||||
width: Math.max(1, Math.round(tableBase.width / headerRepeater.count))
|
||||
height: UM.Theme.getSize("section").height
|
||||
|
||||
color: UM.Theme.getColor("secondary")
|
||||
|
@ -53,7 +53,7 @@ Item
|
|||
color: UM.Theme.getColor("text")
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Rectangle
|
||||
Rectangle //Resize handle.
|
||||
{
|
||||
anchors
|
||||
{
|
||||
|
@ -79,24 +79,31 @@ Item
|
|||
{
|
||||
if(drag.active)
|
||||
{
|
||||
parent.parent.width = Math.max(10, parent.parent.width + mouseX); //Don't go smaller than 10 pixels, to make sure you can still scale it back.
|
||||
let sum_widths = 0;
|
||||
let new_width = parent.parent.width + mouseX; //Don't go smaller than 10 pixels, to make sure you can still scale it back.
|
||||
let sum_widths = mouseX;
|
||||
for(let i = 0; i < headerBar.children.length; ++i)
|
||||
{
|
||||
sum_widths += headerBar.children[i].width;
|
||||
}
|
||||
if(sum_widths > tableBase.width)
|
||||
{
|
||||
parent.parent.width -= sum_widths - tableBase.width; //Limit the total width to not exceed the view.
|
||||
new_width -= sum_widths - tableBase.width; //Limit the total width to not exceed the view.
|
||||
}
|
||||
}
|
||||
tableView.forceLayout();
|
||||
let width_fraction = new_width / tableBase.width; //Scale with the same fraction along with the total width, if the table is resized.
|
||||
parent.parent.width = Qt.binding(function() { return tableBase.width * width_fraction });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onWidthChanged:
|
||||
{
|
||||
tableView.forceLayout(); //Rescale table cells underneath as well.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TableView
|
||||
{
|
||||
id: tableView
|
||||
|
@ -154,15 +161,26 @@ Item
|
|||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
MouseArea
|
||||
TextMetrics
|
||||
{
|
||||
id: cellTextMetrics
|
||||
text: cellContent.text
|
||||
font: cellContent.font
|
||||
elide: cellContent.elide
|
||||
elideWidth: cellContent.width
|
||||
}
|
||||
UM.TooltipArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
|
||||
enabled: tableBase.allowSelection
|
||||
text: (cellTextMetrics.elidedText == cellContent.text) ? "" : cellContent.text //Show full text in tooltip if it was elided.
|
||||
onClicked:
|
||||
{
|
||||
if(tableBase.allowSelection)
|
||||
{
|
||||
tableBase.currentRow = row; //Select this row.
|
||||
}
|
||||
}
|
||||
onDoubleClicked:
|
||||
{
|
||||
tableBase.onDoubleClicked(row);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue