_stack.push_back(decoder);
}
+void DecoderStack::remove(int index)
+{
+ using pv::data::decode::Decoder;
+
+ assert(index >= 0);
+ assert(index < (int)_stack.size());
+
+ // Find the decoder in the stack
+ list< shared_ptr<Decoder> >::iterator iter = _stack.begin();
+ for(int i = 0; i < index; i++, iter++)
+ assert(iter != _stack.end());
+
+ // Delete the element
+ _stack.erase(iter);
+}
+
const vector< shared_ptr<view::decode::Annotation> >
DecoderStack::annotations() const
{
DecodeTrace::DecodeTrace(pv::SigSession &session,
boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
Trace(session, QString(decoder_stack->stack().front()->decoder()->name)),
- _decoder_stack(decoder_stack)
+ _decoder_stack(decoder_stack),
+ _delete_mapper(this)
{
assert(_decoder_stack);
connect(_decoder_stack.get(), SIGNAL(new_decode_data()),
this, SLOT(on_new_decode_data()));
+ connect(&_delete_mapper, SIGNAL(mapped(int)),
+ this, SLOT(on_delete_decoder(int)));
}
bool DecodeTrace::enabled() const
void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
{
+ using pv::data::decode::Decoder;
+
assert(form);
assert(parent);
assert(_decoder_stack);
_bindings.clear();
_probe_selectors.clear();
- BOOST_FOREACH(shared_ptr<data::decode::Decoder> dec,
- _decoder_stack->stack())
- create_decoder_form(dec, parent, form);
+ const list< shared_ptr<Decoder> >& stack = _decoder_stack->stack();
+ list< shared_ptr<Decoder> >::const_iterator iter = stack.begin();
+ for (int i = 0; i < (int)stack.size(); i++, iter++) {
+ shared_ptr<Decoder> dec(*iter);
+ create_decoder_form(i, dec, parent, form);
+ }
form->addRow(new QLabel(
tr("<i>* Required Probes</i>"), parent));
p.drawText(text_rect, message);
}
-void DecodeTrace::create_decoder_form(shared_ptr<data::decode::Decoder> &dec,
- QWidget *parent, QFormLayout *form)
+void DecodeTrace::create_decoder_form(int index,
+ shared_ptr<data::decode::Decoder> &dec, QWidget *parent,
+ QFormLayout *form)
{
const GSList *probe;
pv::widgets::DecoderGroupBox *const group =
new pv::widgets::DecoderGroupBox(decoder->name);
+
+ _delete_mapper.setMapping(group, index);
+ connect(group, SIGNAL(delete_decoder()), &_delete_mapper, SLOT(map()));
+
QFormLayout *const decoder_form = new QFormLayout;
group->add_layout(decoder_form);
create_popup_form();
}
+void DecodeTrace::on_delete_decoder(int index)
+{
+ _decoder_stack->remove(index);
+
+ // Update the popup
+ create_popup_form();
+
+ _decoder_stack->begin_decode();
+}
+
} // namespace view
} // namespace pv
#include <list>
#include <map>
+#include <QSignalMapper>
+
#include <boost/shared_ptr.hpp>
#include <pv/prop/binding/decoderoptions.h>
void draw_error(QPainter &p, const QString &message,
int left, int right);
- void create_decoder_form(
+ void create_decoder_form(int index,
boost::shared_ptr<pv::data::decode::Decoder> &dec,
QWidget *parent, QFormLayout *form);
void on_stack_decoder(srd_decoder *decoder);
+ void on_delete_decoder(int index);
+
private:
boost::shared_ptr<pv::data::DecoderStack> _decoder_stack;
_bindings;
std::list<ProbeSelector> _probe_selectors;
+
+ QSignalMapper _delete_mapper;
};
} // namespace view