2 * This file is part of the PulseView project.
4 * Copyright (C) 2020 Soeren Apel <soeren@apelpie.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef PULSEVIEW_PV_VIEWS_TABULARDECODER_VIEW_HPP
21 #define PULSEVIEW_PV_VIEWS_TABULARDECODER_VIEW_HPP
26 #include <QToolButton>
28 #include "pv/globalsettings.hpp"
29 #include "pv/views/viewbase.hpp"
30 #include "pv/data/decodesignal.hpp"
37 namespace tabular_decoder {
39 class AnnotationCollectionModel : public QAbstractTableModel, public GlobalSettingsInterface
44 AnnotationCollectionModel(QObject* parent = nullptr);
46 QVariant data(const QModelIndex& index, int role) const override;
47 Qt::ItemFlags flags(const QModelIndex& index) const override;
49 QVariant headerData(int section, Qt::Orientation orientation,
50 int role = Qt::DisplayRole) const override;
51 QModelIndex index(int row, int column,
52 const QModelIndex& parent_idx = QModelIndex()) const override;
54 QModelIndex parent(const QModelIndex& index) const override;
56 int rowCount(const QModelIndex& parent_idx = QModelIndex()) const override;
57 int columnCount(const QModelIndex& parent_idx = QModelIndex()) const override;
59 void set_signal_and_segment(data::DecodeSignal* signal, uint32_t current_segment);
61 void on_setting_changed(const QString &key, const QVariant &value) override;
64 vector<QVariant> header_data_;
65 const deque<const Annotation*>* all_annotations_;
66 data::DecodeSignal* signal_;
67 uint32_t prev_segment_;
68 uint64_t prev_last_row_;
73 class QCustomTableView : public QTableView
78 QSize minimumSizeHint() const;
79 QSize sizeHint() const;
83 class View : public ViewBase
88 explicit View(Session &session, bool is_main_view=false, QMainWindow *parent = nullptr);
90 virtual ViewType get_type() const;
93 * Resets the view to its default state after construction. It does however
94 * not reset the signal bases or any other connections with the session.
96 virtual void reset_view_state();
98 virtual void clear_decode_signals();
99 virtual void add_decode_signal(shared_ptr<data::DecodeSignal> signal);
100 virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
102 virtual void save_settings(QSettings &settings) const;
103 virtual void restore_settings(QSettings &settings);
109 void save_data() const;
112 void on_selected_decoder_changed(int index);
113 void on_signal_name_changed(const QString &name);
114 void on_signal_color_changed(const QColor &color);
115 void on_new_annotations();
117 void on_decoder_reset();
118 void on_decoder_stacked(void* decoder);
119 void on_decoder_removed(void* decoder);
121 void on_actionSave_triggered(QAction* action = nullptr);
123 virtual void perform_delayed_view_update();
128 QComboBox* decoder_selector_;
130 QToolButton* save_button_;
131 QAction* save_action_;
133 QCustomTableView* table_view_;
135 AnnotationCollectionModel* model_;
137 data::DecodeSignal* signal_;
138 const data::decode::Decoder* decoder_;
142 } // namespace tabular_decoder
146 #endif // PULSEVIEW_PV_VIEWS_TABULARDECODER_VIEW_HPP