-
Notifications
You must be signed in to change notification settings - Fork 8
/
IssuesList.qml
158 lines (139 loc) · 5.81 KB
/
IssuesList.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
import QtQuick 2.12
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.12
import appmodel 1.0
/** List the error and warning messages of the validation step. */
ColumnLayout {
id: rootComponent
property string label /** The label for the current collection of messages */
property var dataModel /** Set this to the datamodel from the C# side */
property bool showWarnings /** Show messages with severity 'warning' */
property bool showInfo /** Show messages with severity 'informational' */
anchors.left: parent.left
anchors.right: parent.right
signal peekIssue(int lineNumber, int linePosition)
signal rightClickedOnMessage(string message)
Label {
text: label
Layout.alignment: Qt.AlignCenter
color: "#696969"
font.pointSize: 17
visible: messagesRepeater.count > 0
}
Repeater {
id: messagesRepeater
model: dataModel
// Main container for the message
Rectangle {
id: messageRectangle
color: "#f8fafb"
border.color: "#f6f3fb"
border.width: 1
height: errorText.height + 40
width: parent.width - leftMargin - rightMargin
implicitHeight: errorText.height + 40
implicitWidth: parent.width - leftMargin - rightMargin
property int leftMargin: 20
property int rightMargin: 15
visible: {
if (modelData.severity === "error" || modelData.severity === "fatal") {
return true
} else if (modelData.severity === "warning" && showWarnings) {
return true
} else if (modelData.severity === "information" && showInfo) {
return true
} else {
return false
}
}
// Color indicator for the type of message
Rectangle {
width: 10
height: errorText.height + 40
anchors.left: parent.left
gradient: Gradient {
GradientStop { position: 0.0
color: (modelData.severity === "error" || modelData.severity === "fatal")
? "#c31432" :
modelData.severity === "warning" ? "#fe8c00" : "#007ec6"
}
GradientStop { position: 1.0
color: (modelData.severity === "error" || modelData.severity === "fatal")
? "#240b36" :
modelData.severity === "warning" ? "#f83600" : "#007ec6"
}
}
}
// The error message text
Text {
id: errorText
anchors {
left: parent.left; leftMargin: messageRectangle.leftMargin
right: parent.right; rightMargin: messageRectangle.rightMargin
top: parent.top; topMargin: 10
}
color: "#337081"
text: modelData.text
renderType: Text.NativeRendering
textFormat: Text.PlainText
wrapMode: "WrapAtWordBoundaryOrAnywhere"
}
// The error message location (as fhirpath)
Text {
anchors {
bottom: parent.bottom
}
width: parent.width
horizontalAlignment: Text.AlignRight
color: "#34826b"
text: modelData.location
renderType: Text.NativeRendering
font.pointSize: 9
textFormat: Text.PlainText
wrapMode: "WrapAtWordBoundaryOrAnywhere"
}
// The error message location (as line:column)
Text {
anchors {
bottom: parent.bottom
left: parent.left; leftMargin: messageRectangle.leftMargin
}
width: parent.width
horizontalAlignment: Text.AlignLeft
color: "#34826b"
visible: modelData.lineNumber !== 0
text: `line ${modelData.lineNumber}:${modelData.linePosition}`
renderType: Text.NativeRendering
font.pointSize: 9
textFormat: Text.PlainText
wrapMode: "WrapAtWordBoundaryOrAnywhere"
opacity: mousearea.containsMouse ? 1.0 : 0
Behavior on opacity {
OpacityAnimator {
duration: 250
}
}
}
MouseArea {
id: mousearea
anchors.fill: parent
hoverEnabled: true
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (modelData.text == appmodel.noJavaInstall) {
Qt.openUrlExternally(appmodel.javaInstallLink)
} else if (mouse.button === Qt.RightButton) {
var message = modelData.text
if (modelData.lineNumber != 0) {
message += qsTr(` (line ${modelData.lineNumber}:${modelData.linePosition})`)
}
rootComponent.rightClickedOnMessage(message)
} else {
rootComponent.peekIssue(modelData.lineNumber, modelData.linePosition)
}
}
}
}
}
}