comparison base/Clipboard.cpp @ 74:47fd14e29813

* Fix long-standing off-by-1 bug in WaveFileModel that was getting us the wrong values for almost all audio data when merging channels (channel == -1) * Implement cut, copy and paste * Make draw mode work properly in time value layer * Minor fixes to CSV import
author Chris Cannam
date Fri, 07 Apr 2006 17:50:33 +0000
parents
children 516819f2b97b 6f6ab834449d
comparison
equal deleted inserted replaced
73:e9b8b51f6326 74:47fd14e29813
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #include "Clipboard.h"
17
18 Clipboard::Point::Point(long frame, QString label) :
19 m_haveFrame(true),
20 m_frame(frame),
21 m_haveValue(false),
22 m_haveDuration(false),
23 m_haveLabel(true),
24 m_label(label)
25 {
26 }
27
28 Clipboard::Point::Point(long frame, float value, QString label) :
29 m_haveFrame(true),
30 m_frame(frame),
31 m_haveValue(true),
32 m_value(value),
33 m_haveDuration(false),
34 m_haveLabel(true),
35 m_label(label)
36 {
37 }
38
39 Clipboard::Point::Point(long frame, float value, size_t duration, QString label) :
40 m_haveFrame(true),
41 m_frame(frame),
42 m_haveValue(true),
43 m_value(value),
44 m_haveDuration(true),
45 m_duration(duration),
46 m_haveLabel(true),
47 m_label(label)
48 {
49 }
50
51 Clipboard::Point::Point(const Point &point) :
52 m_haveFrame(point.m_haveFrame),
53 m_frame(point.m_frame),
54 m_haveValue(point.m_haveValue),
55 m_value(point.m_value),
56 m_haveDuration(point.m_haveDuration),
57 m_duration(point.m_duration),
58 m_haveLabel(point.m_haveLabel),
59 m_label(point.m_label)
60 {
61 }
62
63 Clipboard::Point &
64 Clipboard::Point::operator=(const Point &point)
65 {
66 if (this == &point) return *this;
67 m_haveFrame = point.m_haveFrame;
68 m_frame = point.m_frame;
69 m_haveValue = point.m_haveValue;
70 m_value = point.m_value;
71 m_haveDuration = point.m_haveDuration;
72 m_duration = point.m_duration;
73 m_haveLabel = point.m_haveLabel;
74 m_label = point.m_label;
75 return *this;
76 }
77
78 bool
79 Clipboard::Point::haveFrame() const
80 {
81 return m_haveFrame;
82 }
83
84 long
85 Clipboard::Point::getFrame() const
86 {
87 return m_frame;
88 }
89
90 bool
91 Clipboard::Point::haveValue() const
92 {
93 return m_haveValue;
94 }
95
96 float
97 Clipboard::Point::getValue() const
98 {
99 return m_value;
100 }
101
102 bool
103 Clipboard::Point::haveDuration() const
104 {
105 return m_haveDuration;
106 }
107
108 size_t
109 Clipboard::Point::getDuration() const
110 {
111 return m_duration;
112 }
113
114 bool
115 Clipboard::Point::haveLabel() const
116 {
117 return m_haveLabel;
118 }
119
120 QString
121 Clipboard::Point::getLabel() const
122 {
123 return m_label;
124 }
125
126 Clipboard::Clipboard() { }
127 Clipboard::~Clipboard() { }
128
129 void
130 Clipboard::clear()
131 {
132 m_points.clear();
133 }
134
135 bool
136 Clipboard::empty() const
137 {
138 return m_points.empty();
139 }
140
141 const Clipboard::PointList &
142 Clipboard::getPoints() const
143 {
144 return m_points;
145 }
146
147 void
148 Clipboard::setPoints(const PointList &pl)
149 {
150 m_points = pl;
151 }
152
153 void
154 Clipboard::addPoint(const Point &point)
155 {
156 m_points.push_back(point);
157 }
158