Added controls to edit the role "amount", "factor" and "type" from the expandable item delegate.
This commit is contained in:
@ -11,6 +11,7 @@ Item {
|
||||
required property string info
|
||||
required property int amount
|
||||
required property real factor
|
||||
required property string type
|
||||
|
||||
property real detailsOpacity: 0
|
||||
width: ListView.view.width
|
||||
@ -66,7 +67,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: qsTr("Details")
|
||||
text: qsTr("Description")
|
||||
font.bold: true
|
||||
font.pointSize: 9
|
||||
opacity: item.detailsOpacity
|
||||
@ -108,6 +109,7 @@ Item {
|
||||
anchors {
|
||||
top: moreInfoTitle.bottom
|
||||
bottom: parent.bottom
|
||||
topMargin: 5
|
||||
}
|
||||
contentHeight: infoText.height
|
||||
clip: true
|
||||
@ -119,11 +121,18 @@ Item {
|
||||
wrapMode: Text.WordWrap
|
||||
width: details.width
|
||||
}
|
||||
|
||||
Text {
|
||||
id: amountText
|
||||
text: "Amount: " + item.amount
|
||||
wrapMode: Text.WordWrap
|
||||
width: details.width
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
value: item.amount
|
||||
width: 80
|
||||
height: 25
|
||||
onValueModified: item.amount = value
|
||||
}
|
||||
Text {
|
||||
id: factorText
|
||||
@ -131,6 +140,59 @@ Item {
|
||||
wrapMode: Text.WordWrap
|
||||
width: details.width
|
||||
}
|
||||
SpinBox {
|
||||
id: spinBox
|
||||
from: 0
|
||||
value: decimalToInt(item.factor)
|
||||
to: decimalToInt(100)
|
||||
stepSize: decimalFactor
|
||||
editable: true
|
||||
|
||||
property int decimals: 2
|
||||
property real realValue: value / decimalFactor
|
||||
readonly property int decimalFactor: Math.pow(10, decimals)
|
||||
|
||||
function decimalToInt(decimal) {
|
||||
return decimal * decimalFactor
|
||||
}
|
||||
|
||||
onValueModified: item.factor = value / decimalFactor
|
||||
|
||||
validator: DoubleValidator {
|
||||
bottom: Math.min(spinBox.from, spinBox.to)
|
||||
top: Math.max(spinBox.from, spinBox.to)
|
||||
decimals: spinBox.decimals
|
||||
notation: DoubleValidator.StandardNotation
|
||||
}
|
||||
|
||||
textFromValue: function (value, locale) {
|
||||
return Number(value / decimalFactor).toLocaleString(
|
||||
locale, 'f', spinBox.decimals)
|
||||
}
|
||||
|
||||
valueFromText: function (text, locale) {
|
||||
return Math.round(Number.fromLocaleString(
|
||||
locale, text) * decimalFactor)
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: typeText
|
||||
text: "Type: " + item.type
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
// TODO use model from metadata.h (in some way)
|
||||
model: ["A", "B", "C", ""]
|
||||
// BUG type will probably not been updated due to undo/redo step
|
||||
currentIndex: find(item.type)
|
||||
Component.onCompleted: currentIndex = find(item.type)
|
||||
onCurrentTextChanged: {
|
||||
item.type = currentText
|
||||
}
|
||||
width: 80
|
||||
height: 25
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ Page {
|
||||
clip: true
|
||||
|
||||
model: mainModel
|
||||
delegateModelAccess: DelegateModel.ReadWrite
|
||||
|
||||
// delegate: ListItemDelegate {}
|
||||
// delegate: ExpandableItemDelegate {}
|
||||
delegate: EditableItemDelegate {}
|
||||
delegate: ExpandableItemDelegate {}
|
||||
// delegate: EditableItemDelegate {}
|
||||
delegateModelAccess: DelegateModel.ReadWrite
|
||||
|
||||
header: bannercomponent
|
||||
footer: Rectangle {
|
||||
|
||||
Reference in New Issue
Block a user