X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Ftoolbars%2Fsamplingbar.cpp;h=367b9b2e6fe4b12ac2d9481af81a7eaa8fc09eef;hp=91c4b076ea6346d46102100ec20eec4a0c201756;hb=d9aecf1fcd9af471db3b59de7efc65b9632a6d79;hpb=e95e8563a1de0d2045cb8f30083889896b6c94df diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 91c4b07..367b9b2 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -22,10 +22,10 @@ #include -#include - #include #include +#include +#include #include "samplingbar.h" @@ -33,6 +33,7 @@ #include #include #include +#include using boost::shared_ptr; using std::map; @@ -93,6 +94,9 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : addWidget(&_sample_rate); addWidget(&_run_stop_button); + + _sample_count.installEventFilter(this); + _sample_rate.installEventFilter(this); } void SamplingBar::set_device_list( @@ -108,7 +112,7 @@ void SamplingBar::set_device_list( _device_selector.clear(); _device_selector_map.clear(); - BOOST_FOREACH (shared_ptr dev_inst, devices) { + for (shared_ptr dev_inst : devices) { assert(dev_inst); const string title = dev_inst->format_device_title(); const sr_dev_inst *sdi = dev_inst->dev_inst(); @@ -142,8 +146,7 @@ shared_ptr SamplingBar::get_selected_device() const index).value(); assert(sdi); - map >:: - const_iterator iter = _device_selector_map.find(sdi); + const auto iter = _device_selector_map.find(sdi); if (iter == _device_selector_map.end()) return shared_ptr(); @@ -446,5 +449,21 @@ void SamplingBar::on_config_changed() update_sample_rate_selector(); } +bool SamplingBar::eventFilter(QObject *watched, QEvent *event) +{ + if ((watched == &_sample_count || watched == &_sample_rate) && + (event->type() == QEvent::ToolTip)) { + double sec = (double)_sample_count.value() / _sample_rate.value(); + QHelpEvent *help_event = static_cast(event); + + QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec)); + QToolTip::showText(help_event->globalPos(), str); + + return true; + } + + return false; +} + } // namespace toolbars } // namespace pv