]> sigrok.org Git - pulseview.git/blobdiff - pv/dialogs/decoder.cpp
Fixes for clang build on OS X
[pulseview.git] / pv / dialogs / decoder.cpp
index 292e4722c3928bdae995c1cd03030fa597059ba0..88ccf76021f9acc7b7888695257cacc6f673c684 100644 (file)
@@ -22,8 +22,15 @@ extern "C" {
 #include <libsigrokdecode/libsigrokdecode.h>
 }
 
+#include <utility>
+
+#include <boost/foreach.hpp>
+
+#include <QDebug>
+
 #include "decoder.h"
 
+#include <pv/view/logicsignal.h>
 #include <pv/view/signal.h>
 
 using namespace boost;
@@ -33,10 +40,10 @@ namespace pv {
 namespace dialogs {
 
 Decoder::Decoder(QWidget *parent, const srd_decoder *decoder,
-       const vector< shared_ptr<view::Signal> > &sigs) :
+       const vector< shared_ptr<view::Signal> > &sigs, GHashTable *options) :
        QDialog(parent),
-       _decoder(decoder),
        _sigs(sigs),
+       _binding(decoder, options),
        _layout(this),
        _form(this),
        _form_layout(&_form),
@@ -62,7 +69,7 @@ Decoder::Decoder(QWidget *parent, const srd_decoder *decoder,
        _layout.addWidget(&_form);
        _layout.addWidget(&_button_box);
 
-       _form_layout.addRow(new QLabel("<h3>Probes</h3>", &_form));
+       _form_layout.addRow(new QLabel(tr("<h3>Probes</h3>"), &_form));
 
        // Add the mandatory probes
        for(probe = decoder->probes; probe; probe = probe->next) {
@@ -90,6 +97,19 @@ Decoder::Decoder(QWidget *parent, const srd_decoder *decoder,
 
        _form_layout.addRow(new QLabel(
                tr("<i>* Required Probes</i>"), &_form));
+
+       // Add the options
+       if (!_binding.properties().empty()) {
+               _form_layout.addRow(new QLabel(tr("<h3>Options</h3>"),
+                       &_form));
+               _binding.add_properties_to_form(&_form_layout);
+       }
+}
+
+void Decoder::accept()
+{
+       QDialog::accept();
+       _binding.commit();
 }
 
 QComboBox* Decoder::create_probe_selector(
@@ -115,5 +135,28 @@ QComboBox* Decoder::create_probe_selector(
        return selector;
 }
 
+map<const srd_probe*, shared_ptr<view::Signal> > Decoder::get_probes()
+{
+       map<const srd_probe*, shared_ptr<view::Signal> > probe_map;
+       for(map<const srd_probe*, QComboBox*>::const_iterator i =
+               _probe_selector_map.begin();
+               i != _probe_selector_map.end(); i++)
+       {
+               const QComboBox *const combo = (*i).second;
+               const int probe_index =
+                       combo->itemData(combo->currentIndex()).value<int>();
+               if(probe_index >= 0) {
+                       shared_ptr<view::Signal> sig = _sigs[probe_index];
+                       if(dynamic_cast<pv::view::LogicSignal*>(sig.get()))
+                               probe_map[(*i).first] = sig;
+                       else
+                               qDebug() << "Currently only logic signals "
+                                       "are supported for decoding";
+               }
+       }
+
+       return probe_map;
+}
+
 } // namespace dialogs
 } // namespace pv