forked from osmocom/wireshark
Show the current selection in the overlay scrollbar.
Change-Id: Ie92b7ae170938eac71ede751d9067e1d47293092 Reviewed-on: https://code.wireshark.org/review/9750 Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
093aef0e28
commit
1514fe06cd
|
@ -32,7 +32,8 @@
|
|||
OverlayScrollBar::OverlayScrollBar(Qt::Orientation orientation, QWidget *parent) :
|
||||
QScrollBar(orientation, parent = 0),
|
||||
near_overlay_(QImage()),
|
||||
far_overlay_(QImage())
|
||||
far_overlay_(QImage()),
|
||||
selected_pos_(-1)
|
||||
{}
|
||||
|
||||
QSize OverlayScrollBar::sizeHint() const
|
||||
|
@ -40,9 +41,10 @@ QSize OverlayScrollBar::sizeHint() const
|
|||
return QSize(QScrollBar::sizeHint().width() + (far_overlay_.width() * 2), QScrollBar::sizeHint().height());
|
||||
}
|
||||
|
||||
void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image)
|
||||
void OverlayScrollBar::setNearOverlayImage(QImage &overlay_image, int selected_pos)
|
||||
{
|
||||
near_overlay_ = overlay_image;
|
||||
selected_pos_ = selected_pos;
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -89,6 +91,17 @@ void OverlayScrollBar::paintEvent(QPaintEvent *event)
|
|||
far_dest.moveLeft(gr_size.width() - fo_width);
|
||||
go_painter.drawImage(far_dest, far_overlay_.mirrored(true, false));
|
||||
}
|
||||
|
||||
// Selected packet indicator
|
||||
if (selected_pos_ >= 0 && selected_pos_ < near_overlay_.height()) {
|
||||
int no_pos = near_dest.height() * selected_pos_ / near_overlay_.height();
|
||||
go_painter.save();
|
||||
go_painter.setBrush(palette().highlight().color());
|
||||
go_painter.drawRect(0, no_pos, near_dest.width(), devicePixelRatio());
|
||||
go_painter.restore();
|
||||
}
|
||||
|
||||
// Outline
|
||||
QRect near_outline(near_dest);
|
||||
near_outline.adjust(0, 0, -1, -1);
|
||||
go_painter.save();
|
||||
|
@ -98,21 +111,6 @@ void OverlayScrollBar::paintEvent(QPaintEvent *event)
|
|||
go_painter.drawRect(near_outline);
|
||||
go_painter.restore();
|
||||
|
||||
#if 0
|
||||
// Fade in from the left and right.
|
||||
go_painter.save();
|
||||
go_painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
QLinearGradient fade(0, 0, groove_overlay.width(), 0);
|
||||
fade.setColorAt(0, Qt::transparent);
|
||||
fade.setColorAt(0.2, Qt::white);
|
||||
fade.setColorAt(0.8, Qt::white);
|
||||
fade.setColorAt(1, Qt::transparent);
|
||||
|
||||
go_painter.setBrush(fade);
|
||||
go_painter.drawRect(groove_overlay.rect());
|
||||
go_painter.restore();
|
||||
#endif
|
||||
|
||||
// Punch a hole for the slider.
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt);
|
||||
|
|
|
@ -33,8 +33,18 @@ public:
|
|||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
// Images are assumed to be 1 pixel wide and grooveRect.height() high.
|
||||
void setNearOverlayImage(QImage &overlay_image);
|
||||
/** Set the "near" overlay image.
|
||||
* @param overlay_image An image containing a 1:1 mapping of nearby
|
||||
* packet colors to raster lines.
|
||||
* @param selected_pos The position of the selected packet within the
|
||||
* image. -1 means no packet is selected.
|
||||
*/
|
||||
void setNearOverlayImage(QImage &overlay_image, int selected_pos = -1);
|
||||
|
||||
/** Set the "far" overlay image.
|
||||
* @param overlay_image An image showing the position of marked, ignored,
|
||||
* and reference time packets over the entire packet list.
|
||||
*/
|
||||
void setFarOverlayImage(QImage &overlay_image);
|
||||
QRect grooveRect();
|
||||
|
||||
|
@ -44,6 +54,7 @@ protected:
|
|||
private:
|
||||
QImage near_overlay_;
|
||||
QImage far_overlay_;
|
||||
int selected_pos_;
|
||||
};
|
||||
|
||||
#endif // __OVERLAY_SCROLL_BAR_H__
|
||||
|
|
|
@ -1312,6 +1312,7 @@ void PacketList::drawNearOverlay()
|
|||
#endif
|
||||
int o_height = overlay_sb_->height() * dp_ratio * height_multiplier_;
|
||||
int o_rows = qMin(packet_list_model_->rowCount(), o_height);
|
||||
int selected_pos = -1;
|
||||
|
||||
if (recent.packet_list_colorize && o_rows > 0) {
|
||||
QImage overlay(1, o_height, QImage::Format_ARGB32_Premultiplied);
|
||||
|
@ -1363,7 +1364,18 @@ void PacketList::drawNearOverlay()
|
|||
cur_line = next_line;
|
||||
}
|
||||
|
||||
overlay_sb_->setNearOverlayImage(overlay);
|
||||
if (selectionModel()->hasSelection()) {
|
||||
int sel_row = selectionModel()->currentIndex().row();
|
||||
if (sel_row < start) {
|
||||
selected_pos = 0;
|
||||
} else if (sel_row >= end) {
|
||||
selected_pos = overlay.height() - 1;
|
||||
} else {
|
||||
selected_pos = sel_row * overlay.height() / packet_list_model_->rowCount();
|
||||
}
|
||||
}
|
||||
|
||||
overlay_sb_->setNearOverlayImage(overlay, selected_pos);
|
||||
} else {
|
||||
QImage overlay;
|
||||
overlay_sb_->setNearOverlayImage(overlay);
|
||||
|
|
Loading…
Reference in New Issue