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