2
0
forked from Ivasoft/DSView

Decode trace label is named using the top decoder's name

This commit is contained in:
dreamsourcelabTAI
2023-05-24 15:51:44 +08:00
parent bd4c037af2
commit 98a4f5f99b
4 changed files with 36 additions and 24 deletions

View File

@@ -1415,6 +1415,15 @@ namespace pv
{
trace->decoder()->add_sub_decoder(sub);
}
if (sub_decoders.size() > 0){
auto lst_sub = sub_decoders.end();
lst_sub--;
QString sub_dec_name((*lst_sub)->decoder()->name);
if (sub_dec_name != "")
trace->set_name(sub_dec_name);
}
sub_decoders.clear();
// set view early for decode start/end region setting
@@ -2212,14 +2221,6 @@ namespace pv
}
}
void SigSession::set_decoder_row_label(int index, QString label)
{
auto trace = get_decoder_trace(index);
if (trace != NULL){
trace->set_name(label);
}
}
void SigSession::clear_signals()
{
DESTROY_OBJECT(_math_trace);
@@ -2268,4 +2269,26 @@ namespace pv
data_updated();
}
void SigSession::set_trace_name(view::Trace *trace, QString name)
{
assert(trace);
trace->set_name(name);
int traceType = trace->get_type();
if (traceType == SR_CHANNEL_LOGIC || traceType == SR_CHANNEL_ANALOG)
{
_device_agent.set_channel_name(trace->get_index(), name.toUtf8());
}
}
void SigSession::set_decoder_row_label(int index, QString label)
{
auto trace = get_decoder_trace(index);
if (trace != NULL){
trace->set_name(label);
}
}
} // namespace pv

View File

@@ -406,9 +406,6 @@ public:
void add_msg_listener(IMessageListener *ln);
void broadcast_msg(int msg);
bool have_new_realtime_refresh(bool keep);
void set_decoder_row_label(int index, QString label);
view::DecodeTrace* get_decoder_trace(int index);
view::Signal* get_signal_by_index(int index);
@@ -424,6 +421,8 @@ public:
}
void clear_view_data();
void set_trace_name(view::Trace *trace, QString name);
void set_decoder_row_label(int index, QString label);
private:
void set_cur_samplelimits(uint64_t samplelimits);

View File

@@ -214,11 +214,6 @@ void DecodeTrace::paint_back(QPainter &p, int left, int right, QColor fore, QCol
QFont font=p.font();
font.setPointSize(DefaultFontSize);
p.setFont(font);
// p.setPen(QApplication::palette().color(QPalette::Base));
// for (int dx = -1; dx <= 1; dx++)
// for (int dy = -1; dy <= 1; dy++)
// if (dx != 0 && dy != 0)
// p.drawText(r.translated(dx, dy), f, h);
// Draw the text
p.setPen(fore);

View File

@@ -445,15 +445,10 @@ void Header::on_action_set_name_triggered()
if (nameEdit->isModified()) {
QString v = nameEdit->text().trimmed();
if (v == ""){
if (v == "")
v = QString::number(context_Trace->get_index());
}
context_Trace->set_name(v);
if (context_Trace->get_type() == SR_CHANNEL_LOGIC ||
context_Trace->get_type() == SR_CHANNEL_ANALOG)
{
_view.session().get_device()->set_channel_name(context_Trace->get_index(), v.toUtf8());
}
_view.session().set_trace_name(context_Trace, v);
}
nameEdit->hide();