diff options
-rw-r--r-- | src/analyzer/networkanalyzer.cpp | 30 | ||||
-rw-r--r-- | src/analyzer/networkanalyzer.h | 3 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/analyzer/networkanalyzer.cpp b/src/analyzer/networkanalyzer.cpp index c5b08835..8783745d 100644 --- a/src/analyzer/networkanalyzer.cpp +++ b/src/analyzer/networkanalyzer.cpp @@ -30,7 +30,10 @@ #include "networkanalyzer.moc" // KDE Includes +#include <KAction> #include <klocalizedstring.h> +#include <KMenu> +#include <KIcon> #include <KPassivePopup> // Qt Includes @@ -38,9 +41,9 @@ #include <QtGui/QVBoxLayout> #include <QtGui/QHeaderView> #include <QtGui/QLabel> - +#include <QApplication> #include <QSignalMapper> - +#include <QClipboard> NetworkAnalyzer::NetworkAnalyzer(QWidget *parent) : QWidget(parent) @@ -61,10 +64,11 @@ NetworkAnalyzer::NetworkAnalyzer(QWidget *parent) QVBoxLayout *lay = new QVBoxLayout(this); lay->addWidget( _requestList ); - - connect( _mapper, SIGNAL(mapped(QObject *)), this, SLOT(requestFinished(QObject *)) ); + _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))); } @@ -72,6 +76,24 @@ NetworkAnalyzer::~NetworkAnalyzer() { } +void NetworkAnalyzer::popupContextMenu(const QPoint& pos) +{ + 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())); + menu.addAction(copy); + menu.exec(mapToGlobal(pos)); + } +} + +void NetworkAnalyzer::copyURL() +{ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(_requestList->currentItem()->text(1)); +} void NetworkAnalyzer::addRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QNetworkReply *reply ) { diff --git a/src/analyzer/networkanalyzer.h b/src/analyzer/networkanalyzer.h index 9e38663f..d71931ff 100644 --- a/src/analyzer/networkanalyzer.h +++ b/src/analyzer/networkanalyzer.h @@ -42,6 +42,7 @@ #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkRequest> +#include <QPoint> // Forward Declarations class QTreeWidgetItem; @@ -63,6 +64,8 @@ private slots: void clear(); void requestFinished( QObject *replyObject ); void showItemDetails( QTreeWidgetItem *item ); + void copyURL(); + void popupContextMenu(const QPoint &pos); private: QMap<QNetworkReply *, QNetworkRequest> _requestMap; |