- dataChanged(index(0, 0, QModelIndex()), index(count, 0, QModelIndex()));
- layoutChanged();
+QModelIndex AnnotationCollectionModel::update_highlighted_rows(QModelIndex first,
+ QModelIndex last, int64_t sample_num)
+{
+ bool has_highlight = false;
+ QModelIndex result;
+
+ highlight_sample_num_ = sample_num;
+
+ if (!dataset_ || dataset_->empty())
+ return result;
+
+ if (sample_num >= 0) {
+ last = last.sibling(last.row() + 1, 0);
+
+ // Check if there are any annotations visible in the table view that
+ // we would need to highlight - only then do we do so
+ QModelIndex index = first;
+ do {
+ const Annotation* ann =
+ static_cast<const Annotation*>(index.internalPointer());
+ assert(ann);
+
+ if (((int64_t)ann->start_sample() <= sample_num) &&
+ ((int64_t)ann->end_sample() >= sample_num)) {
+ result = index;
+ has_highlight = true;
+ break;
+ }
+
+ index = index.sibling(index.row() + 1, 0);
+ } while (index != last);
+ }
+
+ if (has_highlight || had_highlight_before_) {
+ dataChanged(first, last);
+ layoutChanged();
+ }
+
+ had_highlight_before_ = has_highlight;
+
+ return result;