2 * This file is part of the PulseView project.
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
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 "decoder.hpp"
23 #include <libsigrokdecode/libsigrokdecode.h>
37 Row::Row(uint32_t index, Decoder* decoder, const srd_decoder_annotation_row* srd_row) :
45 const Decoder* Row::decoder() const
50 const srd_decoder_annotation_row* Row::get_srd_row() const
55 const QString Row::title() const
57 if (decoder_ && decoder_->name() && srd_row_ && srd_row_->desc)
58 return QString("%1: %2")
59 .arg(QString::fromUtf8(decoder_->name()),
60 QString::fromUtf8(srd_row_->desc));
61 if (decoder_ && decoder_->name())
62 return QString::fromUtf8(decoder_->name());
63 if (srd_row_ && srd_row_->desc)
64 return QString::fromUtf8(srd_row_->desc);
69 const QString Row::description() const
71 if (srd_row_ && srd_row_->desc)
72 return QString::fromUtf8(srd_row_->desc);
76 vector<AnnotationClass*> Row::ann_classes() const
80 vector<AnnotationClass*> result;
84 // When operating as the fallback row, all annotation classes belong to it
85 return decoder_->ann_classes();
90 for (GSList *l = srd_row_->ann_classes; l; l = l->next) {
91 size_t class_id = (size_t)l->data;
92 result.push_back(decoder_->get_ann_class_by_id(class_id));
98 uint32_t Row::index() const
103 bool Row::visible() const
108 void Row::set_visible(bool visible)
113 bool Row::has_hidden_classes() const
115 for (const AnnotationClass* c : ann_classes())
122 bool Row::operator<(const Row& other) const
124 return (decoder_ < other.decoder_) ||
125 (decoder_ == other.decoder_ && srd_row_ < other.srd_row_);
128 bool Row::operator==(const Row& other) const
130 return ((decoder_ == other.decoder()) && (srd_row_ == other.srd_row_));
133 } // namespace decode