+void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signal, uint32_t current_segment)
+{
+ if (!signal) {
+ all_annotations_ = nullptr;
+ dataChanged(QModelIndex(), QModelIndex());
+ layoutChanged();
+ return;
+ }
+
+ all_annotations_ = signal->get_all_annotations_by_segment(current_segment);
+
+ if (!all_annotations_ || all_annotations_->empty()) {
+ prev_segment_ = current_segment;
+ return;
+ }
+
+ const size_t new_row_count = all_annotations_->size() - 1;
+
+ // Force the view associated with this model to update when the segment changes
+ if (prev_segment_ != current_segment) {
+ dataChanged(QModelIndex(), QModelIndex());
+ layoutChanged();
+ } else {
+ // Force the view associated with this model to update when we have more annotations
+ if (prev_last_row_ < new_row_count) {
+ dataChanged(index(prev_last_row_, 0, QModelIndex()),
+ index(new_row_count, 0, QModelIndex()));
+ layoutChanged();
+ }
+ }
+
+ prev_segment_ = current_segment;
+ prev_last_row_ = new_row_count;
+}
+
+void AnnotationCollectionModel::on_setting_changed(const QString &key, const QVariant &value)
+{
+ (void)key;
+ (void)value;
+
+ // We don't really care about the actual setting, we just update the
+ // flag that indicates whether we are using a bright or dark color theme
+ theme_is_dark_ = GlobalSettings::current_theme_is_dark();
+}