forked from osmocom/wireshark
Qt: Fix overlay scrollbar indicator
The indicator for selected packets is not reflecting the relative size of that packet inside the map
This commit is contained in:
parent
f7e0c7028b
commit
33151dc928
|
@ -2059,7 +2059,7 @@ void PacketList::drawNearOverlay()
|
|||
}
|
||||
}
|
||||
|
||||
overlay_sb_->setNearOverlayImage(overlay, packet_list_model_->rowCount(), start, end, positions);
|
||||
overlay_sb_->setNearOverlayImage(overlay, packet_list_model_->rowCount(), start, end, positions, (o_height / o_rows));
|
||||
} else {
|
||||
QImage overlay;
|
||||
overlay_sb_->setNearOverlayImage(overlay);
|
||||
|
|
|
@ -99,7 +99,7 @@ int OverlayScrollBar::sliderPosition()
|
|||
return child_sb_.sliderPosition();
|
||||
}
|
||||
|
||||
void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int packet_count, int start_pos, int end_pos, QList<int> positions)
|
||||
void OverlayScrollBar::setNearOverlayImage(QImage& overlay_image, int packet_count, int start_pos, int end_pos, QList<int> positions, int rowHeight)
|
||||
{
|
||||
int old_width = packet_map_img_.width();
|
||||
packet_map_img_ = overlay_image;
|
||||
|
@ -107,6 +107,7 @@ void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int packet_cou
|
|||
start_pos_ = start_pos;
|
||||
end_pos_ = end_pos;
|
||||
positions_ = positions;
|
||||
row_height_ = rowHeight > devicePixelRatio() ? rowHeight : devicePixelRatio();
|
||||
|
||||
if (old_width != packet_map_img_.width()) {
|
||||
qreal dp_ratio = devicePixelRatio();
|
||||
|
@ -173,17 +174,12 @@ void OverlayScrollBar::paintEvent(QPaintEvent *event)
|
|||
{
|
||||
foreach (int selected_pos_, positions_)
|
||||
{
|
||||
if (selected_pos_ >= 0 && selected_pos_ < packet_map_img_.height()) {
|
||||
int pmiHeight = packet_map_img_.height();
|
||||
if (selected_pos_ >= 0 && selected_pos_ < pmiHeight) {
|
||||
pm_painter.save();
|
||||
int no_pos = near_dest.height() * selected_pos_ / packet_map_img_.height();
|
||||
int height = dp_ratio;
|
||||
if ((selected_pos_ + 1) < packet_map_img_.height())
|
||||
{
|
||||
int nx_pos = near_dest.height() * ( selected_pos_ + 1 ) / packet_map_img_.height();
|
||||
height = (nx_pos - no_pos + 1) > dp_ratio ? nx_pos - no_pos + 1 : dp_ratio;
|
||||
}
|
||||
int no_pos = near_dest.height() * selected_pos_ / pmiHeight;
|
||||
pm_painter.setBrush(palette().highlight().color());
|
||||
pm_painter.drawRect(0, no_pos, pm_size.width(), height);
|
||||
pm_painter.drawRect(0, no_pos, pm_size.width(), row_height_);
|
||||
pm_painter.restore();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,9 @@ public:
|
|||
* means no packet is selected.
|
||||
* @param positions The positions of the selected packets within the
|
||||
* image.
|
||||
* @param rowHeight The row height to be used for displaying the mark
|
||||
*/
|
||||
void setNearOverlayImage(QImage &overlay_image, int packet_count = -1, int start_pos = -1, int end_pos = -1, QList<int> positions = QList<int>());
|
||||
void setNearOverlayImage(QImage &overlay_image, int packet_count = -1, int start_pos = -1, int end_pos = -1, QList<int> positions = QList<int>(), int rowHeight = 1);
|
||||
|
||||
/** Set the "far" overlay image.
|
||||
* @param mp_image An image showing the position of marked, ignored,
|
||||
|
@ -72,7 +73,7 @@ private:
|
|||
int start_pos_;
|
||||
int end_pos_;
|
||||
QList<int> positions_;
|
||||
|
||||
int row_height_;
|
||||
};
|
||||
|
||||
#endif // __OVERLAY_SCROLL_BAR_H__
|
||||
|
|
Loading…
Reference in New Issue