kwave  18.07.70
Kwave::LabelList Class Reference

#include <LabelList.h>

Inheritance diagram for Kwave::LabelList:
Inheritance graph
Collaboration diagram for Kwave::LabelList:
Collaboration graph

Public Member Functions

 LabelList ()
 
 LabelList (const Kwave::MetaDataList &meta_data_list)
 
virtual ~LabelList ()
 
virtual void sort ()
 
Kwave::MetaDataList toMetaDataList () const
 
sample_index_t nextLabelLeft (sample_index_t from)
 
sample_index_t nextLabelRight (sample_index_t from)
 

Detailed Description

not more than a typedef since Qt4

Definition at line 33 of file LabelList.h.

Constructor & Destructor Documentation

◆ LabelList() [1/2]

Kwave::LabelList::LabelList ( )

Default constructor

Definition at line 28 of file LabelList.cpp.

29  :QList<Kwave::Label>()
30 {
31 }

◆ LabelList() [2/2]

Kwave::LabelList::LabelList ( const Kwave::MetaDataList meta_data_list)
explicit

Constructor, creates a label list from a list of meta data objects, by filtering out all objects of label type (already sorted by position)

Parameters
meta_data_listlist of meta data

Definition at line 34 of file LabelList.cpp.

References Kwave::Label::metaDataType(), Kwave::MetaDataList::selectByType(), sort(), and Kwave::MetaDataList::toSortedList().

35  :QList<Kwave::Label>()
36 {
37  if (!meta_data_list.isEmpty()) {
38  // get a list sorted by position
39  QList<Kwave::MetaData> list =
41 
42  if (!list.isEmpty()) {
43  // append a label for each meta data object
44  foreach (const Kwave::MetaData &meta_data, list)
45  append(Kwave::Label(meta_data));
46  }
47 
48  sort();
49  }
50 }
static QString metaDataType()
Definition: Label.h:59
virtual MetaDataList selectByType(const QString &type) const
virtual QList< Kwave::MetaData > toSortedList() const
virtual void sort()
Definition: LabelList.cpp:64
Here is the call graph for this function:

◆ ~LabelList()

Kwave::LabelList::~LabelList ( )
virtual

Destructor

Definition at line 53 of file LabelList.cpp.

54 {
55 }

Member Function Documentation

◆ nextLabelLeft()

sample_index_t Kwave::LabelList::nextLabelLeft ( sample_index_t  from)

returns the position of the next label left from a given position or zero (begin of signal) if there is none

Returns
a sample index [0...length-1]

Definition at line 80 of file LabelList.cpp.

References Kwave::Label::pos().

Referenced by Kwave::PlayerToolBar::toolbarRewindPrev(), and Kwave::PlayerToolBar::updateState().

81 {
82  sample_index_t best = 0;
83  bool found = false;
84  if (!isEmpty()) {
85  foreach (const Kwave::Label &label, *this) {
86  sample_index_t lp = label.pos();
87  if (lp >= from) break;
88  best = lp;
89  found = true;
90  }
91  }
92  return (found) ? best : 0;
93 }
virtual sample_index_t pos() const
Definition: Label.cpp:56
quint64 sample_index_t
Definition: Sample.h:28
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextLabelRight()

sample_index_t Kwave::LabelList::nextLabelRight ( sample_index_t  from)

returns the position of the next label right from a given position or SAMPLE_INDEX_MAX if there is none

Returns
a sample index [0...length-1] or SAMPLE_INDEX_MAX

Definition at line 96 of file LabelList.cpp.

References Kwave::Label::pos(), and SAMPLE_INDEX_MAX.

Referenced by Kwave::PlayerToolBar::toolbarForwardNext(), and Kwave::PlayerToolBar::updateState().

97 {
98  if (!isEmpty()) {
99  foreach (const Kwave::Label &label, *this) {
100  sample_index_t lp = label.pos();
101  if (lp > from)
102  return lp; // found the first label after "from"
103  }
104  }
105  // nothing found: return "infinite"
106  return SAMPLE_INDEX_MAX;
107 }
virtual sample_index_t pos() const
Definition: Label.cpp:56
quint64 sample_index_t
Definition: Sample.h:28
#define SAMPLE_INDEX_MAX
Definition: Sample.h:31
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort()

void Kwave::LabelList::sort ( )
virtual

sorts the list by ascending position

Definition at line 64 of file LabelList.cpp.

References compare_labels().

Referenced by LabelList(), and Kwave::WavDecoder::open().

65 {
66  if (!isEmpty())
67  std::sort(begin(), end(), compare_labels);
68 }
static bool compare_labels(Kwave::Label a, Kwave::Label b)
Definition: LabelList.cpp:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toMetaDataList()

Kwave::MetaDataList Kwave::LabelList::toMetaDataList ( ) const

returns the content of this list as a list of Kwave::MetaData objects

Returns
a meta data list

Definition at line 71 of file LabelList.cpp.

References Kwave::MetaDataList::add().

Referenced by Kwave::AsciiDecoder::open(), and Kwave::WavDecoder::open().

72 {
74  foreach (const Kwave::Label &label, *this)
75  list.add(label);
76  return list;
77 }
virtual void add(const MetaData &metadata)
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: