X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Ftabular_decoder%2Fview.cpp;h=91bcaea197bee2a0645d9f314fb77c2f5053df21;hp=14ae50a2941e8d56d8a532bd1505b566f67921b4;hb=20c99cfc69d3c7430817abd9a1f810698deb4a18;hpb=5a5d3b1de81417f64b58e80cc359dcfde0d3a10c diff --git a/pv/views/tabular_decoder/view.cpp b/pv/views/tabular_decoder/view.cpp index 14ae50a2..91bcaea1 100644 --- a/pv/views/tabular_decoder/view.cpp +++ b/pv/views/tabular_decoder/view.cpp @@ -139,6 +139,14 @@ QSize CustomTableView::sizeHint() const return minimumSizeHint(); } +void CustomTableView::keyPressEvent(QKeyEvent *event) +{ + if ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter)) + activatedByKey(currentIndex()); + else + QTableView::keyPressEvent(event); +} + View::View(Session &session, bool is_main_view, QMainWindow *parent) : ViewBase(session, is_main_view, parent), @@ -239,6 +247,8 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : this, SLOT(on_table_item_clicked(const QModelIndex&))); connect(table_view_, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(on_table_item_double_clicked(const QModelIndex&))); + connect(table_view_, SIGNAL(activatedByKey(const QModelIndex&)), + this, SLOT(on_table_item_double_clicked(const QModelIndex&))); connect(table_view_->horizontalHeader(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(on_table_header_requested(const QPoint&))); @@ -599,7 +609,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 +626,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 +685,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(); } } }