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,72 +261,89 @@ 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
ListView ScrollView
{ {
id: contactView id: objContactView
implicitHeight: parent.height // Layout.fillWidth: true
implicitWidth: parent.width // Layout.preferredHeight: 100
model: contactModel //Layout.columnSpan: 3
header: headline anchors.fill: mainRect
highlight: Rectangle { color: "grey"} ScrollBar.vertical.policy: ScrollBar.AlwaysOn
highlightFollowsCurrentItem: false
onActiveFocusChanged: if(!focus) currentIndex = -1
delegate: Item
ListView
{ {
width: contactView.width id: contactView
anchors.fill: objContactView
height: 15 // implicitHeight: objContactView.height
MouseArea // implicitWidth: objContactView.width
model: contactModel
// header: headline
highlight: Rectangle { color: "slategray"; radius: 3}
highlightFollowsCurrentItem: false
//focus: true
onActiveFocusChanged: if(!focus) currentIndex = -1
delegate: Item
{ {
anchors.fill: parent width: contactView.width
onClicked: height: 77
MouseArea
{ {
contactView.currentIndex = index anchors.fill: parent
contactView.highlightFollowsCurrentItem = true onClicked:
{
contactView.currentIndex = index
contactView.highlightFollowsCurrentItem = true
}
} }
}
Row Column
{
//spacing: 9
Text
{ {
text: model.name anchors.margins: 5
width: 175
horizontalAlignment: Text.AlignLeft
color: "white"
}
Text
{
text: model.phone
width: 100
horizontalAlignment: Text.AlignLeft
color: "white"
}
Text
{
text: model.mobile
width: 100
horizontalAlignment: Text.AlignLeft
color: "white"
}
Text
{
text: model.posizion
width: 150
horizontalAlignment: Text.AlignLeft
color: "white"
}
}
}
//spacing: 3
Text
{
text: qsTr('Name: ') + model.name
horizontalAlignment: Text.AlignLeft
color: "white"
}
Text
{
text: qsTr('Telefon: ') + model.phone
horizontalAlignment: Text.AlignLeft
color: "white"
}
Text
{
text: qsTr('Handy: ') + model.mobile
horizontalAlignment: Text.AlignLeft
color: "white"
}
Text
{
text: qsTr('Position: ') + model.posizion
horizontalAlignment: Text.AlignLeft
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)
{
printers = sys_printers.getPrinters()
if (sys_printers.getDefaultPrinter())
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter())
}
} }
Component.onCompleted: Component.onCompleted:
{ {
printers = sys_printers.getPrinters() if (sys_printers)
if (sys_printers.getDefaultPrinter()) {
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter()) printers = sys_printers.getPrinters()
if (sys_printers.getDefaultPrinter())
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter())
}
} }
} }