]> sigrok.org Git - pulseview.git/blame_incremental - pv/view/signal.cpp
Renamed pv::data::Decoder to DecoderStack
[pulseview.git] / pv / view / signal.cpp
... / ...
CommitLineData
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <extdef.h>
22
23#include <assert.h>
24#include <math.h>
25
26#include <QApplication>
27#include <QFormLayout>
28#include <QMenu>
29
30#include "signal.h"
31#include "view.h"
32
33namespace pv {
34namespace view {
35
36const char *const ProbeNames[] = {
37 "CLK",
38 "DATA",
39 "IN",
40 "OUT",
41 "RST",
42 "Tx",
43 "Rx",
44 "EN",
45 "SCLK",
46 "MOSI",
47 "MISO",
48 "/SS",
49 "SDA",
50 "SCL"
51};
52
53Signal::Signal(pv::SigSession &session, sr_probe *const probe) :
54 Trace(session, probe->name),
55 _probe(probe),
56 _name_widget(NULL),
57 _updating_name_widget(false)
58{
59 assert(_probe);
60}
61
62void Signal::set_name(QString name)
63{
64 Trace::set_name(name);
65 _updating_name_widget = true;
66 _name_widget->setEditText(name);
67 _updating_name_widget = false;
68}
69
70bool Signal::enabled() const
71{
72 return _probe->enabled;
73}
74
75void Signal::enable(bool enable)
76{
77 _probe->enabled = enable;
78 visibility_changed();
79}
80
81const sr_probe* Signal::probe() const
82{
83 return _probe;
84}
85
86void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
87{
88 _name_widget = new QComboBox(parent);
89 _name_widget->setEditable(true);
90
91 for(unsigned int i = 0; i < countof(ProbeNames); i++)
92 _name_widget->insertItem(i, ProbeNames[i]);
93 _name_widget->setEditText(_probe->name);
94
95 connect(_name_widget, SIGNAL(editTextChanged(const QString&)),
96 this, SLOT(on_text_changed(const QString&)));
97
98 form->addRow(tr("Name"), _name_widget);
99
100 add_colour_option(parent, form);
101}
102
103QMenu* Signal::create_context_menu(QWidget *parent)
104{
105 QMenu *const menu = Trace::create_context_menu(parent);
106
107 menu->addSeparator();
108
109 QAction *const disable = new QAction(tr("Disable"), this);
110 disable->setShortcuts(QKeySequence::Delete);
111 connect(disable, SIGNAL(triggered()), this, SLOT(on_disable()));
112 menu->addAction(disable);
113
114 return menu;
115}
116
117void Signal::delete_pressed()
118{
119 on_disable();
120}
121
122void Signal::on_disable()
123{
124 enable(false);
125}
126
127} // namespace view
128} // namespace pv