]> sigrok.org Git - pulseview.git/blobdiff - pv/subwindows/decoder_selector/model.cpp
TabularDecModel: Fix multi-row selection issue
[pulseview.git] / pv / subwindows / decoder_selector / model.cpp
index 31dfd464bf6d07044e5a417f92baeab6dbce960a..2a4182b05840462e2c8a38f9285a26af19f792a9 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
        }
 }
 
@@ -107,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<DecoderCollectionItem*>(index.internalPointer());
 
-       DecoderCollectionItem* item =
-               static_cast<DecoderCollectionItem*>(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;
 }
@@ -127,7 +142,7 @@ Qt::ItemFlags DecoderCollectionModel::flags(const QModelIndex& index) const
 QVariant DecoderCollectionModel::headerData(int section, Qt::Orientation orientation,
        int role) const
 {
-       if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+       if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole))
                return root_->data(section);
 
        return QVariant();