DecoderOutput: Add basic view skeleton
authorSoeren Apel <soeren@apelpie.net>
Mon, 25 Nov 2019 10:22:30 +0000 (11:22 +0100)
committerSoeren Apel <soeren@apelpie.net>
Mon, 25 Nov 2019 10:22:30 +0000 (11:22 +0100)
CMakeLists.txt
pv/views/decoder_output/view.cpp [new file with mode: 0644]
pv/views/decoder_output/view.hpp [new file with mode: 0644]
pv/views/trace/view.hpp

index fd0d8b7e46bb05861bec3afb7c68f36e3e10629f..c5824d3214cec39ed87dd393b7d16fad2c1cdefb 100644 (file)
@@ -386,6 +386,7 @@ if(ENABLE_DECODE)
                pv/subwindows/decoder_selector/item.cpp
                pv/subwindows/decoder_selector/model.cpp
                pv/subwindows/decoder_selector/subwindow.cpp
+               pv/views/decoder_output/view.cpp
                pv/views/trace/decodetrace.cpp
                pv/widgets/decodergroupbox.cpp
                pv/widgets/decodermenu.cpp
@@ -394,6 +395,7 @@ if(ENABLE_DECODE)
        list(APPEND pulseview_HEADERS
                pv/data/decodesignal.hpp
                pv/subwindows/decoder_selector/subwindow.hpp
+               pv/views/decoder_output/view.hpp
                pv/views/trace/decodetrace.hpp
                pv/widgets/decodergroupbox.hpp
                pv/widgets/decodermenu.hpp
diff --git a/pv/views/decoder_output/view.cpp b/pv/views/decoder_output/view.cpp
new file mode 100644 (file)
index 0000000..e6e42cb
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2019 Soeren Apel <soeren@apelpie.net>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libsigrokdecode/libsigrokdecode.h>
+
+#include <QMenu>
+#include <QVBoxLayout>
+
+#include "view.hpp"
+
+#include "pv/session.hpp"
+#include "pv/util.hpp"
+
+using pv::util::TimeUnit;
+using pv::util::Timestamp;
+
+using std::shared_ptr;
+
+namespace pv {
+namespace views {
+namespace decoder_output {
+
+View::View(Session &session, bool is_main_view, QWidget *parent) :
+       ViewBase(session, is_main_view, parent)
+
+       // Note: Place defaults in View::reset_view_state(), not here
+{
+       QVBoxLayout *root_layout = new QVBoxLayout(this);
+       root_layout->setContentsMargins(0, 0, 0, 0);
+
+       reset_view_state();
+}
+
+View::~View()
+{
+}
+
+void View::reset_view_state()
+{
+       ViewBase::reset_view_state();
+}
+
+void View::clear_signals()
+{
+       ViewBase::clear_signalbases();
+}
+
+void View::clear_decode_signals()
+{
+}
+
+void View::add_decode_signal(shared_ptr<data::DecodeSignal> signal)
+{
+       connect(signal.get(), SIGNAL(name_changed(const QString&)),
+               this, SLOT(on_signal_name_changed()));
+}
+
+void View::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
+{
+       (void)signal;
+}
+
+void View::save_settings(QSettings &settings) const
+{
+       (void)settings;
+}
+
+void View::restore_settings(QSettings &settings)
+{
+       // Note: It is assumed that this function is only called once,
+       // immediately after restoring a previous session.
+       (void)settings;
+}
+
+void View::on_signal_name_changed()
+{
+}
+
+} // namespace decoder_output
+} // namespace views
+} // namespace pv
diff --git a/pv/views/decoder_output/view.hpp b/pv/views/decoder_output/view.hpp
new file mode 100644 (file)
index 0000000..a780c2f
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2019 Soeren Apel <soeren@apelpie.net>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP
+#define PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP
+
+#include <pv/views/viewbase.hpp>
+
+namespace pv {
+
+class Session;
+
+namespace views {
+
+namespace decoder_output {
+
+class View : public ViewBase
+{
+       Q_OBJECT
+
+public:
+       explicit View(Session &session, bool is_main_view=false, QWidget *parent = nullptr);
+
+       ~View();
+
+       /**
+        * Resets the view to its default state after construction. It does however
+        * not reset the signal bases or any other connections with the session.
+        */
+       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);
+
+       virtual void save_settings(QSettings &settings) const;
+       virtual void restore_settings(QSettings &settings);
+
+private Q_SLOTS:
+       void on_signal_name_changed();
+
+};
+
+} // namespace decoder_output
+} // namespace views
+} // namespace pv
+
+#endif // PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP
index 439823c09a8994ce7f67b56623834c8b398202d6..6c8ff3d1075d3e42d54ab8c478881fe86e2622a5 100644 (file)
@@ -110,8 +110,8 @@ public:
         */
        virtual void reset_view_state();
 
-       Session& session();
-       const Session& session() const;
+       Session& session();  // This method is needed for TraceTreeItemOwner, not ViewBase
+       const Session& session() const;  // This method is needed for TraceTreeItemOwner, not ViewBase
 
        /**
         * Returns the signals contained in this view.