summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-08-19 20:47:11 +0000
committerGerald Combs <gerald@wireshark.org>2012-08-19 20:47:11 +0000
commit2b21eff0d9a8e0d10974ee2aed38944ed6adf6ac (patch)
tree4d0e97d25754c451526ed3f50e235d77e38107fc /ui/qt
parentc48bc11626d8ce80f862e158d51a560f8adb16f4 (diff)
downloadwireshark-2b21eff0d9a8e0d10974ee2aed38944ed6adf6ac.tar.gz
Add automatic tree expansion. Get rid of some unnecessary void * casts.
Fix a couple of compilation warnings. svn path=/trunk/; revision=44587
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/byte_view_tab.cpp6
-rw-r--r--ui/qt/byte_view_text.cpp4
-rw-r--r--ui/qt/main.cpp4
-rw-r--r--ui/qt/proto_tree.cpp84
-rw-r--r--ui/qt/proto_tree.h5
-rw-r--r--ui/qt/simple_dialog_qt.cpp4
6 files changed, 88 insertions, 19 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp
index ea21e08ec9..27732e9e12 100644
--- a/ui/qt/byte_view_tab.cpp
+++ b/ui/qt/byte_view_tab.cpp
@@ -61,8 +61,7 @@ void ByteViewTab::protoTreeItemChanged(QTreeWidgetItem *current) {
if (current) {
field_info *fi;
- QVariant v = current->data(0, Qt::UserRole);
- fi = (field_info *) v.value<void *>();
+ fi = current->data(0, Qt::UserRole).value<field_info *>();
// g_log(NULL, G_LOG_LEVEL_DEBUG, "fi selected %p", fi);
int i = 0;
@@ -75,8 +74,7 @@ void ByteViewTab::protoTreeItemChanged(QTreeWidgetItem *current) {
parent = parent->parent();
}
if (parent) {
- v = parent->data(0, Qt::UserRole);
- parent_fi = (field_info *) v.value<void *>();
+ parent_fi = parent->data(0, Qt::UserRole).value<field_info *>();
}
if (parent_fi && parent_fi->ds_tvb == fi->ds_tvb) {
byteViewText->highlight(parent_fi->start, parent_fi->length, true);
diff --git a/ui/qt/byte_view_text.cpp b/ui/qt/byte_view_text.cpp
index 5b27e90274..f0f6a4ccbb 100644
--- a/ui/qt/byte_view_text.cpp
+++ b/ui/qt/byte_view_text.cpp
@@ -621,10 +621,8 @@ void ByteViewText::mousePressEvent (QMouseEvent * event) {
if (fi && m_protoTree) {
// XXX - This should probably be a ProtoTree method.
QTreeWidgetItemIterator iter(m_protoTree);
- QVariant v;
while (*iter) {
- v = (*iter)->data(0, Qt::UserRole);
- if (fi == (field_info *) v.value<void *>()) {
+ if (fi == (*iter)->data(0, Qt::UserRole).value<field_info *>()) {
g_log(NULL, G_LOG_LEVEL_DEBUG, "found %p", fi);
m_protoTree->setCurrentItem((*iter));
}
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index a1b92b40b0..4eee037b47 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -132,9 +132,9 @@ int airpcap_dll_ret_val = -1;
GString *comp_info_str, *runtime_info_str;
-static gboolean have_capture_file = FALSE; /* XXX - is there an equivalent in cfile? */
+//static gboolean have_capture_file = FALSE; /* XXX - is there an equivalent in cfile? */
-static guint tap_update_timer_id;
+//static guint tap_update_timer_id;
#ifdef _WIN32
static gboolean has_console; /* TRUE if app has console */
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index 46617c602e..ec29e3c916 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -93,9 +93,12 @@ proto_tree_draw_node(proto_node *node, gpointer data)
}
if((fi->hfinfo->type == FT_FRAMENUM) ||
- (FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) {
+ (FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) {
+ QFont font = item->font(0);
+
item->setData(0, Qt::ForegroundRole, pal.link());
- // XXX - Draw an underline?
+ font.setUnderline(true);
+ item->setData(0, Qt::FontRole, font);
}
}
@@ -120,14 +123,19 @@ proto_tree_draw_node(proto_node *node, gpointer data)
item->setData(0, Qt::ForegroundRole, expert_color_foreground);
}
-// g_log(NULL, G_LOG_LEVEL_DEBUG, "new item %s", label_ptr);
item->setText(0, label_ptr);
- item->setData(0, Qt::UserRole, qVariantFromValue((void *) fi));
+ item->setData(0, Qt::UserRole, qVariantFromValue(fi));
if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) {
g_free(label_ptr);
}
+ if (tree_is_expanded[fi->tree_type]) {
+ item->setExpanded(true);
+ } else {
+ item->setExpanded(false);
+ }
+
if (!is_leaf) {
proto_tree_children_foreach(node, proto_tree_draw_node, item);
}
@@ -138,9 +146,12 @@ ProtoTree::ProtoTree(QWidget *parent) :
{
setAccessibleName(tr("Packet details"));
setFont(get_monospace_font());
+ setUniformRowHeights(true);
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
this, SLOT(updateSelectionStatus(QTreeWidgetItem*)));
+ connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expand(QModelIndex)));
+ connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapse(QModelIndex)));
}
void ProtoTree::clear() {
@@ -159,12 +170,10 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item) {
if (item) {
field_info *fi;
- QVariant v;
QString itemInfo;
int finfo_length;
- v = item->data(0, Qt::UserRole);
- fi = (field_info *) v.value<void *>();
+ fi = item->data(0, Qt::UserRole).value<field_info *>();
if (!fi || !fi->hfinfo) return;
if (fi->hfinfo->blurb != NULL && fi->hfinfo->blurb[0] != '\0') {
@@ -214,7 +223,49 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item) {
}
}
-#include <QDebug>
+void ProtoTree::expand(const QModelIndex & index) {
+ field_info *fi;
+
+ fi = index.data(Qt::UserRole).value<field_info *>();
+ g_assert(fi);
+
+ if(prefs.gui_auto_scroll_on_expand) {
+ ScrollHint scroll_hint = PositionAtTop;
+ if (prefs.gui_auto_scroll_percentage > 66) {
+ scroll_hint = PositionAtBottom;
+ } else if (prefs.gui_auto_scroll_percentage >= 33) {
+ scroll_hint = PositionAtCenter;
+ }
+ scrollTo(index, scroll_hint);
+ }
+
+ /*
+ * Nodes with "finfo->tree_type" of -1 have no ett_ value, and
+ * are thus presumably leaf nodes and cannot be expanded.
+ */
+ if (fi->tree_type != -1) {
+ g_assert(fi->tree_type >= 0 &&
+ fi->tree_type < num_tree_types);
+ tree_is_expanded[fi->tree_type] = TRUE;
+ }
+}
+
+void ProtoTree::collapse(const QModelIndex & index) {
+ field_info *fi;
+
+ fi = index.data(Qt::UserRole).value<field_info *>();
+ g_assert(fi);
+
+ /*
+ * Nodes with "finfo->tree_type" of -1 have no ett_ value, and
+ * are thus presumably leaf nodes and cannot be collapsed.
+ */
+ if (fi->tree_type != -1) {
+ g_assert(fi->tree_type >= 0 &&
+ fi->tree_type < num_tree_types);
+ tree_is_expanded[fi->tree_type] = FALSE;
+ }
+}
void ProtoTree::expandSubtrees()
{
@@ -245,3 +296,20 @@ void ProtoTree::expandSubtrees()
}
}
+void ProtoTree::expandAll()
+{
+ int i;
+ for(i=0; i < num_tree_types; i++) {
+ tree_is_expanded[i] = TRUE;
+ }
+ QTreeWidget::expandAll();
+}
+
+void ProtoTree::collapseAll()
+{
+ int i;
+ for(i=0; i < num_tree_types; i++) {
+ tree_is_expanded[i] = FALSE;
+ }
+ QTreeWidget::collapseAll();
+}
diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h
index a8a615e98b..8610095b8a 100644
--- a/ui/qt/proto_tree.h
+++ b/ui/qt/proto_tree.h
@@ -30,6 +30,7 @@
#include <QTreeWidget>
+Q_DECLARE_METATYPE(field_info *)
class ProtoTree : public QTreeWidget
{
@@ -47,7 +48,11 @@ signals:
public slots:
void updateSelectionStatus(QTreeWidgetItem*);
+ void expand(const QModelIndex & index);
+ void collapse(const QModelIndex & index);
void expandSubtrees();
+ void expandAll();
+ void collapseAll();
};
#endif // PROTO_TREE_H
diff --git a/ui/qt/simple_dialog_qt.cpp b/ui/qt/simple_dialog_qt.cpp
index 72fe218d63..6f9802eae7 100644
--- a/ui/qt/simple_dialog_qt.cpp
+++ b/ui/qt/simple_dialog_qt.cpp
@@ -111,12 +111,12 @@ simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...)
char *
simple_dialog_primary_start(void) {
- return "<span weight=\"bold\" size=\"larger\">";
+ return (char *) "";
}
char *
simple_dialog_primary_end(void) {
- return "</span>";
+ return (char *) "";
}
char *