]> sigrok.org Git - pulseview.git/commitdiff
LogicSignal: Refactored get_trigger_types
authorJoel Holdsworth <redacted>
Sun, 23 Nov 2014 18:10:09 +0000 (18:10 +0000)
committerJoel Holdsworth <redacted>
Sun, 23 Nov 2014 18:10:09 +0000 (18:10 +0000)
pv/view/logicsignal.cpp
pv/view/logicsignal.hpp

index aa581d0a4955351c0738b00ba0fb396c9da3eb64..c58b85d9857a2a622c6e7cf51b3674be7b77a48a 100644 (file)
@@ -272,6 +272,18 @@ void LogicSignal::init_trigger_actions(QWidget *parent)
        connect(trigger_change_, SIGNAL(triggered()), this, SLOT(on_trigger()));
 }
 
+const vector<int32_t> LogicSignal::get_trigger_types() const
+{
+       try {
+               const Glib::VariantContainerBase gvar =
+                       device_->config_list(ConfigKey::TRIGGER_MATCH);
+               return Glib::VariantBase::cast_dynamic<
+                       Glib::Variant<vector<int32_t>>>(gvar).get();
+       } catch (Error e) {
+               return vector<int32_t>();
+       }
+}
+
 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<int32_t> 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<Glib::Variant<vector<int32_t>>>(
-                       gvar).get();
+
+       const vector<int32_t> trig_types = get_trigger_types();
        for (auto type_id : trig_types) {
                const TriggerMatchType *const type =
                        TriggerMatchType::get(type_id);
index 30dea6f4fb39c9d271c7448d44d52d2713d491ca..6d6d89aa3420d66697d47cbbee89fe4e29f177e2 100644 (file)
@@ -98,6 +98,7 @@ private:
 
        void init_trigger_actions(QWidget *parent);
 
+       const std::vector<int32_t> get_trigger_types() const;
        QAction* action_from_trigger_type(
                const sigrok::TriggerMatchType *match);
        const sigrok::TriggerMatchType* trigger_type_from_action(