rework set default transtion, nested proxy edl fixes, doubleclick proxy media fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / clipedls.C
1 #include "bcsignals.h"
2 #include "clipedls.h"
3 #include "edl.h"
4 #include "filexml.h"
5 #include "indexstate.h"
6
7
8 ClipEDLs::ClipEDLs()
9 {
10 }
11
12 ClipEDLs::~ClipEDLs()
13 {
14         clear();
15 }
16
17 void ClipEDLs::clear()
18 {
19         for( int i=0; i<size(); ++i ) get(i)->remove_user();
20         remove_all();
21 }
22
23 void ClipEDLs::add_clip(EDL *edl)
24 {
25         append(edl);
26         edl->add_user();
27 }
28
29 void ClipEDLs::remove_clip(EDL *clip)
30 {
31         int n = size();
32         remove(clip);
33         n -= size();
34         while( --n >= 0 ) clip->remove_user();
35 }
36
37
38 EDL* ClipEDLs::get_nested(EDL *src)
39 {
40         if( !src ) return 0;
41         for( int i=0; i<size(); ++i ) {
42                 EDL *dst = get(i);
43                 if( src == dst || src->id == dst->id ) return dst;
44         }
45         for( int i=0; i<size(); ++i ) {
46                 EDL *dst = get(i);
47                 if( !strcmp(dst->path, src->path) ) return dst;
48         }
49
50         EDL *dst = new EDL;
51         dst->create_objects();
52         dst->copy_all(src);
53         append(dst);
54         return dst;
55 }
56
57 EDL* ClipEDLs::load(char *path)
58 {
59         for( int i=0; i<size(); ++i ) {
60                 EDL *dst = get(i);
61                 if( !strcmp(dst->path, path) ) return dst;
62         }
63
64         EDL *dst = new EDL;
65         dst->create_objects();
66
67         FileXML xml_file;
68         xml_file.read_from_file(path);
69         dst->load_xml(&xml_file, LOAD_ALL);
70
71 // Override path EDL was saved to with the path it was loaded from.
72         dst->set_path(path);
73         append(dst);
74         return dst;
75 }
76
77 void ClipEDLs::copy_nested(ClipEDLs &nested)
78 {
79         clear();
80         for( int i=0; i<nested.size(); ++i ) {
81                 EDL *new_edl = new EDL;
82                 new_edl->create_objects();
83                 new_edl->copy_all(nested[i]);
84                 append(new_edl);
85         }
86 }
87
88 void ClipEDLs::update_index(EDL *clip_edl)
89 {
90         for( int i=0; i<size(); ++i ) {
91                 EDL *current = get(i);
92                 if( !strcmp(current->path, clip_edl->path) ) {
93                         current->update_index(clip_edl);
94                 }
95         }
96 }
97