]> sigrok.org Git - pulseview.git/commitdiff
Fix #1451 by only using decoder tags if they're available
authorSoeren Apel <redacted>
Fri, 20 Dec 2019 15:51:46 +0000 (16:51 +0100)
committerSoeren Apel <redacted>
Fri, 20 Dec 2019 22:52:01 +0000 (23:52 +0100)
pv/subwindows/decoder_selector/model.cpp
pv/subwindows/decoder_selector/subwindow.cpp

index dafe4f2d1bf3fe66a4a8473513788f7174540d27..ebdfd9d7d387635c442be8cabedaa6cebc5016e3 100644 (file)
 
 #include <libsigrokdecode/libsigrokdecode.h>
 
+#define DECODERS_HAVE_TAGS \
+       ((SRD_PACKAGE_VERSION_MAJOR > 0) || \
+        (SRD_PACKAGE_VERSION_MAJOR == 0) && (SRD_PACKAGE_VERSION_MINOR > 5))
+
 using std::make_shared;
 
 namespace pv {
@@ -69,6 +73,7 @@ DecoderCollectionModel::DecoderCollectionModel(QObject* parent) :
                group_item_all->appendSubItem(decoder_item_all);
 
                // Add decoder to all relevant groups using the tag information
+#if DECODERS_HAVE_TAGS
                for (GSList* ti = (GSList*)d->tags; ti; ti = ti->next) {
                        const QString tag = tr((char*)ti->data);
                        const QVariant tag_var = QVariant(tag);
@@ -99,6 +104,7 @@ DecoderCollectionModel::DecoderCollectionModel(QObject* parent) :
                        // Add decoder to tag group
                        group_item->appendSubItem(decoder_item);
                }
+#endif
        }
 }
 
index 0b49c34aa190af74235473839dec121ce2392651..ff2a6c8acad28856b7ee6eacdf5b9efcff3c8102 100644 (file)
 #include "pv/session.hpp"
 #include "pv/subwindows/decoder_selector/subwindow.hpp"
 
+#include <libsigrokdecode/libsigrokdecode.h>
+
+#define DECODERS_HAVE_TAGS \
+       ((SRD_PACKAGE_VERSION_MAJOR > 0) || \
+        (SRD_PACKAGE_VERSION_MAJOR == 0) && (SRD_PACKAGE_VERSION_MINOR > 5))
+
 using std::reverse;
 
 namespace pv {
@@ -102,7 +108,9 @@ SubWindow::SubWindow(Session& session, QWidget* parent) :
        filter->setClearButtonEnabled(true);
        filter->addAction(filter_icon, QLineEdit::LeadingPosition);
 
+
        sort_filter_model_->setSourceModel(model_);
+       sort_filter_model_->setSortCaseSensitivity(Qt::CaseInsensitive);
        sort_filter_model_->setFilterCaseSensitivity(Qt::CaseInsensitive);
        sort_filter_model_->setFilterKeyColumn(-1);
 
@@ -119,6 +127,11 @@ SubWindow::SubWindow(Session& session, QWidget* parent) :
 
        tree_view_->setIndentation(10);
 
+#if (!DECODERS_HAVE_TAGS)
+       tree_view_->expandAll();
+       tree_view_->setItemsExpandable(false);
+#endif
+
        QScrollArea* info_label_body_container = new QScrollArea();
        info_label_body_container->setWidget(info_label_body_);
        info_label_body_container->setWidgetResizable(true);
@@ -226,17 +239,21 @@ void SubWindow::on_item_changed(const QModelIndex& index)
        const QString doc = QString::fromUtf8(srd_decoder_doc_get(d)).trimmed();
 
        QString tags;
+#if DECODERS_HAVE_TAGS
        for (GSList* li = (GSList*)d->tags; li; li = li->next) {
                QString s = (li == (GSList*)d->tags) ?
                        tr((char*)li->data) :
                        QString(tr(", %1")).arg(tr((char*)li->data));
                tags.append(s);
        }
+#endif
 
        info_label_header_->setText(QString("<span style='font-size:large'><b>%1 (%2)</b></span><br><i>%3</i>")
                .arg(longname, id, desc));
        info_label_body_->setText(doc);
-       info_label_footer_->setText(tr("<p align='right'>Tags: %1</p>").arg(tags));
+
+       if (!tags.isEmpty())
+               info_label_footer_->setText(tr("<p align='right'>Tags: %1</p>").arg(tags));
 }
 
 void SubWindow::on_item_activated(const QModelIndex& index)