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 #include "subwindow.hpp"
22 using std::out_of_range;
25 namespace subwindows {
26 namespace decoder_selector {
28 DecoderCollectionItem::DecoderCollectionItem(const vector<QVariant>& data,
29 shared_ptr<DecoderCollectionItem> parent) :
35 void DecoderCollectionItem::appendSubItem(shared_ptr<DecoderCollectionItem> item)
37 subItems_.push_back(item);
40 shared_ptr<DecoderCollectionItem> DecoderCollectionItem::subItem(int row) const
43 return subItems_.at(row);
44 } catch (out_of_range) {
49 shared_ptr<DecoderCollectionItem> DecoderCollectionItem::parent() const
54 shared_ptr<DecoderCollectionItem> DecoderCollectionItem::findSubItem(
55 const QVariant& value, int column)
57 for (shared_ptr<DecoderCollectionItem> item : subItems_)
58 if (item->data(column) == value)
64 int DecoderCollectionItem::subItemCount() const
66 return subItems_.size();
69 int DecoderCollectionItem::columnCount() const
74 int DecoderCollectionItem::row() const
77 for (uint i = 0; i < parent_->subItems_.size(); i++)
78 if (parent_->subItems_.at(i).get() == const_cast<DecoderCollectionItem*>(this))
84 QVariant DecoderCollectionItem::data(int column) const
87 return data_.at(column);
88 } catch (out_of_range) {
93 } // namespace decoder_selector
94 } // namespace subwindows