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