From: Soeren Apel Date: Thu, 7 Nov 2019 21:40:07 +0000 (+0100) Subject: Fix #977 by introducing a setting for always showing all rows X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ab185f78707eb2800c8b9ea577412ea5f6319f22;p=pulseview.git Fix #977 by introducing a setting for always showing all rows --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index ec2b6a23..4a7d6ed8 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -449,7 +449,7 @@ int64_t DecodeSignal::get_decoded_sample_count(uint32_t segment_id, return result; } -vector DecodeSignal::visible_rows() const +vector DecodeSignal::get_rows(bool visible_only) const { lock_guard lock(output_mutex_); @@ -457,7 +457,7 @@ vector DecodeSignal::visible_rows() const for (const shared_ptr& dec : stack_) { assert(dec); - if (!dec->shown()) + if (visible_only && !dec->shown()) continue; const srd_decoder *const decc = dec->decoder(); @@ -507,7 +507,7 @@ void DecodeSignal::get_annotation_subset( { // Note: We put all vectors and lists on the heap, not the stack - const vector rows = visible_rows(); + const vector rows = get_rows(true); // Use forward_lists for faster merging forward_list *all_ann_list = new forward_list(); diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index ba9c9b5e..da66d528 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -134,7 +134,7 @@ public: int64_t get_decoded_sample_count(uint32_t segment_id, bool include_processing) const; - vector visible_rows() const; + vector get_rows(bool visible_only) const; /** * Extracts annotations from a single row into a vector. diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 1cd7d23c..55181e4c 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -382,6 +382,10 @@ QWidget *Settings::get_decoder_settings_form(QWidget *parent) SLOT(on_dec_initialStateConfigurable_changed(int))); decoder_layout->addRow(tr("Allow configuration of &initial signal state"), cb); + cb = create_checkbox(GlobalSettings::Key_Dec_AlwaysShowAllRows, + SLOT(on_dec_alwaysshowallrows_changed(int))); + decoder_layout->addRow(tr("Always show all &rows, even if no annotation is visible"), cb); + // Annotation export settings ann_export_format_ = new QLineEdit(); ann_export_format_->setText( @@ -725,6 +729,12 @@ void Settings::on_dec_exportFormat_changed(const QString &text) GlobalSettings settings; settings.setValue(GlobalSettings::Key_Dec_ExportFormat, text); } + +void Settings::on_dec_alwaysshowallrows_changed(int state) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_Dec_AlwaysShowAllRows, state ? true : false); +} #endif void Settings::on_log_logLevel_changed(int value) diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index e2ee568b..9aff1f13 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -79,6 +79,7 @@ private Q_SLOTS: #ifdef ENABLE_DECODE void on_dec_initialStateConfigurable_changed(int state); void on_dec_exportFormat_changed(const QString &text); + void on_dec_alwaysshowallrows_changed(int state); #endif void on_log_logLevel_changed(int value); void on_log_bufferSize_changed(int value); diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 19ce0cd7..b648d5da 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -62,6 +62,7 @@ const QString GlobalSettings::Key_View_SnapDistance = "View_SnapDistance"; const QString GlobalSettings::Key_View_CursorFillColor = "View_CursorFillColor"; const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat"; +const QString GlobalSettings::Key_Dec_AlwaysShowAllRows = "Dec_AlwaysShowAllRows"; const QString GlobalSettings::Key_Log_BufferSize = "Log_BufferSize"; const QString GlobalSettings::Key_Log_NotifyOfStacktrace = "Log_NotifyOfStacktrace"; diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index a65a723c..bc2a4acd 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -71,6 +71,7 @@ public: static const QString Key_View_CursorFillColor; static const QString Key_Dec_InitialStateConfigurable; static const QString Key_Dec_ExportFormat; + static const QString Key_Dec_AlwaysShowAllRows; static const QString Key_Log_BufferSize; static const QString Key_Log_NotifyOfStacktrace; diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index 638de4da..f7f60a28 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -102,6 +102,11 @@ DecodeTrace::DecodeTrace(pv::Session &session, { decode_signal_ = dynamic_pointer_cast(base_); + GlobalSettings settings; + always_show_all_rows_ = settings.value(GlobalSettings::Key_Dec_AlwaysShowAllRows).toBool(); + + GlobalSettings::add_change_handler(this); + // Determine shortest string we want to see displayed in full QFontMetrics m(QApplication::font()); min_useful_label_width_ = m.width("XX"); // e.g. two hex characters @@ -137,6 +142,11 @@ DecodeTrace::DecodeTrace(pv::Session &session, delayed_trace_updater_.setInterval(1000 / MaxTraceUpdateRate); } +DecodeTrace::~DecodeTrace() +{ + GlobalSettings::remove_change_handler(this); +} + bool DecodeTrace::enabled() const { return true; @@ -182,7 +192,7 @@ void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp) sample_range.second = min((int64_t)sample_range.second, decode_signal_->get_decoded_sample_count(current_segment_, false)); - const vector rows = decode_signal_->visible_rows(); + const vector rows = decode_signal_->get_rows(!always_show_all_rows_); visible_rows_.clear(); for (const Row& row : rows) { @@ -200,7 +210,7 @@ void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp) vector annotations; decode_signal_->get_annotation_subset(annotations, row, current_segment_, sample_range.first, sample_range.second); - if (!annotations.empty()) { + if (always_show_all_rows_ || !annotations.empty()) { draw_annotations(annotations, p, annotation_height, pp, y, get_row_color(row.index()), row_title_width); y += row_height_; @@ -1067,6 +1077,15 @@ void DecodeTrace::export_annotations(vector *annotations) const msg.exec(); } +void DecodeTrace::on_setting_changed(const QString &key, const QVariant &value) +{ + if (key == GlobalSettings::Key_Dec_AlwaysShowAllRows) { + visible_rows_.clear(); + max_visible_rows_ = 0; + always_show_all_rows_ = value.toBool(); + } +} + void DecodeTrace::on_new_annotations() { if (!delayed_trace_updater_.isActive()) diff --git a/pv/views/trace/decodetrace.hpp b/pv/views/trace/decodetrace.hpp index a65f7078..b74524c5 100644 --- a/pv/views/trace/decodetrace.hpp +++ b/pv/views/trace/decodetrace.hpp @@ -86,6 +86,8 @@ public: DecodeTrace(pv::Session &session, shared_ptr signalbase, int index); + ~DecodeTrace(); + bool enabled() const; shared_ptr base() const; @@ -186,6 +188,8 @@ public: virtual void hover_point_changed(const QPoint &hp); private Q_SLOTS: + void on_setting_changed(const QString &key, const QVariant &value); + void on_new_annotations(); void on_delayed_trace_update(); void on_decode_reset(); @@ -220,6 +224,7 @@ private: shared_ptr decode_signal_; vector visible_rows_; + bool always_show_all_rows_; map channel_id_map_; // channel selector -> decode channel ID map init_state_map_; // init state selector -> decode channel ID