From: Joel Holdsworth Date: Sun, 23 Nov 2014 18:10:09 +0000 (+0000) Subject: LogicSignal: Refactored get_trigger_types X-Git-Tag: pulseview-0.3.0~426 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=77817b43ee7cf9f65d1d1fb8e71495347bd925fd;p=pulseview.git LogicSignal: Refactored get_trigger_types --- diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index aa581d0a..c58b85d9 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -272,6 +272,18 @@ void LogicSignal::init_trigger_actions(QWidget *parent) connect(trigger_change_, SIGNAL(triggered()), this, SLOT(on_trigger())); } +const vector LogicSignal::get_trigger_types() const +{ + try { + const Glib::VariantContainerBase gvar = + device_->config_list(ConfigKey::TRIGGER_MATCH); + return Glib::VariantBase::cast_dynamic< + Glib::Variant>>(gvar).get(); + } catch (Error e) { + return vector(); + } +} + QAction* LogicSignal::action_from_trigger_type(const TriggerMatchType *type) { QAction *action; @@ -320,24 +332,14 @@ const TriggerMatchType *LogicSignal::trigger_type_from_action(QAction *action) void LogicSignal::populate_popup_form(QWidget *parent, QFormLayout *form) { - Glib::VariantContainerBase gvar; - vector trig_types; - Signal::populate_popup_form(parent, form); - try { - gvar = device_->config_list(ConfigKey::TRIGGER_MATCH); - } catch (Error e) { - return; - } - trigger_bar_ = new QToolBar(parent); init_trigger_actions(trigger_bar_); trigger_bar_->addAction(trigger_none_); trigger_none_->setChecked(!trigger_match_); - trig_types = - Glib::VariantBase::cast_dynamic>>( - gvar).get(); + + const vector trig_types = get_trigger_types(); for (auto type_id : trig_types) { const TriggerMatchType *const type = TriggerMatchType::get(type_id); diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index 30dea6f4..6d6d89aa 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -98,6 +98,7 @@ private: void init_trigger_actions(QWidget *parent); + const std::vector get_trigger_types() const; QAction* action_from_trigger_type( const sigrok::TriggerMatchType *match); const sigrok::TriggerMatchType* trigger_type_from_action(