When the decode trace label changed, the decoder list view will be updated

This commit is contained in:
dreamsourcelabTAI 2023-05-24 16:37:50 +08:00
parent 98a4f5f99b
commit 9b3a025a96
8 changed files with 59 additions and 7 deletions

View File

@ -388,7 +388,9 @@ bool ProtocolDock::add_protocol_by_id(QString id, bool silent, std::list<pv::dat
protocolId = QString((*it)->decoder()->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::list<pv::dat
_top_layout->insertLayout(_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

View File

@ -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();

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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");

View File

@ -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<pv::data::decode::Decoder *> &sub_decoders)
std::list<pv::data::decode::Decoder *> &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)

View File

@ -202,7 +202,7 @@ public:
std::vector<view::Signal*>& get_signals();
bool add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus,
std::list<pv::data::decode::Decoder*> &sub_decoders);
std::list<pv::data::decode::Decoder*> &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<SessionData*> _data_list;
IDecoderPannel *_decoder_pannel;
private:
// TODO: This should not be necessary. Multiple concurrent