]>
Commit | Line | Data |
---|---|---|
28a4c9c5 | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
28a4c9c5 JH |
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 | ||
cef18fc6 | 21 | #include <extdef.h> |
28a4c9c5 | 22 | |
cec48d16 | 23 | #include <assert.h> |
b47d951e JH |
24 | #include <math.h> |
25 | ||
e3374498 | 26 | #include <QApplication> |
b213ef09 JH |
27 | #include <QFormLayout> |
28 | #include <QMenu> | |
e3374498 | 29 | |
8d3e0764 JH |
30 | #include <libsigrok/libsigrok.h> |
31 | ||
cef18fc6 | 32 | #include "signal.h" |
8d634081 | 33 | #include "view.h" |
3e46726a | 34 | |
8d3e0764 JH |
35 | using boost::shared_ptr; |
36 | ||
51e77110 | 37 | namespace pv { |
8d634081 | 38 | namespace view { |
51e77110 | 39 | |
9e40e83d JH |
40 | const char *const ProbeNames[] = { |
41 | "CLK", | |
42 | "DATA", | |
43 | "IN", | |
44 | "OUT", | |
45 | "RST", | |
46 | "Tx", | |
47 | "Rx", | |
48 | "EN", | |
49 | "SCLK", | |
50 | "MOSI", | |
51 | "MISO", | |
52 | "/SS", | |
53 | "SDA", | |
54 | "SCL" | |
55 | }; | |
56 | ||
8d3e0764 JH |
57 | Signal::Signal(pv::SigSession &session, shared_ptr<pv::DevInst> dev_inst, |
58 | sr_probe *const probe) : | |
931f20b0 | 59 | Trace(session, probe->name), |
8d3e0764 | 60 | _dev_inst(dev_inst), |
cec48d16 | 61 | _probe(probe), |
ef8311a4 | 62 | _name_widget(NULL), |
9e40e83d | 63 | _updating_name_widget(false) |
28a4c9c5 | 64 | { |
cec48d16 | 65 | assert(_probe); |
ef8311a4 JH |
66 | } |
67 | ||
49f8ff3f JH |
68 | void Signal::set_name(QString name) |
69 | { | |
931f20b0 | 70 | Trace::set_name(name); |
9e40e83d | 71 | _updating_name_widget = true; |
ef8311a4 | 72 | _name_widget->setEditText(name); |
9e40e83d | 73 | _updating_name_widget = false; |
49f8ff3f JH |
74 | } |
75 | ||
931f20b0 | 76 | bool Signal::enabled() const |
2e575351 | 77 | { |
931f20b0 | 78 | return _probe->enabled; |
a29bb7fb JH |
79 | } |
80 | ||
aca00b1e JH |
81 | void Signal::enable(bool enable) |
82 | { | |
83 | _probe->enabled = enable; | |
84 | visibility_changed(); | |
85 | } | |
86 | ||
632ba77e JH |
87 | const sr_probe* Signal::probe() const |
88 | { | |
89 | return _probe; | |
90 | } | |
91 | ||
0c0218fd JH |
92 | void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) |
93 | { | |
94 | _name_widget = new QComboBox(parent); | |
95 | _name_widget->setEditable(true); | |
96 | ||
97 | for(unsigned int i = 0; i < countof(ProbeNames); i++) | |
98 | _name_widget->insertItem(i, ProbeNames[i]); | |
99 | _name_widget->setEditText(_probe->name); | |
100 | ||
101 | connect(_name_widget, SIGNAL(editTextChanged(const QString&)), | |
102 | this, SLOT(on_text_changed(const QString&))); | |
103 | ||
104 | form->addRow(tr("Name"), _name_widget); | |
91e8bf08 JH |
105 | |
106 | add_colour_option(parent, form); | |
0c0218fd JH |
107 | } |
108 | ||
86e823ca JH |
109 | QMenu* Signal::create_context_menu(QWidget *parent) |
110 | { | |
111 | QMenu *const menu = Trace::create_context_menu(parent); | |
112 | ||
113 | menu->addSeparator(); | |
114 | ||
115 | QAction *const disable = new QAction(tr("Disable"), this); | |
a2d21018 | 116 | disable->setShortcuts(QKeySequence::Delete); |
86e823ca JH |
117 | connect(disable, SIGNAL(triggered()), this, SLOT(on_disable())); |
118 | menu->addAction(disable); | |
119 | ||
120 | return menu; | |
121 | } | |
122 | ||
5ed1adf5 JH |
123 | void Signal::delete_pressed() |
124 | { | |
125 | on_disable(); | |
126 | } | |
127 | ||
86e823ca JH |
128 | void Signal::on_disable() |
129 | { | |
130 | enable(false); | |
131 | } | |
132 | ||
8d634081 | 133 | } // namespace view |
51e77110 | 134 | } // namespace pv |