]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decode/annotation.cpp
TabularDecView: Make the model/view work
[pulseview.git] / pv / data / decode / annotation.cpp
index e32dcc9fdc7f0b529dde1b90666b21abbe64e69e..689c08dec6eaf16a1ba9a52acc259fd38c30f36e 100644 (file)
@@ -25,6 +25,7 @@ extern "C" {
 #include <vector>
 
 #include <pv/data/decode/annotation.hpp>
+#include <pv/data/decode/decoder.hpp>
 
 using std::vector;
 
@@ -85,8 +86,7 @@ Annotation& Annotation::operator=(Annotation&& a)
 
 Annotation::~Annotation()
 {
-       if (annotations_)
-               delete annotations_;
+       delete annotations_;
 }
 
 uint64_t Annotation::start_sample() const
@@ -104,11 +104,24 @@ Annotation::Class Annotation::ann_class_id() const
        return ann_class_id_;
 }
 
+const QString Annotation::ann_class_name() const
+{
+       const AnnotationClass* ann_class =
+               row_->decoder()->get_ann_class_by_id(ann_class_id_);
+
+       return QString(ann_class->name);
+}
+
 const vector<QString>* Annotation::annotations() const
 {
        return annotations_;
 }
 
+const QString Annotation::longest_annotation() const
+{
+       return annotations_->front();
+}
+
 const Row* Annotation::row() const
 {
        return row_;