const list<QAction*> AnalogSignal::get_context_bar_actions()
{
list<QAction*> actions;
+ actions.push_back(&_name_action);
return actions;
}
connect(_action_set_colour, SIGNAL(triggered()),
this, SLOT(on_action_set_colour_triggered()));
+ connect(&_view.session(), SIGNAL(signals_changed()),
+ this, SLOT(on_signals_changed()));
+
connect(&_view, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
context_signal->set_colour(new_colour);
}
+void Header::on_signals_changed()
+{
+ const vector< shared_ptr<Signal> > sigs(_view.session().get_signals());
+ BOOST_FOREACH(shared_ptr<Signal> s, sigs) {
+ assert(s);
+ connect(s.get(), SIGNAL(text_changed()), this, SLOT(update()));
+ }
+}
+
void Header::on_signals_moved()
{
update();
void contextMenuEvent(QContextMenuEvent *event);
private slots:
+ void on_signals_changed();
+
void on_action_set_name_triggered();
void on_action_set_colour_triggered();
const list<QAction*> LogicSignal::get_context_bar_actions()
{
list<QAction*> actions;
+ actions.push_back(&_name_action);
return actions;
}
const QPen Signal::SignalAxisPen(QColor(128, 128, 128, 64));
+const char *const ProbeNames[] = {
+ "CLK",
+ "DATA",
+ "IN",
+ "OUT",
+ "RST",
+ "Tx",
+ "Rx",
+ "EN",
+ "SCLK",
+ "MOSI",
+ "MISO",
+ "/SS",
+ "SDA",
+ "SCL"
+};
+
Signal::Signal(const sr_probe *const probe) :
_probe(probe),
_name(probe->name),
- _v_offset(0)
+ _v_offset(0),
+ _name_action(NULL),
+ _name_widget(),
+ _updating_name_widget(false)
{
assert(_probe);
+
+ _name_action.setDefaultWidget(&_name_widget);
+
+ _name_widget.setEditable(true);
+ for(unsigned int i = 0; i < countof(ProbeNames); i++)
+ _name_widget.insertItem(i, ProbeNames[i]);
+ _name_widget.setEditText(probe->name);
+
+ connect(&_name_widget, SIGNAL(editTextChanged(const QString&)),
+ this, SLOT(on_text_changed(const QString&)));
}
QString Signal::get_name() const
void Signal::set_name(QString name)
{
_name = name;
+ _updating_name_widget = true;
+ _name_widget.setEditText(name);
+ _updating_name_widget = false;
}
QColor Signal::get_colour() const
label_size.width(), label_size.height());
}
+void Signal::on_text_changed(const QString &text)
+{
+ _name = text;
+ text_changed();
+}
+
} // namespace view
} // namespace pv
#include <boost/shared_ptr.hpp>
#include <QColor>
+#include <QComboBox>
#include <QPainter>
#include <QPen>
#include <QRect>
#include <QString>
+#include <QWidgetAction>
#include <stdint.h>
*/
QRectF get_label_rect(int y, int right);
+private slots:
+ void on_text_changed(const QString &text);
+
+signals:
+ void text_changed();
+
protected:
const sr_probe *const _probe;
int _v_offset;
QSizeF _text_size;
+
+ QWidgetAction _name_action;
+ QComboBox _name_widget;
+ bool _updating_name_widget;
};
} // namespace view