datenbankmodel
This commit is contained in:
@@ -7,7 +7,7 @@ import Qt.labs.qmlmodels
|
||||
Item {
|
||||
|
||||
|
||||
|
||||
property var availableFilters: ["Name", "Adresse", "PLZ", "Ort"]
|
||||
SearchBar
|
||||
{
|
||||
id:searchBar
|
||||
@@ -57,119 +57,48 @@ Item {
|
||||
|
||||
text: qsTr("Erledigt")
|
||||
}
|
||||
|
||||
}
|
||||
TableView {
|
||||
HorizontalHeaderView
|
||||
{
|
||||
id: horizontalHeader
|
||||
Layout.fillWidth: true
|
||||
|
||||
syncView: testTable
|
||||
|
||||
}
|
||||
TableView
|
||||
{
|
||||
id: testTable
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
columnSpacing: 10
|
||||
|
||||
columnSpacing: 1
|
||||
rowSpacing: 2
|
||||
|
||||
|
||||
model: TableModel {
|
||||
TableModelColumn { display: "checked" }
|
||||
TableModelColumn { display: "amount" }
|
||||
TableModelColumn { display: "fruitType" }
|
||||
TableModelColumn { display: "fruitName" }
|
||||
TableModelColumn { display: "fruitPrice" }
|
||||
model: dbm
|
||||
delegate:Item
|
||||
{
|
||||
implicitWidth: 200
|
||||
implicitHeight: 25
|
||||
|
||||
|
||||
rows: [
|
||||
{
|
||||
checked: "checked",
|
||||
amount: "amount",
|
||||
fruitType: "Fruittype",
|
||||
fruitName: "fruitName",
|
||||
fruitPrice: "Price"
|
||||
},
|
||||
{
|
||||
checked: true,
|
||||
amount: 2,
|
||||
fruitType: "Fruittype",
|
||||
fruitName: "blabla",
|
||||
fruitPrice: 1.50
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
checked: true,
|
||||
amount: 1,
|
||||
fruitType: "Apple",
|
||||
fruitName: "Granny Smith",
|
||||
fruitPrice: 1.50
|
||||
},
|
||||
{
|
||||
checked: "true",
|
||||
amount: 4,
|
||||
fruitType: "Orange",
|
||||
fruitName: "Navel",
|
||||
fruitPrice: 2.50
|
||||
},
|
||||
{
|
||||
checked: "false",
|
||||
amount: 1,
|
||||
fruitType: "Banana",
|
||||
fruitName: "Cavendish",
|
||||
fruitPrice: 3.50
|
||||
}
|
||||
]
|
||||
Text
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
text: model.display
|
||||
|
||||
}
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
onClicked: dbm.onRowClicked(row)
|
||||
}
|
||||
}
|
||||
|
||||
delegate: DelegateChooser {
|
||||
|
||||
DelegateChoice {
|
||||
column: 0
|
||||
delegate: Text {
|
||||
}
|
||||
|
||||
text: model.display
|
||||
//selectByMouse: true
|
||||
//implicitWidth: 140
|
||||
//onVisibleChanged: model.display = "checked"
|
||||
}
|
||||
}
|
||||
DelegateChoice {
|
||||
column: 1
|
||||
delegate: Text {
|
||||
|
||||
text: model.display
|
||||
//selectByMouse: true
|
||||
//implicitWidth: 140
|
||||
//onVisibleChanged: model.display = "amount"
|
||||
//onLinkHovered: model.display = checked
|
||||
}
|
||||
}
|
||||
DelegateChoice {
|
||||
column: 2
|
||||
delegate: Text {
|
||||
|
||||
text: model.display
|
||||
//selectByMouse: true
|
||||
//implicitWidth: 140
|
||||
//model.display : "fruitType"
|
||||
}
|
||||
}
|
||||
DelegateChoice {
|
||||
column: 3
|
||||
delegate: Text {
|
||||
|
||||
text: model.display
|
||||
//selectByMouse: true
|
||||
//implicitWidth: 140
|
||||
//onVisibleChanged: model.display = "fruitName"
|
||||
}
|
||||
}
|
||||
DelegateChoice {
|
||||
column: 4
|
||||
delegate: Text {
|
||||
|
||||
text: model.display
|
||||
//selectByMouse: true
|
||||
//implicitWidth: 140
|
||||
//onVisibleChanged: model.display = "fruitPrice"
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
@@ -179,3 +108,4 @@ Item {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
|
||||
Item
|
||||
@@ -15,10 +16,6 @@ Item
|
||||
width: 300
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Button
|
||||
{
|
||||
icon.source: "../images/search.svg"
|
||||
@@ -31,13 +28,57 @@ Item
|
||||
}
|
||||
Button
|
||||
{
|
||||
id: filterBtn
|
||||
icon.source: "../images/filter.svg"
|
||||
icon.color: "olive"
|
||||
anchors.left: searchField.right
|
||||
height: searchField.height
|
||||
flat: true
|
||||
onClicked: filterPopup.open()
|
||||
|
||||
|
||||
}
|
||||
Popup
|
||||
{
|
||||
id: filterPopup
|
||||
x: filterBtn.x + filterBtn.width
|
||||
y: filterBtn.y
|
||||
width: 100
|
||||
height: 150
|
||||
modal: true
|
||||
focus: true
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
||||
contentItem: Item
|
||||
{
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors.fill: parent
|
||||
//id: filterContent
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: availableFilters
|
||||
CheckBox
|
||||
{
|
||||
text: model.modelData
|
||||
onClicked:
|
||||
{
|
||||
setFilter(text, checkState)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function setFilter(filter,activated)
|
||||
{
|
||||
console.log(filter)
|
||||
console.log(activated)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user