Qt: Re-highlight packet bytes when re-selecting packet tree item

Emit the fieldSelected signal when the currently selected dissection
tree item is clicked. This causes the corresponding bytes in the
packet bytes tab to be re-selected.

Change-Id: I9168163f6734ef05ed3196c291a813125d8e86c6
Reviewed-on: https://code.wireshark.org/review/36303
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Rasmus Jonsson 2020-03-05 22:56:57 +01:00 committed by Roland Knall
parent 76c8c3ef0e
commit d8ac2a046b
2 changed files with 13 additions and 0 deletions

View File

@ -84,6 +84,8 @@ ProtoTree::ProtoTree(QWidget *parent, epan_dissect_t *edt_fixed) :
connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(syncExpanded(QModelIndex)));
connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(syncCollapsed(QModelIndex)));
connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(itemClicked(QModelIndex)));
connect(this, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(itemDoubleClicked(QModelIndex)));
@ -584,6 +586,16 @@ void ProtoTree::collapseAll()
updateContentWidth();
}
void ProtoTree::itemClicked(const QModelIndex &index) {
if (index == selectionModel()->selectedIndexes().first()) {
FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(index).protoNode());
if (finfo.isValid()) {
emit fieldSelected(&finfo);
}
}
}
void ProtoTree::itemDoubleClicked(const QModelIndex &index) {
FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(index).protoNode());
if (!finfo.isValid()) return;

View File

@ -91,6 +91,7 @@ public slots:
void collapseSubtrees();
void expandAll();
void collapseAll();
void itemClicked(const QModelIndex & index);
void itemDoubleClicked(const QModelIndex & index);
void selectedFieldChanged(FieldInformation *);
void selectedFrameChanged(QList<int>);