]> sigrok.org Git - pulseview.git/blame_incremental - pv/data/decode/row.cpp
Implement hidable rows
[pulseview.git] / pv / data / decode / row.cpp
... / ...
CommitLineData
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
20#include "decoder.hpp"
21#include "row.hpp"
22
23#include <libsigrokdecode/libsigrokdecode.h>
24
25namespace pv {
26namespace data {
27namespace decode {
28
29Row::Row() :
30 decoder_(nullptr),
31 row_(nullptr)
32{
33}
34
35Row::Row(int index, const Decoder* decoder, const srd_decoder_annotation_row* row) :
36 index_(index),
37 decoder_(decoder),
38 row_(row),
39 visible_(true)
40{
41}
42
43const Decoder* Row::decoder() const
44{
45 return decoder_;
46}
47
48const srd_decoder_annotation_row* Row::srd_row() const
49{
50 return row_;
51}
52
53const QString Row::title() const
54{
55 if (decoder_ && decoder_->name() && row_ && row_->desc)
56 return QString("%1: %2")
57 .arg(QString::fromUtf8(decoder_->name()),
58 QString::fromUtf8(row_->desc));
59 if (decoder_ && decoder_->name())
60 return QString::fromUtf8(decoder_->name());
61 if (row_ && row_->desc)
62 return QString::fromUtf8(row_->desc);
63 return QString();
64}
65
66const QString Row::class_name() const
67{
68 if (row_ && row_->desc)
69 return QString::fromUtf8(row_->desc);
70 return QString();
71}
72
73int Row::index() const
74{
75 return index_;
76}
77
78bool Row::visible() const
79{
80 return visible_;
81}
82
83void Row::set_visible(bool visible)
84{
85 visible_ = visible;
86}
87
88bool Row::operator<(const Row& other) const
89{
90 return (decoder_ < other.decoder_) ||
91 (decoder_ == other.decoder_ && row_ < other.row_);
92}
93
94bool Row::operator==(const Row& other) const
95{
96 return ((decoder_ == other.decoder()) && (row_ == other.srd_row()));
97}
98
99} // namespace decode
100} // namespace data
101} // namespace pv