#include <assert.h>
-#include <boost/foreach.hpp>
-
#include <QAction>
#include <QDebug>
+#include <QHelpEvent>
+#include <QToolTip>
#include "samplingbar.h"
#include <pv/device/devinst.h>
#include <pv/popups/deviceoptions.h>
#include <pv/popups/probes.h>
+#include <pv/util.h>
-using boost::shared_ptr;
using std::map;
using std::max;
using std::min;
+using std::shared_ptr;
using std::string;
namespace pv {
addWidget(&_sample_rate);
addWidget(&_run_stop_button);
+
+ _sample_count.installEventFilter(this);
+ _sample_rate.installEventFilter(this);
}
void SamplingBar::set_device_list(
_device_selector.clear();
_device_selector_map.clear();
- BOOST_FOREACH (shared_ptr<pv::device::DevInst> dev_inst, devices) {
+ for (shared_ptr<pv::device::DevInst> dev_inst : devices) {
assert(dev_inst);
const string title = dev_inst->format_device_title();
const sr_dev_inst *sdi = dev_inst->dev_inst();
index).value<void*>();
assert(sdi);
- map<const sr_dev_inst*, boost::weak_ptr<device::DevInst> >::
- 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<pv::device::DevInst>();
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<QHelpEvent*>(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