]>
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 | |
cef18fc6 | 30 | #include "signal.h" |
8d634081 | 31 | #include "view.h" |
3e46726a | 32 | |
51e77110 | 33 | namespace pv { |
8d634081 | 34 | namespace view { |
51e77110 | 35 | |
9e40e83d JH |
36 | const 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 | ||
aca00b1e | 53 | Signal::Signal(pv::SigSession &session, sr_probe *const probe) : |
931f20b0 | 54 | Trace(session, probe->name), |
cec48d16 | 55 | _probe(probe), |
ef8311a4 | 56 | _name_widget(NULL), |
9e40e83d | 57 | _updating_name_widget(false) |
28a4c9c5 | 58 | { |
cec48d16 | 59 | assert(_probe); |
ef8311a4 JH |
60 | } |
61 | ||
49f8ff3f JH |
62 | void Signal::set_name(QString name) |
63 | { | |
931f20b0 | 64 | Trace::set_name(name); |
9e40e83d | 65 | _updating_name_widget = true; |
ef8311a4 | 66 | _name_widget->setEditText(name); |
9e40e83d | 67 | _updating_name_widget = false; |
49f8ff3f JH |
68 | } |
69 | ||
931f20b0 | 70 | bool Signal::enabled() const |
2e575351 | 71 | { |
931f20b0 | 72 | return _probe->enabled; |
a29bb7fb JH |
73 | } |
74 | ||
aca00b1e JH |
75 | void Signal::enable(bool enable) |
76 | { | |
77 | _probe->enabled = enable; | |
78 | visibility_changed(); | |
79 | } | |
80 | ||
632ba77e JH |
81 | const sr_probe* Signal::probe() const |
82 | { | |
83 | return _probe; | |
84 | } | |
85 | ||
0c0218fd JH |
86 | void 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); | |
91e8bf08 JH |
99 | |
100 | add_colour_option(parent, form); | |
0c0218fd JH |
101 | } |
102 | ||
86e823ca JH |
103 | QMenu* 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); | |
a2d21018 | 110 | disable->setShortcuts(QKeySequence::Delete); |
86e823ca JH |
111 | connect(disable, SIGNAL(triggered()), this, SLOT(on_disable())); |
112 | menu->addAction(disable); | |
113 | ||
114 | return menu; | |
115 | } | |
116 | ||
5ed1adf5 JH |
117 | void Signal::delete_pressed() |
118 | { | |
119 | on_disable(); | |
120 | } | |
121 | ||
86e823ca JH |
122 | void Signal::on_disable() |
123 | { | |
124 | enable(false); | |
125 | } | |
126 | ||
8d634081 | 127 | } // namespace view |
51e77110 | 128 | } // namespace pv |