diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index cc3af8c4..fca1225c 100644 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -388,7 +388,9 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::listdecoder()->id); } - if (_session->add_decoder(decoder, silent, dstatus, sub_decoders) == false){ + pv::view::Trace *trace = NULL; + + if (_session->add_decoder(decoder, silent, dstatus, sub_decoders, trace) == false){ return false; } @@ -398,6 +400,7 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::listinsertLayout(_protocol_lay_items.size(), layer); layer->m_decoderStatus = dstatus; layer->m_protocolId = protocolId; + layer->_trace = trace; // set current protocol format string fmt = AppConfig::Instance().GetProtocolFormat(protocolId.toStdString()); @@ -1015,5 +1018,15 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod _pro_search_button->setEnabled(bEnable); } + void ProtocolDock::update_deocder_item_name(void *trace_handel, const char *name) + { + for(auto p : _protocol_lay_items){ + if (p->_trace == trace_handel){ + p->set_label_name(QString(name)); + break; + } + } + } + } // namespace dock } // namespace pv diff --git a/DSView/pv/dock/protocoldock.h b/DSView/pv/dock/protocoldock.h index 0da3f687..c90c3e43 100644 --- a/DSView/pv/dock/protocoldock.h +++ b/DSView/pv/dock/protocoldock.h @@ -44,7 +44,8 @@ #include "../data/decodermodel.h" #include "protocolitemlayer.h" #include "keywordlineedit.h" -#include "searchcombobox.h" +#include "searchcombobox.h" +#include "../interface/icallbacks.h" struct DecoderInfoItem{ void *_data_handle; //srd_decoder* type @@ -70,7 +71,8 @@ namespace dock { class ProtocolDock : public QScrollArea, public IProtocolItemLayerCallback, public IKeywordActive, -public ISearchItemClick +public ISearchItemClick, +public IDecoderPannel { Q_OBJECT @@ -108,7 +110,10 @@ private: void BeginEditKeyword(); //ISearchItemClick - void OnItemClick(void *sender, void *data_handle); + void OnItemClick(void *sender, void *data_handle); + + //IDecoderPannel + void update_deocder_item_name(void *trace_handel, const char *name); signals: void protocol_updated(); diff --git a/DSView/pv/dock/protocolitemlayer.cpp b/DSView/pv/dock/protocolitemlayer.cpp index 64530732..64ed1c51 100644 --- a/DSView/pv/dock/protocolitemlayer.cpp +++ b/DSView/pv/dock/protocolitemlayer.cpp @@ -35,6 +35,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro _protocolName = protocolName; m_bSetting = false; m_decoderStatus = NULL; + _trace = NULL; _protocol_label = new QLabel(parent); _progress_label = new QLabel(parent); @@ -155,5 +156,10 @@ void ProtocolItemLayer::LoadFormatSelect(bool bSingle) _format_combox->setDisabled(!flag); } + void ProtocolItemLayer::set_label_name(QString name) + { + _protocol_label->setText(name); + } + } //dock } //pv diff --git a/DSView/pv/dock/protocolitemlayer.h b/DSView/pv/dock/protocolitemlayer.h index 1c6bd32d..b4e93bca 100644 --- a/DSView/pv/dock/protocolitemlayer.h +++ b/DSView/pv/dock/protocolitemlayer.h @@ -30,6 +30,11 @@ class DecoderStatus; namespace pv{ + +namespace view{ + class Trace; +} + namespace dock{ class IProtocolItemLayerCallback @@ -59,6 +64,8 @@ public: } void enable_format(bool flag); + + void set_label_name(QString name); private slots: void on_set_protocol(); @@ -68,6 +75,7 @@ private slots: public: DecoderStatus *m_decoderStatus; //DecoderStatus QString m_protocolId; + pv::view::Trace *_trace; private: QLabel *_protocol_label; diff --git a/DSView/pv/interface/icallbacks.h b/DSView/pv/interface/icallbacks.h index f641409a..c5213dda 100644 --- a/DSView/pv/interface/icallbacks.h +++ b/DSView/pv/interface/icallbacks.h @@ -102,4 +102,10 @@ public: virtual void OnMessage(int msg)=0; }; +class IDecoderPannel +{ +public: + virtual void update_deocder_item_name(void *trace_handel, const char *name)=0; +}; + #endif diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 8273627c..0e8f57db 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -186,6 +186,8 @@ namespace pv _protocol_widget = new dock::ProtocolDock(_protocol_dock, *_view, _session); _protocol_dock->setWidget(_protocol_widget); + _session->set_decoder_pannel(_protocol_widget); + // measure dock _measure_dock = new QDockWidget(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_MEASURE_DOCK_TITLE), "Measurement"), this); _measure_dock->setObjectName("measure_dock"); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 3eaeeaca..210129f6 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -98,6 +98,7 @@ namespace pv _capture_data = NULL; _is_stream_mode = false; _is_action = false; + _decoder_pannel = NULL; _data_list.push_back(new SessionData()); _data_list.push_back(new SessionData()); @@ -1376,15 +1377,16 @@ namespace pv } bool SigSession::add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus, - std::list &sub_decoders) + std::list &sub_decoders, view::Trace* &out_trace) { - if (dec == NULL) { dsv_err("%s", "Decoder instance is null!"); assert(false); } + out_trace = NULL; + dsv_info("Create new decoder,name:\"%s\",id:\"%s\"", dec->name, dec->id); try @@ -1457,6 +1459,8 @@ namespace pv signals_changed(); data_updated(); + + out_trace = trace; } else { @@ -2281,6 +2285,9 @@ namespace pv { _device_agent.set_channel_name(trace->get_index(), name.toUtf8()); } + else if (traceType == SR_CHANNEL_DECODER && _decoder_pannel != NULL){ + _decoder_pannel->update_deocder_item_name(trace, name.toUtf8().data()); + } } void SigSession::set_decoder_row_label(int index, QString label) diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 5a6edc5d..f09e67b4 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -202,7 +202,7 @@ public: std::vector& get_signals(); bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus, - std::list &sub_decoders); + std::list &sub_decoders, view::Trace* &out_trace); int get_trace_index_by_key_handel(void *handel); void remove_decoder(int index); void remove_decoder_by_key_handel(void *handel); @@ -424,6 +424,10 @@ public: void set_trace_name(view::Trace *trace, QString name); void set_decoder_row_label(int index, QString label); + inline void set_decoder_pannel(IDecoderPannel *pannel){ + _decoder_pannel = pannel; + } + private: void set_cur_samplelimits(uint64_t samplelimits); void set_cur_snap_samplerate(uint64_t samplerate); @@ -579,6 +583,7 @@ private: SessionData *_view_data; SessionData *_capture_data; std::vector _data_list; + IDecoderPannel *_decoder_pannel; private: // TODO: This should not be necessary. Multiple concurrent