Clip delegated items of object contacts and printer not ready

This commit is contained in:
2025-02-28 11:59:33 +01:00
parent e81407b43d
commit fb81b764f1
2 changed files with 134 additions and 102 deletions

View File

@@ -6,7 +6,7 @@ GridLayout
{ {
property var contacts: null property var contacts: null
columns: 2 columns: 2
Layout.fillWidth: true
Label Label
{ {
text: qsTr("Kontaktdaten") text: qsTr("Kontaktdaten")
@@ -155,7 +155,7 @@ GridLayout
contacts[num_contacts]["phone"] = phonenumber.text.trim() contacts[num_contacts]["phone"] = phonenumber.text.trim()
contacts[num_contacts]["mobile"] = mobile.text.trim() contacts[num_contacts]["mobile"] = mobile.text.trim()
contacts[num_contacts]["position"] = posizion.text.trim() contacts[num_contacts]["position"] = posizion.text.trim()
contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), mobile: mobile.text.trim(), posizion: posizion.text.trim()}) contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), mobile: mobile.text.trim(), posizion: posizion.text.trim(), cdata: contacttype.currentText})
if (checkFields()) if (checkFields())
{ {
saveBtn.enabled = true saveBtn.enabled = true
@@ -184,59 +184,65 @@ GridLayout
id: contactModel id: contactModel
} }
Component // Component
{ // {
id: headline // id: headline
Row // Row
{ // {
Text // spacing: 9
{ // Text
id: cpname // {
text: qsTr("Name") // id: cpname
width: 175 // text: qsTr("Name")
font.bold: true // font.bold: true
horizontalAlignment: Text.AlignLeft // horizontalAlignment: Text.AlignLeft
color: "white" // color: "white"
} // }
Text // Text
{ // {
id: cpphone // id: cpphone
text: qsTr("Telefon") // text: qsTr("Telefon")
width: 100 // font.bold: true
font.bold: true // horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignLeft // color: "white"
color: "white" // }
}
Text // Text
{ // {
id: cpmobile // id: cpmobile
text: qsTr("Mobil") // text: qsTr("Mobil")
width: 100 // font.bold: true
font.bold: true // horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignLeft // color: "white"
color: "white" // }
}
Text // Text
{ // {
id: cppos // id: cppos
text: qsTr("Position") // text: qsTr("Position")
width: 150 // font.bold: true
font.bold: true // horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignLeft // color: "white"
color: "white" // }
}
} // Text
} // {
// id: cttype
// text: qsTr("Typ")
// font.bold: true
// horizontalAlignment: Text.AlignLeft
// color: "white"
// }
// }
// }
Component Component
{ {
id: highlight id: highlight
Rectangle Rectangle
{ {
width: 230; height: 15 width: parent.width
color: "lightsteelblue"; radius: 5 color: "lightsteelblue"; radius: 5
y: contactView.currentItem.y y: contactView.currentItem.y
Behavior on y Behavior on y
@@ -255,25 +261,37 @@ GridLayout
id: mainRect id: mainRect
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: 100 implicitHeight: 100
color: firstname.palette.base color: "salmon" // firstname.palette.base
border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base
clip: true
ScrollView
{
id: objContactView
// Layout.fillWidth: true
// Layout.preferredHeight: 100
//Layout.columnSpan: 3
anchors.fill: mainRect
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ListView ListView
{ {
id: contactView id: contactView
implicitHeight: parent.height anchors.fill: objContactView
implicitWidth: parent.width // implicitHeight: objContactView.height
// implicitWidth: objContactView.width
model: contactModel model: contactModel
header: headline // header: headline
highlight: Rectangle { color: "grey"} highlight: Rectangle { color: "slategray"; radius: 3}
highlightFollowsCurrentItem: false highlightFollowsCurrentItem: false
//focus: true
onActiveFocusChanged: if(!focus) currentIndex = -1 onActiveFocusChanged: if(!focus) currentIndex = -1
delegate: Item delegate: Item
{ {
width: contactView.width width: contactView.width
height: 77
height: 15
MouseArea MouseArea
{ {
anchors.fill: parent anchors.fill: parent
@@ -285,42 +303,47 @@ GridLayout
} }
Row Column
{ {
//spacing: 9 anchors.margins: 5
//spacing: 3
Text Text
{ {
text: model.name text: qsTr('Name: ') + model.name
width: 175
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
Text Text
{ {
text: model.phone text: qsTr('Telefon: ') + model.phone
width: 100
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
Text Text
{ {
text: model.mobile text: qsTr('Handy: ') + model.mobile
width: 100
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
Text Text
{ {
text: model.posizion text: qsTr('Position: ') + model.posizion
width: 150
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
}
}
Text
{
text: qsTr('Typ: ') + model.cdata
horizontalAlignment: Text.AlignLeft
color: "white"
} }
} // Column
} // delegate
} // Listview
} // Scrollview
} }
} }

View File

@@ -123,12 +123,21 @@ Window
{ {
copiesSpinBox.value = 1 copiesSpinBox.value = 1
colorPrint.checked = true colorPrint.checked = true
} if (!sys_printers)
Component.onCompleted:
{ {
printers = sys_printers.getPrinters() printers = sys_printers.getPrinters()
if (sys_printers.getDefaultPrinter()) if (sys_printers.getDefaultPrinter())
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter()) allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter())
} }
}
Component.onCompleted:
{
if (sys_printers)
{
printers = sys_printers.getPrinters()
if (sys_printers.getDefaultPrinter())
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter())
}
}
} }