summaryrefslogtreecommitdiff
path: root/src/analyzer
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-02-25 00:19:27 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-02-25 00:19:27 +0100
commit9d20e99fffeebe67fd8ff27cb4f9e353892f5190 (patch)
tree23462fac2e862a2f408a26f94ab024c4174c3458 /src/analyzer
parentrekonq 0.6.82 (diff)
downloadrekonq-9d20e99fffeebe67fd8ff27cb4f9e353892f5190.tar.xz
Coding style
Diffstat (limited to 'src/analyzer')
-rw-r--r--src/analyzer/analyzerpanel.cpp12
-rw-r--r--src/analyzer/networkanalyzer.cpp102
-rw-r--r--src/analyzer/networkanalyzer.h6
3 files changed, 61 insertions, 59 deletions
diff --git a/src/analyzer/analyzerpanel.cpp b/src/analyzer/analyzerpanel.cpp
index 5520582a..964a512b 100644
--- a/src/analyzer/analyzerpanel.cpp
+++ b/src/analyzer/analyzerpanel.cpp
@@ -72,22 +72,22 @@ void NetworkAnalyzerPanel::toggle(bool enable)
mainWindow()->actionByName("net_analyzer")->setChecked(enable);
WebPage *page = mainWindow()->currentTab()->page();
NetworkAccessManager *manager = qobject_cast<NetworkAccessManager *>(page->networkAccessManager());
-
+
page->enableNetworkAnalyzer(enable);
-
+
if (enable)
{
- connect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear()));
+ connect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear()));
connect(manager, SIGNAL(networkData(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)),
- _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *) ) );
+ _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)));
- show();
+ show();
}
else
{
disconnect(page, SIGNAL(loadStarted()), _viewer, SLOT(clear()));
disconnect(manager, SIGNAL(networkData(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)),
- _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *) ) );
+ _viewer, SLOT(addRequest(QNetworkAccessManager::Operation, const QNetworkRequest &, QNetworkReply *)));
hide();
}
diff --git a/src/analyzer/networkanalyzer.cpp b/src/analyzer/networkanalyzer.cpp
index 752543d9..a3675dfa 100644
--- a/src/analyzer/networkanalyzer.cpp
+++ b/src/analyzer/networkanalyzer.cpp
@@ -46,29 +46,29 @@
#include <QClipboard>
NetworkAnalyzer::NetworkAnalyzer(QWidget *parent)
- : QWidget(parent)
- , _mapper(new QSignalMapper(this))
- , _requestList(new QTreeWidget(this))
+ : QWidget(parent)
+ , _mapper(new QSignalMapper(this))
+ , _requestList(new QTreeWidget(this))
{
QStringList headers;
headers << i18n("Method") << i18n("URL") << i18n("Response") << i18n("Length") << i18n("Content Type") << i18n("Info");
- _requestList->setHeaderLabels( headers );
-
+ _requestList->setHeaderLabels(headers);
+
_requestList->header()->setResizeMode(0, QHeaderView::Interactive);
_requestList->header()->setResizeMode(1, QHeaderView::Interactive);
_requestList->header()->setResizeMode(2, QHeaderView::Interactive);
_requestList->header()->setResizeMode(3, QHeaderView::Interactive);
_requestList->header()->setResizeMode(4, QHeaderView::Interactive);
-
+
_requestList->setAlternatingRowColors(true);
-
+
QVBoxLayout *lay = new QVBoxLayout(this);
- lay->addWidget( _requestList );
+ lay->addWidget(_requestList);
_requestList->setContextMenuPolicy(Qt::CustomContextMenu);
- connect( _mapper, SIGNAL(mapped(QObject *)), this, SLOT(requestFinished(QObject *)) );
- connect( _requestList, SIGNAL(itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( showItemDetails( QTreeWidgetItem *) ) );
- connect( _requestList, SIGNAL(customContextMenuRequested(QPoint) ), this, SLOT( popupContextMenu(QPoint)));
+ connect(_mapper, SIGNAL(mapped(QObject *)), this, SLOT(requestFinished(QObject *)));
+ connect(_requestList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(showItemDetails(QTreeWidgetItem *)));
+ connect(_requestList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint)));
}
@@ -78,12 +78,12 @@ NetworkAnalyzer::~NetworkAnalyzer()
void NetworkAnalyzer::popupContextMenu(const QPoint& pos)
{
- if(_requestList->topLevelItemCount() >= 1)
+ if (_requestList->topLevelItemCount() >= 1)
{
KMenu menu(_requestList);
KAction *copy;
- copy = new KAction(KIcon("edit-copy"),i18n("Copy URL"), this);
- connect(copy,SIGNAL(triggered(bool)),this,SLOT(copyURL()));
+ copy = new KAction(KIcon("edit-copy"), i18n("Copy URL"), this);
+ connect(copy, SIGNAL(triggered(bool)), this, SLOT(copyURL()));
menu.addAction(copy);
menu.exec(mapToGlobal(pos));
}
@@ -95,11 +95,11 @@ void NetworkAnalyzer::copyURL()
clipboard->setText(_requestList->currentItem()->text(1));
}
-void NetworkAnalyzer::addRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply )
+void NetworkAnalyzer::addRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply)
{
// Add to list of requests
QStringList cols;
- switch( op )
+ switch (op)
{
case QNetworkAccessManager::HeadOperation:
cols << QL1S("HEAD");
@@ -126,16 +126,16 @@ void NetworkAnalyzer::addRequest( QNetworkAccessManager::Operation op, const QNe
cols << req.url().toString();
cols << i18n("Pending");
- QTreeWidgetItem *item = new QTreeWidgetItem( cols );
- _requestList->addTopLevelItem( item );
+ QTreeWidgetItem *item = new QTreeWidgetItem(cols);
+ _requestList->addTopLevelItem(item);
// Add to maps
- _requestMap.insert( reply, req );
- _itemMap.insert( reply, item );
- _itemRequestMap.insert( item, req );
+ _requestMap.insert(reply, req);
+ _itemMap.insert(reply, item);
+ _itemRequestMap.insert(item, req);
- _mapper->setMapping( reply, reply );
- connect( reply, SIGNAL( finished() ), _mapper, SLOT( map() ) );
+ _mapper->setMapping(reply, reply);
+ connect(reply, SIGNAL(finished()), _mapper, SLOT(map()));
_requestList->header()->resizeSections(QHeaderView::ResizeToContents);
}
@@ -151,10 +151,11 @@ void NetworkAnalyzer::clear()
}
-void NetworkAnalyzer::requestFinished( QObject *replyObject )
+void NetworkAnalyzer::requestFinished(QObject *replyObject)
{
- QNetworkReply *reply = qobject_cast<QNetworkReply *>( replyObject );
- if ( !reply ) {
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(replyObject);
+ if (!reply)
+ {
kDebug() << "Failed to downcast reply";
return;
}
@@ -163,68 +164,69 @@ void NetworkAnalyzer::requestFinished( QObject *replyObject )
// Record the reply headers
QList<QByteArray> headerValues;
- foreach(const QByteArray &header, reply->rawHeaderList() )
+ foreach(const QByteArray &header, reply->rawHeaderList())
{
- headerValues += reply->rawHeader( header );
+ headerValues += reply->rawHeader(header);
}
-
+
QPair< QList<QByteArray>, QList<QByteArray> > replyHeaders;
replyHeaders.first = reply->rawHeaderList();
replyHeaders.second = headerValues;
_itemReplyMap[item] = replyHeaders;
// Display the request
- int status = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
- QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString();
- item->setText( 2, i18n("%1 %2", status, reason) );
+ int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ QString reason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
+ item->setText(2, i18n("%1 %2", status, reason));
- QString length = reply->header( QNetworkRequest::ContentLengthHeader ).toString();
- item->setText( 3, length );
+ QString length = reply->header(QNetworkRequest::ContentLengthHeader).toString();
+ item->setText(3, length);
- QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
- item->setText( 4, contentType );
+ QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString();
+ item->setText(4, contentType);
- if ( status == 302 ) {
- QUrl target = reply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl();
- item->setText( 5, i18n("Redirect: %1", target.toString() ) );
+ if (status == 302)
+ {
+ QUrl target = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
+ item->setText(5, i18n("Redirect: %1", target.toString()));
}
}
-void NetworkAnalyzer::showItemDetails( QTreeWidgetItem *item )
+void NetworkAnalyzer::showItemDetails(QTreeWidgetItem *item)
{
// Show request details
QString details;
-
+
QNetworkRequest req = _itemRequestMap[item];
details += i18n("<h3>Request Details</h3>");
details += QL1S("<ul>");
- foreach(const QByteArray &header, req.rawHeaderList() )
+ foreach(const QByteArray &header, req.rawHeaderList())
{
details += QL1S("<li>");
- details += QL1S( header );
+ details += QL1S(header);
details += QL1S(": ");
- details += QL1S( req.rawHeader( header ) );
+ details += QL1S(req.rawHeader(header));
details += QL1S("</li>");
}
details += QL1S("</ul>");
-
+
QPair< QList<QByteArray>, QList<QByteArray> > replyHeaders = _itemReplyMap[item];
details += i18n("<h3>Response Details</h3>");
details += QL1S("<ul>");
- for ( int i = 0; i < replyHeaders.first.count(); i++ )
+ for (int i = 0; i < replyHeaders.first.count(); i++)
{
details += QL1S("<li>");
- details += QL1S( replyHeaders.first[i] );
+ details += QL1S(replyHeaders.first[i]);
details += QL1S(": ");
- details += QL1S( replyHeaders.second[i] );
+ details += QL1S(replyHeaders.second[i]);
details += QL1S("</li>");
}
details += QL1S("</ul>");
-
+
// QLabel *label = new QLabel(details, this);
// KPassivePopup *popup = new KPassivePopup(this);
// popup->setView(label);
// popup->show(_requestList->mapToGlobal(_requestList->pos()));
- KPassivePopup::message(details,this);
+ KPassivePopup::message(details, this);
}
diff --git a/src/analyzer/networkanalyzer.h b/src/analyzer/networkanalyzer.h
index d52978d1..9ff1bae6 100644
--- a/src/analyzer/networkanalyzer.h
+++ b/src/analyzer/networkanalyzer.h
@@ -59,11 +59,11 @@ public:
~NetworkAnalyzer();
private slots:
- void addRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply );
+ void addRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply);
void clear();
- void requestFinished( QObject *replyObject );
- void showItemDetails( QTreeWidgetItem *item );
+ void requestFinished(QObject *replyObject);
+ void showItemDetails(QTreeWidgetItem *item);
void copyURL();
void popupContextMenu(const QPoint &pos);