X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=samplingbar.cpp;h=b2ca6e066980fe8b1b36d7f7e06eb3771a8154b5;hb=b3f22de060b73f15ad3eb2dabee04a0b4f5d947e;hp=c411f3c15260dfda8adcefc7e9322c6cfbba6318;hpb=dde1a56346815349ed4e3cc1c5c63c2ffbc6c7b7;p=pulseview.git diff --git a/samplingbar.cpp b/samplingbar.cpp index c411f3c..b2ca6e0 100644 --- a/samplingbar.cpp +++ b/samplingbar.cpp @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the PulseView project. * * Copyright (C) 2012 Joel Holdsworth * @@ -20,6 +20,8 @@ #include +#include + extern "C" { #include } @@ -28,20 +30,49 @@ extern "C" { #include "samplingbar.h" +const uint64_t SamplingBar::RecordLengths[11] = { + 1000000, + 2000000, + 5000000, + 10000000, + 25000000, + 50000000, + 100000000, + 250000000, + 500000000, + 1000000000, + 10000000000 +}; + SamplingBar::SamplingBar(QWidget *parent) : QToolBar("Sampling Bar", parent), _device_selector(this), - _sample_rate_list(this) + _record_length_selector(this), + _sample_rate_list(this), + _run_stop_button(this) { + connect(&_run_stop_button, SIGNAL(clicked()), this, SIGNAL(run_stop())); connect(&_device_selector, SIGNAL(currentIndexChanged (int)), this, SLOT(on_device_selected())); _sample_rate_value.setDecimals(0); _sample_rate_value.setSuffix("Hz"); + BOOST_FOREACH(uint64_t l, RecordLengths) + { + char *const text = sr_si_string_u64(l, " samples"); + _record_length_selector.addItem(QString(text), + qVariantFromValue(l)); + g_free(text); + } + + _run_stop_button.setText("Run"); + addWidget(&_device_selector); + addWidget(&_record_length_selector); _sample_rate_list_action = addWidget(&_sample_rate_list); _sample_rate_value_action = addWidget(&_sample_rate_value); + addWidget(&_run_stop_button); update_device_selector(); update_sample_rate_selector(); @@ -57,6 +88,15 @@ struct sr_dev_inst* SamplingBar::get_selected_device() const index).value(); } +uint64_t SamplingBar::get_record_length() const +{ + const int index = _record_length_selector.currentIndex(); + if(index < 0) + return 0; + + return _record_length_selector.itemData(index).value(); +} + uint64_t SamplingBar::get_sample_rate() const { assert(_sample_rate_value_action); @@ -66,11 +106,11 @@ uint64_t SamplingBar::get_sample_rate() const return (uint64_t)_sample_rate_value.value(); else if(_sample_rate_list_action->isVisible()) { - const int index = _device_selector.currentIndex(); + const int index = _sample_rate_list.currentIndex(); if(index < 0) return 0; - return _device_selector.itemData(index).value(); + return _sample_rate_list.itemData(index).value(); } return 0;