]> sigrok.org Git - pulseview.git/commitdiff
Only show first-level decoders in the menu
authorJoel Holdsworth <redacted>
Tue, 4 Mar 2014 19:10:21 +0000 (19:10 +0000)
committerJoel Holdsworth <redacted>
Tue, 4 Mar 2014 19:10:21 +0000 (19:10 +0000)
pv/mainwindow.cpp
pv/widgets/decodermenu.cpp
pv/widgets/decodermenu.h

index c75b3a9e59a5e940cbb2da11168c98e577be2b7d..fcc929e988c12d8f1755be8b436c1b348b77447f 100644 (file)
@@ -220,7 +220,7 @@ void MainWindow::setup_ui()
                "MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8));
 
        pv::widgets::DecoderMenu *const menu_decoders_add =
-               new pv::widgets::DecoderMenu(menu_decoders);
+               new pv::widgets::DecoderMenu(menu_decoders, true);
        menu_decoders_add->setTitle(QApplication::translate(
                "MainWindow", "&Add", 0, QApplication::UnicodeUTF8));
        connect(menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)),
index 3273123ecc40cf6bbf66b8c5122765a8561c570d..23c74a0ac70abe3f1e25db3e871b9a5291349fdf 100644 (file)
@@ -25,7 +25,7 @@
 namespace pv {
 namespace widgets {
 
-DecoderMenu::DecoderMenu(QWidget *parent) :
+DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) :
        QMenu(parent),
        _mapper(this)
 {
@@ -33,12 +33,17 @@ DecoderMenu::DecoderMenu(QWidget *parent) :
                (GSList*)srd_decoder_list()), decoder_name_cmp);
        for(; l; l = l->next)
        {
-               QAction *const action = addAction(QString::fromUtf8(
-                       ((srd_decoder*)l->data)->name));
-               action->setData(qVariantFromValue(l->data));
-               _mapper.setMapping(action, action);
-               connect(action, SIGNAL(triggered()),
-                       &_mapper, SLOT(map()));
+               const srd_decoder *const d = (srd_decoder*)l->data;
+               assert(d);
+
+               if (!first_level_decoder || d->probes || d->opt_probes) {
+                       QAction *const action =
+                               addAction(QString::fromUtf8(d->name));
+                       action->setData(qVariantFromValue(l->data));
+                       _mapper.setMapping(action, action);
+                       connect(action, SIGNAL(triggered()),
+                               &_mapper, SLOT(map()));
+               }
        }
        g_slist_free(l);
 
index 88dcfaa4edc0ef05598a79a9062050167aea1aa2..20dd41203684d2219378c41a9d14c9d0cb63a04e 100644 (file)
@@ -34,7 +34,7 @@ class DecoderMenu : public QMenu
        Q_OBJECT;
 
 public:
-       DecoderMenu(QWidget *parent);
+       DecoderMenu(QWidget *parent, bool first_level_decoder = false);
 
 private:
        static int decoder_name_cmp(const void *a, const void *b);