projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
95237c1
)
Made Probes popup reusable
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sun, 13 Oct 2013 22:12:37 +0000
(23:12 +0100)
committer
Joel Holdsworth
<joel.holdsworth@udptechnology.com>
Mon, 14 Oct 2013 12:00:26 +0000
(13:00 +0100)
pv/popups/probes.cpp
patch
|
blob
|
history
pv/popups/probes.h
patch
|
blob
|
history
pv/toolbars/samplingbar.cpp
patch
|
blob
|
history
pv/toolbars/samplingbar.h
patch
|
blob
|
history
pv/widgets/popup.cpp
patch
|
blob
|
history
pv/widgets/popup.h
patch
|
blob
|
history
diff --git
a/pv/popups/probes.cpp
b/pv/popups/probes.cpp
index 5499df62cd9496dc141ee3ef5cc2a45fb596b69a..51ba3ddca8b2744bfd60e89a109906ab741f60dd 100644
(file)
--- a/
pv/popups/probes.cpp
+++ b/
pv/popups/probes.cpp
@@
-35,6
+35,7
@@
Probes::Probes(SigSession &session, QWidget *parent) :
_session(session),
_layout(this),
_probes(this),
_session(session),
_layout(this),
_probes(this),
+ _updating_probes(false),
_probes_bar(this),
_enable_all_probes(this),
_disable_all_probes(this)
_probes_bar(this),
_enable_all_probes(this),
_disable_all_probes(this)
@@
-56,27
+57,39
@@
Probes::Probes(SigSession &session, QWidget *parent) :
_layout.addWidget(&_probes_bar);
_layout.addWidget(&_probes_bar);
+ connect(&_probes, SIGNAL(itemChanged(QListWidgetItem*)),
+ this, SLOT(item_changed(QListWidgetItem*)));
+}
+
+void Probes::set_all_probes(bool set)
+{
+ using pv::view::Signal;
+
+ _updating_probes = true;
+
const vector< shared_ptr<pv::view::Signal> > sigs =
_session.get_signals();
for (unsigned int i = 0; i < sigs.size(); i++)
{
const shared_ptr<pv::view::Signal> &s = sigs[i];
assert(s);
const vector< shared_ptr<pv::view::Signal> > sigs =
_session.get_signals();
for (unsigned int i = 0; i < sigs.size(); i++)
{
const shared_ptr<pv::view::Signal> &s = sigs[i];
assert(s);
- QListWidgetItem *const item = new QListWidgetItem(
- s->get_name(), &_probes);
+ s->enable(set);
+
+ QListWidgetItem *const item = _probes.item(i);
assert(item);
assert(item);
- item->setData(UserRole, qVariantFromValue(i));
- item->setCheckState(s->enabled() ? Checked : Unchecked);
- _probes.addItem(item);
+ item->setCheckState(set ? Qt::Checked : Qt::Unchecked);
}
}
- connect(&_probes, SIGNAL(itemChanged(QListWidgetItem*)),
- this, SLOT(item_changed(QListWidgetItem*)));
+ _updating_probes = false;
}
}
-void Probes::s
et_all_probes(bool set
)
+void Probes::s
howEvent(QShowEvent *e
)
{
{
- using pv::view::Signal;
+ pv::widgets::Popup::showEvent(e);
+
+ _updating_probes = true;
+
+ _probes.clear();
const vector< shared_ptr<pv::view::Signal> > sigs =
_session.get_signals();
const vector< shared_ptr<pv::view::Signal> > sigs =
_session.get_signals();
@@
-84,18
+97,24
@@
void Probes::set_all_probes(bool set)
{
const shared_ptr<pv::view::Signal> &s = sigs[i];
assert(s);
{
const shared_ptr<pv::view::Signal> &s = sigs[i];
assert(s);
- s->enable(set);
-
- QListWidgetItem *const item = _probes.item(i);
+ QListWidgetItem *const item = new QListWidgetItem(
+ s->get_name(), &_probes);
assert(item);
assert(item);
- item->setCheckState(set ? Qt::Checked : Qt::Unchecked);
+ item->setCheckState(s->enabled() ? Checked : Unchecked);
+ item->setData(UserRole, qVariantFromValue(i));
+ _probes.addItem(item);
}
}
+
+ _updating_probes = false;
}
void Probes::item_changed(QListWidgetItem *item)
{
using pv::view::Signal;
}
void Probes::item_changed(QListWidgetItem *item)
{
using pv::view::Signal;
+ if (_updating_probes)
+ return;
+
assert(item);
const vector< shared_ptr<pv::view::Signal> > sigs =
_session.get_signals();
assert(item);
const vector< shared_ptr<pv::view::Signal> > sigs =
_session.get_signals();
diff --git
a/pv/popups/probes.h
b/pv/popups/probes.h
index 8a1fdd5753efa60a3cb6b89f7eef71efb9b962c4..b5eda58f3d9f5dd2c53a2286f4daa133765020b4 100644
(file)
--- a/
pv/popups/probes.h
+++ b/
pv/popups/probes.h
@@
-44,6
+44,9
@@
public:
private:
void set_all_probes(bool set);
private:
void set_all_probes(bool set);
+private:
+ void showEvent(QShowEvent *e);
+
private slots:
void item_changed(QListWidgetItem *item);
private slots:
void item_changed(QListWidgetItem *item);
@@
-56,6
+59,8
@@
private:
QVBoxLayout _layout;
QListWidget _probes;
QVBoxLayout _layout;
QListWidget _probes;
+ bool _updating_probes;
+
QToolBar _probes_bar;
QToolButton _enable_all_probes;
QToolButton _disable_all_probes;
QToolBar _probes_bar;
QToolButton _enable_all_probes;
QToolButton _disable_all_probes;
diff --git
a/pv/toolbars/samplingbar.cpp
b/pv/toolbars/samplingbar.cpp
index bafb9cd406bf05f9c76b54f2d91156e34d593e93..b80d6f80f0df737811aeb6c24c2132b11b77d613 100644
(file)
--- a/
pv/toolbars/samplingbar.cpp
+++ b/
pv/toolbars/samplingbar.cpp
@@
-71,6
+71,7
@@
SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
_updating_device_selector(false),
_configure_button(this),
_probes_button(this),
_updating_device_selector(false),
_configure_button(this),
_probes_button(this),
+ _probes_popup(_session, this),
_record_length_selector(this),
_sample_rate_list(this),
_icon_red(":/icons/status-red.svg"),
_record_length_selector(this),
_sample_rate_list(this),
_icon_red(":/icons/status-red.svg"),
@@
-102,8
+103,10
@@
SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
_configure_button.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/configure.png")));
_configure_button.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/configure.png")));
+
_probes_button.setIcon(QIcon::fromTheme("probes",
QIcon(":/icons/probes.svg")));
_probes_button.setIcon(QIcon::fromTheme("probes",
QIcon(":/icons/probes.svg")));
+ _probes_button.set_popup(&_probes_popup);
_run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
_run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@@
-136,7
+139,7
@@
void SamplingBar::set_device_list(
_updating_device_selector = false;
_updating_device_selector = false;
-
update_sample_rate_selector
();
+
on_device_selected
();
}
struct sr_dev_inst* SamplingBar::get_selected_device() const
}
struct sr_dev_inst* SamplingBar::get_selected_device() const
@@
-311,7
+314,6
@@
void SamplingBar::on_device_selected()
_session.set_device(sdi);
_configure_button.set_popup(new DeviceOptions(sdi, this));
_session.set_device(sdi);
_configure_button.set_popup(new DeviceOptions(sdi, this));
- _probes_button.set_popup(new Probes(_session, this));
}
void SamplingBar::on_sample_rate_changed()
}
void SamplingBar::on_sample_rate_changed()
diff --git
a/pv/toolbars/samplingbar.h
b/pv/toolbars/samplingbar.h
index 806a79a6c57547626d6175a9ec6c8ab0ba5fcecb..e4aa40d48a869e59c557ebd187fef13a0dab8df8 100644
(file)
--- a/
pv/toolbars/samplingbar.h
+++ b/
pv/toolbars/samplingbar.h
@@
-83,7
+83,9
@@
private:
bool _updating_device_selector;
pv::widgets::PopupToolButton _configure_button;
bool _updating_device_selector;
pv::widgets::PopupToolButton _configure_button;
+
pv::widgets::PopupToolButton _probes_button;
pv::widgets::PopupToolButton _probes_button;
+ pv::popups::Probes _probes_popup;
QComboBox _record_length_selector;
QComboBox _record_length_selector;
diff --git
a/pv/widgets/popup.cpp
b/pv/widgets/popup.cpp
index f89e38a6b1b84e3fdc9b923060f31688277c87f1..399f5e28b6d56d4d525b896a371208f304c7bb97 100644
(file)
--- a/
pv/widgets/popup.cpp
+++ b/
pv/widgets/popup.cpp
@@
-198,11
+198,6
@@
void Popup::resizeEvent(QResizeEvent*)
setMask(popup_region());
}
setMask(popup_region());
}
-void Popup::showEvent(QShowEvent*)
-{
- reposition_widget();
-}
-
void Popup::mouseReleaseEvent(QMouseEvent *e)
{
assert(e);
void Popup::mouseReleaseEvent(QMouseEvent *e)
{
assert(e);
@@
-213,6
+208,11
@@
void Popup::mouseReleaseEvent(QMouseEvent *e)
close();
}
close();
}
+void Popup::showEvent(QShowEvent*)
+{
+ reposition_widget();
+}
+
} // namespace widgets
} // namespace pv
} // namespace widgets
} // namespace pv
diff --git
a/pv/widgets/popup.h
b/pv/widgets/popup.h
index 402fc6bda3d60944f7b087c4a99034133ef69d5e..1da09d85eb5965401205d459ccd038ab160e1fb0 100644
(file)
--- a/
pv/widgets/popup.h
+++ b/
pv/widgets/popup.h
@@
-67,10
+67,11
@@
private:
void resizeEvent(QResizeEvent*);
void resizeEvent(QResizeEvent*);
- void showEvent(QShowEvent*);
-
void mouseReleaseEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
+protected:
+ void showEvent(QShowEvent *e);
+
private:
QPoint _point;
Position _pos;
private:
QPoint _point;
Position _pos;