]> git.sesse.net Git - kdenlive/blob - src/addclipcommand.h
Start of the undo framework
[kdenlive] / src / addclipcommand.h
1 #ifndef ADDCLIPCOMMAND_H
2 #define ADDCLIPCOMMAND_H
3
4 #include <QUndoCommand>
5 #include <KDebug>
6
7 #include "projectlist.h"
8
9 class AddClipCommand : public QUndoCommand
10  {
11  public:
12      AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, bool doIt)
13          : m_list(list), m_names(names), m_xml(xml), m_id(id), m_url(url), m_doIt(doIt) {
14             if (doIt) setText(i18n("Add clip"));
15             else setText(i18n("Delete clip"));
16           }
17      virtual void undo()
18          {
19             kDebug()<<"----  undoing action";
20             if (m_doIt) m_list->deleteClip(m_id);
21             else m_list->addClip(m_names, m_xml, m_id, m_url);
22          }
23      virtual void redo()
24          {
25             kDebug()<<"----  redoing action";
26             if (m_doIt) m_list->addClip(m_names, m_xml, m_id, m_url);
27             else m_list->deleteClip(m_id);
28          }
29  private:
30      ProjectList *m_list;
31      QStringList m_names;
32      QDomElement m_xml;
33      int m_id;
34      KUrl m_url;
35      bool m_doIt;
36  };
37
38 #endif
39