-
Notifications
You must be signed in to change notification settings - Fork 2
/
ticsoutputpane.cpp
92 lines (77 loc) · 2.33 KB
/
ticsoutputpane.cpp
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
#include "ticsoutputpane.h"
#include "ticsqtcreatorplugin.h"
#include <coreplugin/editormanager/editormanager.h>
namespace TICSQtCreator {
namespace Internal {
TicsOutputPane::TicsOutputPane(QObject* parent): IOutputPane( parent )
{
this->textEdit = new QTextBrowser();
textEdit->setOpenLinks(false);
connect(textEdit, &QTextBrowser::anchorClicked,this,&TicsOutputPane::openFileLink);
}
QWidget* TicsOutputPane::outputWidget( QWidget* parent ){
Q_UNUSED( parent );
return this->textEdit;
}
QList<QWidget*> TicsOutputPane::toolBarWidgets() const{
QList<QWidget*> widgets;
return widgets;
}
QString TicsOutputPane::displayName() const{
return "TICS Output";
}
int TicsOutputPane::priorityInStatusBar() const{
return 1;
}
void TicsOutputPane::clearContents(){
textEdit->clear();
textEdit->document()->clear();
}
void TicsOutputPane::visibilityChanged( bool visible ){
Q_UNUSED( visible );
}
void TicsOutputPane::setFocus(){
}
bool TicsOutputPane::hasFocus() const{
return true;
}
bool TicsOutputPane::canFocus() const{
return true;
}
bool TicsOutputPane::canNavigate() const{
return true;
}
bool TicsOutputPane::canNext() const{
return false;
}
bool TicsOutputPane::canPrevious() const{
return false;
}
void TicsOutputPane::goToNext(){
}
void TicsOutputPane::goToPrev(){
}
void TicsOutputPane::writeText(QString text){
qDebug() << "write text"<<endl;
//matches violation trace file paths
QRegularExpression re("^(.*)\\(([0-9]+)\\):$",QRegularExpression::MultilineOption);
QRegularExpressionMatch match = re.match(text);
while(match.hasMatch()){
QString textBeforeLink = text.left(match.capturedStart(0));
QString textAfterLink = text.mid(match.capturedEnd(0),text.size());
QString fileLink = "<a href=\""+match.captured(1)+"#"+match.captured(2)+"\">"+match.captured(0)+"</a>";
textEdit->append(textBeforeLink);
textEdit->append(fileLink);
qDebug()<< "Transforming fileLink in violations summary: " << match.captured(0) << endl;
text = textAfterLink;
match = re.match(text);
}
textEdit->append(text);
}
void TicsOutputPane::openFileLink(const QUrl & url)
{
qInfo()<< "Opening file" << url.path() << "at line " << url.fragment();
Core::EditorManager::openEditorAt(url.path(),url.fragment().toInt());
}
}
}