-- fy
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2025 Martin Leutelt <martin.leutelt@basyskom.com>
|
|
||||||
// SPDX-FileCopyrightText: 2025 basysKom GmbH
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
|
|
||||||
Control {
|
|
||||||
id: container
|
|
||||||
|
|
||||||
required property int column
|
|
||||||
required property var model
|
|
||||||
property int sortOrder: Qt.AscendingOrder
|
|
||||||
|
|
||||||
signal clicked(int sortOrder)
|
|
||||||
|
|
||||||
padding: 8
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: tapHandler.pressed ? "gray" : "lightgray"
|
|
||||||
|
|
||||||
TapHandler {
|
|
||||||
id: tapHandler
|
|
||||||
|
|
||||||
onTapped: {
|
|
||||||
if (container.sortOrder === Qt.AscendingOrder) {
|
|
||||||
container.sortOrder = Qt.DescendingOrder
|
|
||||||
} else {
|
|
||||||
container.sortOrder = Qt.AscendingOrder
|
|
||||||
}
|
|
||||||
|
|
||||||
container.clicked(container.sortOrder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
contentItem: Label {
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
elide: Text.ElideRight
|
|
||||||
text: container.model.display
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
|
|
||||||
Control {
|
|
||||||
id: container
|
|
||||||
|
|
||||||
required property int row
|
|
||||||
required property var model
|
|
||||||
|
|
||||||
padding: 8
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: tapHandler.pressed ? "gray" : "lightgray"
|
|
||||||
|
|
||||||
TapHandler {
|
|
||||||
id: tapHandler
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
contentItem: Label {
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
elide: Text.ElideRight
|
|
||||||
text: container.model.display
|
|
||||||
}
|
|
||||||
}
|
|
161
qml/XMain.qml
161
qml/XMain.qml
@@ -1,161 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2025 Martin Leutelt <martin.leutelt@basyskom.com>
|
|
||||||
// SPDX-FileCopyrightText: 2025 basysKom GmbH
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
||||||
|
|
||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
ApplicationWindow {
|
|
||||||
width: 640
|
|
||||||
height: 480
|
|
||||||
visible: true
|
|
||||||
title: Application.displayName
|
|
||||||
|
|
||||||
header: ToolBar {
|
|
||||||
ColumnLayout {
|
|
||||||
RowLayout {
|
|
||||||
Label {
|
|
||||||
text: "Rows"
|
|
||||||
}
|
|
||||||
SpinBox {
|
|
||||||
id: rowSettings
|
|
||||||
from: 1
|
|
||||||
to: 20
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolSeparator {}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: "Columns"
|
|
||||||
}
|
|
||||||
SpinBox {
|
|
||||||
id: columnSettings
|
|
||||||
from: 1
|
|
||||||
to: 20
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolSeparator {}
|
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: movableColumnsSetting
|
|
||||||
|
|
||||||
text: "Movable columns"
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolSeparator {}
|
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: resizableColumnsSetting
|
|
||||||
|
|
||||||
text: "Resizable columns"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Label {
|
|
||||||
text: "Selection"
|
|
||||||
}
|
|
||||||
ComboBox {
|
|
||||||
id: selectionSetting
|
|
||||||
textRole: "text"
|
|
||||||
valueRole: "value"
|
|
||||||
model: [
|
|
||||||
{ text: "disabled", value: TableView.SelectionDisabled },
|
|
||||||
{ text: "by cells", value: TableView.SelectCells },
|
|
||||||
{ text: "by rows", value: TableView.SelectRows },
|
|
||||||
{ text: "by columns", value: TableView.SelectColumns }
|
|
||||||
]
|
|
||||||
|
|
||||||
onCurrentIndexChanged: tableView.selectionModel.clear()
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: "Longpress to start selection, modify selection with CTRL/SHIFT of by mouse"
|
|
||||||
visible: selectionSetting.currentIndex > 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: tableBackground
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
color: Application.styleHints.colorScheme === Qt.Light ? palette.mid : palette.midlight
|
|
||||||
|
|
||||||
HorizontalHeaderView {
|
|
||||||
id: horizontalHeader
|
|
||||||
|
|
||||||
anchors.left: tableView.left
|
|
||||||
anchors.top: parent.top
|
|
||||||
|
|
||||||
syncView: tableView
|
|
||||||
movableColumns: movableColumnsSetting.checked
|
|
||||||
resizableColumns: resizableColumnsSetting.checked
|
|
||||||
clip: true
|
|
||||||
boundsBehavior: tableView.boundsBehavior
|
|
||||||
|
|
||||||
delegate: HorizontalHeaderViewDelegate {
|
|
||||||
onClicked: (sortOrder) => tableView.model.sort(column, sortOrder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VerticalHeaderView {
|
|
||||||
id: verticalHeader
|
|
||||||
|
|
||||||
anchors.top: tableView.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
|
|
||||||
syncView: tableView
|
|
||||||
clip: true
|
|
||||||
boundsBehavior: tableView.boundsBehavior
|
|
||||||
|
|
||||||
delegate: VerticalHeaderViewDelegate {}
|
|
||||||
}
|
|
||||||
|
|
||||||
TableView {
|
|
||||||
id: tableView
|
|
||||||
|
|
||||||
anchors.left: verticalHeader.right
|
|
||||||
anchors.top: horizontalHeader.bottom
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
columnSpacing: 1
|
|
||||||
rowSpacing: 1
|
|
||||||
rowHeightProvider: (row) => 40
|
|
||||||
boundsBehavior: TableView.StopAtBounds
|
|
||||||
selectionModel: ItemSelectionModel {}
|
|
||||||
selectionBehavior: selectionSetting.currentValue
|
|
||||||
|
|
||||||
model: SortFilterModel {
|
|
||||||
sourceModel: TableModel {
|
|
||||||
columns: columnSettings.value
|
|
||||||
rows: rowSettings.value
|
|
||||||
|
|
||||||
// when adding a new column its width isn't properly applied to the header, so we do that manually
|
|
||||||
onColumnsInserted: {
|
|
||||||
if (columns > 1) {
|
|
||||||
horizontalHeader.setColumnWidth(columns - 1, tableView.implicitColumnWidth(columns - 1))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delegate: TableViewDelegate {
|
|
||||||
implicitWidth: tableView.width / columnSettings.to
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.horizontal: ScrollBar {}
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectionRectangle {
|
|
||||||
target: tableView
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,56 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import QtQuick.Window
|
|
||||||
|
|
||||||
ApplicationWindow
|
|
||||||
{
|
|
||||||
visible: true
|
|
||||||
width: 600
|
|
||||||
height: 400
|
|
||||||
|
|
||||||
TreeView
|
|
||||||
{
|
|
||||||
anchors.fill: parent
|
|
||||||
clip: true
|
|
||||||
columnSpacing: 1
|
|
||||||
rowSpacing: 1
|
|
||||||
|
|
||||||
model: myChildModel
|
|
||||||
|
|
||||||
columnWidthProvider: function(column)
|
|
||||||
{
|
|
||||||
var z= 2*(width / columns);
|
|
||||||
console.log("Firz:", z);
|
|
||||||
console.log("Berechne Spaltenbreite für column:", column);
|
|
||||||
console.log("Aktuelle TreeView-Breite:", width);
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Rectangle
|
|
||||||
{
|
|
||||||
required property int row
|
|
||||||
required property int column
|
|
||||||
required property var model
|
|
||||||
|
|
||||||
border.width: 0
|
|
||||||
|
|
||||||
implicitWidth: 30
|
|
||||||
implicitHeight: 30
|
|
||||||
border.color: "#cccccc"
|
|
||||||
//color: index % 2 === 0 ? "#f9f9f9" : "#e0e0e0"
|
|
||||||
color: TreeView.isSelected ? "#d0eaff" : (row % 2 === 0 ? "#f9f9f9" : "#ffffff")
|
|
||||||
|
|
||||||
Text
|
|
||||||
{
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: display
|
|
||||||
font.pixelSize: 14
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.horizontal: ScrollBar {}
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user