forked from Ivasoft/DSView
update: decoder options dialog
This commit is contained in:
@@ -249,6 +249,7 @@ set(DSView_SOURCES
|
||||
pv/dialogs/applicationpardlg.cpp
|
||||
pv/dock/keywordlineedit.cpp
|
||||
pv/dock/searchcombobox.cpp
|
||||
pv/dialogs/decoderoptionsdlg.cpp
|
||||
)
|
||||
|
||||
set(DSView_HEADERS
|
||||
@@ -334,6 +335,7 @@ set(DSView_HEADERS
|
||||
pv/dialogs/applicationpardlg.h
|
||||
pv/dock/keywordlineedit.h
|
||||
pv/dock/searchcombobox.h
|
||||
pv/dialogs/decoderoptionsdlg.h
|
||||
)
|
||||
|
||||
set(DSView_FORMS
|
||||
|
||||
@@ -293,8 +293,11 @@ void ProtocolDock::resizeEvent(QResizeEvent *event)
|
||||
_dn_search_layout->spacing() * 2 -
|
||||
_pre_button->width()-_nxt_button->width();
|
||||
width = std::max(width, 0);
|
||||
|
||||
_search_edit->setMinimumWidth(width);
|
||||
_keyword_edit->setMinimumWidth(width-20);
|
||||
width = std::max(width-20, 0);
|
||||
_keyword_edit->setMinimumWidth(width);
|
||||
|
||||
QScrollArea::resizeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "searchcombobox.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef SEARCHCOMBOBOX_H
|
||||
#define SEARCHCOMBOBOX_H
|
||||
|
||||
|
||||
@@ -1363,7 +1363,7 @@ bool SigSession::add_decoder(srd_decoder *const dec, bool silent, DecoderStatus
|
||||
|
||||
if (silent) {
|
||||
ret = true;
|
||||
} else if (trace->create_popup()) {
|
||||
} else if (trace->create_popup(true)) {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
@@ -1440,7 +1440,7 @@ void SigSession::rst_decoder(int index)
|
||||
{
|
||||
auto trace = get_decoder_trace(index);
|
||||
|
||||
if (trace && trace->create_popup() ){
|
||||
if (trace && trace->create_popup(false) ){
|
||||
remove_decode_task(trace); //remove old task
|
||||
trace->decoder()->clear();
|
||||
add_decode_task(trace);
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "../ui/dscombobox.h"
|
||||
#include "../ui/msgbox.h"
|
||||
#include "../appcontrol.h"
|
||||
#include "../dialogs/decoderoptionsdlg.h"
|
||||
#include <QDebug>
|
||||
|
||||
using namespace boost;
|
||||
@@ -126,19 +127,14 @@ DecodeTrace::DecodeTrace(pv::SigSession *session,
|
||||
assert(decoder_stack);
|
||||
|
||||
_colour = DecodeColours[index % countof(DecodeColours)];
|
||||
_start_comboBox = NULL;
|
||||
_end_comboBox = NULL;
|
||||
|
||||
_pub_input_layer = NULL;
|
||||
_progress = 0;
|
||||
|
||||
_decode_start = 0;
|
||||
_decode_end = INT64_MAX;
|
||||
_end_count = 0;
|
||||
_start_count = 0;
|
||||
_end_index = 0;
|
||||
_start_index = 0;
|
||||
_decoder_container = NULL;
|
||||
_form_base_height = 0;
|
||||
_start_index = 0;
|
||||
|
||||
_decoder_stack = decoder_stack;
|
||||
_session = session;
|
||||
@@ -150,11 +146,9 @@ DecodeTrace::DecodeTrace(pv::SigSession *session,
|
||||
}
|
||||
|
||||
DecodeTrace::~DecodeTrace()
|
||||
{ _cur_row_headings.clear();
|
||||
_decoder_forms.clear();
|
||||
_probe_selectors.clear();
|
||||
_bindings.clear();
|
||||
|
||||
{
|
||||
_cur_row_headings.clear();
|
||||
|
||||
DESTROY_OBJECT(_decoder_stack);
|
||||
}
|
||||
|
||||
@@ -162,12 +156,7 @@ bool DecodeTrace::enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
pv::data::DecoderStack* DecodeTrace::decoder()
|
||||
{
|
||||
return _decoder_stack;
|
||||
}
|
||||
|
||||
|
||||
void DecodeTrace::set_view(pv::view::View *view)
|
||||
{
|
||||
assert(view);
|
||||
@@ -350,161 +339,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right, QColor fore, QCol
|
||||
(void)fore;
|
||||
(void)back;
|
||||
}
|
||||
|
||||
//to show decoder's property setting dialog
|
||||
bool DecodeTrace::create_popup()
|
||||
{
|
||||
int ret = false; //setting have changed flag
|
||||
_form_base_height = 0;
|
||||
_decoder_container = NULL;
|
||||
|
||||
QWidget *topWindow = AppControl::Instance()->GetTopWindow();
|
||||
dialogs::DSDialog dlg(topWindow);
|
||||
//dlg.setMinimumSize(500,600);
|
||||
create_popup_form(&dlg);
|
||||
|
||||
if (QDialog::Accepted == dlg.exec())
|
||||
{
|
||||
for(auto &dec : _decoder_stack->stack())
|
||||
{
|
||||
if (dec->commit() || _decoder_stack->options_changed()) {
|
||||
_decoder_stack->set_options_changed(true);
|
||||
_decode_start = dec->decode_start();
|
||||
_decode_end = dec->decode_end();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_decoder_container = NULL;
|
||||
_decoder_panels.clear();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DecodeTrace::create_popup_form(dialogs::DSDialog *dlg)
|
||||
{
|
||||
// Transfer the layout and the child widgets to a temporary widget
|
||||
// which then goes out of scope destroying the layout and all the child
|
||||
// widgets.
|
||||
QFormLayout *form = new QFormLayout();
|
||||
form->setVerticalSpacing(5);
|
||||
form->setFormAlignment(Qt::AlignLeft);
|
||||
form->setLabelAlignment(Qt::AlignLeft);
|
||||
form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
|
||||
_decoder_container = new QWidget(dlg);
|
||||
dlg->layout()->addWidget(_decoder_container);
|
||||
|
||||
QVBoxLayout *decoder_lay = new QVBoxLayout();
|
||||
decoder_lay->setContentsMargins(0, 0, 0, 0);
|
||||
decoder_lay->setDirection(QBoxLayout::TopToBottom);
|
||||
_decoder_container->setLayout(decoder_lay);
|
||||
|
||||
dlg->layout()->addLayout(form);
|
||||
dlg->setTitle(tr("Decoder Options"));
|
||||
|
||||
populate_popup_form(dlg, form);
|
||||
}
|
||||
|
||||
void DecodeTrace::load_all_decoder_property(std::list<pv::data::decode::Decoder*> &ls)
|
||||
{
|
||||
assert(_decoder_container);
|
||||
QVBoxLayout *lay = dynamic_cast<QVBoxLayout*>(_decoder_container->layout());
|
||||
assert(lay);
|
||||
|
||||
for(auto &dec : ls)
|
||||
{
|
||||
QWidget *panel = new QWidget(_decoder_container);
|
||||
QFormLayout *form = new QFormLayout();
|
||||
form->setContentsMargins(0,0,0,0);
|
||||
panel->setLayout(form);
|
||||
lay->addWidget(panel);
|
||||
|
||||
create_decoder_form(_decoder_stack, dec, panel, form);
|
||||
|
||||
//spacing
|
||||
if (ls.size() > 1){
|
||||
QWidget *spc = new QWidget();
|
||||
spc->setMinimumHeight(15);
|
||||
lay->addWidget(spc);
|
||||
}
|
||||
|
||||
decoder_panel_item inf;
|
||||
inf.decoder_handle = dec;
|
||||
inf.panel = panel;
|
||||
inf.panel_height = 0;
|
||||
_decoder_panels.push_back(inf);
|
||||
}
|
||||
}
|
||||
|
||||
void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
|
||||
{
|
||||
using pv::data::decode::Decoder;
|
||||
|
||||
assert(form);
|
||||
assert(parent);
|
||||
assert(_decoder_stack);
|
||||
|
||||
// Add the decoder options
|
||||
_bindings.clear();
|
||||
_probe_selectors.clear();
|
||||
_decoder_forms.clear();
|
||||
|
||||
load_all_decoder_property(_decoder_stack->stack());
|
||||
|
||||
if (_decoder_stack->stack().size() > 0){
|
||||
form->addRow(new QLabel(tr("<i>* Required channels</i>"), parent));
|
||||
}
|
||||
|
||||
//Add region combobox
|
||||
_start_comboBox = new DsComboBox(parent);
|
||||
_end_comboBox = new DsComboBox(parent);
|
||||
_start_comboBox->addItem(RegionStart);
|
||||
_end_comboBox->addItem(RegionEnd);
|
||||
|
||||
if (_view) {
|
||||
int index = 1;
|
||||
for(std::list<Cursor*>::iterator i = _view->get_cursorList().begin();
|
||||
i != _view->get_cursorList().end(); i++) {
|
||||
QString curCursor = tr("Cursor ")+QString::number(index);
|
||||
_start_comboBox->addItem(curCursor);
|
||||
_end_comboBox->addItem(curCursor);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (_start_count > _start_comboBox->count())
|
||||
_start_index = 0;
|
||||
if (_end_count > _end_comboBox->count())
|
||||
_end_index = 0;
|
||||
_start_count = _start_comboBox->count();
|
||||
_end_count = _end_comboBox->count();
|
||||
|
||||
_start_comboBox->setCurrentIndex(_start_index);
|
||||
_end_comboBox->setCurrentIndex(_end_index);
|
||||
|
||||
on_region_set(_start_index);
|
||||
form->addRow(_start_comboBox, new QLabel(
|
||||
tr("Decode Start From")));
|
||||
form->addRow(_end_comboBox, new QLabel(
|
||||
tr("Decode End to")));
|
||||
|
||||
|
||||
// Add ButtonBox (OK/Cancel)
|
||||
QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
|
||||
Qt::Horizontal, parent);
|
||||
|
||||
|
||||
QHBoxLayout *confirm_button_box = new QHBoxLayout;
|
||||
confirm_button_box->addWidget(button_box, 0, Qt::AlignRight);
|
||||
form->addRow(confirm_button_box);
|
||||
|
||||
connect(_start_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_region_set(int)));
|
||||
connect(_end_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_region_set(int)));
|
||||
connect(button_box, SIGNAL(accepted()), parent, SLOT(accept()));
|
||||
connect(button_box, SIGNAL(rejected()), parent, SLOT(reject()));
|
||||
}
|
||||
|
||||
void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
|
||||
QPainter &p, QColor text_color, int h, int left, int right,
|
||||
double samples_per_pixel, double pixels_offset, int y,
|
||||
@@ -723,138 +558,7 @@ void DecodeTrace::draw_unshown_row(QPainter &p, int y, int h, int left,
|
||||
p.setPen(fore);
|
||||
p.drawText(unshown_rect, Qt::AlignCenter | Qt::AlignVCenter, info);
|
||||
}
|
||||
|
||||
void DecodeTrace::create_decoder_form(
|
||||
pv::data::DecoderStack *decoder_stack,
|
||||
data::decode::Decoder *dec, QWidget *parent,
|
||||
QFormLayout *form)
|
||||
{
|
||||
const GSList *l;
|
||||
|
||||
assert(dec);
|
||||
assert(decoder_stack);
|
||||
|
||||
const srd_decoder *const decoder = dec->decoder();
|
||||
assert(decoder);
|
||||
|
||||
QFormLayout *const decoder_form = new QFormLayout();
|
||||
decoder_form->setContentsMargins(0,0,0,0);
|
||||
decoder_form->setVerticalSpacing(5);
|
||||
decoder_form->setFormAlignment(Qt::AlignLeft);
|
||||
decoder_form->setLabelAlignment(Qt::AlignLeft);
|
||||
decoder_form->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
|
||||
// Add the mandatory channels
|
||||
for(l = decoder->channels; l; l = l->next) {
|
||||
const struct srd_channel *const pdch =
|
||||
(struct srd_channel *)l->data;
|
||||
DsComboBox *const combo = create_probe_selector(parent, dec, pdch);
|
||||
|
||||
decoder_form->addRow(tr("<b>%1</b> (%2) *")
|
||||
.arg(QString::fromUtf8(pdch->name))
|
||||
.arg(QString::fromUtf8(pdch->desc)), combo);
|
||||
|
||||
const ProbeSelector s = {combo, dec, pdch};
|
||||
_probe_selectors.push_back(s);
|
||||
|
||||
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_probe_selected(int)));
|
||||
}
|
||||
|
||||
// Add the optional channels
|
||||
for(l = decoder->opt_channels; l; l = l->next) {
|
||||
const struct srd_channel *const pdch =
|
||||
(struct srd_channel *)l->data;
|
||||
DsComboBox *const combo = create_probe_selector(parent, dec, pdch);
|
||||
|
||||
decoder_form->addRow(tr("<b>%1</b> (%2)")
|
||||
.arg(QString::fromUtf8(pdch->name))
|
||||
.arg(QString::fromUtf8(pdch->desc)), combo);
|
||||
|
||||
const ProbeSelector s = {combo, dec, pdch};
|
||||
_probe_selectors.push_back(s);
|
||||
|
||||
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_probe_selected(int)));
|
||||
}
|
||||
|
||||
// Add the options
|
||||
auto binding = new prop::binding::DecoderOptions(decoder_stack, dec);
|
||||
binding->add_properties_to_form(decoder_form, true);
|
||||
_bindings.push_back(binding);
|
||||
|
||||
pv::widgets::DecoderGroupBox *const group =
|
||||
new pv::widgets::DecoderGroupBox(decoder_stack, dec, decoder_form, parent);
|
||||
|
||||
form->addRow(group);
|
||||
_decoder_forms.push_back(group);
|
||||
}
|
||||
|
||||
DsComboBox* DecodeTrace::create_probe_selector(
|
||||
QWidget *parent, const data::decode::Decoder *dec,
|
||||
const srd_channel *const pdch)
|
||||
{
|
||||
assert(dec);
|
||||
const auto &sigs = _session->get_signals();
|
||||
assert(_decoder_stack);
|
||||
|
||||
data::decode::Decoder *_dec = const_cast<data::decode::Decoder*>(dec);
|
||||
auto probe_iter = _dec->channels().find(pdch);
|
||||
DsComboBox *selector = new DsComboBox(parent);
|
||||
selector->addItem("-", QVariant::fromValue(-1));
|
||||
|
||||
if (probe_iter == _dec->channels().end())
|
||||
selector->setCurrentIndex(0);
|
||||
|
||||
for(size_t i = 0; i < sigs.size(); i++) {
|
||||
const auto s = sigs[i];
|
||||
assert(s);
|
||||
|
||||
if (dynamic_cast<LogicSignal*>(s) && s->enabled())
|
||||
{
|
||||
selector->addItem(s->get_name(),
|
||||
QVariant::fromValue(s->get_index()));
|
||||
if (probe_iter != _dec->channels().end()) {
|
||||
if ((*probe_iter).second == s->get_index())
|
||||
selector->setCurrentIndex(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selector;
|
||||
}
|
||||
|
||||
void DecodeTrace::commit_decoder_probes(data::decode::Decoder *dec)
|
||||
{
|
||||
assert(dec);
|
||||
|
||||
std::map<const srd_channel*, int> probe_map;
|
||||
const auto &sigs = _session->get_signals();
|
||||
|
||||
_index_list.clear();
|
||||
for(auto &s : _probe_selectors)
|
||||
{
|
||||
if(s._decoder != dec)
|
||||
break;
|
||||
|
||||
const int selection = s._combo->itemData(
|
||||
s._combo->currentIndex()).value<int>();
|
||||
|
||||
for(auto &sig : sigs)
|
||||
if(sig->get_index() == selection) {
|
||||
probe_map[s._pdch] = selection;
|
||||
_index_list.push_back(selection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dec->set_probes(probe_map);
|
||||
}
|
||||
|
||||
void DecodeTrace::commit_probes()
|
||||
{
|
||||
assert(_decoder_stack);
|
||||
for(auto &dec : _decoder_stack->stack())
|
||||
commit_decoder_probes(dec);
|
||||
}
|
||||
|
||||
|
||||
void DecodeTrace::on_new_decode_data()
|
||||
{
|
||||
@@ -886,102 +590,7 @@ void DecodeTrace::on_decode_done()
|
||||
on_new_decode_data();
|
||||
_session->decode_done();
|
||||
}
|
||||
|
||||
|
||||
void DecodeTrace::on_probe_selected(int)
|
||||
{
|
||||
commit_probes();
|
||||
}
|
||||
|
||||
void DecodeTrace::on_add_stack(srd_decoder *decoder)
|
||||
{
|
||||
assert(decoder);
|
||||
assert(_decoder_stack);
|
||||
|
||||
auto dec = new data::decode::Decoder(decoder);
|
||||
|
||||
_decoder_stack->add_sub_decoder(dec);
|
||||
std::list<pv::data::decode::Decoder*> items;
|
||||
items.push_back(dec);
|
||||
|
||||
if (_decoder_panels.size()){
|
||||
auto it = _decoder_panels.end();
|
||||
--it;
|
||||
if ((*it).panel_height == 0){
|
||||
(*it).panel_height = (*it).panel->geometry().height();
|
||||
}
|
||||
}
|
||||
|
||||
if (_decoder_panels.size() == 1 && _decoder_container && _form_base_height == 0){
|
||||
QWidget *dlg = dynamic_cast<QWidget*>(_decoder_container->parent());
|
||||
assert(dlg);
|
||||
_form_base_height = dlg->geometry().height();
|
||||
}
|
||||
|
||||
load_all_decoder_property(items);
|
||||
|
||||
on_region_set(_start_index);
|
||||
}
|
||||
|
||||
void DecodeTrace::on_del_stack(data::decode::Decoder *dec)
|
||||
{
|
||||
assert(dec);
|
||||
assert(_decoder_stack);
|
||||
|
||||
if (MsgBox::Confirm("Are you sure to remove the sub protocol?") == false){
|
||||
return;
|
||||
}
|
||||
|
||||
_decoder_stack->remove_sub_decoder(dec);
|
||||
|
||||
std::list<decoder_panel_item> dels;
|
||||
std::list<pv::data::decode::Decoder*> adds;
|
||||
|
||||
for (auto it = _decoder_panels.begin(); it != _decoder_panels.end(); it++){
|
||||
if ((*it).decoder_handle == dec){
|
||||
dels.push_back((*it));
|
||||
auto del_it = it;
|
||||
|
||||
//rebuild the panel
|
||||
it++;
|
||||
while (it != _decoder_panels.end())
|
||||
{
|
||||
dels.push_back((*it));
|
||||
adds.push_back((pv::data::decode::Decoder*)(*it).decoder_handle);
|
||||
it++;
|
||||
}
|
||||
_decoder_panels.erase(del_it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (dels.size() > 0)
|
||||
{
|
||||
auto it = dels.end();
|
||||
it--;
|
||||
auto inf = (*it);
|
||||
assert(inf.panel);
|
||||
|
||||
inf.panel->deleteLater();
|
||||
inf.panel = NULL;
|
||||
dels.erase(it);
|
||||
|
||||
for (auto fd = _decoder_panels.begin(); fd != _decoder_panels.end(); ++fd){
|
||||
if ((*fd).decoder_handle == inf.decoder_handle){
|
||||
_decoder_panels.erase(fd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (adds.size() > 0){
|
||||
load_all_decoder_property(adds);
|
||||
}
|
||||
|
||||
on_region_set(_start_index);
|
||||
}
|
||||
|
||||
|
||||
int DecodeTrace::rows_size()
|
||||
{
|
||||
using pv::data::decode::Decoder;
|
||||
@@ -1045,43 +654,6 @@ QRectF DecodeTrace::get_rect(DecodeSetRegions type, int y, int right)
|
||||
return QRectF(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void DecodeTrace::on_region_set(int index)
|
||||
{
|
||||
(void)index;
|
||||
const uint64_t last_samples = _session->cur_samplelimits() - 1;
|
||||
const int index1 = _start_comboBox->currentIndex();
|
||||
const int index2 = _end_comboBox->currentIndex();
|
||||
uint64_t decode_start, decode_end;
|
||||
|
||||
if (index1 == 0) {
|
||||
decode_start = 0;
|
||||
} else {
|
||||
decode_start = _view->get_cursor_samples(index1-1);
|
||||
}
|
||||
if (index2 == 0) {
|
||||
decode_end = last_samples;
|
||||
} else {
|
||||
decode_end = _view->get_cursor_samples(index2-1);
|
||||
}
|
||||
|
||||
if (decode_start > last_samples)
|
||||
decode_start = 0;
|
||||
if (decode_end > last_samples)
|
||||
decode_end = last_samples;
|
||||
|
||||
if (decode_start > decode_end) {
|
||||
uint64_t tmp = decode_start;
|
||||
decode_start = decode_end;
|
||||
decode_end = tmp;
|
||||
}
|
||||
_start_index = index1;
|
||||
_end_index = index2;
|
||||
|
||||
for(auto &dec : _decoder_stack->stack()) {
|
||||
dec->set_decode_region(decode_start, decode_end);
|
||||
}
|
||||
}
|
||||
|
||||
void DecodeTrace::frame_ended()
|
||||
{
|
||||
const uint64_t last_samples = _session->cur_samplelimits() - 1;
|
||||
@@ -1105,6 +677,32 @@ void* DecodeTrace::get_key_handel()
|
||||
return _decoder_stack->get_key_handel();
|
||||
}
|
||||
|
||||
//to show decoder's property setting dialog
|
||||
bool DecodeTrace::create_popup(bool isnew)
|
||||
{
|
||||
int ret = false; //setting have changed flag
|
||||
QWidget *top = AppControl::Instance()->GetTopWindow();
|
||||
dialogs::DecoderOptionsDlg dlg(top);
|
||||
dlg.set_sample_range(_start_index, _end_index);
|
||||
dlg.load_options(this);
|
||||
|
||||
if (QDialog::Accepted == dlg.exec())
|
||||
{
|
||||
for(auto &dec : _decoder_stack->stack())
|
||||
{
|
||||
if (dec->commit() || _decoder_stack->options_changed()) {
|
||||
_decoder_stack->set_options_changed(true);
|
||||
_decode_start = dec->decode_start();
|
||||
_decode_end = dec->decode_end();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
dlg.get_sample_range(_start_index, _end_index);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -36,13 +36,7 @@
|
||||
|
||||
struct srd_channel;
|
||||
struct srd_decoder;
|
||||
|
||||
struct decoder_panel_item{
|
||||
QWidget *panel;
|
||||
void *decoder_handle;
|
||||
int panel_height;
|
||||
};
|
||||
|
||||
|
||||
class DsComboBox;
|
||||
|
||||
namespace pv {
|
||||
@@ -59,10 +53,6 @@ class Row;
|
||||
}
|
||||
}
|
||||
|
||||
namespace widgets {
|
||||
class DecoderGroupBox;
|
||||
}
|
||||
|
||||
namespace view {
|
||||
|
||||
//create by SigSession
|
||||
@@ -71,13 +61,6 @@ class DecodeTrace : public Trace
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
struct ProbeSelector
|
||||
{
|
||||
const DsComboBox *_combo;
|
||||
const pv::data::decode::Decoder *_decoder;
|
||||
const srd_channel *_pdch;
|
||||
};
|
||||
|
||||
enum DecodeSetRegions{
|
||||
NONEREG = -1,
|
||||
CHNLREG,
|
||||
@@ -112,7 +95,10 @@ public:
|
||||
|
||||
bool enabled();
|
||||
|
||||
pv::data::DecoderStack* decoder();
|
||||
inline pv::data::DecoderStack* decoder()
|
||||
{
|
||||
return _decoder_stack;
|
||||
}
|
||||
|
||||
void set_view(pv::view::View *view);
|
||||
|
||||
@@ -139,9 +125,7 @@ public:
|
||||
* @param right the x-coordinate of the right edge of the signal
|
||||
**/
|
||||
void paint_fore(QPainter &p, int left, int right, QColor fore, QColor back);
|
||||
|
||||
bool create_popup();
|
||||
|
||||
|
||||
int rows_size();
|
||||
|
||||
QRectF get_rect(DecodeSetRegions type, int y, int right);
|
||||
@@ -155,14 +139,17 @@ public:
|
||||
|
||||
void* get_key_handel();
|
||||
|
||||
inline std::list<int>* get_sig_index_list(){
|
||||
return &_index_list;
|
||||
}
|
||||
|
||||
bool create_popup(bool isnew);
|
||||
|
||||
protected:
|
||||
void paint_type_options(QPainter &p, int right, const QPoint pt, QColor fore);
|
||||
|
||||
private:
|
||||
void create_popup_form(dialogs::DSDialog *dlg);
|
||||
|
||||
void populate_popup_form(QWidget *parent, QFormLayout *form);
|
||||
|
||||
private:
|
||||
|
||||
void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p,
|
||||
QColor text_colour, int text_height, int left, int right,
|
||||
double samples_per_pixel, double pixels_offset, int y,
|
||||
@@ -184,32 +171,15 @@ private:
|
||||
|
||||
void draw_unshown_row(QPainter &p, int y, int h, int left,
|
||||
int right, QString info, QColor fore, QColor back);
|
||||
|
||||
void create_decoder_form(data::DecoderStack *decoder_stack,
|
||||
pv::data::decode::Decoder *dec,
|
||||
QWidget *parent, QFormLayout *form);
|
||||
|
||||
DsComboBox* create_probe_selector(QWidget *parent,
|
||||
const pv::data::decode::Decoder *dec,
|
||||
const srd_channel *const pdch);
|
||||
|
||||
void commit_decoder_probes(
|
||||
data::decode::Decoder *dec);
|
||||
|
||||
void commit_probes();
|
||||
void load_all_decoder_property(std::list<pv::data::decode::Decoder*> &ls);
|
||||
|
||||
|
||||
signals:
|
||||
void decoded_progress(int progress);
|
||||
|
||||
private slots:
|
||||
void on_new_decode_data();
|
||||
void on_probe_selected(int);
|
||||
void on_add_stack(srd_decoder *decoder);
|
||||
void on_del_stack(data::decode::Decoder *dec);
|
||||
void on_new_decode_data();
|
||||
|
||||
void on_decode_done();
|
||||
void on_region_set(int index);
|
||||
void on_decode_done();
|
||||
|
||||
public:
|
||||
volatile bool _delete_flag; //destroy it when deocde task end
|
||||
@@ -217,27 +187,18 @@ public:
|
||||
private:
|
||||
pv::SigSession *_session;
|
||||
pv::data::DecoderStack *_decoder_stack;
|
||||
std::list<int> _index_list;
|
||||
|
||||
uint64_t _decode_start;
|
||||
uint64_t _decode_end;
|
||||
int _start_index;
|
||||
int _end_index;
|
||||
int _start_count;
|
||||
int _end_count;
|
||||
|
||||
DsComboBox *_start_comboBox;
|
||||
DsComboBox *_end_comboBox;
|
||||
|
||||
QFormLayout *_pub_input_layer;
|
||||
int _progress;
|
||||
QWidget *_decoder_container;
|
||||
std::list<decoder_panel_item> _decoder_panels;
|
||||
int _form_base_height;
|
||||
|
||||
std::list<pv::prop::binding::DecoderOptions*> _bindings;
|
||||
std::list<ProbeSelector> _probe_selectors;
|
||||
std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms;
|
||||
int _progress;
|
||||
|
||||
std::vector<QString> _cur_row_headings;
|
||||
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QVariant>
|
||||
#include <QScrollBar>
|
||||
#include <QScreen>
|
||||
//#include <QScrollBar>
|
||||
//#include <QScreen>
|
||||
#include <QApplication>
|
||||
|
||||
#include "../config/appconfig.h"
|
||||
@@ -46,19 +46,21 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
data::decode::Decoder *dec,
|
||||
QLayout *dec_layout,
|
||||
QWidget *parent) :
|
||||
QScrollArea(parent),
|
||||
_decoder_stack(decoder_stack),
|
||||
_dec(dec)
|
||||
QWidget(parent)
|
||||
{
|
||||
_dec = dec;
|
||||
_decoder_stack = decoder_stack;
|
||||
_widget = new QWidget(this);
|
||||
_layout = new QGridLayout(_widget);
|
||||
_layout->setContentsMargins(0, 0, 0, 0);
|
||||
_layout->setVerticalSpacing(5);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setWidgetResizable(true);
|
||||
_layout->setVerticalSpacing(2);
|
||||
|
||||
//setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
//setWidgetResizable(true);
|
||||
|
||||
QString iconPath = GetIconPath();
|
||||
_layout->addWidget(new QLabel(QString("<h3>%1</h3>").arg(_dec->decoder()->name), _widget),
|
||||
_layout->addWidget(new QLabel(QString("<h3 style='font-style:italic'>%1</h3>").arg(_dec->decoder()->name), _widget),
|
||||
//_layout->addWidget(new QLabel(QString("<span style='text-decoration:underline'>%1</span>").arg(_dec->decoder()->name), _widget),
|
||||
0, 0);
|
||||
_layout->setColumnStretch(0, 1);
|
||||
|
||||
@@ -81,15 +83,17 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
iconPath+"/shown.svg" :
|
||||
iconPath+"/hidden.svg"), QString(), _widget);
|
||||
_show_button->setProperty("index", -1);
|
||||
connect(_show_button, SIGNAL(clicked()),
|
||||
this, SLOT(tog_icon()));
|
||||
|
||||
connect(_show_button, SIGNAL(clicked()), this, SLOT(tog_icon()));
|
||||
|
||||
_layout->addWidget(_show_button, 0, 2);
|
||||
|
||||
|
||||
// add row show/hide
|
||||
int index = 0;
|
||||
const std::map<const pv::data::decode::Row, bool> rows = _decoder_stack->get_rows_gshow();
|
||||
for (std::map<const pv::data::decode::Row, bool>::const_iterator i = rows.begin();
|
||||
auto rows = _decoder_stack->get_rows_gshow();
|
||||
|
||||
for (auto i = rows.begin();
|
||||
i != rows.end(); i++) {
|
||||
if ((*i).first.decoder() == _dec->decoder()) {
|
||||
QPushButton *show_button = new QPushButton(QIcon((*i).second ?
|
||||
@@ -97,6 +101,7 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
iconPath+"/hidden.svg"), QString(), _widget);
|
||||
show_button->setProperty("index", index);
|
||||
connect(show_button, SIGNAL(clicked()), this, SLOT(tog_icon()));
|
||||
|
||||
_row_show_button.push_back(show_button);
|
||||
_layout->addWidget(new QLabel((*i).first.title(), _widget), _row_show_button.size(), 0);
|
||||
_layout->addWidget(show_button, _row_show_button.size(), 2);
|
||||
@@ -107,8 +112,9 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack,
|
||||
_layout->addLayout(dec_layout, _row_show_button.size()+1, 0, 1, 3);
|
||||
|
||||
_widget->setLayout(_layout);
|
||||
setWidget(_widget);
|
||||
_widget->installEventFilter(this);
|
||||
parent->layout()->addWidget(_widget);
|
||||
// setWidget(_widget);
|
||||
// _widget->installEventFilter(this);
|
||||
}
|
||||
|
||||
DecoderGroupBox::~DecoderGroupBox()
|
||||
@@ -117,6 +123,7 @@ DecoderGroupBox::~DecoderGroupBox()
|
||||
|
||||
bool DecoderGroupBox::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
/*
|
||||
if(o == _widget && e->type() == QEvent::Resize) {
|
||||
setMinimumWidth(_widget->minimumSizeHint().width() + verticalScrollBar()->width());
|
||||
QScreen *screen=QGuiApplication::primaryScreen ();
|
||||
@@ -124,6 +131,7 @@ bool DecoderGroupBox::eventFilter(QObject *o, QEvent *e)
|
||||
if (_widget->minimumSizeHint().height() < mm.height()/2)
|
||||
setMinimumHeight(_widget->minimumSizeHint().height());
|
||||
}
|
||||
*/
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -132,12 +140,12 @@ void DecoderGroupBox::tog_icon()
|
||||
{
|
||||
QString iconPath = GetIconPath();
|
||||
QPushButton *sc = dynamic_cast<QPushButton*>(sender());
|
||||
QVariant id = sc->property("index");
|
||||
int index = id.toInt();
|
||||
int index = sc->property("index").toInt();
|
||||
|
||||
if (index == -1) {
|
||||
int i = _index;
|
||||
|
||||
for(auto &dec : _decoder_stack->stack()) {
|
||||
for(auto dec : _decoder_stack->stack()) {
|
||||
if (i-- == 0) {
|
||||
dec->show(!dec->shown());
|
||||
sc->setIcon(QIcon(dec->shown() ? iconPath+"/shown.svg" :
|
||||
@@ -146,9 +154,9 @@ void DecoderGroupBox::tog_icon()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::map<const pv::data::decode::Row, bool> rows = _decoder_stack->get_rows_gshow();
|
||||
for (std::map<const pv::data::decode::Row, bool>::const_iterator i = rows.begin();
|
||||
i != rows.end(); i++) {
|
||||
auto rows = _decoder_stack->get_rows_gshow();
|
||||
|
||||
for (auto i = rows.begin(); i != rows.end(); i++) {
|
||||
if (index-- == 0) {
|
||||
_decoder_stack->set_rows_gshow((*i).first, !(*i).second);
|
||||
//rows[(*i).first] = !(*i).second;
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
#include <QToolBar>
|
||||
#include <QScrollArea>
|
||||
//#include <QToolBar>
|
||||
//#include <QScrollArea>
|
||||
#include <QWidget>
|
||||
|
||||
namespace pv {
|
||||
|
||||
@@ -40,7 +41,7 @@ class Decoder;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class DecoderGroupBox : public QScrollArea
|
||||
class DecoderGroupBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user