Fix Objects Table
This commit is contained in:
@@ -5,13 +5,13 @@ import Qt.labs.qmlmodels
|
||||
|
||||
Item {
|
||||
property var availableFilters: [""]
|
||||
anchors.fill: parent
|
||||
|
||||
StackView
|
||||
{
|
||||
id: objectsStack
|
||||
anchors.fill: parent
|
||||
initialItem: "ObjectsTable.qml"
|
||||
anchors.margins: 9
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,154 +3,136 @@ import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import Qt.labs.qmlmodels
|
||||
|
||||
Item
|
||||
{
|
||||
SearchBar
|
||||
{
|
||||
id:searchBar
|
||||
anchors.margins: 9
|
||||
ColumnLayout {
|
||||
spacing: Dimensions.l
|
||||
function onObjectContactAdded(added) {
|
||||
console.log(added);
|
||||
if (added)
|
||||
object_model.viewCriterion("");
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
Component.onCompleted: {
|
||||
contact_model.objectContactAdded.connect(onObjectContactAdded);
|
||||
objectsStack.pop();
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: Dimensions.l
|
||||
|
||||
SearchBar {
|
||||
}
|
||||
|
||||
Button {
|
||||
id: addObjectBtn
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
||||
icon.source: "qrc:/images/PlusCircle.svg"
|
||||
text: qsTr("Objekt Hinzufügen")
|
||||
anchors.right: parent.right
|
||||
|
||||
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
|
||||
{
|
||||
ColumnLayout {
|
||||
id: tableColumn
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.verticalStretchFactor: 1
|
||||
|
||||
clip: true
|
||||
|
||||
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
|
||||
border.color: addObjectBtn.palette.base
|
||||
color: addObjectBtn.palette.alternateBase
|
||||
implicitHeight: 40
|
||||
implicitWidth: 1
|
||||
Text
|
||||
{
|
||||
text: model.display
|
||||
|
||||
Text {
|
||||
color: addObjectBtn.palette.text
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: model.display
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: addObjectBtn.palette.text
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TableView
|
||||
{
|
||||
property real newWidth: 0
|
||||
TableView {
|
||||
id: objectTable
|
||||
z: 0
|
||||
height: tableColumn.height - horizontalHeaderview.height
|
||||
|
||||
property real newWidth: 0
|
||||
|
||||
Layout.fillWidth: true
|
||||
columnSpacing: 1
|
||||
rowSpacing: 2
|
||||
model: object_model
|
||||
Layout.fillHeight: true
|
||||
alternatingRows: true
|
||||
columnSpacing: 1
|
||||
height: parent.height - horizontalHeaderview.height
|
||||
model: object_model
|
||||
resizableColumns: true // @disable-check M16
|
||||
rowSpacing: 2
|
||||
selectionBehavior: TableView.SelectRows
|
||||
ScrollBar.vertical: ScrollBar
|
||||
{
|
||||
z: 0
|
||||
|
||||
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
|
||||
delegate: Rectangle {
|
||||
required property bool current
|
||||
implicitWidth: objectTable.width / objectTable.columns
|
||||
required property bool selected
|
||||
|
||||
color: selected ? addObjectBtn.palette.highlight
|
||||
: (objectTable.alternatingRows && row % 2 !== 0 ? addObjectBtn.palette.base
|
||||
: addObjectBtn.palette.alternateBase)
|
||||
|
||||
implicitHeight: 25
|
||||
color: selected
|
||||
? addObjectBtn.palette.highlight //palette.highlight
|
||||
: (objectTable.alternatingRows && row % 2 !== 0
|
||||
? addObjectBtn.palette.base // palette.base
|
||||
: addObjectBtn.palette.alternateBase) //palette.alternateBase)
|
||||
implicitWidth: objectTable.width / objectTable.columns
|
||||
|
||||
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
|
||||
Text {
|
||||
color: addObjectBtn.palette.text
|
||||
elide: Text.ElideRight
|
||||
height: parent.height
|
||||
leftPadding: 9 //@disable-check M16
|
||||
text: (model.display === null || model.display === undefined) ? "" : model.display
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
MouseArea
|
||||
{
|
||||
property bool hovered: false
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
property bool hovered: false
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onDoubleClicked:
|
||||
{
|
||||
objectsStack.push("ObjectDetails.qml", {selectedObject: row});
|
||||
|
||||
onDoubleClicked: {
|
||||
objectsStack.push("ObjectDetails.qml", {
|
||||
selectedObject: row
|
||||
});
|
||||
}
|
||||
onEntered:
|
||||
{
|
||||
objectTable.selectionModel.select(objectTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows)
|
||||
onEntered: {
|
||||
objectTable.selectionModel.select(objectTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// onContentWidthChanged:
|
||||
// {
|
||||
selectionModel: ItemSelectionModel {
|
||||
id: obmodel
|
||||
|
||||
// redrawTable.start()
|
||||
// }
|
||||
model: objectTable.model
|
||||
}
|
||||
|
||||
Item
|
||||
{
|
||||
|
||||
}
|
||||
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("")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user