MaterialInfo: Begin replace HTML-text with QML-elements for 'by material-type'. [CURA-6141]

This commit is contained in:
Remco Burema 2019-01-24 18:08:02 +01:00
parent cbed8038e9
commit 654cd8e645

View File

@ -1,4 +1,4 @@
// Copyright (c) 2018 Ultimaker B.V. // Copyright (c) 2019 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7 import QtQuick 2.7
@ -85,31 +85,18 @@ Column
Label Label
{ {
id: byMaterialType
property var printMaterialLengths: PrintInformation.materialLengths property var printMaterialLengths: PrintInformation.materialLengths
property var printMaterialWeights: PrintInformation.materialWeights property var printMaterialWeights: PrintInformation.materialWeights
property var printMaterialCosts: PrintInformation.materialCosts property var printMaterialCosts: PrintInformation.materialCosts
property var printMaterialNames: PrintInformation.materialNames property var printMaterialNames: PrintInformation.materialNames
property var columnWidthMultipliers: [ 0.4, 0.2, 0.2, 0.2 ]
function formatRow(items) function getMaterialTable()
{ {
var rowHTML = "<tr>" var result = []
for(var item = 0; item < items.length; item++)
{
if (item == 0)
{
rowHTML += "<td valign=\"bottom\">%1</td>".arg(items[item])
}
else
{
rowHTML += "<td align=\"right\" valign=\"bottom\">&nbsp;&nbsp;%1</td>".arg(items[item])
}
}
rowHTML += "</tr>"
return rowHTML
}
text:
{
var lengths = [] var lengths = []
var weights = [] var weights = []
var costs = [] var costs = []
@ -135,20 +122,42 @@ Column
costs = ["0.00"] costs = ["0.00"]
} }
var text = "<table width=\"100%\">"
for(var index = 0; index < lengths.length; index++) for(var index = 0; index < lengths.length; index++)
{ {
text += formatRow([ var row = []
"%1:".arg(names[index]), row.push("%1:".arg(names[index]))
catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]), row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]))
catalog.i18nc("@label g for grams", "%1g").arg(weights[index]), row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index]))
"%1&nbsp;%2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]), row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]))
]) result.push(row)
} }
text += "</table>"
return text return result
} }
Column
{
Repeater
{
model: byMaterialType.getMaterialTable()
Row
{
//property var rowLength: modelData.length
Repeater
{
model: modelData
Text
{
width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index])
wrapMode: Text.WrapAnywhere
text: modelData
}
}
}
}
}
width: parent.width - 2 * UM.Theme.getSize("default_margin").width width: parent.width - 2 * UM.Theme.getSize("default_margin").width
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")