Q_ARG(QString, info_text));
}
-void MainWindow::update_device_list(
- shared_ptr<pv::device::DevInst> selected_device)
+void MainWindow::update_device_list()
{
assert(_sampling_bar);
+ shared_ptr<pv::device::DevInst> selected_device = _session.get_device();
list< shared_ptr<device::DevInst> > devices;
std::copy(_device_manager.devices().begin(),
_device_manager.devices().end(), std::back_inserter(devices));
_sampling_bar->set_device_list(devices);
- if (!selected_device && !devices.empty()) {
- // Fall back to the first device in the list.
- selected_device = devices.front();
-
- // Try and find the demo device and select that by default
- BOOST_FOREACH (shared_ptr<pv::device::DevInst> dev_inst, devices)
- if (strcmp(dev_inst->dev_inst()->driver->name,
- "demo") == 0) {
- selected_device = dev_inst;
- }
- }
-
- if (selected_device) {
- // Setting the selected device in the sampling bar, generates
- // an event which updates the selected device in the SigSession.
+ if (selected_device)
_sampling_bar->set_selected_device(selected_device);
- }
}
void MainWindow::load_file(QString file_name)
// If the user selected a device, select it in the device list. Select the
// current device otherwise.
- shared_ptr<device::DevInst> dev_inst = dlg.exec() ?
- dlg.get_selected_device() : _session.get_device();
+ if (dlg.exec())
+ _session.set_device(dlg.get_selected_device());
- update_device_list(dev_inst);
+ update_device_list();
}
void MainWindow::on_actionQuit_triggered()
void session_error(const QString text, const QString info_text);
/**
- * Updates the device list in the sampling bar, and updates the
- * selection.
- * @param selected_device The device to select, or NULL if the
- * first device in the device list should be selected.
+ * Updates the device list in the sampling bar
*/
- void update_device_list(
- boost::shared_ptr<pv::device::DevInst> selected_device =
- boost::shared_ptr<pv::device::DevInst>());
+ void update_device_list();
private slots:
void load_file(QString file_name);
using boost::lock_guard;
using boost::mutex;
using boost::shared_ptr;
+using std::list;
using std::map;
using std::set;
using std::string;
{
// TODO: This should not be necessary
_session = this;
+
+ set_default_device();
}
SigSession::~SigSession()
capture_state_changed(state);
}
+void SigSession::set_default_device()
+{
+ shared_ptr<pv::device::DevInst> default_device;
+ const list< shared_ptr<device::Device> > &devices =
+ _device_manager.devices();
+
+ if (!devices.empty()) {
+ // Fall back to the first device in the list.
+ default_device = devices.front();
+
+ // Try and find the demo device and select that by default
+ BOOST_FOREACH (shared_ptr<pv::device::Device> dev, devices)
+ if (strcmp(dev->dev_inst()->driver->name,
+ "demo") == 0) {
+ default_device = dev;
+ break;
+ }
+ }
+
+ set_device(default_device);
+}
+
void SigSession::update_signals(shared_ptr<device::DevInst> dev_inst)
{
assert(dev_inst);
void update_signals(boost::shared_ptr<device::DevInst> dev_inst);
+ void set_default_device();
+
boost::shared_ptr<view::Signal> signal_from_probe(
const sr_probe *probe) const;
_viewport->installEventFilter(this);
_ruler->installEventFilter(this);
_header->installEventFilter(this);
+
+ signals_changed();
}
SigSession& View::session()