-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistory.qml
131 lines (111 loc) · 4.13 KB
/
History.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Foreign Language Trainer is a program to study foreign languages through
* various exercises.
*
* Copyright (C) 2019 Sergey Kovalev
* https://github.com/skvl/flt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.0
Page {
header: ToolBar {
ToolButton {
text: qsTr("Home")
onClicked: stack.pop()
Layout.alignment: Qt.AlignVCenter
}
}
// It was quit difficult to deal with headers
// Links:
// - https://stackoverflow.com/a/27657021
// - https://forum.qt.io/post/504932
// - https://forum.qt.io/post/502134
TableView {
id: tableView
columnWidthProvider: function (column) {
return tableView.width / (tableView.columns + 1);
}
rowHeightProvider: function (column) { return 80; }
anchors.fill: parent
leftMargin: rowsHeader.implicitWidth
topMargin: columnsHeader.implicitHeight
model: settings.history
delegate: Item {
width: tableView.columnWidthProvider(modelData)
Text {
id: txt
text: display
anchors.fill: parent
anchors.margins: 10
color: '#aaaaaa'
font.pixelSize: 15
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
clip: true
}
x: column * tableView.columnWidthProvider(column)
}
Rectangle { // mask the headers
z: 3
color: "#222222"
y: tableView.contentY
x: tableView.contentX
width: tableView.leftMargin
height: tableView.topMargin
}
Row {
id: columnsHeader
y: tableView.contentY
z: 2
Repeater {
model: settings.history.columnHeaders
Label {
width: tableView.columnWidthProvider(modelData)
height: 35
text: modelData
color: '#aaaaaa'
font.pixelSize: 15
padding: 10
verticalAlignment: Text.AlignVCenter
background: Rectangle { color: "#333333" }
wrapMode: Text.Wrap
clip: true
}
}
}
Column {
id: rowsHeader
x: tableView.contentX
z: 2
Repeater {
model: settings.history.rowHeaders
Label {
width: tableView.columnWidthProvider(modelData)
height: tableView.rowHeightProvider(modelData)
text: modelData
color: '#aaaaaa'
font.pixelSize: 15
padding: 10
verticalAlignment: Text.AlignVCenter
background: Rectangle { color: "#333333" }
wrapMode: Text.Wrap
clip: true
}
}
}
ScrollIndicator.horizontal: ScrollIndicator { }
ScrollIndicator.vertical: ScrollIndicator { }
}
}