aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2016-06-27 20:13:35 -0700
committerGerald Combs <gerald@wireshark.org>2016-06-28 19:12:32 +0000
commit422c0f45d497872a963363132ec92d400a79538f (patch)
tree99230c42be815d7c8da213616caa8937b1778638 /ui
parent000ac66fce801e4f28e322893ae9280115906330 (diff)
Qt: Make the packet map work with Qt 5.7.
It's not safe to assume that the overlay scroll bar range is equal(ish) to the number of packets. Adjust our arithmetic accordingly. Change-Id: Ic8cc8a746bdd2bdc6771794303e95a810bc3d1d2 Reviewed-on: https://code.wireshark.org/review/16186 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/overlay_scroll_bar.cpp14
-rw-r--r--ui/qt/overlay_scroll_bar.h3
-rw-r--r--ui/qt/packet_list.cpp2
3 files changed, 12 insertions, 7 deletions
diff --git a/ui/qt/overlay_scroll_bar.cpp b/ui/qt/overlay_scroll_bar.cpp
index 65fe66d784..3b27e04224 100644
--- a/ui/qt/overlay_scroll_bar.cpp
+++ b/ui/qt/overlay_scroll_bar.cpp
@@ -76,6 +76,7 @@ OverlayScrollBar::OverlayScrollBar(Qt::Orientation orientation, QWidget *parent)
packet_map_img_(QImage()),
packet_map_width_(0),
marked_packet_width_(0),
+ packet_count_(-1),
start_pos_(-1),
end_pos_(-1),
selected_pos_(-1)
@@ -99,10 +100,11 @@ QSize OverlayScrollBar::sizeHint() const
QScrollBar::sizeHint().height());
}
-void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int start_pos, int end_pos, int selected_pos)
+void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int packet_count, int start_pos, int end_pos, int selected_pos)
{
int old_width = packet_map_img_.width();
packet_map_img_ = overlay_image;
+ packet_count_ = packet_count;
start_pos_ = start_pos;
end_pos_ = end_pos;
selected_pos_ = selected_pos;
@@ -242,11 +244,13 @@ void OverlayScrollBar::mouseReleaseEvent(QMouseEvent *event)
{
QRect pm_r(0, 0, packet_map_width_, height());
- if (pm_r.contains(event->pos())) {
- qreal map_ratio = qreal(end_pos_ - start_pos_) / geometry().height();
+ if (pm_r.contains(event->pos()) && geometry().height() > 0 && packet_count_ > 0 && pageStep() > 0) {
+ double map_ratio = double(end_pos_ - start_pos_) / geometry().height();
+ int clicked_packet = (event->pos().y() * map_ratio) + start_pos_;
+ double packet_to_sb_value = double(maximum() - minimum()) / packet_count_;
+ int top_pad = pageStep() / 4; // Land near, but not at, the top.
- // Try to put the clicked packet near but not at the top.
- setValue((event->pos().y() * map_ratio) + start_pos_ - (pageStep() / 4));
+ setValue((clicked_packet * packet_to_sb_value) + top_pad);
}
}
diff --git a/ui/qt/overlay_scroll_bar.h b/ui/qt/overlay_scroll_bar.h
index 1b4de73bd9..c6d2909f32 100644
--- a/ui/qt/overlay_scroll_bar.h
+++ b/ui/qt/overlay_scroll_bar.h
@@ -44,7 +44,7 @@ public:
* @param selected_pos The position of the selected packet within the
* image. -1 means no packet is selected.
*/
- void setNearOverlayImage(QImage &overlay_image, int start_pos = -1, int end_pos = -1, int selected_pos = -1);
+ void setNearOverlayImage(QImage &overlay_image, int packet_count = -1, int start_pos = -1, int end_pos = -1, int selected_pos = -1);
/** Set the "far" overlay image.
* @param mp_image An image showing the position of marked, ignored,
@@ -77,6 +77,7 @@ private:
QImage marked_packet_img_;
int packet_map_width_;
int marked_packet_width_;
+ int packet_count_;
int start_pos_;
int end_pos_;
int selected_pos_;
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 14b799cc11..5266af072c 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -1565,7 +1565,7 @@ void PacketList::drawNearOverlay()
}
}
- overlay_sb_->setNearOverlayImage(overlay, start, end, selected_pos);
+ overlay_sb_->setNearOverlayImage(overlay, packet_list_model_->rowCount(), start, end, selected_pos);
} else {
QImage overlay;
overlay_sb_->setNearOverlayImage(overlay);