+void View::update_data()
+{
+ if (!signal_) {
+ hex_view_->clear();
+ return;
+ }
+
+ if (signal_->get_binary_data_chunk_count(current_segment_, decoder_, bin_class_id_) == 0) {
+ hex_view_->clear();
+ return;
+ }
+
+ const DecodeBinaryClass* bin_class =
+ signal_->get_binary_data_class(current_segment_, decoder_, bin_class_id_);
+
+ hex_view_->setData(bin_class);
+}
+
+void View::on_selected_decoder_changed(int index)
+{
+ if (signal_)
+ disconnect(signal_, SIGNAL(new_binary_data(unsigned int, void*, unsigned int)));
+
+ decoder_ = (Decoder*)decoder_selector_->itemData(index).value<void*>();
+
+ // Find the signal that contains the selected decoder
+ signal_ = nullptr;
+
+ for (const shared_ptr<DecodeSignal>& ds : decode_signals_)
+ for (const shared_ptr<Decoder>& dec : ds->decoder_stack())
+ if (decoder_ == dec.get())
+ signal_ = ds.get();
+
+ class_selector_->clear();
+
+ if (signal_) {
+ // Populate binary class selector
+ uint8_t bin_classes = decoder_->get_binary_class_count();
+ for (uint8_t i = 0; i < bin_classes; i++) {
+ const data::decode::DecodeBinaryClassInfo* class_info = decoder_->get_binary_class(i);
+ class_selector_->addItem(class_info->name, QVariant::fromValue(i));
+ }
+
+ connect(signal_, SIGNAL(new_binary_data(unsigned int, void*, unsigned int)),
+ this, SLOT(on_new_binary_data(unsigned int, void*, unsigned int)));
+ }
+
+ update_data();
+}
+
+void View::on_selected_class_changed(int index)
+{
+ bin_class_id_ = class_selector_->itemData(index).value<uint8_t>();
+
+ update_data();
+}
+
+void View::on_signal_name_changed(const QString &name)
+{
+ (void)name;
+
+ SignalBase* sb = qobject_cast<SignalBase*>(QObject::sender());
+ assert(sb);
+
+ DecodeSignal* signal = dynamic_cast<DecodeSignal*>(sb);
+ assert(signal);
+
+ // Update all decoder entries provided by this signal
+ auto stack = signal->decoder_stack();
+ if (stack.size() > 1) {
+ for (const shared_ptr<Decoder>& dec : stack) {
+ QString title = QString("%1 (%2)").arg(signal->name(), dec->name());
+ int index = decoder_selector_->findData(QVariant::fromValue((void*)dec.get()));
+
+ if (index != -1)
+ decoder_selector_->setItemText(index, title);
+ }
+ } else
+ if (!stack.empty()) {
+ shared_ptr<Decoder>& dec = stack.at(0);
+ int index = decoder_selector_->findData(QVariant::fromValue((void*)dec.get()));
+
+ if (index != -1)
+ decoder_selector_->setItemText(index, signal->name());
+ }
+}
+
+void View::on_new_binary_data(unsigned int segment_id, void* decoder, unsigned int bin_class_id)
+{
+ if ((segment_id == current_segment_) && (decoder == decoder_) && (bin_class_id == bin_class_id_))
+ update_data();
+}
+
+void View::on_decoder_stacked(void* decoder)
+{
+ // TODO This doesn't change existing entries for the same signal - but it should as the naming scheme may change
+
+ Decoder* d = static_cast<Decoder*>(decoder);
+
+ // Only add the decoder if it has binary output
+ if (d->get_binary_class_count() == 0)
+ return;
+
+ // Find the signal that contains the selected decoder
+ DecodeSignal* signal = nullptr;
+
+ for (const shared_ptr<DecodeSignal>& ds : decode_signals_)
+ for (const shared_ptr<Decoder>& dec : ds->decoder_stack())
+ if (d == dec.get())
+ signal = ds.get();
+
+ assert(signal);
+
+ // Add the decoder to the list
+ QString title = QString("%1 (%2)").arg(signal->name(), d->name());
+ decoder_selector_->addItem(title, QVariant::fromValue((void*)d));
+}
+
+void View::on_decoder_removed(void* decoder)