Files
pyqcrm/Gui/ObjectsTable.qml

159 lines
4.6 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Qt.labs.qmlmodels
import QtQuick.Controls.Fusion
Item
{
SearchBar
{
id:searchBar
anchors.margins: 9
}
Button
{
id: addObjectBtn
icon.source: "qrc:/images/addbusiness.svg"
icon.color: "olive"
anchors.right: parent.right
flat: true
onClicked: appLoader.source = "AddObject.qml"
}
ColumnLayout
{
id: tableColumn
clip: true
anchors
{
top: searchBar.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
topMargin: 15
}
HorizontalHeaderView
{
id: horizontalHeaderview
Layout.fillWidth: true
implicitHeight: 40
//visible: false
movableColumns: true //@disable-check M16
syncView: objectTable
delegate: Rectangle {
color: addObjectBtn.palette.alternateBase
border.color: addObjectBtn.palette.base
implicitHeight: 40
Layout.fillWidth: true
implicitWidth: 1
Text
{
text: model.display
elide: Text.ElideRight
width: parent.width
height: parent.height
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: addObjectBtn.palette.text
}
}
}
TableView
{
property real newWidth: 0
id: objectTable
z: 0
height: tableColumn.height - horizontalHeaderview.height
Layout.fillWidth: true
columnSpacing: 1
rowSpacing: 2
model: object_model
alternatingRows: true
resizableColumns: true // @disable-check M16
selectionBehavior: TableView.SelectRows
ScrollBar.vertical: ScrollBar
{
policy: objectTable.contentHeight > objectTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}
selectionModel: ItemSelectionModel
{
id: obmodel
model: objectTable.model
}
delegate:Rectangle
{
required property bool selected
required property bool current
implicitWidth: objectTable.width / objectTable.columns
implicitHeight: 25
color: selected
? addObjectBtn.palette.highlight //palette.highlight
: (objectTable.alternatingRows && row % 2 !== 0
? addObjectBtn.palette.base // palette.base
: addObjectBtn.palette.alternateBase) //palette.alternateBase)
Text
{
text: (model.display === null || model.display === undefined)? "": model.display
elide: Text.ElideRight
width: parent.width
height: parent.height
verticalAlignment: Text.AlignVCenter
leftPadding: 9 //@d isable-check M16
color: addObjectBtn.palette.text
}
MouseArea
{
property bool hovered: false
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onDoubleClicked:
{
objectsStack.push("ObjectDetails.qml", {selectedObject: row});
}
onEntered:
{
objectTable.selectionModel.select(objectTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows)
}
}
}
// onContentWidthChanged:
// {
// redrawTable.start()
// }
}
Item
{
Layout.fillWidth: true
}
}
// function viewCriterion(criterion)
// {
// object_model.viewCriterion(criterion.text)
// }
Component.onCompleted:
{
contact_model.objectContactAdded.connect(onObjectContactAdded)
objectsStack.pop()
}
function onObjectContactAdded(added)
{
console.log(added)
if (added) object_model.viewCriterion("")
}
}