mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
cabana: sort events based on priority (#27809)
* sort events based on priority * cleanup for pr * pr cleanup 2 * pr cleanup 3 old-commit-hash: f8d9263eae3525a0a535c38f04f64f88010cabad
This commit is contained in:
@@ -19,6 +19,20 @@ static const QColor timeline_colors[] = {
|
||||
[(int)TimelineType::AlertCritical] = QColor(199, 0, 57),
|
||||
};
|
||||
|
||||
|
||||
bool sortTimelineBasedOnEventPriority(const std::tuple<int, int, TimelineType> &left, const std::tuple<int, int, TimelineType> &right){
|
||||
const static std::map<TimelineType, int> timelinePriority = {
|
||||
{ TimelineType::None, 0 },
|
||||
{ TimelineType::Engaged, 10 },
|
||||
{ TimelineType::AlertInfo, 20 },
|
||||
{ TimelineType::AlertWarning, 30 },
|
||||
{ TimelineType::AlertCritical, 40 },
|
||||
{ TimelineType::UserFlag, 35 }
|
||||
};
|
||||
|
||||
return timelinePriority.at(std::get<2>(left)) < timelinePriority.at(std::get<2>(right));
|
||||
}
|
||||
|
||||
VideoWidget::VideoWidget(QWidget *parent) : QFrame(parent) {
|
||||
setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
||||
auto main_layout = new QVBoxLayout(this);
|
||||
@@ -129,6 +143,8 @@ void VideoWidget::updatePlayBtnState() {
|
||||
Slider::Slider(QWidget *parent) : timer(this), thumbnail_label(this), QSlider(Qt::Horizontal, parent) {
|
||||
timer.callOnTimeout([this]() {
|
||||
timeline = can->getTimeline();
|
||||
std::sort(timeline.begin(), timeline.end(), sortTimelineBasedOnEventPriority);
|
||||
|
||||
update();
|
||||
});
|
||||
setMouseTracking(true);
|
||||
@@ -189,6 +205,7 @@ void Slider::paintEvent(QPaintEvent *ev) {
|
||||
p.fillRect(r, timeline_colors[(int)TimelineType::None]);
|
||||
double min = minimum() / 1000.0;
|
||||
double max = maximum() / 1000.0;
|
||||
|
||||
for (auto [begin, end, type] : timeline) {
|
||||
if (begin > max || end < min)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user