161 lines
4.6 KiB
QML
161 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
|
|
anchors
|
|
{
|
|
top: searchBar.bottom
|
|
bottom: parent.bottom
|
|
left: parent.left
|
|
right: parent.right
|
|
}
|
|
|
|
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
|
|
Layout.fillHeight: true
|
|
Layout.fillWidth: true
|
|
ScrollBar.vertical: ScrollBar
|
|
{
|
|
policy: objectTable.contentHeight > objectTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
}
|
|
columnSpacing: 1
|
|
rowSpacing: 2
|
|
//model: object_model
|
|
alternatingRows: true
|
|
resizableColumns: true // @disable-check M16
|
|
selectionBehavior: TableView.SelectRows
|
|
selectionModel: ItemSelectionModel
|
|
{
|
|
id: obmodel
|
|
model: objectTable.model
|
|
}
|
|
|
|
// Timer
|
|
// {
|
|
// id: redrawTable
|
|
// running: true
|
|
// interval: 1
|
|
// repeat: false
|
|
// onTriggered:
|
|
// {
|
|
// objectTable.forceLayout();
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
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
|
|
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: objectsStack.pop()
|
|
}
|