From 2bdc5796c866b9494b2c40051e973e4385d9c46f Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Mon, 25 Nov 2019 11:22:30 +0100 Subject: [PATCH] DecoderOutput: Add basic view skeleton --- CMakeLists.txt | 2 + pv/views/decoder_output/view.cpp | 97 ++++++++++++++++++++++++++++++++ pv/views/decoder_output/view.hpp | 66 ++++++++++++++++++++++ pv/views/trace/view.hpp | 4 +- 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 pv/views/decoder_output/view.cpp create mode 100644 pv/views/decoder_output/view.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fd0d8b7e..c5824d32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 00000000..e6e42cbb --- /dev/null +++ b/pv/views/decoder_output/view.cpp @@ -0,0 +1,97 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2019 Soeren Apel + * + * 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 . + */ + +#include + +#include +#include + +#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 signal) +{ + connect(signal.get(), SIGNAL(name_changed(const QString&)), + this, SLOT(on_signal_name_changed())); +} + +void View::remove_decode_signal(shared_ptr 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 index 00000000..a780c2f3 --- /dev/null +++ b/pv/views/decoder_output/view.hpp @@ -0,0 +1,66 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2019 Soeren Apel + * + * 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 . + */ + +#ifndef PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP +#define PULSEVIEW_PV_VIEWS_DECODEROUTPUT_VIEW_HPP + +#include + +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 signal); + virtual void remove_decode_signal(shared_ptr 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 diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index 439823c0..6c8ff3d1 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -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. -- 2.30.2