X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fsubwindows%2Fdecoder_selector%2Fmodel.cpp;h=ebdfd9d7d387635c442be8cabedaa6cebc5016e3;hb=e352126139ca6ba64ef8bc0a4611cdb1c58c6a1b;hp=07faee8ebea3b1e4a723c3e8bc46f0bb9a39859f;hpb=97378470ded88af84edaa0f1063d10d834475665;p=pulseview.git diff --git a/pv/subwindows/decoder_selector/model.cpp b/pv/subwindows/decoder_selector/model.cpp index 07faee8e..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 { @@ -51,8 +55,7 @@ DecoderCollectionModel::DecoderCollectionModel(QObject* parent) : make_shared(item_data, root_); root_->appendSubItem(group_item_all); - GSList* l = g_slist_copy((GSList*)srd_decoder_list()); - for (GSList* li = l; li; li = li->next) { + for (GSList* li = (GSList*)srd_decoder_list(); li; li = li->next) { const srd_decoder *const d = (srd_decoder*)li->data; assert(d); @@ -70,8 +73,8 @@ DecoderCollectionModel::DecoderCollectionModel(QObject* parent) : group_item_all->appendSubItem(decoder_item_all); // Add decoder to all relevant groups using the tag information - GSList* t = g_slist_copy((GSList*)d->tags); - for (GSList* ti = t; ti; ti = ti->next) { +#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); @@ -101,9 +104,8 @@ DecoderCollectionModel::DecoderCollectionModel(QObject* parent) : // Add decoder to tag group group_item->appendSubItem(decoder_item); } - g_slist_free(t); +#endif } - g_slist_free(l); } QVariant DecoderCollectionModel::data(const QModelIndex& index, int role) const @@ -111,19 +113,28 @@ QVariant DecoderCollectionModel::data(const QModelIndex& index, int role) const if (!index.isValid()) return QVariant(); - if (role != Qt::DisplayRole) - return QVariant(); + if (role == Qt::DisplayRole) + { + DecoderCollectionItem* item = + static_cast(index.internalPointer()); - DecoderCollectionItem* item = - static_cast(index.internalPointer()); + return item->data(index.column()); + } - return item->data(index.column()); + if ((role == Qt::FontRole) && (index.parent().isValid()) && (index.column() == 0)) + { + QFont font; + font.setItalic(true); + return QVariant(font); + } + + return QVariant(); } Qt::ItemFlags DecoderCollectionModel::flags(const QModelIndex& index) const { if (!index.isValid()) - return 0; + return nullptr; return Qt::ItemIsEnabled | Qt::ItemIsSelectable; }