-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
588 lines (515 loc) · 18.1 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
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
/********************************************************************************************************************************************************
* @file main.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 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import io.qt.examples.backend 1.0 // This flags as an error, but works perfectly fine
// Main iTrace_Toolkit Window
Window {
id: main
property int menuHeight: 40;
property int buttonHeight: 30;
property int margin: 15;
property int minHeight: 760;
property int minWidth: 420;
property string iTraceRed: "#680314"
visible: true
width: minWidth
height: minHeight //+ menuHeight
/*maximumHeight: height
maximumWidth: width*/
minimumHeight: minHeight
minimumWidth: minWidth
title: qsTr("iTrace Toolkit V0.2.2")
function getBottomY(obj) {
return obj.y + obj.height;
}
function getRightX(obj) {
return obj.x + obj.width;
}
function equalWidth(width, num) {
var tempN = width - margin * (num+1)
return tempN / num;
}
function swapDBButtons() {
// openDatabaseButton.enabled = !openDatabaseButton.enabled;
// createDatabaseButton.enabled = !createDatabaseButton.enabled;
// mapTokensButton fixationSettingsButton genFixationDataButton queryFixationButton
folderOpenButton.enabled = true;
//xmlButton.enabled = true;
databaseImportButton.enabled = true;
mapTokensButton.enabled = true;
fixationSettingsButton.enabled = true;
genFixationDataButton.enabled = true;
queryFixationButton.enabled = true;
}
// Rectangle {
// x: 0; y: 0
// width: main.width;
// height: 40;
// color: "light grey"
// }
// MenuBar {
// Menu {
// title: qsTr("File")
// Action {
// text: "Exit"
// onTriggered: {
// main.close()
// }
// }
// }
// // Database Menu
// Menu {
// title: qsTr("Database")
// // Create New Database File
// Action {
// text: "Create New Database"
// onTriggered: {
// databaseCreate.open()
// }
// }
// // Open Database File
// Action {
// text: "Open Database"
// onTriggered: {
// databaseOpen.open()
// }
// }
// Action {
// text: "Close Database"
// onTriggered: {
// control.closeDatabase()
// participantList.model.clearTasks()
// }
// }
// // Load XML File(s) Submenu
// Menu {
// title: qsTr("Load XML")
// // Load Individual XML
// Action {
// text: "Load XML File"
// onTriggered: {
// xmlOpen.open()
// }
// }
// // Batch Load XML From File
// Action {
// text: "Load XML From Folder"
// onTriggered: {
// folderOpen.open()
// }
// }
// }
// }
// Menu {
// title: qsTr("Analyze")
// Action {
// text: "Fixation Settings"
// onTriggered: options.open()
// }
// Action {
// text: "Map Tokens"
// onTriggered: {
// mappingMenu.open()
//// control.mapTokens("C:/Users/Joshua/Desktop/iTrace/data/001/cppcheck.xml")
// }
// }
// Action {
// text: "Generate Fixation Data"
// onTriggered: {
// generateFixations(options.getSettings())
// }
// function generateFixations(algorithm) {
// control.generateFixationData(participantList.model.getModelList().getSelected(),algorithm)
// }
// }
// Action {
// text: "Query Fixation Data"
// onTriggered: filter.open()
// }
// Action {
// text: "Export Fixation Highlighting (WIP)"
// onTriggered: {
// control.highlightFixations("C:/Users/Joshua/Desktop/iTrace/Output","C:/Users/Joshua/Desktop/iTrace/data/001/cppcheck.xml")
// }
// }
// }
// /*Menu {
// title: qsTr("Help")
// }
// Menu {
// title: qsTr("About")
// }*/
// }
Controller {
id: control
// Signal Catchers
onTaskAdded: participantList.model.appendTask(task);
onOutputToScreen: outputFlick.myAppend("<font color=\""+color+"\">" + msg + "</font>\n");
onWarning: {
warningDialog.title = title;
warningDialog.text = msg;
warningDialog.open();
}
onDatabaseSet: {
loadedDatabaseText.text = "Current Database: " + path;
loadedDatabaseText.color = "green"
}
onDatabaseClosed: {
loadedDatabaseText.text = "No Database Is Loaded"
loadedDatabaseText.color = iTraceRed
// Need to clear the participantList
}
onStartProgressBar: {
// loadingBar.visible = true
// loadingBar.from = start
// loadingBar.to = stop
gif.visible = true;
}
onStopProgressBar: {
// loadingBar.visible = false
// loadingBar.value = 0.0
// loadingBar.indeterminate = false
gif.visible = false;
}
onSetProgressBarValue: {
//loadingBar.value = val
}
onSetProgressBarToIndeterminate: {
//loadingBar.visible = true
//loadingBar.indeterminate = true
gif.visible = true;
}
}
//Database Tab
Text {
id: dataBaseTabLabel
text: "Database"
x: margin; y: margin
}
Rectangle {
id: databaseTab
width: parent.width - 2 * margin
// height: parent.height - menuHeight - outputTab.height - (4 * margin) // Old Height with menubar
height: parent.height - outputTab.height - outputTabLabel.height - analysisTab.height - analysisTabLabel.height - (5 * margin)
x: margin; y: getBottomY(dataBaseTabLabel) // + menuHeight
border.color: iTraceRed
border.width: 3
// color: "red"
Rectangle {
id: gifRect
x: parent.width - gif.width - margin; y: parent.height - gif.width - margin
width: gif.width; height: gif.height
AnimatedImage {
id: gif
source: "loading_128.gif"
visible: false
}
}
Button {
id: openDatabaseButton
height: buttonHeight; width: equalWidth(parent.width, 2)
x: margin; y: margin;
enabled: true;
text: "Open Database"
onClicked: {
databaseOpen.open();
}
}
Button {
id: createDatabaseButton
height: buttonHeight; width: equalWidth(parent.width, 2)
x: getRightX(openDatabaseButton) + margin; y: margin;
enabled: true;
text: "Create Database"
onClicked: {
databaseCreate.open();
}
}
// Loaded Files Area
Text {
id: loadedDatabaseText
x: margin; y: getBottomY(openDatabaseButton) + margin/2;
width: parent.width - 2 * margin
elide: Text.ElideMiddle
text: "No Database Is Loaded"
color: iTraceRed
}
Button {
id: folderOpenButton
height: buttonHeight; width: equalWidth(parent.width, 2);
x: margin; y: getBottomY(loadedDatabaseText) + margin;
onClicked: {
folderOpen.open();
}
ToolTip.visible: hovered | down
ToolTip.text: "Select a folder to recursively upload all Core and Plugin XML files inside it"
enabled: false
// Image {
// id: folderUploadImg
// source: "folder upload.png"
// anchors.top: parent.top
// anchors.bottom: parent.bottom
// anchors.left: folderButtonText.right
// anchors.margins: 5
// fillMode: Image.PreserveAspectFit
// }
Text {
id: folderButtonText
anchors.verticalCenter: parent.verticalCenter
color: parent.enabled ? "black" : "grey";
// x: parent.width/2 - width/2 - folderUploadImg.width/2 - folderUploadImg.anchors.margins/2
anchors.horizontalCenter: parent.horizontalCenter
text: "Import Data From Folder"
}
}
Button {
id: databaseImportButton
height: buttonHeight; width: equalWidth(parent.width, 2); // equalWidth(parent.width - buttonHeight, 2); // For if close button
x: getRightX(folderOpenButton) + margin; y: getBottomY(loadedDatabaseText) + margin;
onClicked: {
//xmlOpen.open();
databaseImportOpen.open();
}
ToolTip.visible: hovered | down
ToolTip.text: "Select a previous iTrace Database to import"
//ToolTip.text: "Select individual srcML or XML files to upload"
enabled: false
/*Text {
id: xmlButtonText
anchors.verticalCenter: parent.verticalCenter
color: parent.enabled ? "black" : "grey";
// x: parent.width/2 - width/2 - xmlUploadImg.width/2 - xmlUploadImg.anchors.margins/2
anchors.horizontalCenter: parent.horizontalCenter;
text: "Import From XML"
}*/
Text {
id: databaseImportButtonText
anchors.verticalCenter: parent.verticalCenter
color: parent.enabled ? "black" : "grey";
//x: parent.width/2 - width/2 - xmlUploadImg.width/2 - xmlUploadImg.anchors.margins/2
anchors.horizontalCenter: parent.horizontalCenter;
text: "Import from Database"
}
}
// Button {
// id: closeButton
// height: buttonHeight; width: buttonHeight;
// x: getRightX(xmlButton) + margin/2; y: getBottomY(loadedDatabaseText) + margin/2;
// onClicked: {
// control.closeDatabase()
// participantList.model.clearTasks();
// swapDBButtons();
// }
// ToolTip.visible: hovered | down
// ToolTip.text: "Close currently selected database"
// visible: false;
// Image {
// id: closeImg
// source: "cross.png";
// anchors.fill: parent
// anchors.margins: 5
// }
// }
Text {
id: loadedParticipantsText
x: margin; y: getBottomY(folderOpenButton) + margin;
font.bold: true
text: "Loaded Participants - Tasks:"
}
Participant {
id: participantList
x: margin; y: getBottomY(loadedParticipantsText) + margin/2;
height: parent.height - getBottomY(loadedParticipantsText) - 3 * margin / 2
anchors.horizontalCenter: parent.horizontalCenter
spacing: margin
}
}
Text {
id: analysisTabLabel
text: "Analysis"
x: margin; y: getBottomY(databaseTab) + margin;
}
Rectangle {
id: analysisTab
x: margin; y: getBottomY(analysisTabLabel)
width: parent.width - 2 * margin; height: 3 * margin + 2 * buttonHeight
border.color: iTraceRed
border.width: 3
Button {
id: mapTokensButton
x: margin; y: margin;
height: buttonHeight; width: equalWidth(parent.width, 2)
text: "Map Tokens"
enabled: false
onClicked: {
mappingMenu.open()
}
}
Button {
id: fixationSettingsButton
x: getRightX(mapTokensButton) + margin; y: margin;
height: buttonHeight; width: equalWidth(parent.width, 2)
text: "Fixation Settings"
enabled: false
onClicked: options.open()
}
Button {
id: genFixationDataButton
x: margin; y: getBottomY(mapTokensButton) + margin;
height: buttonHeight; width: equalWidth(parent.width, 2)
text: "Generate Fixations"
enabled: false
onClicked: {
generateFixations(options.getSettings())
}
function generateFixations(algorithm) {
control.generateFixationData(participantList.model.getModelList().getSelected(),algorithm)
}
}
Button {
id: queryFixationButton
x: getRightX(genFixationDataButton) + margin; y: getBottomY(mapTokensButton) + margin;
height: buttonHeight; width: equalWidth(parent.width, 2)
text: "Query Fixations"
enabled: false
onClicked: filter.open()
}
}
Text {
id: outputTabLabel
text: "Output"
x: margin; y: parent.height - outputTab.height - margin - height
}
// Output TextArea
Rectangle {
id: outputTab
width: parent.width - (margin*2); height: 90
x: margin; y: getBottomY(outputTabLabel)//parent.height - height - margin
border.color: "black"
border.width: 3
Flickable {
id: outputFlick
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar {}
TextArea.flickable: TextArea {
id: output
anchors.fill: parent
text: ""
readOnly: true
textFormat: Text.RichText
}
function currPos(){
return outputFlick.contentY
}
function setPos(pos){
outputFlick.contentY = pos;
}
function getEndPos(){
var ratio = 1.0 - outputFlick.visibleArea.heightRatio;
var endPos = outputFlick.contentHeight * ratio;
return endPos;
}
function scrollToEnd(){
outputFlick.contentY = getEndPos();
}
function myAppend(text){ //TODO: Make this put a newline
var pos, endPos, value;
value = output.text + String(text);
// Limit value size here
endPos = getEndPos();
pos = currPos();
output.text = value;
if(pos === endPos){
scrollToEnd();
} else {
setPos(pos);
}
}
}
}
// ProgressBar
// ProgressBar {
// id: loadingBar
// x: margin; y: parent.height - outputTab.height - 2*margin
// width: parent.width - margin*2
// value: 0.0
// visible: false
// }
// File Dialogs
FileDialog { // DatabaseOpen
id: databaseOpen
selectExisting: true
nameFilters: ["SQLite Files (*.db3; *.db; *.sqlite; *.sqlite3)","All Files (*.*)"]
onAccepted: {
control.closeDatabase()
participantList.model.clearTasks()
control.loadDatabaseFile(fileUrl)
swapDBButtons()
}
}
FileDialog { // DatabaseCreate
id: databaseCreate
selectExisting: false
nameFilters: ["SQLite Files (*.db3; *.db; *.sqlite; *.sqlite3)","All Files (*.*)"]
onAccepted: {
control.closeDatabase()
participantList.model.clearTasks()
control.saveDatabaseFile(fileUrl)
swapDBButtons()
}
}
FileDialog { // XMLOpen
id: xmlOpen
selectExisting: true
nameFilters: ["iTrace XML (*.xml)", "SrcML Files (*.xml; *.srcml)", "All Files (*.*)"]
onAccepted: {
control.importXMLFile(fileUrl)
}
}
FileDialog {
id: databaseImportOpen
selectExisting: true
nameFilters: ["SQLite Files (*.db3; *.db; *.sqlite; *.sqlite3)","All Files (*.*)"]
onAccepted: {
participantList.model.clearTasks()
control.importDatabaseFile(fileUrl);
}
}
FileDialog { // FolderOpen
id: folderOpen
selectExisting: true
selectFolder: true
onAccepted: {
control.batchAddXML(fileUrl)
}
}
MessageDialog {
id: warningDialog
title: ""
text: ""
icon: StandardIcon.Warning
}
Options {
id: options
}
Filter {
id: filter
}
Mapping {
id: mappingMenu
}
}