]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/decodetrace.cpp
Make new views take over the main view's signal settings
[pulseview.git] / pv / views / trace / decodetrace.cpp
index 002e195439e9d3f3d32e60fab95fb91df0cef16c..50156ddf7f865bb0d0f58fda546423ebf4b2a522 100644 (file)
@@ -70,7 +70,7 @@ using std::vector;
 
 using pv::data::decode::Annotation;
 using pv::data::decode::Row;
-using pv::data::DecodeChannel;
+using pv::data::decode::DecodeChannel;
 using pv::data::DecodeSignal;
 
 namespace pv {
@@ -192,15 +192,17 @@ 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_->get_rows(!always_show_all_rows_);
+       const vector<Row> rows = decode_signal_->get_rows();
 
        visible_rows_.clear();
        for (const Row& row : rows) {
                // Cache the row title widths
                int row_title_width;
-               try {
-                       row_title_width = row_title_widths_.at(row);
-               } catch (out_of_range&) {
+               auto cached_width = row_title_widths_.find(row);
+
+               if (cached_width != row_title_widths_.end())
+                       row_title_width = cached_width->second;
+               else {
                        const int w = p.boundingRect(QRectF(), 0, row.title()).width() +
                                RowTitleMargin;
                        row_title_widths_[row] = w;
@@ -210,7 +212,13 @@ 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 (always_show_all_rows_ || !annotations.empty()) {
+
+               // Show row if there are visible annotations or when user wants to see
+               // all rows that have annotations somewhere and this one is one of them
+               bool row_visible = !annotations.empty() ||
+                       (always_show_all_rows_ && (decode_signal_->get_annotation_count(row, current_segment_) > 0));
+
+               if (row_visible) {
                        draw_annotations(annotations, p, annotation_height, pp, y,
                                get_row_color(row.index()), row_title_width);
                        y += row_height_;
@@ -410,7 +418,7 @@ QMenu* DecodeTrace::create_view_context_menu(QWidget *parent, QPoint &click_pos)
        QAction *const copy_annotation_to_clipboard =
                new QAction(tr("Copy annotation text to clipboard"), this);
        copy_annotation_to_clipboard->setIcon(QIcon::fromTheme("edit-paste",
-               QIcon(":/icons/edit-paste.png")));
+               QIcon(":/icons/edit-paste.svg")));
        connect(copy_annotation_to_clipboard, SIGNAL(triggered()), this, SLOT(on_copy_annotation_to_clipboard()));
        menu->addAction(copy_annotation_to_clipboard);
 
@@ -1217,7 +1225,7 @@ void DecodeTrace::on_copy_annotation_to_clipboard()
        if (annotations->empty())
                return;
 
-       QClipboard *clipboard = QGuiApplication::clipboard();
+       QClipboard *clipboard = QApplication::clipboard();
        clipboard->setText(annotations->front().annotations().front(), QClipboard::Clipboard);
 
        if (clipboard->supportsSelection())