forked from AlloyTeam/Rythem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
waterfallwindow.cpp
70 lines (63 loc) · 2.45 KB
/
waterfallwindow.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
#include <QWebFrame>
#include "waterfallwindow.h"
#include "ui_waterfallwindow.h"
WaterfallWindow::WaterfallWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::WaterfallWindow)
{
ui->setupUi(this);
connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(onWebContentLoaded()));
}
WaterfallWindow::~WaterfallWindow()
{
delete ui;
qDebug() << "[WaterfallWindow] i am dead";
}
bool compareRequestTime(RyPipeData_ptr p1, RyPipeData_ptr p2){
return p1->performances.requestBegin < p2->performances.requestBegin;
}
void WaterfallWindow::setPipeData(QList<RyPipeData_ptr> list){
//save the list first
pipes = list;
if(loaded){
//constructor the js object
qSort(pipes.begin(), pipes.end(), compareRequestTime);
QStringList results;
QListIterator<RyPipeData_ptr> it(list);
qDebug() << "--------------------------";
while(it.hasNext()){
RyPipeData_ptr p = it.next();
qDebug() << "requestBegin" << p->performances.requestBegin;
QString result;
QTextStream stream(&result);
stream << "{id:" << p->id
<< ", socketID:" << p->socketConnectionId
<< ", host:\"" << p->host << "\""
<< ", url:\"" << p->fullUrl << "\""
<< ", method:\"" << p->method << "\""
<< ", status:\"" << p->responseStatus+"\""
<< ", startTime:" << p->performances.requestBegin
<< ", responseStartTime:" << p->performances.responseBegin
<< ", responseFinishTime:" << p->performances.responseDone
<< ", requestContentLength:" << p->requestBodyRawData().length()
<< ", responseContentLength:" << p->responseBodyRawData().length()
<< "}";
results << result;
}
//invoke js update method
QWebFrame *frame = ui->webView->page()->mainFrame();
QString args = "[" + results.join(",") + "]";
qDebug()<<args;
frame->evaluateJavaScript("window.updateAllConnections(" + args + ")");
}
}
void WaterfallWindow::onWebContentLoaded(){
loaded = true;
if(pipes.length()){
setPipeData(pipes);
}
}
void WaterfallWindow::closeEvent(QCloseEvent *event){
event->accept();
deleteLater();
}