+ const vector<int32_t> trig_types = get_trigger_types();
+
+ if (!trig_types.empty()) {
+ trigger_bar_ = new QToolBar(parent);
+ init_trigger_actions(trigger_bar_);
+ trigger_bar_->addAction(trigger_none_);
+ trigger_none_->setChecked(!trigger_match_);
+
+ for (auto type_id : trig_types) {
+ const TriggerMatchType *const type =
+ TriggerMatchType::get(type_id);
+ QAction *const action = action_from_trigger_type(type);
+ trigger_bar_->addAction(action);
+ action->setChecked(trigger_match_ == type);
+ }
+ form->addRow(tr("Trigger"), trigger_bar_);
+ }
+}
+
+void LogicSignal::modify_trigger()
+{
+ auto trigger = session_.session()->trigger();
+ auto new_trigger = session_.device_manager().context()->create_trigger("pulseview");
+
+ if (trigger) {
+ for (auto stage : trigger->stages()) {
+ const auto &matches = stage->matches();
+ if (std::none_of(matches.begin(), matches.end(),
+ [&](shared_ptr<TriggerMatch> match) {
+ return match->channel() != base_->channel(); }))
+ continue;
+
+ auto new_stage = new_trigger->add_stage();
+ for (auto match : stage->matches()) {
+ if (match->channel() == base_->channel())
+ continue;
+ new_stage->add_match(match->channel(), match->type());
+ }
+ }
+ }
+
+ if (trigger_match_) {
+ // Until we can let the user decide how to group trigger matches
+ // into stages, put all of the matches into a single stage --
+ // most devices only support a single trigger stage.
+ if (new_trigger->stages().empty())
+ new_trigger->add_stage();
+
+ new_trigger->stages().back()->add_match(base_->channel(),
+ trigger_match_);