4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "recordlabel.h"
28 RecordLabel::RecordLabel(double position)
29 : ListItem<RecordLabel>()
31 this->position = position;
34 RecordLabel::~RecordLabel()
39 RecordLabels::RecordLabels()
44 RecordLabels::RecordLabels(File *file)
48 double last_position = -1.;
50 while( !file->get_cell_time(++cell_no, position) ) {
51 if( position > last_position )
52 append(new RecordLabel(last_position=position));
56 RecordLabels::~RecordLabels()
61 int RecordLabels::delete_labels()
63 RecordLabel *current, *next_;
64 for(current = first; current; current = next_)
72 int RecordLabels::toggle_label(double position)
75 // find label the position is after
77 current && current->position < position;
85 //printf("position %ld current->position %ld current->original %d\n", position, current->position, current->original);
86 if(EQUIV(current->position, position))
94 current = insert_before(current);
95 current->position = position;
99 { // insert after last
100 //printf("position %ld\n", position);
101 append(new RecordLabel(position));
106 double RecordLabels::get_prev_label(double position)
108 RecordLabel *current;
111 current && current->position > position;
116 //printf("%ld\n", current->position);
117 if(current && current->position <= position)
118 return current->position;
123 double RecordLabels::get_next_label(double position)
125 RecordLabel *current;
128 current && current->position <= position;
133 if(current && current->position >= position) return current->position;
137 double RecordLabels::goto_prev_label(double position)
139 RecordLabel *current;
142 current && current->position >= position;
147 //printf("%ld\n", current->position);
148 if(current && current->position <= position) return current->position;
152 double RecordLabels::goto_next_label(double position)
154 RecordLabel *current;
157 current && current->position <= position;
162 if(current && current->position >= position) return current->position;