From: Soeren Apel Date: Fri, 20 Dec 2019 15:51:46 +0000 (+0100) Subject: Fix #1451 by only using decoder tags if they're available X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=e352126139ca6ba64ef8bc0a4611cdb1c58c6a1b;ds=sidebyside Fix #1451 by only using decoder tags if they're available --- diff --git a/pv/subwindows/decoder_selector/model.cpp b/pv/subwindows/decoder_selector/model.cpp index dafe4f2d..ebdfd9d7 100644 --- a/pv/subwindows/decoder_selector/model.cpp +++ b/pv/subwindows/decoder_selector/model.cpp @@ -23,6 +23,10 @@ #include +#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 } } diff --git a/pv/subwindows/decoder_selector/subwindow.cpp b/pv/subwindows/decoder_selector/subwindow.cpp index 0b49c34a..ff2a6c8a 100644 --- a/pv/subwindows/decoder_selector/subwindow.cpp +++ b/pv/subwindows/decoder_selector/subwindow.cpp @@ -32,6 +32,12 @@ #include "pv/session.hpp" #include "pv/subwindows/decoder_selector/subwindow.hpp" +#include + +#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("%1 (%2)
%3") .arg(longname, id, desc)); info_label_body_->setText(doc); - info_label_footer_->setText(tr("

Tags: %1

").arg(tags)); + + if (!tags.isEmpty()) + info_label_footer_->setText(tr("

Tags: %1

").arg(tags)); } void SubWindow::on_item_activated(const QModelIndex& index)