From: Soeren Apel Date: Mon, 8 Jun 2020 19:44:27 +0000 (+0200) Subject: TabularDecView: Model fixes X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=49a0a40345eb84be2c953c5f83cd0c9ccada6360;p=pulseview.git TabularDecView: Model fixes --- diff --git a/pv/views/tabular_decoder/model.cpp b/pv/views/tabular_decoder/model.cpp index 3733e138..110cfd62 100644 --- a/pv/views/tabular_decoder/model.cpp +++ b/pv/views/tabular_decoder/model.cpp @@ -213,6 +213,8 @@ int AnnotationCollectionModel::columnCount(const QModelIndex& parent_idx) const void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signal, uint32_t current_segment) { + layoutAboutToBeChanged(); + if (!signal) { all_annotations_ = nullptr; dataset_ = nullptr; @@ -262,6 +264,8 @@ void AnnotationCollectionModel::set_signal_and_segment(data::DecodeSignal* signa void AnnotationCollectionModel::set_hide_hidden(bool hide_hidden) { + layoutAboutToBeChanged(); + hide_hidden_ = hide_hidden; if (hide_hidden_) { @@ -335,10 +339,8 @@ QModelIndex AnnotationCollectionModel::update_highlighted_rows(QModelIndex first } while (index != last); } - if (has_highlight || had_highlight_before_) { + if (has_highlight || had_highlight_before_) dataChanged(first, last); - layoutChanged(); - } had_highlight_before_ = has_highlight; @@ -350,6 +352,8 @@ void AnnotationCollectionModel::on_annotation_visibility_changed() if (!hide_hidden_) return; + layoutAboutToBeChanged(); + update_annotations_without_hidden(); if (dataset_) diff --git a/pv/views/tabular_decoder/view.cpp b/pv/views/tabular_decoder/view.cpp index 14ae50a2..4715b4a9 100644 --- a/pv/views/tabular_decoder/view.cpp +++ b/pv/views/tabular_decoder/view.cpp @@ -599,7 +599,10 @@ void View::on_table_item_clicked(const QModelIndex& index) void View::on_table_item_double_clicked(const QModelIndex& index) { - const Annotation* ann = static_cast(index.internalPointer()); + const QModelIndex src_idx = filter_proxy_model_->mapToSource(index); + + const Annotation* ann = static_cast(src_idx.internalPointer()); + assert(ann); shared_ptr main_view = session_.main_view(); @@ -613,7 +616,8 @@ void View::on_table_header_requested(const QPoint& pos) for (int i = 0; i < table_view_->horizontalHeader()->count(); i++) { int column = table_view_->horizontalHeader()->logicalIndex(i); - const QString title = model_->headerData(column, Qt::Horizontal, Qt::DisplayRole).toString(); + const QString title = + filter_proxy_model_->headerData(column, Qt::Horizontal, Qt::DisplayRole).toString(); QAction* action = new QAction(title, this); action->setCheckable(true); @@ -671,6 +675,9 @@ void View::on_metadata_object_changed(MetadataObject* obj, const QModelIndex idx = filter_proxy_model_->mapFromSource(first_highlighted_idx); table_view_->scrollTo(idx, QAbstractItemView::EnsureVisible); } + + // Force repaint, otherwise the table doesn't immediately update for some reason + table_view_->viewport()->update(); } } }