]> sigrok.org Git - pulseview.git/commitdiff
DecoderOutput: Add format selector
authorSoeren Apel <redacted>
Fri, 29 Nov 2019 22:36:56 +0000 (23:36 +0100)
committerSoeren Apel <redacted>
Fri, 29 Nov 2019 22:36:56 +0000 (23:36 +0100)
pv/views/decoder_output/view.cpp
pv/views/decoder_output/view.hpp

index d407747605e8f03a8ec9948bb5ac0a8d7af7b545..fdf4bc7d5950debdb1426ca22d371075d1b87877 100644 (file)
@@ -43,7 +43,8 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) :
        ViewBase(session, is_main_view, parent),
 
        // Note: Place defaults in View::reset_view_state(), not here
-       signal_selector_(new QComboBox())
+       signal_selector_(new QComboBox()),
+       format_selector_(new QComboBox())
 {
        QVBoxLayout *root_layout = new QVBoxLayout(this);
        root_layout->setContentsMargins(0, 0, 0, 0);
@@ -56,6 +57,12 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) :
        // Populate toolbar
        toolbar->addWidget(new QLabel(tr("Decoder:")));
        toolbar->addWidget(signal_selector_);
+       toolbar->addSeparator();
+       toolbar->addWidget(new QLabel(tr("Show data as")));
+       toolbar->addWidget(format_selector_);
+
+       // Add format types
+       format_selector_->addItem(tr("Hexdump"), qVariantFromValue(QString("text/hexdump")));
 
        reset_view_state();
 }
@@ -82,6 +89,7 @@ void View::clear_signals()
 void View::clear_decode_signals()
 {
        signal_selector_->clear();
+       format_selector_->setCurrentIndex(0);
 }
 
 void View::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
@@ -89,12 +97,12 @@ void View::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
        connect(signal.get(), SIGNAL(name_changed(const QString&)),
                this, SLOT(on_signal_name_changed(const QString&)));
 
-       signal_selector_->addItem(signal->name(), qVariantFromValue(signal.get()));
+       signal_selector_->addItem(signal->name(), QVariant::fromValue(signal.get()));
 }
 
 void View::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
 {
-       int index = signal_selector_->findData(qVariantFromValue(signal.get()));
+       int index = signal_selector_->findData(QVariant::fromValue(signal.get()));
 
        if (index != -1)
                signal_selector_->removeItem(index);
@@ -117,7 +125,7 @@ void View::on_signal_name_changed(const QString &name)
        SignalBase *sb = qobject_cast<SignalBase*>(QObject::sender());
        assert(sb);
 
-       int index = signal_selector_->findData(qVariantFromValue(sb));
+       int index = signal_selector_->findData(QVariant::fromValue(sb));
        if (index != -1)
                signal_selector_->setItemText(index, name);
 }
index 4f772c822d01c99d30cb2cd17742a68345b7b5a6..cd90b5ca8fb642d11393b9385bbf5838e895be37 100644 (file)
@@ -62,7 +62,7 @@ private Q_SLOTS:
        void on_signal_name_changed(const QString &name);
 
 private:
-       QComboBox *signal_selector_;
+       QComboBox *signal_selector_, *format_selector_;
 };
 
 } // namespace decoder_output