mixer undo fix, new ffmpeg opts, docs
[goodguy/history.git] / cinelerra-5.1 / cinelerra / nestededls.C
1 #include "bcsignals.h"
2 #include "edl.h"
3 #include "filexml.h"
4 #include "indexstate.h"
5 #include "nestededls.h"
6
7
8 NestedEDLs::NestedEDLs()
9 {
10 }
11
12 NestedEDLs::~NestedEDLs()
13 {
14         for(int i = 0; i < nested_edls.size(); i++)
15                 nested_edls.get(i)->Garbage::remove_user();
16         nested_edls.remove_all();
17 }
18
19 int NestedEDLs::size()
20 {
21         return nested_edls.size();
22 }
23
24 EDL* NestedEDLs::get(int number)
25 {
26         return nested_edls.get(number);
27 }
28
29 EDL* NestedEDLs::get_copy(EDL *src)
30 {
31         if(!src) return 0;
32         for(int i = 0; i < nested_edls.size(); i++)
33         {
34                 EDL *dst = nested_edls.get(i);
35                 if(!strcmp(dst->path, src->path))
36                         return dst;
37         }
38
39         EDL *dst = new EDL;
40         dst->create_objects();
41         dst->copy_all(src);
42         nested_edls.append(dst);
43         return dst;
44 }
45
46 EDL* NestedEDLs::get(char *path)
47 {
48         for(int i = 0; i < nested_edls.size(); i++)
49         {
50                 EDL *dst = nested_edls.get(i);
51                 if(!strcmp(dst->path, path))
52                         return dst;
53         }
54
55         EDL *dst = new EDL;
56         dst->create_objects();
57         FileXML xml_file;
58         xml_file.read_from_file(path);
59 //printf("NestedEDLs::get %d %s\n", __LINE__, path);
60         dst->load_xml(&xml_file, LOAD_ALL);
61
62 // Override path EDL was saved to with the path it was loaded from.
63         dst->set_path(path);
64         nested_edls.append(dst);
65         return dst;
66 }
67
68 void NestedEDLs::clear()
69 {
70         for(int i = 0; i < nested_edls.size(); i++)
71                 nested_edls.get(i)->Garbage::remove_user();
72         nested_edls.remove_all();
73 }
74
75
76 void NestedEDLs::update_index(EDL *nested_edl)
77 {
78         for(int i = 0; i < nested_edls.size(); i++)
79         {
80                 EDL *current = nested_edls.get(i);
81                 if(!strcmp(current->path, nested_edl->path))
82                 {
83 // printf("NestedEDLs::update_index %d %p %d\n",
84 // __LINE__,
85 // current->index_state,
86 // nested_edl->index_state->index_status);
87                         current->update_index(nested_edl);
88                 }
89         }
90 }
91
92 void NestedEDLs::remove_edl(EDL *nested_edl)
93 {
94         nested_edls.remove(nested_edl);
95         nested_edl->Garbage::remove_user();
96 }
97
98
99