@@ -84,7 +84,6 @@ void HistoryLogModel::updateState() {
84
84
if ((has_more_data = !new_msgs.empty ())) {
85
85
beginInsertRows ({}, 0 , new_msgs.size () - 1 );
86
86
messages.insert (messages.begin (), std::move_iterator (new_msgs.begin ()), std::move_iterator (new_msgs.end ()));
87
- updateColors ();
88
87
endInsertRows ();
89
88
}
90
89
last_fetch_time = current_time;
@@ -97,29 +96,11 @@ void HistoryLogModel::fetchMore(const QModelIndex &parent) {
97
96
if ((has_more_data = !new_msgs.empty ())) {
98
97
beginInsertRows ({}, messages.size (), messages.size () + new_msgs.size () - 1 );
99
98
messages.insert (messages.end (), std::move_iterator (new_msgs.begin ()), std::move_iterator (new_msgs.end ()));
100
- if (!dynamic_mode) {
101
- updateColors ();
102
- }
103
99
endInsertRows ();
104
100
}
105
101
}
106
102
}
107
103
108
- void HistoryLogModel::updateColors () {
109
- if (!display_signals_mode || sigs.empty ()) {
110
- const auto freq = can->lastMessage (msg_id).freq ;
111
- if (dynamic_mode) {
112
- for (auto it = messages.rbegin (); it != messages.rend (); ++it) {
113
- it->colors = hex_colors.compute (it->data , it->mono_time / (double )1e9 , freq);
114
- }
115
- } else {
116
- for (auto it = messages.begin (); it != messages.end (); ++it) {
117
- it->colors = hex_colors.compute (it->data , it->mono_time / (double )1e9 , freq);
118
- }
119
- }
120
- }
121
- }
122
-
123
104
template <class InputIt >
124
105
std::deque<HistoryLogModel::Message> HistoryLogModel::fetchData (InputIt first, InputIt last, uint64_t min_time) {
125
106
std::deque<HistoryLogModel::Message> msgs;
@@ -153,17 +134,28 @@ template std::deque<HistoryLogModel::Message> HistoryLogModel::fetchData<>(std::
153
134
154
135
std::deque<HistoryLogModel::Message> HistoryLogModel::fetchData (uint64_t from_time, uint64_t min_time) {
155
136
auto events = can->events ();
137
+ const auto freq = can->lastMessage (msg_id).freq ;
138
+ const bool update_colors = !display_signals_mode || sigs.empty ();
139
+
156
140
if (dynamic_mode) {
157
- auto it = std::upper_bound (events->rbegin (), events->rend (), from_time, [=](uint64_t ts, auto &e) {
158
- return e->mono_time < ts;
159
- });
160
- return fetchData (it, events->rend (), min_time);
141
+ auto first = std::upper_bound (events->rbegin (), events->rend (), from_time, [=](uint64_t ts, auto &e) { return e->mono_time < ts; });
142
+ auto msgs = fetchData (first, events->rend (), min_time);
143
+ if (update_colors && min_time > 0 ) {
144
+ for (auto it = msgs.rbegin (); it != msgs.rend (); ++it) {
145
+ it->colors = hex_colors.compute (it->data , it->mono_time / (double )1e9 , freq);
146
+ }
147
+ }
148
+ return msgs;
161
149
} else {
162
150
assert (min_time == 0 );
163
- auto it = std::upper_bound (events->begin (), events->end (), from_time, [=](uint64_t ts, auto &e) {
164
- return ts < e->mono_time ;
165
- });
166
- return fetchData (it, events->end (), 0 );
151
+ auto first = std::upper_bound (events->begin (), events->end (), from_time, [=](uint64_t ts, auto &e) { return ts < e->mono_time ; });
152
+ auto msgs = fetchData (first, events->end (), 0 );
153
+ if (update_colors) {
154
+ for (auto it = msgs.rbegin (); it != msgs.rend (); ++it) {
155
+ it->colors = hex_colors.compute (it->data , it->mono_time / (double )1e9 , freq);
156
+ }
157
+ }
158
+ return msgs;
167
159
}
168
160
}
169
161
0 commit comments