Make member variable underscores a suffix instead of a prefix
[pulseview.git] / pv / toolbars / samplingbar.h
index d7ad4f2f604107c50b783ab22cb6e545826f11cc..2397e2aa5c20b6821b4e2159f20bd9598a5346fd 100644 (file)
 #include <stdint.h>
 
 #include <list>
+#include <memory>
 
 #include <QComboBox>
 #include <QDoubleSpinBox>
 #include <QToolBar>
 #include <QToolButton>
 
-struct st_dev_inst;
+#include <pv/sigsession.h>
+#include <pv/widgets/popuptoolbutton.h>
+#include <pv/widgets/sweeptimingwidget.h>
+
+namespace sigrok {
+       class Device;
+}
+
+Q_DECLARE_METATYPE(std::shared_ptr<sigrok::Device>)
+
 class QAction;
 
 namespace pv {
+
+class SigSession;
+
 namespace toolbars {
 
 class SamplingBar : public QToolBar
@@ -41,48 +54,65 @@ class SamplingBar : public QToolBar
        Q_OBJECT
 
 private:
-       static const uint64_t RecordLengths[20];
-       static const uint64_t DefaultRecordLength;
+       static const uint64_t MinSampleCount;
+       static const uint64_t MaxSampleCount;
+       static const uint64_t DefaultSampleCount;
 
 public:
-       SamplingBar(QWidget *parent);
-
-       void set_device_list(const std::list<struct sr_dev_inst*> &devices);
+       SamplingBar(SigSession &session, QWidget *parent);
 
-       struct sr_dev_inst* get_selected_device() const;
-       void set_selected_device(struct sr_dev_inst *const sdi);
+       void set_device_list(
+               const std::list< std::pair<std::shared_ptr<sigrok::Device>, std::string> > &devices,
+               std::shared_ptr<sigrok::Device> selected);
 
-       uint64_t get_record_length() const;
+       std::shared_ptr<sigrok::Device> get_selected_device() const;
 
-       void set_sampling(bool sampling);
+       void set_capture_state(pv::SigSession::capture_state state);
 
-signals:
+Q_SIGNALS:
        void run_stop();
 
 private:
        void update_sample_rate_selector();
        void update_sample_rate_selector_value();
+       void update_sample_count_selector();
+       void update_device_config_widgets();
        void commit_sample_rate();
+       void commit_sample_count();
 
-private slots:
+private Q_SLOTS:
        void on_device_selected();
+       void on_sample_count_changed();
        void on_sample_rate_changed();
-       void on_configure();
+       void on_run_stop();
+
+       void on_config_changed();
+
+protected:
+       bool eventFilter(QObject *watched, QEvent *event);
 
 private:
-       QComboBox _device_selector;
-       QToolButton _configure_button;
+       SigSession &session_;
+
+       QComboBox device_selector_;
+       bool updating_device_selector_;
+
+       pv::widgets::PopupToolButton configure_button_;
+       QAction *configure_button_action_;
+
+       pv::widgets::PopupToolButton channels_button_;
 
-       QComboBox _record_length_selector;
+       pv::widgets::SweepTimingWidget sample_count_;
+       pv::widgets::SweepTimingWidget sample_rate_;
+       bool updating_sample_rate_;
+       bool updating_sample_count_;
 
-       QComboBox _sample_rate_list;
-       QAction *_sample_rate_list_action;
-       QDoubleSpinBox _sample_rate_value;
-       QAction *_sample_rate_value_action;
+       bool sample_count_supported_;
 
-       QIcon _icon_green;
-       QIcon _icon_grey;
-       QToolButton _run_stop_button;
+       QIcon icon_red_;
+       QIcon icon_green_;
+       QIcon icon_grey_;
+       QToolButton run_stop_button_;
 };
 
 } // namespace toolbars