  
  void HistoryLogModel::updateState() {
    int prev_row_count = messages.size();
    if (!msg_id.isEmpty()) {
      messages = can->messages(msg_id);
    }
    int delta = messages.size() - prev_row_count;
    if (delta > 0) {
      beginInsertRows({}, prev_row_count, messages.size() - 1);
      endInsertRows();
    } else if (delta < 0) {
      beginRemoveRows({}, messages.size(), prev_row_count - 1);
      endRemoveRows();
    }
    if (!messages.empty()) {
      emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1), {Qt::DisplayRole});
    }
  }
 
</s> remove   int prev_row_count = messages.size();
 </s> add  </s> remove     emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1), {Qt::DisplayRole});
 </s> add     auto new_msgs = fetchData(0, messages.back().mono_time);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, messages.size(), messages.size() + new_msgs.size() - 1);
      messages.insert(messages.end(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    } </s> remove 
      std::lock_guard lk(lock);
      auto &list = received_msgs[id];
      while (list.size() > settings.can_msg_log_size) {
        list.pop_back();
      }
      CanData &data = list.emplace_front();
 </s> add       CanData &data = (*new_msgs)[id]; </s> remove     return !sigs.empty() ? QString::number(get_raw_value((uint8_t *)m.dat.data(), m.dat.size(), *sigs[index.column() - 1]))
                         : toHex(m.dat);
 </s> add     return !sigs.empty() ? QString::number(m.sig_values[index.column() - 1]) : toHex(m.data);
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
  
  void HistoryLogModel::updateState() {
    int prev_row_count = messages.size();
    if (!msg_id.isEmpty()) {
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    uint64_t last_mono_time = messages.empty() ? 0 : messages.front().mono_time;
    auto new_msgs = fetchData(last_mono_time, (can->currentSec() + can->routeStartTime()) * 1e9);
    if ((has_more_data = !new_msgs.empty())) {
      beginInsertRows({}, 0, new_msgs.size() - 1);
      messages.insert(messages.begin(), std::move_iterator(new_msgs.begin()), std::move_iterator(new_msgs.end()));
      endInsertRows();
    }
    }
    if (!messages.empty()) {
      emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1), {Qt::DisplayRole});
    }
  }
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Cabana: display all logs in log view (#26659)

* fetch more

* clear log in showevent

* fix wrong time value

* check list size

* fix canmessages::process

* cache all events

* improve segment cache

* cleanup 
tools/cabana/historylog.cc