forked from osmocom/wireshark
Qt: Proto tree fixes
Make sure ProtoTree::toString stops at the right place. Don't emit fieldSelected when we're processing a context menu event. It doesn't appear to be needed and it triggers unwanted automatic scrolling when prefs.gui_auto_scroll_on_expand is enabled. Change-Id: I351a6974d07aea6fdd3eb0b5c1975a1b8d8eb7da Reviewed-on: https://code.wireshark.org/review/25396 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>
This commit is contained in:
parent
73f5afb75f
commit
145e3a5dc3
|
@ -183,8 +183,6 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
|
||||||
decode_as_->setData(QVariant::fromValue(true));
|
decode_as_->setData(QVariant::fromValue(true));
|
||||||
|
|
||||||
// Set menu sensitivity and action data.
|
|
||||||
emit fieldSelected(&finfo);
|
|
||||||
ctx_menu_.exec(event->globalPos());
|
ctx_menu_.exec(event->globalPos());
|
||||||
decode_as_->setData(QVariant());
|
decode_as_->setData(QVariant());
|
||||||
}
|
}
|
||||||
|
@ -499,9 +497,10 @@ void ProtoTree::restoreSelectedField()
|
||||||
autoScrollTo(cur_index);
|
autoScrollTo(cur_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ProtoTree::toString(const QModelIndex &index) const
|
const QString ProtoTree::toString(const QModelIndex &start_idx) const
|
||||||
{
|
{
|
||||||
QModelIndex cur_idx = index.isValid() ? index : proto_tree_model_->index(0, 0);
|
QModelIndex cur_idx = start_idx.isValid() ? start_idx : proto_tree_model_->index(0, 0);
|
||||||
|
QModelIndex stop_idx = proto_tree_model_->index(cur_idx.row() + 1, 0, cur_idx.parent());
|
||||||
QString tree_string;
|
QString tree_string;
|
||||||
int indent_level = 0;
|
int indent_level = 0;
|
||||||
|
|
||||||
|
@ -524,7 +523,7 @@ const QString ProtoTree::toString(const QModelIndex &index) const
|
||||||
// Next parent
|
// Next parent
|
||||||
cur_idx = proto_tree_model_->index(cur_idx.parent().row() + 1, 0, cur_idx.parent().parent());
|
cur_idx = proto_tree_model_->index(cur_idx.parent().row() + 1, 0, cur_idx.parent().parent());
|
||||||
indent_level--;
|
indent_level--;
|
||||||
} while (cur_idx.isValid() && cur_idx != index && indent_level >= 0);
|
} while (cur_idx.isValid() && cur_idx.internalPointer() != stop_idx.internalPointer() && indent_level >= 0);
|
||||||
|
|
||||||
return tree_string;
|
return tree_string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
void closeContextMenu();
|
void closeContextMenu();
|
||||||
void restoreSelectedField();
|
void restoreSelectedField();
|
||||||
const QString toString(const QModelIndex &index = QModelIndex()) const;
|
const QString toString(const QModelIndex &start_idx = QModelIndex()) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
Loading…
Reference in New Issue