forked from osmocom/wireshark
Handle double-clicks in the tree.
svn path=/trunk/; revision=44592
This commit is contained in:
parent
7e924beee9
commit
44cb77d8de
|
@ -23,12 +23,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef FTYPES_H
|
#ifndef __FTYPES_H__
|
||||||
#define FTYPES_H
|
#define __FTYPES_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "../emem.h"
|
#include "../emem.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* field types */
|
/* field types */
|
||||||
enum ftenum {
|
enum ftenum {
|
||||||
FT_NONE, /* used for text labels with no value */
|
FT_NONE, /* used for text labels with no value */
|
||||||
|
@ -369,4 +373,8 @@ fvalue_length(fvalue_t *fv);
|
||||||
fvalue_t*
|
fvalue_t*
|
||||||
fvalue_slice(fvalue_t *fv, drange *dr);
|
fvalue_slice(fvalue_t *fv, drange *dr);
|
||||||
|
|
||||||
#endif /* ftypes.h */
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* __FTYPES_H__ */
|
||||||
|
|
|
@ -250,26 +250,28 @@ PacketList::PacketList(QWidget *parent) :
|
||||||
setUniformRowHeights(TRUE);
|
setUniformRowHeights(TRUE);
|
||||||
setAccessibleName("Packet list");
|
setAccessibleName("Packet list");
|
||||||
|
|
||||||
m_packet_list_model = new PacketListModel(this, &cfile);
|
packet_list_model_ = new PacketListModel(this, &cfile);
|
||||||
setModel(m_packet_list_model);
|
setModel(packet_list_model_);
|
||||||
|
|
||||||
g_assert(cur_packet_list == NULL);
|
g_assert(cur_packet_list == NULL);
|
||||||
cur_packet_list = this;
|
cur_packet_list = this;
|
||||||
|
|
||||||
m_protoTree = NULL;
|
proto_tree_ = NULL;
|
||||||
m_byteViewTab = NULL;
|
byte_view_tab_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::setProtoTree (ProtoTree *protoTree) {
|
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) {
|
void PacketList::setByteViewTab (ByteViewTab *byteViewTab) {
|
||||||
m_byteViewTab = byteViewTab;
|
byte_view_tab_ = byteViewTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketListModel *PacketList::packetListModel() const {
|
PacketListModel *PacketList::packetListModel() const {
|
||||||
return m_packet_list_model;
|
return packet_list_model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::showEvent (QShowEvent *event) {
|
void PacketList::showEvent (QShowEvent *event) {
|
||||||
|
@ -293,7 +295,7 @@ void PacketList::showEvent (QShowEvent *event) {
|
||||||
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) {
|
void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) {
|
||||||
QTreeView::selectionChanged(selected, deselected);
|
QTreeView::selectionChanged(selected, deselected);
|
||||||
|
|
||||||
if (m_protoTree) {
|
if (proto_tree_) {
|
||||||
int row = selected.first().top();
|
int row = selected.first().top();
|
||||||
cf_select_packet(&cfile, row);
|
cf_select_packet(&cfile, row);
|
||||||
|
|
||||||
|
@ -301,39 +303,39 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
|
||||||
return;
|
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;
|
GSList *src_le;
|
||||||
data_source *source;
|
data_source *source;
|
||||||
|
|
||||||
// Clear out existing tabs
|
// Clear out existing tabs
|
||||||
while (m_byteViewTab->currentWidget()) {
|
while (byte_view_tab_->currentWidget()) {
|
||||||
delete m_byteViewTab->currentWidget();
|
delete byte_view_tab_->currentWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (src_le = cfile.edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
|
for (src_le = cfile.edt->pi.data_src; src_le != NULL; src_le = src_le->next) {
|
||||||
source = (data_source *)src_le->data;
|
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 signals between the proto tree and byte views.
|
||||||
connect(m_protoTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
connect(proto_tree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
||||||
m_byteViewTab, SLOT(protoTreeItemChanged(QTreeWidgetItem*)));
|
byte_view_tab_, SLOT(protoTreeItemChanged(QTreeWidgetItem*)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::clear() {
|
void PacketList::clear() {
|
||||||
// packet_history_clear();
|
// packet_history_clear();
|
||||||
packetListModel()->clear();
|
packetListModel()->clear();
|
||||||
m_protoTree->clear();
|
proto_tree_->clear();
|
||||||
|
|
||||||
// Clear out existing tabs
|
// Clear out existing tabs
|
||||||
while (m_byteViewTab->currentWidget()) {
|
while (byte_view_tab_->currentWidget()) {
|
||||||
delete m_byteViewTab->currentWidget();
|
delete byte_view_tab_->currentWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /* XXX is this correct in all cases?
|
// /* XXX is this correct in all cases?
|
||||||
|
@ -396,3 +398,7 @@ void PacketList::goFirstPacket(void) {
|
||||||
void PacketList::goLastPacket(void) {
|
void PacketList::goLastPacket(void) {
|
||||||
setCurrentIndex(moveCursor(MoveEnd, Qt::NoModifier));
|
setCurrentIndex(moveCursor(MoveEnd, Qt::NoModifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PacketList::goToPacket(int packet) {
|
||||||
|
setCurrentIndex(packet_list_model_->index(packet, 0));
|
||||||
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ protected:
|
||||||
void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
|
void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PacketListModel *m_packet_list_model;
|
PacketListModel *packet_list_model_;
|
||||||
ProtoTree *m_protoTree;
|
ProtoTree *proto_tree_;
|
||||||
ByteViewTab *m_byteViewTab;
|
ByteViewTab *byte_view_tab_;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public slots:
|
||||||
void goPreviousPacket();
|
void goPreviousPacket();
|
||||||
void goFirstPacket();
|
void goFirstPacket();
|
||||||
void goLastPacket();
|
void goLastPacket();
|
||||||
|
void goToPacket(int packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACKET_LIST_H
|
#endif // PACKET_LIST_H
|
||||||
|
|
|
@ -26,11 +26,14 @@
|
||||||
#include "proto_tree.h"
|
#include "proto_tree.h"
|
||||||
#include "monospace_font.h"
|
#include "monospace_font.h"
|
||||||
|
|
||||||
|
#include <epan/ftypes/ftypes.h>
|
||||||
#include <epan/prefs.h>
|
#include <epan/prefs.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QTreeWidgetItemIterator>
|
#include <QTreeWidgetItemIterator>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */
|
QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */
|
||||||
QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */
|
QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */
|
||||||
|
@ -152,6 +155,8 @@ ProtoTree::ProtoTree(QWidget *parent) :
|
||||||
this, SLOT(updateSelectionStatus(QTreeWidgetItem*)));
|
this, SLOT(updateSelectionStatus(QTreeWidgetItem*)));
|
||||||
connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expand(QModelIndex)));
|
connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expand(QModelIndex)));
|
||||||
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapse(QModelIndex)));
|
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapse(QModelIndex)));
|
||||||
|
connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
|
||||||
|
this, SLOT(itemDoubleClick(QTreeWidgetItem*, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtoTree::clear() {
|
void ProtoTree::clear() {
|
||||||
|
@ -313,3 +318,25 @@ void ProtoTree::collapseAll()
|
||||||
}
|
}
|
||||||
QTreeWidget::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ private:
|
||||||
signals:
|
signals:
|
||||||
void protoItemSelected(QString &);
|
void protoItemSelected(QString &);
|
||||||
void protoItemSelected(bool);
|
void protoItemSelected(bool);
|
||||||
|
void goToFrame(int);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateSelectionStatus(QTreeWidgetItem*);
|
void updateSelectionStatus(QTreeWidgetItem*);
|
||||||
|
@ -53,6 +54,7 @@ public slots:
|
||||||
void expandSubtrees();
|
void expandSubtrees();
|
||||||
void expandAll();
|
void expandAll();
|
||||||
void collapseAll();
|
void collapseAll();
|
||||||
|
void itemDoubleClick(QTreeWidgetItem *item, int column);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROTO_TREE_H
|
#endif // PROTO_TREE_H
|
||||||
|
|
Loading…
Reference in New Issue