fix ctl-x cut, reorganize track/edit popup, pack cut fixes, paste plugin new feature...
[goodguy/cinelerra.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         edl->folder_no = AW_CLIP_FOLDER;
26         append(edl);
27         edl->add_user();
28 }
29
30 void ClipEDLs::remove_clip(EDL *clip)
31 {
32         int n = size();
33         remove(clip);
34         n -= size();
35         while( --n >= 0 ) clip->remove_user();
36 }
37
38
39 EDL* ClipEDLs::get_nested(EDL *src)
40 {
41         if( !src ) return 0;
42         for( int i=0; i<size(); ++i ) {
43                 EDL *dst = get(i);
44                 if( src == dst || src->id == dst->id ) return dst;
45         }
46         for( int i=0; i<size(); ++i ) {
47                 EDL *dst = get(i);
48                 if( !strcmp(dst->path, src->path) ) return dst;
49         }
50
51         EDL *dst = new EDL;
52         dst->create_objects();
53         dst->copy_all(src);
54         append(dst);
55         return dst;
56 }
57
58 EDL* ClipEDLs::load(char *path)
59 {
60         for( int i=0; i<size(); ++i ) {
61                 EDL *dst = get(i);
62                 if( !strcmp(dst->path, path) ) return dst;
63         }
64
65         EDL *dst = new EDL;
66         dst->create_objects();
67
68         FileXML xml_file;
69         xml_file.read_from_file(path);
70         dst->load_xml(&xml_file, LOAD_ALL);
71
72 // Override path EDL was saved to with the path it was loaded from.
73         dst->set_path(path);
74         append(dst);
75         return dst;
76 }
77
78 void ClipEDLs::copy_nested(ClipEDLs &nested)
79 {
80         clear();
81         for( int i=0; i<nested.size(); ++i ) {
82                 EDL *new_edl = new EDL;
83                 new_edl->create_objects();
84                 new_edl->copy_all(nested[i]);
85                 append(new_edl);
86         }
87 }
88
89 void ClipEDLs::update_index(EDL *clip_edl)
90 {
91         for( int i=0; i<size(); ++i ) {
92                 EDL *current = get(i);
93                 if( !strcmp(current->path, clip_edl->path) ) {
94                         current->update_index(clip_edl);
95                 }
96         }
97 }
98