#include <QLineEdit>
#include <QMenu>
-#include <libsigrok/libsigrok.h>
+#include <libsigrok/libsigrok.hpp>
#include "signal.h"
#include "view.h"
-#include <pv/device/devinst.h>
-
using std::shared_ptr;
+using sigrok::Channel;
+
namespace pv {
namespace view {
-const char *const ProbeNames[] = {
+const char *const ChannelNames[] = {
"CLK",
"DATA",
"IN",
"SCL"
};
-Signal::Signal(shared_ptr<pv::device::DevInst> dev_inst,
- const sr_channel *const probe) :
- Trace(probe->name),
- _dev_inst(dev_inst),
- _probe(probe),
+Signal::Signal(shared_ptr<Channel> channel) :
+ Trace(channel->name().c_str()),
+ _channel(channel),
_name_widget(NULL),
_updating_name_widget(false)
{
- assert(_probe);
+ assert(_channel);
}
void Signal::set_name(QString name)
bool Signal::enabled() const
{
- return _probe->enabled;
+ return _channel->enabled();
}
void Signal::enable(bool enable)
{
- _dev_inst->enable_probe(_probe, enable);
+ _channel->set_enabled(enable);
visibility_changed();
}
-const sr_channel* Signal::probe() const
+shared_ptr<Channel> Signal::channel() const
{
- return _probe;
+ return _channel;
}
void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
_name_widget = new QComboBox(parent);
_name_widget->setEditable(true);
- for(unsigned int i = 0; i < countof(ProbeNames); i++)
- _name_widget->insertItem(i, ProbeNames[i]);
+ for(unsigned int i = 0; i < countof(ChannelNames); i++)
+ _name_widget->insertItem(i, ChannelNames[i]);
index = _name_widget->findText(_name, Qt::MatchExactly);
_name_widget->setCurrentIndex(index);
}
- _name_widget->lineEdit()->selectAll();
- _name_widget->setFocus();
-
connect(_name_widget, SIGNAL(editTextChanged(const QString&)),
this, SLOT(on_text_changed(const QString&)));
- // We want to close the popup when the Enter key was pressed.
- _name_widget->installEventFilter(this);
-
form->addRow(tr("Name"), _name_widget);
add_colour_option(parent, form);
return menu;
}
-bool Signal::eventFilter(QObject *obj, QEvent *evt)
-{
- QKeyEvent *keyEvent;
-
- (void)obj;
-
- if (evt->type() == QEvent::KeyPress) {
- keyEvent = static_cast<QKeyEvent*>(evt);
- if (keyEvent->key() == Qt::Key_Enter ||
- keyEvent->key() == Qt::Key_Return) {
- close_popup();
- return true;
- }
- }
-
- return false;
-}
-
void Signal::delete_pressed()
{
on_disable();