aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/proto_tree.cpp
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2017-10-30 13:58:28 +0100
committerRoland Knall <rknall@gmail.com>2017-11-08 20:20:31 +0000
commit8a6ea0e454dddcc1d9c14ad1e02a43a53a4ef667 (patch)
tree1afd59377e5e62f8f0b057cfb406f077823872e4 /ui/qt/proto_tree.cpp
parent87431fef2836c8d77ea694844cd5dff0e8b801f8 (diff)
Qt: Further cleanup ByteView
This further separates ByteView and the rest of the system. Using FieldInformation and DataPrinter, this is the final cleanup of the ByteViewTab Change-Id: If41521167527cf5664c2564cdd0d45fea0f3f612 Reviewed-on: https://code.wireshark.org/review/22783 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'ui/qt/proto_tree.cpp')
-rw-r--r--ui/qt/proto_tree.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index 5afe0e33d3..06938e3e0a 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -317,6 +317,7 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event)
conv_menu_.addAction(action);
}
+ FieldInformation * finfo = 0;
field_info *fi = NULL;
const char *module_name = NULL;
if (selectedItems().count() > 0) {
@@ -328,17 +329,19 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event)
module_name = proto_registrar_get_abbrev(fi->hfinfo->parent);
}
}
+ finfo = new FieldInformation(fi, this);
}
proto_prefs_menu_.setModule(module_name);
foreach (QAction *action, copy_actions_) {
- action->setData(VariantPointer<field_info>::asQVariant(fi));
+ action->setProperty("idataprintable_",
+ VariantPointer<IDataPrintable>::asQVariant((IDataPrintable *)finfo));
}
decode_as_->setData(qVariantFromValue(true));
// Set menu sensitivity and action data.
- emit protoItemSelected(fi);
+ emit fieldSelected(finfo);
ctx_menu_.exec(event->globalPos());
decode_as_->setData(QVariant());
}
@@ -429,29 +432,21 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item)
fi = VariantPointer<field_info>::asPtr(item->data(0, Qt::UserRole));
if (!fi || !fi->hfinfo) return;
- if (fi->hfinfo->blurb != NULL && fi->hfinfo->blurb[0] != '\0') {
- item_info.append(QString().fromUtf8(fi->hfinfo->blurb));
- } else {
- item_info.append(QString().fromUtf8(fi->hfinfo->name));
- }
-
- if (!item_info.isEmpty()) {
- int finfo_length;
- item_info.append(" (" + QString().fromUtf8(fi->hfinfo->abbrev) + ")");
+ FieldInformation * finfo = new FieldInformation(fi, this);
- finfo_length = fi->length + fi->appendix_length;
- if (finfo_length == 1) {
- item_info.append(tr(", 1 byte"));
- } else if (finfo_length > 1) {
- item_info.append(QString(tr(", %1 bytes")).arg(finfo_length));
- }
+ // Find and highlight the protocol bytes
+ QTreeWidgetItem * parent = item->parent();
+ while (parent && parent->parent()) {
+ parent = parent->parent();
+ }
+ if (parent) {
+ finfo->setParentField(VariantPointer<field_info>::asPtr(parent->data(0, Qt::UserRole)));
+ }
+ if ( finfo->isValid() )
+ {
saveSelectedField(item);
-
- emit protoItemSelected("");
- emit protoItemSelected(NULL);
- emit protoItemSelected(item_info);
- emit protoItemSelected(fi);
+ emit fieldSelected(finfo);
} // else the GTK+ version pushes an empty string as described below.
/*
* Don't show anything if the field name is zero-length;
@@ -473,8 +468,7 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item)
*/
} else {
- emit protoItemSelected("");
- emit protoItemSelected(NULL);
+ emit fieldSelected(NULL);
}
}
@@ -598,16 +592,21 @@ void ProtoTree::itemDoubleClick(QTreeWidgetItem *item, int) {
}
}
-void ProtoTree::selectField(field_info *fi)
+void ProtoTree::selectedFieldChanged(FieldInformation * finfo)
{
- QTreeWidgetItemIterator iter(this);
- while (*iter) {
- if (fi == VariantPointer<field_info>::asPtr((*iter)->data(0, Qt::UserRole))) {
- setCurrentItem(*iter);
- scrollToItem(*iter);
- break;
+ if ( finfo )
+ {
+ field_info * fi = finfo->fieldInfo();
+
+ QTreeWidgetItemIterator iter(this);
+ while (*iter) {
+ if (fi == VariantPointer<field_info>::asPtr((*iter)->data(0, Qt::UserRole))) {
+ setCurrentItem(*iter);
+ scrollToItem(*iter);
+ break;
+ }
+ ++iter;
}
- ++iter;
}
}