]> sigrok.org Git - pulseview.git/blame - pv/data/decode/row.cpp
DecodeTrace: Add widget container
[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
JH
37 decoder_(decoder),
38 row_(row)
f9101a91
JH
39{
40}
41
cbb2e4da 42const Decoder* Row::decoder() const
f9101a91 43{
8dbbc7f0 44 return decoder_;
f9101a91
JH
45}
46
cbb2e4da 47const srd_decoder_annotation_row* Row::srd_row() const
f9101a91 48{
8dbbc7f0 49 return row_;
f9101a91
JH
50}
51
88908838
JH
52const QString Row::title() const
53{
cbb2e4da 54 if (decoder_ && decoder_->name() && row_ && row_->desc)
88908838 55 return QString("%1: %2")
cbb2e4da 56 .arg(QString::fromUtf8(decoder_->name()),
744aa24f 57 QString::fromUtf8(row_->desc));
cbb2e4da
SA
58 if (decoder_ && decoder_->name())
59 return QString::fromUtf8(decoder_->name());
8dbbc7f0
JH
60 if (row_ && row_->desc)
61 return QString::fromUtf8(row_->desc);
88908838
JH
62 return QString();
63}
64
1ed996b4
SA
65const QString Row::class_name() const
66{
67 if (row_ && row_->desc)
68 return QString::fromUtf8(row_->desc);
69 return QString();
70}
71
f9807084
SA
72int Row::index() const
73{
74 return index_;
75}
76
cbb2e4da 77bool Row::operator<(const Row& other) const
f9101a91 78{
8dbbc7f0
JH
79 return (decoder_ < other.decoder_) ||
80 (decoder_ == other.decoder_ && row_ < other.row_);
f9101a91
JH
81}
82
cbb2e4da 83bool Row::operator==(const Row& other) const
84002113 84{
cbb2e4da 85 return ((decoder_ == other.decoder()) && (row_ == other.srd_row()));
84002113
SA
86}
87
870ea3db
UH
88} // namespace decode
89} // namespace data
90} // namespace pv