+ (void)parent_idx;
+
+ return header_data_.size();
+}
+
+void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signal, uint32_t current_segment)
+{
+ layoutAboutToBeChanged();
+
+ if (!signal) {
+ all_annotations_ = nullptr;
+ dataset_ = nullptr;
+ signal_ = nullptr;
+
+ dataChanged(QModelIndex(), QModelIndex());
+ layoutChanged();
+ return;
+ }
+
+ disconnect(this, SLOT(on_annotation_visibility_changed()));
+
+ all_annotations_ = signal->get_all_annotations_by_segment(current_segment);
+ signal_ = signal;
+
+ for (const shared_ptr<Decoder>& dec : signal_->decoder_stack())
+ connect(dec.get(), SIGNAL(annotation_visibility_changed()),
+ this, SLOT(on_annotation_visibility_changed()));
+
+ if (hide_hidden_) {
+ update_annotations_without_hidden();
+ dataset_ = &all_annotations_without_hidden_;
+ } else
+ dataset_ = all_annotations_;
+
+ if (!dataset_ || dataset_->empty()) {
+ prev_segment_ = current_segment;
+ return;
+ }
+
+ const size_t new_row_count = dataset_->size() - 1;
+
+ // Force the view associated with this model to update when the segment changes
+ if (prev_segment_ != current_segment) {
+ dataChanged(index(0, 0), index(new_row_count, 0));
+ 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), index(new_row_count, 0));
+ layoutChanged();
+ }
+ }
+
+ prev_segment_ = current_segment;
+ prev_last_row_ = new_row_count;
+}
+
+void AnnotationCollectionModel::set_hide_hidden(bool hide_hidden)
+{
+ layoutAboutToBeChanged();
+
+ hide_hidden_ = hide_hidden;
+
+ if (hide_hidden_) {
+ dataset_ = &all_annotations_without_hidden_;
+ update_annotations_without_hidden();
+ } else {
+ dataset_ = all_annotations_;
+ all_annotations_without_hidden_.clear(); // To conserve memory
+ }
+
+ if (dataset_)
+ dataChanged(index(0, 0), index(dataset_->size() - 1, 0));