addToolBar(_toolbar);
_sampling_bar = new SamplingBar(this);
+ scan_devices();
connect(_sampling_bar, SIGNAL(run_stop()), this,
SLOT(run_stop()));
addToolBar(_sampling_bar);
}
+void MainWindow::scan_devices()
+{
+ _devices.clear();
+
+ /* Scan all drivers for all devices. */
+ struct sr_dev_driver **const drivers = sr_driver_list();
+ for (struct sr_dev_driver **driver = drivers; *driver; driver++) {
+ GSList *const devices = sr_driver_scan(*driver, NULL);
+ for (GSList *l = devices; l; l = l->next)
+ _devices.push_back((sr_dev_inst*)l->data);
+ g_slist_free(devices);
+ }
+
+ assert(_sampling_bar);
+ _sampling_bar->set_device_list(_devices);
+}
+
void MainWindow::load_file(QString file_name)
{
_session.load_file(file_name.toStdString());
#include <assert.h>
+#include <boost/foreach.hpp>
+
#include <libsigrok/libsigrok.h>
#include <QAction>
_sample_rate_value_action = addWidget(&_sample_rate_value);
addWidget(&_run_stop_button);
- update_device_selector();
-
- update_sample_rate_selector();
connect(&_sample_rate_list, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_sample_rate_changed()));
- connect(&_sample_rate_value, SIGNAL(valueChanged(double)),
+ connect(&_sample_rate_value, SIGNAL(editingFinished()),
this, SLOT(on_sample_rate_changed()));
}
+void SamplingBar::set_device_list(
+ const std::list<struct sr_dev_inst*> &devices)
+{
+ _device_selector.clear();
+
+ BOOST_FOREACH (sr_dev_inst *sdi, devices) {
+ QString title;
+ if (sdi->vendor && sdi->vendor[0])
+ title += sdi->vendor + QString(" ");
+ if (sdi->model && sdi->model[0])
+ title += sdi->model + QString(" ");
+ if (sdi->version && sdi->version[0])
+ title += sdi->version + QString(" ");
+
+ _device_selector.addItem(title, qVariantFromValue(
+ (void*)sdi));
+ }
+
+ update_sample_rate_selector();
+}
+
struct sr_dev_inst* SamplingBar::get_selected_device() const
{
const int index = _device_selector.currentIndex();
_run_stop_button.setText(sampling ? "Stop" : "Run");
}
-void SamplingBar::update_device_selector()
-{
- GSList *devices = NULL;
-
- /* Scan all drivers for all devices. */
- struct sr_dev_driver **const drivers = sr_driver_list();
- for (struct sr_dev_driver **driver = drivers; *driver; driver++) {
- GSList *tmpdevs = sr_driver_scan(*driver, NULL);
- for (GSList *l = tmpdevs; l; l = l->next)
- devices = g_slist_append(devices, l->data);
- g_slist_free(tmpdevs);
- }
-
- for (GSList *l = devices; l; l = l->next) {
- sr_dev_inst *const sdi = (sr_dev_inst*)l->data;
-
- QString title;
- if (sdi->vendor && sdi->vendor[0])
- title += sdi->vendor + QString(" ");
- if (sdi->model && sdi->model[0])
- title += sdi->model + QString(" ");
- if (sdi->version && sdi->version[0])
- title += sdi->version + QString(" ");
-
- _device_selector.addItem(title, qVariantFromValue(
- (void*)sdi));
- }
-
- g_slist_free(devices);
-}
-
void SamplingBar::update_sample_rate_selector()
{
const sr_dev_inst *const sdi = get_selected_device();
#include <stdint.h>
+#include <list>
+
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QToolBar>
#include <QToolButton>
+struct st_dev_inst;
class QAction;
namespace pv {
public:
SamplingBar(QWidget *parent);
+ void set_device_list(const std::list<struct sr_dev_inst*> &devices);
+
struct sr_dev_inst* get_selected_device() const;
+
uint64_t get_record_length() const;
void set_sampling(bool sampling);
void run_stop();
private:
- void update_device_selector();
void update_sample_rate_selector();
void update_sample_rate_selector_value();
void commit_sample_rate();