+void View::on_metadata_object_changed(MetadataObject* obj,
+ MetadataValueType value_type)
+{
+ // Check if we need to update the model's data range. We only work on the
+ // end sample value because the start sample value is updated first and
+ // we don't want to update the model twice
+
+ if ((view_mode_selector_->currentIndex() == ViewModeVisible) &&
+ (obj->type() == MetadataObjMainViewRange) &&
+ (value_type == MetadataValueEndSample)) {
+
+ int64_t start_sample = obj->value(MetadataValueStartSample).toLongLong();
+ int64_t end_sample = obj->value(MetadataValueEndSample).toLongLong();
+
+ filter_proxy_model_->set_sample_range(max((int64_t)0, start_sample),
+ max((int64_t)0, end_sample));
+ }
+
+ if (obj->type() == MetadataObjMousePos) {
+ QModelIndex first_visible_idx =
+ filter_proxy_model_->mapToSource(filter_proxy_model_->index(0, 0));
+ QModelIndex last_visible_idx =
+ filter_proxy_model_->mapToSource(filter_proxy_model_->index(filter_proxy_model_->rowCount() - 1, 0));
+
+ if (first_visible_idx.isValid()) {
+ const QModelIndex first_highlighted_idx =
+ model_->update_highlighted_rows(first_visible_idx, last_visible_idx,
+ obj->value(MetadataValueStartSample).toLongLong());
+
+ if (view_mode_selector_->currentIndex() == ViewModeVisible) {
+ const QModelIndex idx = filter_proxy_model_->mapFromSource(first_highlighted_idx);
+ table_view_->scrollTo(idx, QAbstractItemView::EnsureVisible);
+ }
+ }
+ }
+}
+