]> sigrok.org Git - pulseview.git/blobdiff - pv/views/decoder_output/view.hpp
QHexView: Fix selection display
[pulseview.git] / pv / views / decoder_output / view.hpp
index 39869d514b289b8a80d53cd11fd2b743e27b0065..a6362ede7ac59646e1b08e43124c741abaab96d9 100644 (file)
 #ifndef PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP
 #define PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP
 
+#include <QAction>
 #include <QComboBox>
 #include <QStackedWidget>
+#include <QToolButton>
 
 #include <pv/views/viewbase.hpp>
 #include <pv/data/decodesignal.hpp>
@@ -36,6 +38,18 @@ namespace views {
 
 namespace decoder_output {
 
+// When adding an entry here, don't forget to update SaveTypeNames as well
+enum SaveType {
+       SaveTypeBinary,
+       SaveTypeHexDumpPlain,
+       SaveTypeHexDumpWithOffset,
+       SaveTypeHexDumpComplete,
+       SaveTypeCount  // Indicates how many save types there are, must always be last
+};
+
+extern const char* SaveTypeNames[SaveTypeCount];
+
+
 class View : public ViewBase
 {
        Q_OBJECT
@@ -53,8 +67,6 @@ public:
         */
        virtual void reset_view_state();
 
-       virtual void clear_signals();
-
        virtual void clear_decode_signals();
        virtual void add_decode_signal(shared_ptr<data::DecodeSignal> signal);
        virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
@@ -63,8 +75,12 @@ public:
        virtual void restore_settings(QSettings &settings);
 
 private:
+       void reset_data();
        void update_data();
 
+       void save_data() const;
+       void save_data_as_hex_dump(bool with_offset=false, bool with_ascii=false) const;
+
 private Q_SLOTS:
        void on_selected_decoder_changed(int index);
        void on_selected_class_changed(int index);
@@ -74,6 +90,8 @@ private Q_SLOTS:
        void on_decoder_stacked(void* decoder);
        void on_decoder_removed(void* decoder);
 
+       void on_actionSave_triggered(QAction* action = nullptr);
+
        virtual void perform_delayed_view_update();
 
 private:
@@ -83,9 +101,13 @@ private:
        QStackedWidget *stacked_widget_;
        QHexView *hex_view_;
 
+       QToolButton* save_button_;
+       QAction* save_action_;
+
        data::DecodeSignal *signal_;
        const data::decode::Decoder *decoder_;
        uint32_t bin_class_id_;
+       bool binary_data_exists_;
 };
 
 } // namespace decoder_output