X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fview.cpp;h=65b06aea82cba76279f185f40b4af933578a18dd;hp=2837e57fae3332e84ade1bfe8a50dd28c4acab12;hb=cbd9ec7f751a5403d1465e966ccecd31b7086e8a;hpb=ba804ad012807c3c689bf696e9885d1dff559e7b diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 2837e57f..65b06aea 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -246,6 +247,7 @@ void View::reset_view_state() suppress_zoom_to_fit_after_acq_ = false; show_cursors_ = false; + cursor_state_changed(show_cursors_); flags_.clear(); // Update the zoom state @@ -384,7 +386,7 @@ void View::restore_settings(QSettings &settings) boost::archive::text_iarchive ia(ss); ia >> boost::serialization::make_nvp("ruler_shift", shift); ruler_shift_ = shift; - } catch (boost::archive::archive_exception) { + } catch (boost::archive::archive_exception&) { qDebug() << "Could not restore the view ruler shift"; } } @@ -399,7 +401,7 @@ void View::restore_settings(QSettings &settings) ia >> boost::serialization::make_nvp("offset", offset); // This also updates ruler_offset_ set_offset(offset); - } catch (boost::archive::archive_exception) { + } catch (boost::archive::archive_exception&) { qDebug() << "Could not restore the view offset"; } } @@ -618,8 +620,6 @@ Trace::SegmentDisplayMode View::segment_display_mode() const void View::set_segment_display_mode(Trace::SegmentDisplayMode mode) { - trigger_markers_.clear(); - segment_display_mode_ = mode; for (shared_ptr signal : signals_) @@ -699,23 +699,6 @@ void View::zoom_fit(bool gui_state) set_scale_offset(scale.convert_to(), extents.first); } -void View::zoom_one_to_one() -{ - using pv::data::SignalData; - - // Make a set of all the visible data objects - set< shared_ptr > visible_data = get_visible_data(); - if (visible_data.empty()) - return; - - assert(viewport_); - const int w = viewport_->width(); - if (w <= 0) - return; - - set_zoom(1.0 / session_.get_samplerate(), w / 2); -} - void View::set_scale_offset(double scale, const Timestamp& offset) { // Disable sticky scrolling / always zoom to fit when acquisition runs @@ -815,6 +798,7 @@ bool View::cursors_shown() const void View::show_cursors(bool show) { show_cursors_ = show; + cursor_state_changed(show); ruler_->update(); viewport_->update(); } @@ -891,6 +875,11 @@ void View::restack_all_trace_tree_items() i->animate_to_layout_v_offset(); } +int View::header_width() const +{ + return header_->extended_size_hint().width(); +} + void View::on_setting_changed(const QString &key, const QVariant &value) { if (key == GlobalSettings::Key_View_TriggerIsZeroTime) @@ -1070,8 +1059,10 @@ void View::update_scroll() vscrollbar->setRange(extents.first - areaSize.height(), extents.second); - if (scroll_needs_defaults_) + if (scroll_needs_defaults_) { set_scroll_default(); + scroll_needs_defaults_ = false; + } } void View::reset_scroll() @@ -1101,12 +1092,11 @@ void View::set_scroll_default() void View::determine_if_header_was_shrunk() { const int header_pane_width = splitter_->sizes().front(); - const int header_width = header_->extended_size_hint().width(); // Allow for a slight margin of error so that we also accept // slight differences when e.g. a label name change increased // the overall width - header_was_shrunk_ = (header_pane_width < (header_width - 10)); + header_was_shrunk_ = (header_pane_width < (header_width() - 10)); } void View::resize_header_to_fit() @@ -1266,6 +1256,19 @@ bool View::eventFilter(QObject *object, QEvent *event) return QObject::eventFilter(object, event); } +void View::contextMenuEvent(QContextMenuEvent *event) +{ + QPoint pos = event->pos() - QPoint(0, ruler_->sizeHint().height()); + + const shared_ptr r = viewport_->get_mouse_over_item(pos); + if (!r) + return; + + QMenu *menu = r->create_view_context_menu(this, pos); + if (menu) + menu->exec(event->globalPos()); +} + void View::resizeEvent(QResizeEvent* event) { // Only adjust the top margin if we shrunk vertically @@ -1312,6 +1315,7 @@ void View::extents_changed(bool horz, bool vert) (horz ? TraceTreeItemHExtentsChanged : 0) | (vert ? TraceTreeItemVExtentsChanged : 0); + lazy_event_handler_.stop(); lazy_event_handler_.start(); }