aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/utils/field_information.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-12-07 08:15:30 -0800
committerAnders Broman <a.broman58@gmail.com>2017-12-15 20:58:14 +0000
commitbdb6baa7405d259fa2cd2f6f7d2fb21e13315885 (patch)
tree5c70190af46fef3fadb8a876e7b3e7f66dfe77b6 /ui/qt/utils/field_information.cpp
parent0909580a7e98c134785a96829b58076534b477b6 (diff)
Qt: Switch ProtoTree to a treeview+model.
Add a ProtoTreeModel and use it in ProtoTree. This should make the UI more responsive when we have lots of items in the tree. Change-Id: Id26e6bcff84663867a8da17fd9ae86ff639b633f Reviewed-on: https://code.wireshark.org/review/24774 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/utils/field_information.cpp')
-rw-r--r--ui/qt/utils/field_information.cpp69
1 files changed, 63 insertions, 6 deletions
diff --git a/ui/qt/utils/field_information.cpp b/ui/qt/utils/field_information.cpp
index aac03277c5..9b4213412a 100644
--- a/ui/qt/utils/field_information.cpp
+++ b/ui/qt/utils/field_information.cpp
@@ -11,23 +11,33 @@
#include <ui/qt/utils/field_information.h>
-FieldInformation::FieldInformation(field_info * fi, QObject * parent)
+FieldInformation::FieldInformation(field_info *fi, QObject * parent)
:QObject(parent)
{
fi_ = fi;
parent_fi_ = 0;
}
+FieldInformation::FieldInformation(proto_node *node, QObject * parent)
+:QObject(parent)
+{
+ fi_ = NULL;
+ if (node) {
+ fi_ = node->finfo;
+ }
+ parent_fi_ = NULL;
+}
+
bool FieldInformation::isValid()
{
bool ret = false;
- if ( fi_ )
+ if ( fi_ && fi_->hfinfo )
{
if (fi_->hfinfo->blurb != 0 && fi_->hfinfo->blurb[0] != '\0') {
ret = true;
} else {
- ret = ((QString().fromUtf8(fi_->hfinfo->name)).length() > 0 );
+ ret = QString((fi_->hfinfo->name)).length() > 0;
}
}
@@ -39,6 +49,15 @@ void FieldInformation::setParentField(field_info * par_fi)
parent_fi_ = par_fi;
}
+int FieldInformation::treeType()
+{
+ if (fi_) {
+ Q_ASSERT(fi_->tree_type >= 0 && fi_->tree_type < num_tree_types);
+ return fi_->tree_type;
+ }
+ return -1;
+}
+
field_info * FieldInformation::fieldInfo() const
{
return fi_;
@@ -52,9 +71,12 @@ FieldInformation::HeaderInfo FieldInformation::headerInfo() const
if ( fi_ && fi_->hfinfo )
{
header.isValid = true;
- header.name = QString().fromUtf8(fi_->hfinfo->name);
- header.description = QString().fromUtf8(fi_->hfinfo->blurb);
- header.abbreviation = QString().fromUtf8(fi_->hfinfo->abbrev);
+ header.name = fi_->hfinfo->name;
+ header.description = fi_->hfinfo->blurb;
+ header.abbreviation = fi_->hfinfo->abbrev;
+ header.type = fi_->hfinfo->type;
+ header.parent = fi_->hfinfo->parent;
+ header.id = fi_->hfinfo->id;
}
return header;
@@ -73,6 +95,41 @@ bool FieldInformation::tvbContains(FieldInformation *child)
return false;
}
+unsigned FieldInformation::flag(unsigned mask)
+{
+ if (fi_) {
+ return FI_GET_FLAG(fi_, mask);
+ }
+ return 0;
+}
+
+const QString FieldInformation::moduleName()
+{
+ QString module_name;
+ if (isValid()) {
+ if (headerInfo().parent == -1) {
+ module_name = fi_->hfinfo->abbrev;
+ } else {
+ module_name = proto_registrar_get_abbrev(headerInfo().parent);
+ }
+ }
+ return module_name;
+}
+
+QString FieldInformation::url()
+{
+ QString url;
+ if (flag(FI_URL) && headerInfo().isValid && IS_FT_STRING(fi_->hfinfo->type)) {
+ gchar *url_str;
+ url_str = fvalue_to_string_repr(NULL, &fi_->value, FTREPR_DISPLAY, fi_->hfinfo->display);
+ if (url_str) {
+ url = url_str;
+ }
+ wmem_free(NULL, url_str);
+ }
+ return url;
+}
+
FieldInformation::Position FieldInformation::position() const
{
Position pos = {-1, -1};