]> sigrok.org Git - pulseview.git/commitdiff
Moved SamplingBar into pv::toolbars namespace
authorJoel Holdsworth <redacted>
Sat, 16 Mar 2013 08:22:29 +0000 (08:22 +0000)
committerJoel Holdsworth <redacted>
Thu, 21 Mar 2013 22:44:18 +0000 (22:44 +0000)
CMakeLists.txt
pv/mainwindow.cpp
pv/mainwindow.h
pv/samplingbar.cpp [deleted file]
pv/samplingbar.h [deleted file]
pv/toolbars/samplingbar.cpp [new file with mode: 0644]
pv/toolbars/samplingbar.h [new file with mode: 0644]

index 8c18ad7e254e526fb470a2621cba6be7b7d39f41..fc8fb4c9e521b6856e1d7fe189e90b804b99505f 100644 (file)
@@ -91,7 +91,6 @@ configure_file (
 set(pulseview_SOURCES
        main.cpp
        pv/mainwindow.cpp
-       pv/samplingbar.cpp
        pv/sigsession.cpp
        pv/data/analog.cpp
        pv/data/analogsnapshot.cpp
@@ -107,6 +106,7 @@ set(pulseview_SOURCES
        pv/prop/property.cpp
        pv/prop/binding/binding.cpp
        pv/prop/binding/deviceoptions.cpp
+       pv/toolbars/samplingbar.cpp
        pv/view/analogsignal.cpp
        pv/view/cursor.cpp
        pv/view/header.cpp
@@ -120,11 +120,11 @@ set(pulseview_SOURCES
 
 set(pulseview_HEADERS
        pv/mainwindow.h
-       pv/samplingbar.h
        pv/sigsession.h
        pv/dialogs/about.h
        pv/dialogs/connect.h
        pv/dialogs/deviceoptions.h
+       pv/toolbars/samplingbar.h
        pv/view/cursor.h
        pv/view/header.h
        pv/view/ruler.h
index 90ac324bab1ed7bbffde9fe7c8a8d1d5cd7243d0..e2f29e34d133afed3cf765d6d8dd58cfdc6e67a5 100644 (file)
@@ -34,9 +34,9 @@
 #include <QWidget>
 
 #include "mainwindow.h"
-#include "samplingbar.h"
 #include "dialogs/about.h"
 #include "dialogs/connect.h"
+#include "toolbars/samplingbar.h"
 #include "view/view.h"
 
 /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
@@ -181,7 +181,7 @@ void MainWindow::setup_ui()
        _toolbar->addAction(_action_view_zoom_out);
        addToolBar(_toolbar);
 
-       _sampling_bar = new SamplingBar(this);
+       _sampling_bar = new toolbars::SamplingBar(this);
        scan_devices();
        connect(_sampling_bar, SIGNAL(run_stop()), this,
                SLOT(run_stop()));
index 3887717fb4e6c76931f245a3cfe9da89d0902969..47d3e66d0cad0efa131b7a72b4d796026966eb34 100644 (file)
@@ -37,7 +37,9 @@ class QWidget;
 
 namespace pv {
 
+namespace toolbars {
 class SamplingBar;
+}
 
 namespace view {
 class View;
@@ -106,7 +108,7 @@ private:
        QVBoxLayout *_vertical_layout;
 
        QToolBar *_toolbar;
-       SamplingBar *_sampling_bar;
+       toolbars::SamplingBar *_sampling_bar;
 };
 
 } // namespace pv
diff --git a/pv/samplingbar.cpp b/pv/samplingbar.cpp
deleted file mode 100644 (file)
index 24fcc40..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#include <extdef.h>
-
-#include <assert.h>
-
-#include <boost/foreach.hpp>
-
-#include <libsigrok/libsigrok.h>
-
-#include <QAction>
-#include <QDebug>
-
-#include "samplingbar.h"
-
-#include <pv/dialogs/deviceoptions.h>
-
-namespace pv {
-
-const uint64_t SamplingBar::RecordLengths[20] = {
-       1000,
-       2500,
-       5000,
-       10000,
-       25000,
-       50000,
-       100000,
-       250000,
-       500000,
-       1000000,
-       2000000,
-       5000000,
-       10000000,
-       25000000,
-       50000000,
-       100000000,
-       250000000,
-       500000000,
-       1000000000,
-       10000000000ULL,
-};
-
-const uint64_t SamplingBar::DefaultRecordLength = 1000000;
-
-SamplingBar::SamplingBar(QWidget *parent) :
-       QToolBar("Sampling Bar", parent),
-       _device_selector(this),
-       _configure_button(this),
-       _record_length_selector(this),
-       _sample_rate_list(this),
-       _icon_green(":/icons/status-green.svg"),
-       _icon_grey(":/icons/status-grey.svg"),
-       _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()));
-       connect(&_configure_button, SIGNAL(clicked()),
-               this, SLOT(configure()));
-
-       _sample_rate_value.setDecimals(0);
-       _sample_rate_value.setSuffix("Hz");
-
-       for (size_t i = 0; i < countof(RecordLengths); i++)
-       {
-               const uint64_t &l = RecordLengths[i];
-               char *const text = sr_si_string_u64(l, " samples");
-               _record_length_selector.addItem(QString(text),
-                       qVariantFromValue(l));
-               g_free(text);
-
-               if (l == DefaultRecordLength)
-                       _record_length_selector.setCurrentIndex(i);
-       }
-
-       set_sampling(false);
-
-       _configure_button.setIcon(QIcon::fromTheme("configure",
-               QIcon(":/icons/configure.png")));
-
-       _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
-
-       addWidget(&_device_selector);
-       addWidget(&_configure_button);
-       addWidget(&_record_length_selector);
-       _sample_rate_list_action = addWidget(&_sample_rate_list);
-       _sample_rate_value_action = addWidget(&_sample_rate_value);
-       addWidget(&_run_stop_button);
-
-       connect(&_sample_rate_list, SIGNAL(currentIndexChanged(int)),
-               this, SLOT(on_sample_rate_changed()));
-       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();
-       if (index < 0)
-               return NULL;
-
-       return (sr_dev_inst*)_device_selector.itemData(
-               index).value<void*>();
-}
-
-void SamplingBar::set_selected_device(struct sr_dev_inst *const sdi)
-{
-       for (int i = 0; i < _device_selector.count(); i++)
-               if (sdi == _device_selector.itemData(i).value<void*>()) {
-                       _device_selector.setCurrentIndex(i);
-                       return;
-               }
-}
-
-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>();
-}
-
-void SamplingBar::set_sampling(bool sampling)
-{
-       _run_stop_button.setIcon(sampling ? _icon_green : _icon_grey);
-       _run_stop_button.setText(sampling ? "Stop" : "Run");
-}
-
-void SamplingBar::update_sample_rate_selector()
-{
-       const sr_dev_inst *const sdi = get_selected_device();
-       const struct sr_samplerates *samplerates;
-
-       assert(_sample_rate_value_action);
-       assert(_sample_rate_list_action);
-
-       if (!sdi)
-               return;
-
-       if (sr_config_list(sdi->driver, SR_CONF_SAMPLERATE,
-               (const void **)&samplerates, sdi) != SR_OK)
-               return;
-
-       _sample_rate_list_action->setVisible(false);
-       _sample_rate_value_action->setVisible(false);
-
-       if (samplerates->step)
-       {
-               _sample_rate_value.setRange(
-                       samplerates->low, samplerates->high);
-               _sample_rate_value.setSingleStep(samplerates->step);
-               _sample_rate_value_action->setVisible(true);
-       }
-       else
-       {
-               _sample_rate_list.clear();
-               for (const uint64_t *rate = samplerates->list;
-                    *rate; rate++)
-                       _sample_rate_list.addItem(
-                               sr_samplerate_string(*rate),
-                               qVariantFromValue(*rate));
-               _sample_rate_list.show();
-               _sample_rate_list_action->setVisible(true);
-       }
-
-       update_sample_rate_selector_value();
-}
-
-void SamplingBar::update_sample_rate_selector_value()
-{
-       sr_dev_inst *const sdi = get_selected_device();
-       assert(sdi);
-
-       uint64_t *samplerate = NULL;
-       if (sr_config_get(sdi->driver, SR_CONF_SAMPLERATE,
-               (const void**)&samplerate, sdi) != SR_OK) {
-               qDebug() <<
-                               "WARNING: Failed to get value of sample rate";
-               return;
-       }
-
-       assert(_sample_rate_value_action);
-       assert(_sample_rate_list_action);
-
-       if (_sample_rate_value_action->isVisible())
-               _sample_rate_value.setValue(*samplerate);
-       else if (_sample_rate_list_action->isVisible())
-       {
-               for (int i = 0; i < _sample_rate_list.count(); i++)
-                       if (*samplerate == _sample_rate_list.itemData(
-                               i).value<uint64_t>())
-                               _sample_rate_list.setCurrentIndex(i);
-       }
-}
-
-void SamplingBar::commit_sample_rate()
-{
-       uint64_t sample_rate = 0;
-
-       sr_dev_inst *const sdi = get_selected_device();
-       assert(sdi);
-
-       assert(_sample_rate_value_action);
-       assert(_sample_rate_list_action);
-
-       if (_sample_rate_value_action->isVisible())
-               sample_rate = (uint64_t)_sample_rate_value.value();
-       else if (_sample_rate_list_action->isVisible())
-       {
-               const int index = _sample_rate_list.currentIndex();
-               if (index >= 0)
-                       sample_rate = _sample_rate_list.itemData(
-                               index).value<uint64_t>();
-       }
-
-       // Set the samplerate
-       if (sr_config_set(sdi, SR_CONF_SAMPLERATE,
-               &sample_rate) != SR_OK) {
-               qDebug() << "Failed to configure samplerate.";
-               return;
-       }
-}
-
-void SamplingBar::on_device_selected()
-{
-       update_sample_rate_selector();
-}
-
-void SamplingBar::on_sample_rate_changed()
-{
-       commit_sample_rate();
-}
-
-void SamplingBar::configure()
-{
-       commit_sample_rate();
-
-       sr_dev_inst *const sdi = get_selected_device();
-       assert(sdi);
-
-       pv::dialogs::DeviceOptions dlg(this, sdi);
-       dlg.exec();
-
-       update_sample_rate_selector_value();
-}
-
-} // namespace pv
diff --git a/pv/samplingbar.h b/pv/samplingbar.h
deleted file mode 100644 (file)
index 7034962..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef PULSEVIEW_PV_SAMPLINGBAR_H
-#define PULSEVIEW_PV_SAMPLINGBAR_H
-
-#include <stdint.h>
-
-#include <list>
-
-#include <QComboBox>
-#include <QDoubleSpinBox>
-#include <QToolBar>
-#include <QToolButton>
-
-struct st_dev_inst;
-class QAction;
-
-namespace pv {
-
-class SamplingBar : public QToolBar
-{
-       Q_OBJECT
-
-private:
-       static const uint64_t RecordLengths[20];
-       static const uint64_t DefaultRecordLength;
-
-public:
-       SamplingBar(QWidget *parent);
-
-       void set_device_list(const std::list<struct sr_dev_inst*> &devices);
-
-       struct sr_dev_inst* get_selected_device() const;
-       void set_selected_device(struct sr_dev_inst *const sdi);
-
-       uint64_t get_record_length() const;
-
-       void set_sampling(bool sampling);
-
-signals:
-       void run_stop();
-
-private:
-       void update_sample_rate_selector();
-       void update_sample_rate_selector_value();
-       void commit_sample_rate();
-
-private slots:
-       void on_device_selected();
-       void on_sample_rate_changed();
-       void configure();
-
-private:
-       QComboBox _device_selector;
-       QToolButton _configure_button;
-
-       QComboBox _record_length_selector;
-
-       QComboBox _sample_rate_list;
-       QAction *_sample_rate_list_action;
-       QDoubleSpinBox _sample_rate_value;
-       QAction *_sample_rate_value_action;
-
-       QIcon _icon_green;
-       QIcon _icon_grey;
-       QToolButton _run_stop_button;
-};
-
-} // namespace pv
-
-#endif // PULSEVIEW_PV_SAMPLINGBAR_H
diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp
new file mode 100644 (file)
index 0000000..d42e6de
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <extdef.h>
+
+#include <assert.h>
+
+#include <boost/foreach.hpp>
+
+#include <libsigrok/libsigrok.h>
+
+#include <QAction>
+#include <QDebug>
+
+#include "samplingbar.h"
+
+#include <pv/dialogs/deviceoptions.h>
+
+namespace pv {
+namespace toolbars {
+
+const uint64_t SamplingBar::RecordLengths[20] = {
+       1000,
+       2500,
+       5000,
+       10000,
+       25000,
+       50000,
+       100000,
+       250000,
+       500000,
+       1000000,
+       2000000,
+       5000000,
+       10000000,
+       25000000,
+       50000000,
+       100000000,
+       250000000,
+       500000000,
+       1000000000,
+       10000000000ULL,
+};
+
+const uint64_t SamplingBar::DefaultRecordLength = 1000000;
+
+SamplingBar::SamplingBar(QWidget *parent) :
+       QToolBar("Sampling Bar", parent),
+       _device_selector(this),
+       _configure_button(this),
+       _record_length_selector(this),
+       _sample_rate_list(this),
+       _icon_green(":/icons/status-green.svg"),
+       _icon_grey(":/icons/status-grey.svg"),
+       _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()));
+       connect(&_configure_button, SIGNAL(clicked()),
+               this, SLOT(configure()));
+
+       _sample_rate_value.setDecimals(0);
+       _sample_rate_value.setSuffix("Hz");
+
+       for (size_t i = 0; i < countof(RecordLengths); i++)
+       {
+               const uint64_t &l = RecordLengths[i];
+               char *const text = sr_si_string_u64(l, " samples");
+               _record_length_selector.addItem(QString(text),
+                       qVariantFromValue(l));
+               g_free(text);
+
+               if (l == DefaultRecordLength)
+                       _record_length_selector.setCurrentIndex(i);
+       }
+
+       set_sampling(false);
+
+       _configure_button.setIcon(QIcon::fromTheme("configure",
+               QIcon(":/icons/configure.png")));
+
+       _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+
+       addWidget(&_device_selector);
+       addWidget(&_configure_button);
+       addWidget(&_record_length_selector);
+       _sample_rate_list_action = addWidget(&_sample_rate_list);
+       _sample_rate_value_action = addWidget(&_sample_rate_value);
+       addWidget(&_run_stop_button);
+
+       connect(&_sample_rate_list, SIGNAL(currentIndexChanged(int)),
+               this, SLOT(on_sample_rate_changed()));
+       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();
+       if (index < 0)
+               return NULL;
+
+       return (sr_dev_inst*)_device_selector.itemData(
+               index).value<void*>();
+}
+
+void SamplingBar::set_selected_device(struct sr_dev_inst *const sdi)
+{
+       for (int i = 0; i < _device_selector.count(); i++)
+               if (sdi == _device_selector.itemData(i).value<void*>()) {
+                       _device_selector.setCurrentIndex(i);
+                       return;
+               }
+}
+
+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>();
+}
+
+void SamplingBar::set_sampling(bool sampling)
+{
+       _run_stop_button.setIcon(sampling ? _icon_green : _icon_grey);
+       _run_stop_button.setText(sampling ? "Stop" : "Run");
+}
+
+void SamplingBar::update_sample_rate_selector()
+{
+       const sr_dev_inst *const sdi = get_selected_device();
+       const struct sr_samplerates *samplerates;
+
+       assert(_sample_rate_value_action);
+       assert(_sample_rate_list_action);
+
+       if (!sdi)
+               return;
+
+       if (sr_config_list(sdi->driver, SR_CONF_SAMPLERATE,
+               (const void **)&samplerates, sdi) != SR_OK)
+               return;
+
+       _sample_rate_list_action->setVisible(false);
+       _sample_rate_value_action->setVisible(false);
+
+       if (samplerates->step)
+       {
+               _sample_rate_value.setRange(
+                       samplerates->low, samplerates->high);
+               _sample_rate_value.setSingleStep(samplerates->step);
+               _sample_rate_value_action->setVisible(true);
+       }
+       else
+       {
+               _sample_rate_list.clear();
+               for (const uint64_t *rate = samplerates->list;
+                    *rate; rate++)
+                       _sample_rate_list.addItem(
+                               sr_samplerate_string(*rate),
+                               qVariantFromValue(*rate));
+               _sample_rate_list.show();
+               _sample_rate_list_action->setVisible(true);
+       }
+
+       update_sample_rate_selector_value();
+}
+
+void SamplingBar::update_sample_rate_selector_value()
+{
+       sr_dev_inst *const sdi = get_selected_device();
+       assert(sdi);
+
+       uint64_t *samplerate = NULL;
+       if (sr_config_get(sdi->driver, SR_CONF_SAMPLERATE,
+               (const void**)&samplerate, sdi) != SR_OK) {
+               qDebug() <<
+                               "WARNING: Failed to get value of sample rate";
+               return;
+       }
+
+       assert(_sample_rate_value_action);
+       assert(_sample_rate_list_action);
+
+       if (_sample_rate_value_action->isVisible())
+               _sample_rate_value.setValue(*samplerate);
+       else if (_sample_rate_list_action->isVisible())
+       {
+               for (int i = 0; i < _sample_rate_list.count(); i++)
+                       if (*samplerate == _sample_rate_list.itemData(
+                               i).value<uint64_t>())
+                               _sample_rate_list.setCurrentIndex(i);
+       }
+}
+
+void SamplingBar::commit_sample_rate()
+{
+       uint64_t sample_rate = 0;
+
+       sr_dev_inst *const sdi = get_selected_device();
+       assert(sdi);
+
+       assert(_sample_rate_value_action);
+       assert(_sample_rate_list_action);
+
+       if (_sample_rate_value_action->isVisible())
+               sample_rate = (uint64_t)_sample_rate_value.value();
+       else if (_sample_rate_list_action->isVisible())
+       {
+               const int index = _sample_rate_list.currentIndex();
+               if (index >= 0)
+                       sample_rate = _sample_rate_list.itemData(
+                               index).value<uint64_t>();
+       }
+
+       // Set the samplerate
+       if (sr_config_set(sdi, SR_CONF_SAMPLERATE,
+               &sample_rate) != SR_OK) {
+               qDebug() << "Failed to configure samplerate.";
+               return;
+       }
+}
+
+void SamplingBar::on_device_selected()
+{
+       update_sample_rate_selector();
+}
+
+void SamplingBar::on_sample_rate_changed()
+{
+       commit_sample_rate();
+}
+
+void SamplingBar::configure()
+{
+       commit_sample_rate();
+
+       sr_dev_inst *const sdi = get_selected_device();
+       assert(sdi);
+
+       pv::dialogs::DeviceOptions dlg(this, sdi);
+       dlg.exec();
+
+       update_sample_rate_selector_value();
+}
+
+} // namespace toolbars
+} // namespace pv
diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h
new file mode 100644 (file)
index 0000000..3502e25
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
+#define PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
+
+#include <stdint.h>
+
+#include <list>
+
+#include <QComboBox>
+#include <QDoubleSpinBox>
+#include <QToolBar>
+#include <QToolButton>
+
+struct st_dev_inst;
+class QAction;
+
+namespace pv {
+namespace toolbars {
+
+class SamplingBar : public QToolBar
+{
+       Q_OBJECT
+
+private:
+       static const uint64_t RecordLengths[20];
+       static const uint64_t DefaultRecordLength;
+
+public:
+       SamplingBar(QWidget *parent);
+
+       void set_device_list(const std::list<struct sr_dev_inst*> &devices);
+
+       struct sr_dev_inst* get_selected_device() const;
+       void set_selected_device(struct sr_dev_inst *const sdi);
+
+       uint64_t get_record_length() const;
+
+       void set_sampling(bool sampling);
+
+signals:
+       void run_stop();
+
+private:
+       void update_sample_rate_selector();
+       void update_sample_rate_selector_value();
+       void commit_sample_rate();
+
+private slots:
+       void on_device_selected();
+       void on_sample_rate_changed();
+       void configure();
+
+private:
+       QComboBox _device_selector;
+       QToolButton _configure_button;
+
+       QComboBox _record_length_selector;
+
+       QComboBox _sample_rate_list;
+       QAction *_sample_rate_list_action;
+       QDoubleSpinBox _sample_rate_value;
+       QAction *_sample_rate_value_action;
+
+       QIcon _icon_green;
+       QIcon _icon_grey;
+       QToolButton _run_stop_button;
+};
+
+} // namespace toolbars
+} // namespace pv
+
+#endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H