File: Label.cpp

package info (click to toggle)
kwave 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,272 kB
  • sloc: cpp: 56,173; xml: 817; perl: 688; sh: 57; makefile: 11
file content (80 lines) | stat: -rw-r--r-- 3,174 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/***************************************************************************
              Label.cpp  -  representation of a label within a signal
                             -------------------
    begin                : Mon Jul 31 2006
    copyright            : (C) 2006 by Thomas Eschenbacher
    email                : Thomas.Eschenbacher@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "config.h"
#include "libkwave/Label.h"

//***************************************************************************
Kwave::Label::Label()
    :Kwave::MetaData() // must be empty, isNull() should return true
{
}

//***************************************************************************
Kwave::Label::Label(const Kwave::MetaData &meta_data)
    :Kwave::MetaData(meta_data)
{
}

//***************************************************************************
Kwave::Label::Label(sample_index_t position, const QString &name)
    :Kwave::MetaData(Kwave::MetaData::Position)
{
    setProperty(Kwave::MetaData::STDPROP_TYPE, metaDataType());
    setProperty(Kwave::MetaData::STDPROP_POS, position);
    if (name.length())
        setProperty(Kwave::MetaData::STDPROP_DESCRIPTION, name);
}

//***************************************************************************
Kwave::Label::~Label()
{
}

//***************************************************************************
void Kwave::Label::moveTo(sample_index_t position)
{
    if (isNull()) setProperty(Kwave::MetaData::STDPROP_TYPE, metaDataType());
    setProperty(Kwave::MetaData::STDPROP_POS, position);
}

//***************************************************************************
sample_index_t Kwave::Label::pos() const
{
    return static_cast<sample_index_t>(
        property(Kwave::MetaData::STDPROP_POS).toULongLong()
    );
}

//***************************************************************************
void Kwave::Label::rename(const QString &name)
{
    if (isNull()) setProperty(Kwave::MetaData::STDPROP_TYPE, metaDataType());
    if (name.length())
        setProperty(Kwave::MetaData::STDPROP_DESCRIPTION, name);
    else
        setProperty(Kwave::MetaData::STDPROP_DESCRIPTION, QVariant());
}

//***************************************************************************
QString Kwave::Label::name() const
{
    return property(Kwave::MetaData::STDPROP_DESCRIPTION).toString();
}

//***************************************************************************
//***************************************************************************