-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.qml
115 lines (99 loc) · 2.93 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
ApplicationWindow {
id: window
visible: true
width: 300
height: 480
ColumnLayout {
id: rowLayout
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 5
spacing: 10
Text { text: qsTr("FirstName") }
TextField { id: firstnameField }
Text { text: qsTr("LastName") }
TextField { id: lastnameField }
Text { text: qsTr("Mobile") }
TextField { id: mobileField }
Button {
text: qsTr("Add Data")
onClicked: {
database.insertIntoTable(firstnameField.text, lastnameField.text, mobileField.text)
myModel.updateModel()
}
}
Button {
text: "Remove"
onClicked: contextMenu.open();
}
}
ListView {
id: tableView
anchors.top: rowLayout.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 5
anchors.topMargin: 30
model: myModel
Row {
id: rl
x:0
y: -30
Text { text: "FirstName"; font.bold: true; width: 120; }
Text { text: "LastName"; font.bold: true; width: 120; }
Text { text: "Mobile"; font.bold: true; width: 120; }
spacing: 10
}
delegate: RowLayout {
id: rowlayout
spacing: 10
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
tableView.currentIndex = index
}
}
Rectangle {
id: rc;
anchors.fill: parent
color: mouseArea.containsMouse ? "#55CCccCC" : "#00ffFFff"
}
Rectangle {
id: rowLayoutBackground
anchors.fill: parent
color: (tableView.currentIndex == index) ? "#55CCccCC" : "#00ffFFff"
}
Column { Text { text: firstname; width: 120; } }
Column { Text { text: lastname; width: 120; } }
Column { Text { text: mobile; width: 120; } }
}
}
Menu {
id: contextMenu
MenuItem {
text: qsTr("Remove")
onTriggered: {
dialogDelete.open()
}
}
}
MessageDialog {
id: dialogDelete
title: qsTr("Remove record")
text: qsTr("Confirm the deletation of log entries")
icon: StandardIcon.Warning
standardButtons: StandardButton.Ok | StandardButton.Cancel
onAccepted: {
database.removeRecord(myModel.getId(tableView.currentIndex))
myModel.updateModel()
}
}
}