]> sigrok.org Git - pulseview.git/commitdiff
DecodeTrace: Prevent user from hiding the only row
authorSoeren Apel <redacted>
Thu, 6 Feb 2020 19:15:35 +0000 (20:15 +0100)
committerSoeren Apel <redacted>
Thu, 6 Feb 2020 19:15:35 +0000 (20:15 +0100)
pv/views/trace/decodetrace.cpp
pv/views/trace/decodetrace.hpp

index 8ca8d580c8b4a4bb4fadf89e84421491fd567056..f4b9f3359ccbf35f41b845fb95842141c0e73afe 100644 (file)
@@ -1316,6 +1316,7 @@ void DecodeTrace::initialize_row_widgets(DecodeTraceRow* r, unsigned int row_id)
 
        // Add widgets inside the header container
        QCheckBox* cb = new QCheckBox();
+       r->row_visibility_checkbox = cb;
        header_container_layout->addWidget(cb);
        cb->setText(tr("Show this row"));
        cb->setChecked(r->decode_row->visible());
@@ -1426,6 +1427,10 @@ void DecodeTrace::update_rows()
                row_id++;
        }
 
+       // If there's only one row, it must not be hidden or else it can't be un-hidden
+       if (row_id == 1)
+               rows_.front().row_visibility_checkbox->setEnabled(false);
+
        // Remove any rows that no longer exist, obeying that iterators are invalidated
        bool any_exists;
        do {
@@ -1433,6 +1438,8 @@ void DecodeTrace::update_rows()
 
                for (unsigned int i = 0; i < rows_.size(); i++)
                        if (!rows_[i].exists) {
+                               delete rows_[i].row_visibility_checkbox;
+
                                for (QCheckBox* cb : rows_[i].selectors)
                                        delete cb;
 
index b6791c4381af50a5c81396bc7ecf217e0506738d..215ae0ae95b52d58af1ac1f4a4026491ddcbea27 100644 (file)
@@ -97,6 +97,7 @@ struct DecodeTraceRow {
        ContainerWidget* container;
        QWidget* header_container;
        QWidget* selector_container;
+       QCheckBox* row_visibility_checkbox;
        vector<QCheckBox*> selectors;
 
        QColor row_color;