X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Fheader.cpp;h=ca5df96fca250dc23666bbdcf59f644a07083139;hb=a6c1726e1132f475754482a1194d9ee58cdfb816;hp=f8f5b6380514ac2604730ce0a687c0c469fff04a;hpb=569d1e41fbc1be584efdbcdc2c8a01e7af3353ed;p=pulseview.git diff --git a/pv/view/header.cpp b/pv/view/header.cpp index f8f5b638..ca5df96f 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -42,10 +42,13 @@ using namespace std; namespace pv { namespace view { +const int Header::Padding = 12; + Header::Header(View &parent) : MarginWidget(parent), _dragging(false) { + setFocusPolicy(Qt::ClickFocus); setMouseTracking(true); connect(&_view.session(), SIGNAL(signals_changed()), @@ -55,6 +58,19 @@ Header::Header(View &parent) : this, SLOT(on_signals_moved())); } +QSize Header::sizeHint() const +{ + int max_width = 0; + + const vector< shared_ptr > traces(_view.get_traces()); + BOOST_FOREACH(shared_ptr t, traces) { + assert(t); + max_width = max(max_width, (int)t->get_label_rect(0).width()); + } + + return QSize(max_width + Padding, 0); +} + shared_ptr Header::get_mouse_over_trace(const QPoint &pt) { const int w = width(); @@ -235,12 +251,34 @@ void Header::contextMenuEvent(QContextMenuEvent *event) t->create_context_menu(this)->exec(event->globalPos()); } +void Header::keyPressEvent(QKeyEvent *e) +{ + assert(e); + + switch (e->key()) + { + case Qt::Key_Delete: + { + const vector< shared_ptr > traces(_view.get_traces()); + BOOST_FOREACH(const shared_ptr t, traces) + if (t->selected()) + t->delete_pressed(); + break; + } + } +} + void Header::on_signals_changed() { const vector< shared_ptr > traces(_view.get_traces()); BOOST_FOREACH(shared_ptr t, traces) { assert(t); - connect(t.get(), SIGNAL(text_changed()), this, SLOT(update())); + connect(t.get(), SIGNAL(visibility_changed()), + this, SLOT(update())); + connect(t.get(), SIGNAL(text_changed()), + this, SLOT(on_trace_text_changed())); + connect(t.get(), SIGNAL(colour_changed()), + this, SLOT(update())); } } @@ -249,6 +287,11 @@ void Header::on_signals_moved() update(); } +void Header::on_trace_text_changed() +{ + update(); + geometry_updated(); +} } // namespace view } // namespace pv