summaryrefslogtreecommitdiffstats
path: root/ui/qt/packet_diagram.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/packet_diagram.cpp')
-rw-r--r--ui/qt/packet_diagram.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/ui/qt/packet_diagram.cpp b/ui/qt/packet_diagram.cpp
index a5bbc106..4d83deb2 100644
--- a/ui/qt/packet_diagram.cpp
+++ b/ui/qt/packet_diagram.cpp
@@ -322,19 +322,11 @@ private:
QFontMetrics fm = QFontMetrics(layout_->regularFont());
painter->setFont(layout_->regularFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int label_w = fm.horizontalAdvance(label);
-#else
- int label_w = fm.width(label);
-#endif
if (label_w > label_rect.width()) {
painter->setFont(layout_->smallFont());
fm = QFontMetrics(layout_->smallFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
label_w = fm.horizontalAdvance(label);
-#else
- label_w = fm.width(label);
-#endif
if (label_w > label_rect.width()) {
// XXX Use parent+ItemClipsChildrenToShape or setScale instead?
label = fm.elidedText(label, Qt::ElideRight, label_rect.width());
@@ -379,6 +371,8 @@ void PacketDiagram::setRootNode(proto_node *root_node)
// useful in our case because it gives us a cheap way to retain our
// scroll position between packets.
scene()->clear();
+ viewport()->update();
+
selected_field_ = nullptr;
y_pos_ = 0;
@@ -399,7 +393,7 @@ void PacketDiagram::setRootNode(proto_node *root_node)
kids.next();
// Exclude all ("Frame") and nothing
- if (tl_node->finfo->start == 0 && tl_node->finfo->length == (int) tvb_captured_length(cap_file_->edt->tvb)) {
+ if (tl_node == root_node->first_child) {
continue;
}
if (tl_node->finfo->length < 1) {
@@ -475,6 +469,9 @@ void PacketDiagram::contextMenuEvent(QContextMenuEvent *event)
action->setChecked(layout_->showFields());
connect(action, &QAction::toggled, this, &PacketDiagram::showFieldsToggled);
+ action = ctx_menu->addAction(tr("Refresh"));
+ connect(action, &QAction::triggered, this, &PacketDiagram::resetScene);
+
ctx_menu->addSeparator();
action = ctx_menu->addAction(tr("Save Diagram As…"));
@@ -564,11 +561,7 @@ void PacketDiagram::addDiagram(proto_node *tl_node)
qreal y_bottom = y_pos_ + bit_width;
QGraphicsItem *tl_item = scene()->addLine(x, y_bottom, x + diag_w, y_bottom);
QFontMetrics sfm = QFontMetrics(layout_->smallFont());
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int space_w = sfm.horizontalAdvance(' ');
-#else
- int space_w = sfm.width(' ');
-#endif
#ifdef Q_OS_WIN
// t_item->boundingRect() has a pixel of space on the left on my (gcc)
// Windows VM.