diff options
author | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2012-08-19 23:52:08 +0000 |
---|---|---|
committer | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2012-08-19 23:52:08 +0000 |
commit | 2c2056f5b2e2917a3c9382b98dd87bab2bf8dc79 (patch) | |
tree | 3732b218623d68f334273388a6d43c0bd6056619 | |
parent | e6244006476cbafa987ce88b0b61b698ce9e8351 (diff) |
Handle double-clicks in the tree.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@44592 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | epan/ftypes/ftypes.h | 14 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 44 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 8 | ||||
-rw-r--r-- | ui/qt/proto_tree.cpp | 27 | ||||
-rw-r--r-- | ui/qt/proto_tree.h | 2 |
5 files changed, 69 insertions, 26 deletions
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index 2b883908bb..e8ddc59740 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -23,12 +23,16 @@ */ -#ifndef FTYPES_H -#define FTYPES_H +#ifndef __FTYPES_H__ +#define __FTYPES_H__ #include <glib.h> #include "../emem.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + /* field types */ enum ftenum { FT_NONE, /* used for text labels with no value */ @@ -369,4 +373,8 @@ fvalue_length(fvalue_t *fv); fvalue_t* fvalue_slice(fvalue_t *fv, drange *dr); -#endif /* ftypes.h */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __FTYPES_H__ */ diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index bef96f054e..68b74f118b 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -250,26 +250,28 @@ PacketList::PacketList(QWidget *parent) : setUniformRowHeights(TRUE); setAccessibleName("Packet list"); - m_packet_list_model = new PacketListModel(this, &cfile); - setModel(m_packet_list_model); + packet_list_model_ = new PacketListModel(this, &cfile); + setModel(packet_list_model_); g_assert(cur_packet_list == NULL); cur_packet_list = this; - m_protoTree = NULL; - m_byteViewTab = NULL; + proto_tree_ = NULL; + byte_view_tab_ = NULL; } void PacketList::setProtoTree (ProtoTree *protoTree) { - m_protoTree = protoTree; + proto_tree_ = protoTree; + + connect(proto_tree_, SIGNAL(goToFrame(int)), this, SLOT(goToPacket(int))); } void PacketList::setByteViewTab (ByteViewTab *byteViewTab) { - m_byteViewTab = byteViewTab; + byte_view_tab_ = byteViewTab; } PacketListModel *PacketList::packetListModel() const { - return m_packet_list_model; + return packet_list_model_; } void PacketList::showEvent (QShowEvent *event) { @@ -293,7 +295,7 @@ void PacketList::showEvent (QShowEvent *event) { void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) { QTreeView::selectionChanged(selected, deselected); - if (m_protoTree) { + if (proto_tree_) { int row = selected.first().top(); cf_select_packet(&cfile, row); @@ -301,39 +303,39 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS return; } - m_protoTree->fillProtocolTree(cfile.edt->tree); + proto_tree_->fillProtocolTree(cfile.edt->tree); } - if (m_byteViewTab && cfile.edt) { + if (byte_view_tab_ && cfile.edt) { GSList *src_le; data_source *source; // Clear out existing tabs - while (m_byteViewTab->currentWidget()) { - delete m_byteViewTab->currentWidget(); + while (byte_view_tab_->currentWidget()) { + delete byte_view_tab_->currentWidget(); } for (src_le = cfile.edt->pi.data_src; src_le != NULL; src_le = src_le->next) { source = (data_source *)src_le->data; - m_byteViewTab->addTab(get_data_source_name(source), source->tvb, cfile.edt->tree, m_protoTree, cfile.current_frame->flags.encoding); + byte_view_tab_->addTab(get_data_source_name(source), source->tvb, cfile.edt->tree, proto_tree_, cfile.current_frame->flags.encoding); } } - if (m_protoTree && m_byteViewTab) { + if (proto_tree_ && byte_view_tab_) { // Connect signals between the proto tree and byte views. - connect(m_protoTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - m_byteViewTab, SLOT(protoTreeItemChanged(QTreeWidgetItem*))); + connect(proto_tree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), + byte_view_tab_, SLOT(protoTreeItemChanged(QTreeWidgetItem*))); } } void PacketList::clear() { // packet_history_clear(); packetListModel()->clear(); - m_protoTree->clear(); + proto_tree_->clear(); // Clear out existing tabs - while (m_byteViewTab->currentWidget()) { - delete m_byteViewTab->currentWidget(); + while (byte_view_tab_->currentWidget()) { + delete byte_view_tab_->currentWidget(); } // /* XXX is this correct in all cases? @@ -396,3 +398,7 @@ void PacketList::goFirstPacket(void) { void PacketList::goLastPacket(void) { setCurrentIndex(moveCursor(MoveEnd, Qt::NoModifier)); } + +void PacketList::goToPacket(int packet) { + setCurrentIndex(packet_list_model_->index(packet, 0)); +} diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index bde7934289..25b79ece64 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -48,9 +48,9 @@ protected: void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected); private: - PacketListModel *m_packet_list_model; - ProtoTree *m_protoTree; - ByteViewTab *m_byteViewTab; + PacketListModel *packet_list_model_; + ProtoTree *proto_tree_; + ByteViewTab *byte_view_tab_; signals: @@ -59,7 +59,7 @@ public slots: void goPreviousPacket(); void goFirstPacket(); void goLastPacket(); - + void goToPacket(int packet); }; #endif // PACKET_LIST_H diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index ec29e3c916..1c490a3b47 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -26,11 +26,14 @@ #include "proto_tree.h" #include "monospace_font.h" +#include <epan/ftypes/ftypes.h> #include <epan/prefs.h> #include <QApplication> #include <QHeaderView> #include <QTreeWidgetItemIterator> +#include <QDesktopServices> +#include <QUrl> QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */ QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */ @@ -152,6 +155,8 @@ ProtoTree::ProtoTree(QWidget *parent) : this, SLOT(updateSelectionStatus(QTreeWidgetItem*))); connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expand(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapse(QModelIndex))); + connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), + this, SLOT(itemDoubleClick(QTreeWidgetItem*, int))); } void ProtoTree::clear() { @@ -313,3 +318,25 @@ void ProtoTree::collapseAll() } QTreeWidget::collapseAll(); } + +void ProtoTree::itemDoubleClick(QTreeWidgetItem *item, int column) { + Q_UNUSED(column); + + gchar *url; + field_info *fi; + + fi = item->data(0, Qt::UserRole).value<field_info *>(); + + if(fi->hfinfo->type == FT_FRAMENUM) { + emit goToFrame(fi->value.value.uinteger - 1); + } + + if(FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type)) { + url = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, NULL); + if(url){ +// browser_open_url(url); + QDesktopServices::openUrl(QUrl(url)); + g_free(url); + } + } +} diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h index 8610095b8a..574e519614 100644 --- a/ui/qt/proto_tree.h +++ b/ui/qt/proto_tree.h @@ -45,6 +45,7 @@ private: signals: void protoItemSelected(QString &); void protoItemSelected(bool); + void goToFrame(int); public slots: void updateSelectionStatus(QTreeWidgetItem*); @@ -53,6 +54,7 @@ public slots: void expandSubtrees(); void expandAll(); void collapseAll(); + void itemDoubleClick(QTreeWidgetItem *item, int column); }; #endif // PROTO_TREE_H |