Commit 85e79c5f authored by Jason Wood's avatar Jason Wood

Added command allowing avfile creation and deletion to be undoable.

svn path=/trunk/kdenlive/; revision=300
parent 05c8c489
/***************************************************************************
kaddclipcommand.cpp - description
-------------------
begin : Fri Dec 13 2002
copyright : (C) 2002 by Jason Wood
email : jasonwood@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <kdebug.h>
#include "kaddavfilecommand.h"
#include "kdenlivedoc.h"
#include "docclipbase.h"
namespace Command {
/** Construct an AddClipCommand that will add or delete a clip */
KAddAVFileCommand::KAddAVFileCommand(KdenliveDoc *doc, const KURL &url, bool create) :
m_doc(doc),
m_url(url),
m_create(create)
{
}
KAddAVFileCommand::KAddAVFileCommand(KdenliveDoc *doc, AVFile *avfile, bool create) :
m_doc(doc),
m_url(avfile->fileURL()),
m_create(create)
{
}
KAddAVFileCommand::~KAddAVFileCommand()
{
}
/** Returns the name of this command */
QString KAddAVFileCommand::name() const
{
if(m_create) {
return i18n("Add Clip");
} else {
return i18n("Delete Clip");
}
}
/** Execute the command */
void KAddAVFileCommand::execute()
{
if(m_create) {
m_doc->insertAVFile(m_url);
} else {
deleteAVFile();
}
}
/** Unexecute the command */
void KAddAVFileCommand::unexecute()
{
if(m_create) {
deleteAVFile();
} else {
m_doc->insertAVFile(m_url);
}
}
void KAddAVFileCommand::deleteAVFile()
{
AVFile *file = m_doc->findAVFile(m_url);
if(file) {
m_doc->deleteAVFile(file);
}
}
} // namespace command
/***************************************************************************
kaddclipcommand.h - description
-------------------
begin : Fri Dec 13 2002
copyright : (C) 2002 by Jason Wood
email : jasonwood@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KADDAVFILECOMMAND_H
#define KADDAVFILECOMMAND_H
#include <kcommand.h>
#include <klocale.h>
#include <kurl.h>
#include <qdom.h>
#include "gentime.h"
class KdenliveDoc;
class DocClipBase;
class AVFile;
/**Adds a clip to the document
*@author Jason Wood
*/
namespace Command {
class KAddAVFileCommand : public KCommand {
public:
/** Construct an AddClipCommand that will delete a clip */
KAddAVFileCommand(KdenliveDoc *doc, const KURL &url, bool create=true);
KAddAVFileCommand(KdenliveDoc *doc, AVFile *avfile, bool create=true);
~KAddAVFileCommand();
/** Unexecute the command */
void unexecute();
/** Execute the command */
void execute();
/** Returns the name of this command */
QString name() const;
private: // Private methods
void deleteAVFile();
private: // Private attributes
/** The KdenliveDoc that this action works upon. */
KdenliveDoc * m_doc;
/** The url for the avfile being added. */
KURL m_url;
/** If true, then executing the command will create a clip, and
unexecuting the command will delete a clip. Otherwise, it will be the
other way around. */
bool m_create;
};
} // namespace command
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment