-
Notifications
You must be signed in to change notification settings - Fork 0
/
Filter.qml
441 lines (416 loc) · 17.1 KB
/
Filter.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/********************************************************************************************************************************************************
* @file Filer.qml
*
* @Copyright (C) 2022 i-trace.org
*
* This file is part of iTrace Infrastructure http://www.i-trace.org/.
* iTrace Infrastructure 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.
* iTrace Infrastructure 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 iTrace Infrastructure. If not, see <https://www.gnu.org/licenses/>.
********************************************************************************************************************************************************/
import QtQuick.Window 2.15
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
Popup {
id: filter
property var margin: 15 // TODO: Make this property in a config file or something that way if we want to change it we only change it in one spot
property string output_folder: "."
x: margin; y: margin
height: parent.height - 2 * margin
width: parent.width - 2 * margin
modal: true
focus: true
closePolicy: Popup.NoAutoClose | Popup.CloseOnEscape /*| Popup.CloseOnPressOutside //*/
/* List of properties:
* fixation_target: file name, textbox, or dropdown list of files loaded
* source_file_line: filter which source file lines wanted, set to 0 and -1 to disable filter
* source_file_col: filter which source file lines wanted, set to 0 and -1 to disable filter
* token: comma separated list of tokens to be filtered
* left_pupil_diameter: ranges from 0 to 4
* right_pupil_diameter: ranges from 0 to 4
* duration: Range of duration to filter, measured in milliseconds, set to 0 and -1 to disable filter
* save/load options to/from file
*/
GridLayout {
x: 0; y: 0;
height: parent.height
width: parent.width
columns: 1
GridLayout { // Fixation Target
columns: 1
Text {
text: "Fixation Target (leave blank to disable): "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
TextField {
id: fixationTargetFilter
Layout.fillWidth: true
placeholderText: "Comma separated list of file names to filter for"
}
}
GridLayout { // Token Type
columns: 1
Text {
text: "Token Type (leave blank to disable): "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
TextField {
id: fixationTokenFilter
Layout.fillWidth: true
placeholderText: "Comma separated list of token names to filter for"
}
}
GridLayout { // Duration
columns: 1
Text {
text: "Duration (ms): "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
GridLayout {
columns: 4
Text {
text: "Min: "
}
TextField {
id: fixationDurationFilterMin
Layout.fillWidth: true
validator: IntValidator{bottom: 0}
readonly property string defaultVal: "0"
text: defaultVal
}
Text {
text: "Max: "
}
TextField {
id: fixationDurationFilterMax
Layout.fillWidth: true
// When -1, disable filter
validator: IntValidator{bottom:-1}
readonly property string defaultVal: "-1"
text: defaultVal
}
}
}
GridLayout { // Source File Line
columns: 1
Text {
text: "Source File Line: "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
GridLayout {
columns: 4
Text {
text: "Min: "
}
TextField {
id: fixationLineFilterMin
Layout.fillWidth: true
validator: IntValidator{bottom: -1}
readonly property string defaultVal: "-1"
text: defaultVal
}
Text {
text: "Max: "
}
TextField {
id: fixationLineFilterMax
Layout.fillWidth: true
// When -1, disable filter
validator: IntValidator{bottom:-1}
readonly property string defaultVal: "-1"
text: defaultVal
}
}
}
GridLayout { // Source File Column
columns: 1
Text {
text: "Source File Column: "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
GridLayout {
columns: 4
Text {
text: "Min: "
}
TextField {
id: fixationColFilterMin
Layout.fillWidth: true
validator: IntValidator{bottom: -1}
readonly property string defaultVal: "-1"
text: defaultVal
}
Text {
text: "Max: "
}
TextField {
id: fixationColFilterMax
Layout.fillWidth: true
// When -1, disable filter
validator: IntValidator{bottom:-1}
readonly property string defaultVal: "-1"
text: defaultVal
}
}
}
GridLayout { // Pupil Diameter
columns: 1
id: pupilLayout
readonly property string min: "0.00"
readonly property string max: "10.0"
Text {
text: "Pupil Diameters (mm)"
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
GridLayout {
columns: 2
GridLayout {
columns: 1
id: diameterGrid
Text {
text: "Right"
}
GridLayout {
columns: 3
TextField {
id: rightMin
text: pupilLayout.min
implicitWidth: 50
onEditingFinished: {
fixationRightDiameterFilter.first.value = rightMin.text
}
}
RangeSlider {
id: fixationRightDiameterFilter
Layout.fillWidth: true
from: pupilLayout.min
to: pupilLayout.max
first.value: pupilLayout.min
second.value: pupilLayout.max
stepSize: 0.001
snapMode: RangeSlider.SnapOnRelease
Connections {
target: fixationRightDiameterFilter.first
function onValueChanged() {
if(linkButton.toggled) {
leftMin.text = fixationRightDiameterFilter.first.value.toPrecision(3)
fixationLeftDiameterFilter.first.value = leftMin.text
}
rightMin.text = fixationRightDiameterFilter.first.value.toPrecision(3)
}
}
Connections {
target: fixationRightDiameterFilter.second
function onValueChanged() {
if(linkButton.toggled) {
leftMax.text = fixationRightDiameterFilter.second.value.toPrecision(3)
fixationLeftDiameterFilter.second.value = leftMax.text
}
rightMax.text = fixationRightDiameterFilter.second.value.toPrecision(3)
}
}
}
TextField {
id: rightMax
text: pupilLayout.max
implicitWidth: 50
onEditingFinished: fixationRightDiameterFilter.second.value = rightMax.text
}
}
Text {
text: "Left"
}
GridLayout {
columns: 3
TextField {
id: leftMin
text: pupilLayout.min
implicitWidth: 50
validator: DoubleValidator {
bottom: pupilLayout.min
top: pupilLayout.max
decimals: 3
}
onEditingFinished: fixationLeftDiameterFilter.first.value = leftMin.text
}
RangeSlider {
id: fixationLeftDiameterFilter
Layout.fillWidth: true
from: pupilLayout.min
to: pupilLayout.max
first.value: pupilLayout.min
second.value: pupilLayout.max
stepSize: 0.001
snapMode: RangeSlider.SnapOnRelease
Connections {
target: fixationLeftDiameterFilter.first
function onValueChanged() {
if(linkButton.toggled) {
rightMin.text = fixationLeftDiameterFilter.first.value.toPrecision(3)
fixationRightDiameterFilter.first.value = rightMin.text
}
leftMin.text = fixationLeftDiameterFilter.first.value.toPrecision(3)
}
}
Connections {
target: fixationLeftDiameterFilter.second
function onValueChanged() {
if(linkButton.toggled) {
rightMax.text = fixationLeftDiameterFilter.second.value.toPrecision(3)
fixationRightDiameterFilter.second.value = rightMax.text
}
leftMax.text = fixationLeftDiameterFilter.second.value.toPrecision(3)
}
}
}
TextField {
id: leftMax
text: pupilLayout.max
implicitWidth: 50
validator: DoubleValidator {
bottom: pupilLayout.min
top: pupilLayout.max
decimals: 3
}
onEditingFinished: fixationLeftDiameterFilter.second.value = leftMax.text
}
}
}
Button {
id: linkButton
property var toggled: true
implicitHeight: diameterGrid.height
implicitWidth: 25
onClicked: {
toggled = !toggled
}
Image {
source: linkButton.toggled? "chain-closed.png" : "chain-open.png"
anchors.fill: parent
anchors.margins: 4
}
}
}
}
Text {
text: "Output File Type: "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
ComboBox {
id: exportBox
model: [".db3",".tsv",".xml",".json"]
implicitWidth: parent.width
}
Text {
text: "Import/Export SQL Files: "
font.pointSize: 10
font.bold: true
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
GridLayout {
id: sqlButtonGrid
columns: 2
Button {
id: exportCurrentButton
Layout.fillWidth: true
text: "Export Current Settings"
onClicked: queryFileCreate.open()
}
Button {
id: importSQLButton
Layout.fillWidth: true
text: "Load SQL File and Filter"
onClicked: {
queryFileOpen.open();
filter.close();
}
}
}
Item {
// Filler element, fills the rest of the space in the layout to force the above elements to be closer to each other
// rather than equally spaced in the entire layout space
Layout.fillHeight: true
}
GridLayout {
id: buttonGrid
columns: 3
Button {
id: closeButton
Layout.fillWidth: true
text: "Close"
onClicked: filter.close()
}
Button {
id: setOutputFolderButton
Layout.fillWidth: true
text: "Output Folder"
onClicked: {
folderSelect.open();
}
}
Button {
id: filterButton
Layout.fillWidth: true
text: "Filter"
onClicked: {
filter.close()
control.generateQueriedData(control.generateQuery(fixationTargetFilter.text,fixationTokenFilter.text,fixationDurationFilterMin.text,fixationDurationFilterMax.text,fixationLineFilterMin.text,fixationLineFilterMax.text,fixationColFilterMin.text,fixationColFilterMax.text,rightMin.text,rightMax.text,leftMin.text,leftMax.text),exportBox.model[exportBox.currentIndex],filter.output_folder)
}
}
}
}
FileDialog {
id: queryFileOpen
selectExisting: true
nameFilters: ["Query Files (*.sql)","All Files (*.*)"]
onAccepted: {
control.loadQueryFile(fileUrl,exportBox.model[exportBox.currentIndex],output_folder)
}
}
FileDialog {
id: queryFileCreate
selectExisting: false
nameFilters: ["Query Files (*.sql)","All Files (*.*)"]
onAccepted: {
control.saveQueryFile(control.generateQuery(fixationTargetFilter.text,fixationTokenFilter.text,fixationDurationFilterMin.text,fixationDurationFilterMax.text,fixationLineFilterMin.text,fixationLineFilterMax.text,fixationColFilterMin.text,fixationColFilterMax.text,rightMin.text,rightMax.text,leftMin.text,leftMax.text),fileUrl);
}
}
FileDialog {
id: folderSelect
selectFolder: true
onAccepted: {
filter.output_folder = fileUrl
}
}
FileDialog {
id: filterFileSave
selectExisting: true
nameFilters: ["SQLite Files (*.db3; *.db; *.sqlite; *.sqlite3)","Tab-Separated Values (*.tsv;)","JSON Files (*.json;)","XML Files (*.xml;)"]
onAccepted: {
}
}
}