]> sigrok.org Git - pulseview.git/commitdiff
Fix #977 by introducing a setting for always showing all rows
authorSoeren Apel <redacted>
Thu, 7 Nov 2019 21:40:07 +0000 (22:40 +0100)
committerSoeren Apel <redacted>
Thu, 7 Nov 2019 21:46:00 +0000 (22:46 +0100)
pv/data/decodesignal.cpp
pv/data/decodesignal.hpp
pv/dialogs/settings.cpp
pv/dialogs/settings.hpp
pv/globalsettings.cpp
pv/globalsettings.hpp
pv/views/trace/decodetrace.cpp
pv/views/trace/decodetrace.hpp

index ec2b6a23f6e1aac6487ef0629d28e77b45a6218f..4a7d6ed8c60a7593773d50bf17026176f018678b 100644 (file)
@@ -449,7 +449,7 @@ int64_t DecodeSignal::get_decoded_sample_count(uint32_t segment_id,
        return result;
 }
 
-vector<Row> DecodeSignal::visible_rows() const
+vector<Row> DecodeSignal::get_rows(bool visible_only) const
 {
        lock_guard<mutex> lock(output_mutex_);
 
@@ -457,7 +457,7 @@ vector<Row> DecodeSignal::visible_rows() const
 
        for (const shared_ptr<decode::Decoder>& 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<Row> rows = visible_rows();
+       const vector<Row> rows = get_rows(true);
 
        // Use forward_lists for faster merging
        forward_list<Annotation> *all_ann_list = new forward_list<Annotation>();
index ba9c9b5e4ecaa8021b712446e487ede10a54eb6b..da66d5289c494703615410d63b78d635c3deeced 100644 (file)
@@ -134,7 +134,7 @@ public:
        int64_t get_decoded_sample_count(uint32_t segment_id,
                bool include_processing) const;
 
-       vector<decode::Row> visible_rows() const;
+       vector<decode::Row> get_rows(bool visible_only) const;
 
        /**
         * Extracts annotations from a single row into a vector.
index 1cd7d23c8bf83068e97a91a1e6d518feb528d34b..55181e4c3e86bc5a7b5cebb6a0c54790ac7a9d07 100644 (file)
@@ -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)
index e2ee568b28971f98497f6c322a09f71a2cb3532e..9aff1f137f0a2bcac155e60c76c8bb2ac70cb35d 100644 (file)
@@ -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);
index 19ce0cd79104cce58878f1ee194fd4ac452f1736..b648d5da4e6d1fe388eb69052272dd3044edd0ae 100644 (file)
@@ -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";
 
index a65a723c0c0e85f4704fa38bb712a8e68276c0ba..bc2a4acd795c8d2bab594eccfd84474e006ce609 100644 (file)
@@ -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;
 
index 638de4da5b84bd3686c8ff44afbdee5b562f9115..f7f60a28b49d9586c539bf4c4c8875fe7a9a46db 100644 (file)
@@ -102,6 +102,11 @@ DecodeTrace::DecodeTrace(pv::Session &session,
 {
        decode_signal_ = dynamic_pointer_cast<data::DecodeSignal>(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<Row> rows = decode_signal_->visible_rows();
+       const vector<Row> 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<Annotation> 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<Annotation> *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())
index a65f707872bda76265faf56d73a306bdc9bb6193..b74524c56e5b90b860fee83356e9dc21a208a330 100644 (file)
@@ -86,6 +86,8 @@ public:
        DecodeTrace(pv::Session &session, shared_ptr<data::SignalBase> signalbase,
                int index);
 
+       ~DecodeTrace();
+
        bool enabled() const;
 
        shared_ptr<data::SignalBase> 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<data::DecodeSignal> decode_signal_;
 
        vector<data::decode::Row> visible_rows_;
+       bool always_show_all_rows_;
 
        map<QComboBox*, uint16_t> channel_id_map_;  // channel selector -> decode channel ID
        map<QComboBox*, uint16_t> init_state_map_;  // init state selector -> decode channel ID