X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsubwindows%2Fdecoder_selector%2Fsubwindow.hpp;fp=pv%2Fsubwindows%2Fdecoder_selector%2Fsubwindow.hpp;h=1b75a6c7d3bc30fd59eed491c3ff59b1bf1f40c7;hp=0000000000000000000000000000000000000000;hb=97378470ded88af84edaa0f1063d10d834475665;hpb=58cd5b584f5bcb19d7c9bd28391c53dd2488fc59 diff --git a/pv/subwindows/decoder_selector/subwindow.hpp b/pv/subwindows/decoder_selector/subwindow.hpp new file mode 100644 index 0000000..1b75a6c --- /dev/null +++ b/pv/subwindows/decoder_selector/subwindow.hpp @@ -0,0 +1,127 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2018 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_SUBWINDOWS_DECODERSELECTOR_SUBWINDOW_HPP +#define PULSEVIEW_PV_SUBWINDOWS_DECODERSELECTOR_SUBWINDOW_HPP + +#include + +#include +#include +#include + +#include "pv/subwindows/subwindowbase.hpp" + +using std::shared_ptr; + +namespace pv { +namespace subwindows { +namespace decoder_selector { + +class DecoderCollectionItem +{ +public: + DecoderCollectionItem(const vector& data, + shared_ptr parent = nullptr); + + void appendSubItem(shared_ptr item); + + shared_ptr subItem(int row) const; + shared_ptr parent() const; + shared_ptr findSubItem(const QVariant& value, int column); + + int subItemCount() const; + int columnCount() const; + int row() const; + QVariant data(int column) const; + +private: + vector< shared_ptr > subItems_; + vector data_; + shared_ptr parent_; +}; + + +class DecoderCollectionModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + DecoderCollectionModel(QObject* parent = 0); + + QVariant data(const QModelIndex& index, int role) const override; + Qt::ItemFlags flags(const QModelIndex& index) const override; + + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; + QModelIndex index(int row, int column, + const QModelIndex& parent_idx = QModelIndex()) const override; + + QModelIndex parent(const QModelIndex& index) const override; + + int rowCount(const QModelIndex& parent_idx = QModelIndex()) const override; + int columnCount(const QModelIndex& parent_idx = QModelIndex()) const override; + +private: + shared_ptr root_; +}; + + +class SubWindow : public SubWindowBase +{ + Q_OBJECT + +public: + explicit SubWindow(Session &session, QWidget *parent = nullptr); + + bool has_toolbar() const; + QToolBar* create_toolbar(QWidget *parent) const; + + const srd_decoder* get_srd_decoder_from_id(QString id) const; + + /** + * Returns a list of input types that a given protocol decoder requires + * ("logic", "uart", etc.) + */ + vector decoder_inputs(const srd_decoder* d) const; + + /** + * Returns a list of protocol decoder IDs which provide a given output + * ("uart", "spi", etc.) + */ + vector decoders_providing(const char* output) const; + +Q_SIGNALS: + void new_decoders_selected(vector decoders); + +public Q_SLOTS: + void on_item_double_clicked(const QModelIndex& index); + +private: + QSplitter* splitter_; + QTreeView* tree_view_; + DecoderCollectionModel* model_; +}; + +} // decoder_selector +} // namespace subwindows +} // namespace pv + +#endif // PULSEVIEW_PV_SUBWINDOWS_DECODERSELECTOR_SUBWINDOW_HPP +