]> sigrok.org Git - pulseview.git/blame - pv/data/decode/row.cpp
Implement hidable rows
[pulseview.git] / pv / data / decode / row.cpp
CommitLineData
f9101a91
JH
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
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
f9101a91
JH
18 */
19
cbb2e4da 20#include "decoder.hpp"
2acdb232 21#include "row.hpp"
f9101a91 22
88908838
JH
23#include <libsigrokdecode/libsigrokdecode.h>
24
f9101a91
JH
25namespace pv {
26namespace data {
27namespace decode {
28
29Row::Row() :
4c60462b
JH
30 decoder_(nullptr),
31 row_(nullptr)
f9101a91
JH
32{
33}
34
cbb2e4da 35Row::Row(int index, const Decoder* decoder, const srd_decoder_annotation_row* row) :
f9807084 36 index_(index),
8dbbc7f0 37 decoder_(decoder),
c6b4e925
SA
38 row_(row),
39 visible_(true)
f9101a91
JH
40{
41}
42
cbb2e4da 43const Decoder* Row::decoder() const
f9101a91 44{
8dbbc7f0 45 return decoder_;
f9101a91
JH
46}
47
cbb2e4da 48const srd_decoder_annotation_row* Row::srd_row() const
f9101a91 49{
8dbbc7f0 50 return row_;
f9101a91
JH
51}
52
88908838
JH
53const QString Row::title() const
54{
cbb2e4da 55 if (decoder_ && decoder_->name() && row_ && row_->desc)
88908838 56 return QString("%1: %2")
cbb2e4da 57 .arg(QString::fromUtf8(decoder_->name()),
744aa24f 58 QString::fromUtf8(row_->desc));
cbb2e4da
SA
59 if (decoder_ && decoder_->name())
60 return QString::fromUtf8(decoder_->name());
8dbbc7f0
JH
61 if (row_ && row_->desc)
62 return QString::fromUtf8(row_->desc);
88908838
JH
63 return QString();
64}
65
1ed996b4
SA
66const QString Row::class_name() const
67{
68 if (row_ && row_->desc)
69 return QString::fromUtf8(row_->desc);
70 return QString();
71}
72
f9807084
SA
73int Row::index() const
74{
75 return index_;
76}
77
c6b4e925
SA
78bool Row::visible() const
79{
80 return visible_;
81}
82
83void Row::set_visible(bool visible)
84{
85 visible_ = visible;
86}
87
cbb2e4da 88bool Row::operator<(const Row& other) const
f9101a91 89{
8dbbc7f0
JH
90 return (decoder_ < other.decoder_) ||
91 (decoder_ == other.decoder_ && row_ < other.row_);
f9101a91
JH
92}
93
cbb2e4da 94bool Row::operator==(const Row& other) const
84002113 95{
cbb2e4da 96 return ((decoder_ == other.decoder()) && (row_ == other.srd_row()));
84002113
SA
97}
98
870ea3db
UH
99} // namespace decode
100} // namespace data
101} // namespace pv