2 * This file is part of the PulseView project.
4 * Copyright (C) 2018 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_SUBWINDOWS_DECODERSELECTOR_SUBWINDOW_HPP
21 #define PULSEVIEW_PV_SUBWINDOWS_DECODERSELECTOR_SUBWINDOW_HPP
25 #include <QAbstractItemModel>
30 #include "pv/subwindows/subwindowbase.hpp"
32 using std::shared_ptr;
35 namespace subwindows {
36 namespace decoder_selector {
38 class DecoderCollectionItem
41 DecoderCollectionItem(const vector<QVariant>& data,
42 shared_ptr<DecoderCollectionItem> parent = nullptr);
44 void appendSubItem(shared_ptr<DecoderCollectionItem> item);
46 shared_ptr<DecoderCollectionItem> subItem(int row) const;
47 shared_ptr<DecoderCollectionItem> parent() const;
48 shared_ptr<DecoderCollectionItem> findSubItem(const QVariant& value, int column);
50 int subItemCount() const;
51 int columnCount() const;
53 QVariant data(int column) const;
56 vector< shared_ptr<DecoderCollectionItem> > subItems_;
57 vector<QVariant> data_;
58 shared_ptr<DecoderCollectionItem> parent_;
62 class DecoderCollectionModel : public QAbstractItemModel
67 DecoderCollectionModel(QObject* parent = 0);
69 QVariant data(const QModelIndex& index, int role) const override;
70 Qt::ItemFlags flags(const QModelIndex& index) const override;
72 QVariant headerData(int section, Qt::Orientation orientation,
73 int role = Qt::DisplayRole) const override;
74 QModelIndex index(int row, int column,
75 const QModelIndex& parent_idx = QModelIndex()) const override;
77 QModelIndex parent(const QModelIndex& index) const override;
79 int rowCount(const QModelIndex& parent_idx = QModelIndex()) const override;
80 int columnCount(const QModelIndex& parent_idx = QModelIndex()) const override;
83 shared_ptr<DecoderCollectionItem> root_;
87 class SubWindow : public SubWindowBase
92 explicit SubWindow(Session &session, QWidget *parent = nullptr);
94 bool has_toolbar() const;
95 QToolBar* create_toolbar(QWidget *parent) const;
97 const srd_decoder* get_srd_decoder_from_id(QString id) const;
100 * Returns a list of input types that a given protocol decoder requires
101 * ("logic", "uart", etc.)
103 vector<const char*> decoder_inputs(const srd_decoder* d) const;
106 * Returns a list of protocol decoder IDs which provide a given output
107 * ("uart", "spi", etc.)
109 vector<const srd_decoder*> decoders_providing(const char* output) const;
112 void new_decoders_selected(vector<const srd_decoder*> decoders);
115 void on_item_clicked(const QModelIndex& index);
116 void on_item_double_clicked(const QModelIndex& index);
119 QSplitter* splitter_;
120 QTreeView* tree_view_;
122 QLabel* info_label_header_;
123 QLabel* info_label_body_;
124 QLabel* info_label_footer_;
125 DecoderCollectionModel* model_;
128 } // decoder_selector
129 } // namespace subwindows
132 #endif // PULSEVIEW_PV_SUBWINDOWS_DECODERSELECTOR_SUBWINDOW_HPP