1 /*
2 Copyright (C) 2005-2007 Remon Sijrier
3 
4 This file is part of Traverso
5 
6 Traverso 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.
10 
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.
15 
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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
19 
20 */
21 
22 #include "RemoveClip.h"
23 
24 #include "AudioClip.h"
25 #include "AudioClipManager.h"
26 #include "Sheet.h"
27 
28 // Always put me below _all_ includes, this is needed
29 // in case we run with memory leak detection enabled!
30 #include "Debugger.h"
31 
32 
AddRemoveClip(AudioClip * clip,int type)33 AddRemoveClip::AddRemoveClip(AudioClip* clip, int type)
34 	: Command(clip, tr("Remove Clip"))
35 {
36 	if (clip->is_selected()) {
37 		QList<AudioClip*> selectedClips;
38 		clip->get_sheet()->get_audioclip_manager()->get_selected_clips(selectedClips);
39 		m_group.set_clips(selectedClips);
40 		setText(tr("Remove Selected Clips"));
41 	} else {
42 		m_group.add_clip(clip);
43 	}
44 	m_type = type;
45 }
46 
47 
prepare_actions()48 int AddRemoveClip::prepare_actions()
49 {
50 	return 1;
51 }
52 
53 
do_action()54 int AddRemoveClip::do_action()
55 {
56 	PENTER;
57 	if (m_type == REMOVE) {
58 		m_group.remove_all_clips_from_tracks();
59 	}
60 
61 	if (m_type == ADD) {
62 		m_group.add_all_clips_to_tracks();
63 	}
64 
65 	return 1;
66 }
67 
undo_action()68 int AddRemoveClip::undo_action()
69 {
70 	PENTER;
71 
72 	if (m_type == REMOVE) {
73 		m_group.add_all_clips_to_tracks();
74 	}
75 
76 	if (m_type == ADD) {
77 		m_group.remove_all_clips_from_tracks();
78 	}
79 
80 	return 1;
81 }
82 
83 // eof
84 
85