resizeclipcommand.cpp
addtimelineclipcommand.cpp
kthumb.cpp
+ clipmanager.cpp
)
kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc )
#include "addclipcommand.h"
-AddClipCommand::AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, const QString &group, bool doIt)
- : m_list(list), m_names(names), m_xml(xml), m_id(id), m_url(url), m_group(group), m_doIt(doIt) {
+AddClipCommand::AddClipCommand(KdenliveDoc *doc, const QDomElement &xml, const uint id, bool doIt)
+ : m_doc(doc), m_xml(xml), m_id(id), m_doIt(doIt) {
if (doIt) setText(i18n("Add clip"));
else setText(i18n("Delete clip"));
}
// virtual
void AddClipCommand::undo()
{
- if (!m_list) kDebug()<<"---- ERROR, NO LIST FOR undoing action";
kDebug()<<"---- undoing action";
- if (m_doIt) m_list->deleteClip(m_id);
- else m_list->addClip(m_names, m_xml, m_id, m_url, m_group);
+ if (m_doIt) m_doc->deleteClip(m_id);
+ else m_doc->addClip(m_xml, m_id);
}
// virtual
void AddClipCommand::redo()
{
- if (!m_list) kDebug()<<"---- ERROR, NO LIST FOR redoing action";
kDebug()<<"---- redoing action";
- if (m_doIt) m_list->addClip(m_names, m_xml, m_id, m_url, m_group);
- else m_list->deleteClip(m_id);
+ if (m_doIt) m_doc->addClip(m_xml, m_id);
+ else m_doc->deleteClip(m_id);
}
#include "addclipcommand.moc"
#include <QUndoCommand>
#include <KDebug>
-#include "projectlist.h"
+#include "kdenlivedoc.h"
class AddClipCommand : public QUndoCommand
{
public:
- AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, const QString &group, bool doIt);
+ AddClipCommand(KdenliveDoc *list, const QDomElement &xml, const uint id, bool doIt);
virtual void undo();
virtual void redo();
private:
- ProjectList *m_list;
- QStringList m_names;
+ KdenliveDoc *m_doc;
QDomElement m_xml;
- int m_id;
- KUrl m_url;
+ uint m_id;
bool m_doIt;
- QString m_group;
};
#endif
#include "kdenlivesettings.h"
ClipItem::ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect, int duration)
- : QGraphicsRectItem(rect), m_xml(xml), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos), m_thumbProd(NULL), startThumbTimer(NULL), endThumbTimer(NULL), m_startFade(0), m_endFade(0)
+ : QGraphicsRectItem(rect), m_xml(xml), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_startFade(0), m_endFade(0)
{
//setToolTip(name);
setBrush(QColor(100, 100, 150));
if (m_clipType == VIDEO || m_clipType == AV) {
- m_thumbProd = new KThumb(KUrl(xml.attribute("resource")), KdenliveSettings::track_height() * KdenliveSettings::project_display_ratio(), KdenliveSettings::track_height());
- connect(this, SIGNAL(getThumb(int, int)), m_thumbProd, SLOT(extractImage(int, int)));
- connect(m_thumbProd, SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
+ m_hasThumbs = true;
+ //connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
+ //connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
QTimer::singleShot(300, this, SLOT(slotFetchThumbs()));
startThumbTimer = new QTimer(this);
}
}
+ClipItem::ClipItem(DocClipBase *clip, int track, int startpos, const QRectF & rect, int duration)
+ : QGraphicsRectItem(rect), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_startFade(0), m_endFade(0)
+{
+ //setToolTip(name);
+ kDebug()<<"******* CREATING NEW TML CLIP, DUR: "<<duration;
+ m_xml = clip->toXML();
+ m_clipName = clip->name();
+ m_producer = clip->getId();
+ m_clipType = clip->clipType();
+ m_cropStart = 0;
+ m_maxDuration = duration;
+ if (duration != -1) m_cropDuration = duration;
+ else m_cropDuration = m_maxDuration;
+
+ setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+
+ setBrush(QColor(100, 100, 150));
+ if (m_clipType == VIDEO || m_clipType == AV) {
+ m_hasThumbs = true;
+ connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
+ connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
+ QTimer::singleShot(300, this, SLOT(slotFetchThumbs()));
+
+ startThumbTimer = new QTimer(this);
+ startThumbTimer->setSingleShot(true);
+ connect(startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
+ endThumbTimer = new QTimer(this);
+ endThumbTimer->setSingleShot(true);
+ connect(endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
+
+ }
+ else if (m_clipType == COLOR) {
+ QString colour = m_xml.attribute("colour");
+ colour = colour.replace(0, 2, "#");
+ setBrush(QColor(colour.left(7)));
+ }
+ else if (m_clipType == IMAGE) {
+ m_startPix = KThumb::getImage(KUrl(m_xml.attribute("resource")), 50 * KdenliveSettings::project_display_ratio(), 50);
+ }
+}
+
+
ClipItem::~ClipItem()
{
if (startThumbTimer) delete startThumbTimer;
if (endThumbTimer) delete endThumbTimer;
- if (m_thumbProd) delete m_thumbProd;
}
void ClipItem::slotFetchThumbs()
break;
}
}
- if (m_thumbProd) startThumbTimer->start(100);
+ if (m_hasThumbs) startThumbTimer->start(100);
}
void ClipItem::resizeEnd(int posx, double scale)
break;
}
}
- if (m_thumbProd) endThumbTimer->start(100);
+ if (m_hasThumbs) endThumbTimer->start(100);
}
// virtual
#include "definitions.h"
#include "gentime.h"
+#include "docclipbase.h"
#include "kthumb.h"
public:
ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect, int duration = -1);
+ ClipItem(DocClipBase *clip, int track, int startpos, const QRectF & rect, int duration);
virtual ~ ClipItem();
virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
private:
QDomElement m_xml;
+ DocClipBase *m_clip;
int m_textWidth;
OPERATIONTYPE m_resizeMode;
int m_grabPoint;
int m_startPos;
QPixmap m_startPix;
QPixmap m_endPix;
- KThumb *m_thumbProd;
+ bool m_hasThumbs;
QTimer *startThumbTimer;
QTimer *endThumbTimer;
uint m_startFade;
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+#include <KDebug>
+#include <KFileDialog>
+
+#include "addclipcommand.h"
+#include "kdenlivesettings.h"
+#include "clipmanager.h"
+
+
+ClipManager::ClipManager(KdenliveDoc *doc):m_doc(doc)
+{
+ m_clipIdCounter = 1;
+}
+
+ClipManager::~ClipManager()
+{
+}
+
+void ClipManager::addClip(DocClipBase *clip)
+{
+ m_clipList.append(clip);
+}
+
+void ClipManager::deleteClip(uint clipId)
+{
+ for (int i = 0; i < m_clipList.count(); i++) {
+ if (m_clipList.at(i)->getId() == clipId)
+ m_clipList.removeAt(i);
+ }
+}
+
+DocClipBase *ClipManager::getClipAt(int pos)
+{
+ return m_clipList.at(pos);
+}
+
+DocClipBase *ClipManager::getClipById(int clipId)
+{
+ kDebug()<<"++++ CLIP MAN, LOOKING FOR CLIP ID: "<<clipId;
+ for (int i = 0; i < m_clipList.count(); i++) {
+ if (m_clipList.at(i)->getId() == clipId)
+ {
+ kDebug()<<"++++ CLIP MAN, FOUND FOR CLIP ID: "<<clipId;
+ return m_clipList.at(i);
+ }
+ }
+ return NULL;
+}
+
+void ClipManager::slotAddClipFile(const KUrl url, const QString group)
+{
+ kDebug()<<"///// CLIP MANAGER, ADDING CLIP: "<<url;
+ QDomDocument doc;
+ QDomElement prod = doc.createElement("producer");
+ prod.setAttribute("resource", url.path());
+ uint id = m_clipIdCounter++;
+ prod.setAttribute("id", QString::number(id));
+ if (!group.isEmpty()) prod.setAttribute("group", group);
+ KMimeType::Ptr type = KMimeType::findByUrl(url);
+ if (type->name().startsWith("image/")) {
+ prod.setAttribute("type", (int) IMAGE);
+ prod.setAttribute("in", "0");
+ prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()));
+ }
+ AddClipCommand *command = new AddClipCommand(m_doc, prod, id, true);
+ m_doc->commandStack()->push(command);
+}
+
+void ClipManager::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group)
+{
+ QDomDocument doc;
+ QDomElement prod = doc.createElement("producer");
+ prod.setAttribute("mlt_service", "colour");
+ prod.setAttribute("colour", color);
+ prod.setAttribute("type", (int) COLOR);
+ uint id = m_clipIdCounter++;
+ prod.setAttribute("id", QString::number(id));
+ prod.setAttribute("in", "0");
+ prod.setAttribute("out", m_doc->getFramePos(duration));
+ prod.setAttribute("name", name);
+ AddClipCommand *command = new AddClipCommand(m_doc, prod, id, true);
+ m_doc->commandStack()->push(command);
+}
+
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef CLIPMANAGER_H
+#define CLIPMANAGER_H
+
+/**ClipManager manages the list of clips in a document
+ *@author Jean-Baptiste Mardelle
+ */
+
+#include <qdom.h>
+#include <QPixmap>
+#include <QObject>
+
+#include <KUrl>
+#include <KUndoStack>
+#include <klocale.h>
+
+#include "gentime.h"
+#include "definitions.h"
+#include "docclipbase.h"
+
+class KdenliveDoc;
+
+
+class ClipManager:public QObject {
+ Q_OBJECT public:
+
+
+ ClipManager(KdenliveDoc *doc);
+ virtual ~ ClipManager();
+ void addClip(DocClipBase *clip);
+ DocClipBase *getClipAt(int pos);
+ void deleteClip(uint clipId);
+ void slotAddClipFile(const KUrl url, const QString group);
+ void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group);
+ DocClipBase *getClipById(int clipId);
+
+ private: // Private attributes
+ /** the list of clips in the document */
+ QList <DocClipBase*> m_clipList;
+ /** the document undo stack*/
+ KdenliveDoc *m_doc;
+ int m_clipIdCounter;
+
+};
+
+#endif
void CustomTrackView::dragEnterEvent ( QDragEnterEvent * event )
{
if (event->mimeData()->hasText()) {
- QString clip = event->mimeData()->text();
+ kDebug()<<"/////////////// DRAG ENTERED, TEXT: "<<event->mimeData()->text();
+ QStringList ids = QString(event->mimeData()->text()).split(";");
+ //TODO: drop of several clips
+ for (int i = 0; i < ids.size(); ++i) {
+ }
+ DocClipBase *clip = m_document->getBaseClip(ids.at(0).toInt());
+ if (clip == NULL) kDebug()<<" WARNING))))))))) CLIP NOT FOUND : "<<ids.at(0).toInt();
addItem(clip, event->pos());
event->acceptProposedAction();
}
}
+void CustomTrackView::addItem(DocClipBase *clip, QPoint pos)
+{
+ int in =0;
+ int out = clip->duration().frames(m_document->fps());
+ //kdDebug()<<"- - - -CREATING CLIP, duration = "<<out<<", URL: "<<clip->fileURL();
+ int trackTop = ((int) mapToScene(pos).y()/50) * 50 + 1;
+ m_dropItem = new ClipItem(clip, ((int) mapToScene(pos).y()/50), in, QRectF(mapToScene(pos).x() * m_scale, trackTop, out * m_scale, 49), out);
+ scene()->addItem(m_dropItem);
+}
+
void CustomTrackView::addItem(QString producer, QPoint pos)
{
ClipItem *m_dropItem;
KdenliveDoc *m_document;
void addItem(QString producer, QPoint pos);
+ void addItem(DocClipBase *clip, QPoint pos);
QGraphicsLineItem *m_cursorLine;
QPointF m_startPos;
OPERATIONTYPE m_operationMode;
#include <KDebug>
+#include "kdenlivesettings.h"
#include "docclipbase.h"
-/*#include "docclipavfile.h"
-#include "doccliptextfile.h"
-#include "docclipproject.h"
-#include "doctrackbase.h"*/
-DocClipBase::DocClipBase():
-m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false)
+DocClipBase::DocClipBase(QDomElement xml, uint id):
+m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL)
{
- //thumbCreator = 0;
+ int type = xml.attribute("type").toInt();
+ m_clipType = (CLIPTYPE) type;
+ m_name = xml.attribute("name");
+ m_xml.setAttribute("id", QString::number(id));
+ KUrl url = KUrl(xml.attribute("resource"));
+ int out = xml.attribute("out").toInt();
+ if (out != 0) setDuration(GenTime(out, 25));
+ if (m_name.isEmpty()) m_name = url.fileName();
+ if (!url.isEmpty())
+ m_thumbProd = new KThumb(url, KdenliveSettings::track_height() * KdenliveSettings::project_display_ratio(), KdenliveSettings::track_height());
+}
+
+DocClipBase::DocClipBase(const DocClipBase& clip)
+{
+ m_xml = clip.toXML();
+ m_id = clip.getId();
+ m_clipType = clip.clipType();
+ m_name = clip.name();
+ m_duration = clip.duration();
+}
+
+DocClipBase & DocClipBase::operator=(const DocClipBase & clip)
+{
+ DocClipBase::operator=(clip);
+ m_xml = clip.toXML();
+ m_id = clip.getId();
+ m_clipType = clip.clipType();
+ m_name = clip.name();
+ m_duration = clip.duration();
+ return *this;
}
DocClipBase::~DocClipBase()
{
- //delete thumbCreator;
+ //if (m_thumbProd) delete m_thumbProd;
+}
+
+KThumb *DocClipBase::thumbProducer()
+{
+ return m_thumbProd;
}
void DocClipBase::setName(const QString name)
const QString & DocClipBase::name() const
{
+
return m_name;
}
m_id = newId;
}
+const CLIPTYPE & DocClipBase::clipType() const
+{
+ return m_clipType;
+}
+
+void DocClipBase::setClipType(CLIPTYPE type)
+{
+ m_clipType = type;
+}
+
+const KUrl & DocClipBase::fileURL() const
+{
+ QString res = m_xml.attribute("resource");
+ if (m_clipType != COLOR && !res.isEmpty()) return KUrl(res);
+ return KUrl();
+}
+
void DocClipBase::setProjectThumbFrame( const uint &ix)
{
m_projectThumbFrame = ix;
return m_description;
}
+void DocClipBase::setDuration(GenTime dur)
+{
+ m_duration = dur;
+}
+
+const GenTime &DocClipBase::duration() const
+{
+ return m_duration;
+}
+
+bool DocClipBase::hasFileSize() const
+{
+ return true;
+}
+
+
// virtual
-QDomDocument DocClipBase::toXML() const
+QDomElement DocClipBase::toXML() const
{
+/*
QDomDocument doc;
QDomElement clip = doc.createElement("kdenliveclip");
QDomText text = doc.createTextNode(description());
clip.appendChild(text);
doc.appendChild(clip);
-
- return doc;
+*/
+ return m_xml;
}
DocClipBase *DocClipBase::
*/
#include <qdom.h>
-#include <qobject.h>
-#include <qpixmap.h>
+#include <QPixmap>
+#include <QObject>
-#include <kurl.h>
+#include <KUrl>
#include <klocale.h>
#include "gentime.h"
-// #include "kthumb.h"
+#include "definitions.h"
+ #include "kthumb.h"
/*
class DocTrackBase;
* - e.g. if you can have audio and video seperately, it should be possible to combin the two, as is
* done here. If a new clip type is added then it should be possible to combine it with both audio
* and video. */
- enum CLIPTYPE { NONE = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR =
- 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9};
- DocClipBase();
+ DocClipBase(QDomElement xml, uint id);
+ DocClipBase(const DocClipBase& clip);
+ DocClipBase & operator=(const DocClipBase & clip);
virtual ~ DocClipBase();
/** sets the name of this clip. */
bool audioThumbCreated;
/** returns the duration of this clip */
- virtual const GenTime & duration() const = 0;
+ const GenTime & duration() const;
+ /** returns the duration of this clip */
+ void setDuration(GenTime dur);
/** returns clip type (audio, text, image,...) */
- virtual const DocClipBase::CLIPTYPE & clipType() const = 0;
+ const CLIPTYPE & clipType() const;
+ /** set clip type (audio, text, image,...) */
+ void setClipType(CLIPTYPE type);
/** remove tmp file if the clip has one (for example text clips) */
- virtual void removeTmpFile() const = 0;
+ void removeTmpFile() const;
/** Returns a url to a file describing this clip. Exactly what this url is,
whether it is temporary or not, and whether it provokes a render will
depend entirely on what the clip consists of. */
- virtual const KUrl & fileURL() const = 0;
+ const KUrl & fileURL() const;
/** Returns true if the clip duration is known, false otherwise. */
- virtual bool durationKnown() const = 0;
+ bool durationKnown() const;
// Returns the number of frames per second that this clip should play at.
- virtual double framesPerSecond() const = 0;
+ double framesPerSecond() const;
- virtual bool isDocClipAVFile() const {
+ bool isDocClipAVFile() const {
return false;
}
/** Returns true if this clip is a project clip, false otherwise. Overridden in DocClipProject,
* where it returns true. */
- virtual bool isProjectClip() const {
+ bool isProjectClip() const {
return false;
}
// Appends scene times for this clip to the passed vector.
/** Reads in the element structure and creates a clip out of it.*/
// Returns an XML document that describes part of the current scene.
- virtual QDomDocument sceneToXML(const GenTime & startTime,
- const GenTime & endTime) const = 0;
+ QDomDocument sceneToXML(const GenTime & startTime,
+ const GenTime & endTime) const;
/** returns a QString containing all of the XML data required to recreate this clip. */
- virtual QDomDocument toXML() const;
- virtual QDomDocument generateSceneList(bool addProducers = true, bool rendering = false) const;
+ QDomElement toXML() const;
+ QDomDocument generateSceneList(bool addProducers = true, bool rendering = false) const;
/** Returns true if the xml passed matches the values in this clip */
- virtual bool matchesXML(const QDomElement & element) const = 0;
+ bool matchesXML(const QDomElement & element) const;
void addReference() {
++m_refcount;
return m_refcount;
}
/** Returns true if this clip has a meaningful filesize. */
- virtual bool hasFileSize() const = 0;
+ bool hasFileSize() const;
/** Returns the filesize, or 0 if there is no appropriate filesize. */
- virtual uint fileSize() const = 0;
+ uint fileSize() const;
/** Returns true if this clip refers to the clip passed in. A clip refers to another clip if
* it uses it as part of it's own composition. */
- virtual bool referencesClip(DocClipBase * clip) const = 0;
+ bool referencesClip(DocClipBase * clip) const;
/** Sets the thumbnail to be used by this clip */
void setThumbnail(const QPixmap & pixmap);
+ /** Returns the thumbnail producer used by this clip */
+ KThumb *thumbProducer();
+
/** Returns the thumbnail used by this clip */
const QPixmap & thumbnail() const;
* that exist. */
uint m_refcount;
+ CLIPTYPE m_clipType;
+
/** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
QList < CommentedTime > m_snapMarkers;
-
+ QDomElement m_xml;
/** A thumbnail for this clip */
QPixmap m_thumbnail;
+ GenTime m_duration;
+
+ KThumb *m_thumbProd;
/** a unique numeric id */
uint m_id;
#include "kdenlivedoc.h"
-
KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL), m_commandStack(new KUndoStack())
{
+ m_clipManager = new ClipManager(this);
if (!url.isEmpty()) {
QString tmpFile;
if(KIO::NetAccess::download(url.path(), tmpFile, parent))
KdenliveDoc::~KdenliveDoc()
{
delete m_commandStack;
+ delete m_clipManager;
+}
+
+ClipManager *KdenliveDoc::clipManager()
+{
+ return m_clipManager;
}
KUndoStack *KdenliveDoc::commandStack()
return m_render;
}
+int KdenliveDoc::getFramePos(QString duration)
+{
+ return m_timecode.getFrameCount(duration, m_fps);
+}
+
QString KdenliveDoc::producerName(int id)
{
QString result = "unnamed";
return m_url;
}
+void KdenliveDoc::addClip(const QDomElement &elem, const int clipId)
+{
+ kDebug()<<"///////// DOCUM, CREATING NEW CLIP, ID:"<<clipId;
+ DocClipBase *clip = new DocClipBase(elem, clipId);
+ m_clipManager->addClip(clip);
+ emit addProjectClip(clip);
+}
+
+void KdenliveDoc::deleteClip(const uint clipId)
+{
+ m_clipManager->deleteClip(clipId);
+}
+
+void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group)
+{
+ kDebug()<<"///////// DOCUM, ADD CLP: "<<url;
+ m_clipManager->slotAddClipFile(url, group);
+}
+
+DocClipBase *KdenliveDoc::getBaseClip(int clipId)
+{
+ return m_clipManager->getClipById(clipId);
+}
+
+void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group)
+{
+ m_clipManager->slotAddColorClipFile(name, color, duration, group);
+}
+
#include "kdenlivedoc.moc"
#include "gentime.h"
#include "timecode.h"
#include "renderer.h"
+#include "clipmanager.h"
class KdenliveDoc:public QObject {
Q_OBJECT public:
void setProducerDuration(int id, int duration);
int getProducerDuration(int id);
Render *renderer();
+ ClipManager *clipManager();
+ void addClip(const QDomElement &elem, const int clipId);
+ void slotAddClipFile(const KUrl url, const QString group);
+ void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group);
+ void deleteClip(const uint clipId);
+ int getFramePos(QString duration);
+ DocClipBase *getBaseClip(int clipId);
private:
KUrl m_url;
Render *m_render;
KUndoStack *m_commandStack;
QDomDocument generateSceneList();
+ ClipManager *m_clipManager;
public slots:
+ signals:
+ void addProjectClip(DocClipBase *);
};
#endif
void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
{
//m_projectMonitor->stop();
+ kDebug()<<"/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
if (m_activeDocument) {
if (m_activeDocument == doc) return;
m_activeDocument->setProducers(m_projectList->producersList());
connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
+ connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
+
m_projectList->setDocument(doc);
m_monitorManager->setTimecode(doc->timecode());
doc->setRenderer(m_projectMonitor->render);
setIcon(0, KIcon("folder"));
}
+ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip)
+ : QTreeWidgetItem(parent, QStringList(), QTreeWidgetItem::UserType), m_isGroup(false)
+{
+ setSizeHint(0, QSize(65, 45));
+ setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+ m_clip = clip;
+ m_element = clip->toXML();
+ m_clipId = clip->getId();
+ QString name = m_element.attribute("name");
+ if (name.isEmpty()) name = KUrl(m_element.attribute("resource")).fileName();
+ m_clipType = (CLIPTYPE) m_element.attribute("type").toInt();
+ m_groupName = m_element.attribute("group");
+ setText(1, name);
+ kDebug()<<"PROJECT ITE;. ADDING LCIP: "<< m_clipId;
+}
+
+
ProjectItem::~ProjectItem()
{
}
void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata)
{
- if (attributes.contains("duration")) {
- if (m_clipType == AUDIO || m_clipType == VIDEO || m_clipType == AV) m_element.setAttribute("duration", attributes["duration"].toInt());
- m_duration = GenTime(attributes["duration"].toInt(), 25);
- setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
- m_durationKnown = true;
- } else {
+ if (attributes.contains("duration")) {
+ if (m_clipType == AUDIO || m_clipType == VIDEO || m_clipType == AV) m_element.setAttribute("duration", attributes["duration"].toInt());
+ m_duration = GenTime(attributes["duration"].toInt(), 25);
+ setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25));
+ m_durationKnown = true;
+ m_clip->setDuration(m_duration);
+ kDebug()<<"//// LOADED CLIP, DURATION SET TO: "<<m_duration.frames(25);
+ } else {
// No duration known, use an arbitrary one until it is.
m_duration = GenTime(0.0);
m_durationKnown = false;
//extend attributes -reh
- if (m_clipType == UNKNOWN) {
+ if (m_clipType == UNKNOWN) {
if (attributes.contains("type")) {
if (attributes["type"] == "audio")
m_clipType = AUDIO;
} else {
m_clipType = AV;
}
+ m_clip->setClipType(m_clipType);
}
slotSetToolTip();
#include "gentime.h"
#include "definitions.h"
+#include "docclipbase.h"
class ProjectItem : public QTreeWidgetItem
{
ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId);
ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId);
ProjectItem(QTreeWidget * parent, const QStringList & strings, int clipId);
+ ProjectItem(QTreeWidget * parent, DocClipBase *clip);
virtual ~ProjectItem();
QDomElement toXml() const;
void slotSetToolTip();
bool m_isGroup;
QString m_groupName;
+ DocClipBase *m_clip;
};
#endif
#include "kdenlivesettings.h"
#include "ui_colorclip_ui.h"
-#include "addclipcommand.h"
#include "definitions.h"
#include <QtGui>
layout->addWidget( m_toolbar );
layout->addWidget( listView );
setLayout( layout );
- m_toolbar->setEnabled(false);
+ //m_toolbar->setEnabled(false);
searchView->setTreeWidget(listView);
listView->setColumnCount(3);
void ProjectList::slotRemoveClip()
{
+/*
if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!! NO CMD STK";
if (!listView->currentItem()) return;
ProjectItem *item = ((ProjectItem *)listView->currentItem());
if (!item) kDebug()<<"/////////////// ERROR NOT FOUND";
if (KMessageBox::questionYesNo(this, i18n("Delete clip <b>%1</b> ?").arg(item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
AddClipCommand *command = new AddClipCommand(this, item->names(), item->toXml(), item->clipId(), item->clipUrl(), item->groupName(), false);
- m_commandStack->push(command);
+ m_commandStack->push(command);*/
}
void ProjectList::selectItemById(const int clipId)
void ProjectList::slotAddFolder()
{
+/*
QString folderName = KInputDialog::getText(i18n("New Folder"), i18n("Enter new folder name: "));
if (folderName.isEmpty()) return;
QStringList itemEntry;
itemEntry.append(QString::null);
itemEntry.append(folderName);
AddClipCommand *command = new AddClipCommand(this, itemEntry, QDomElement(), m_clipIdCounter++, KUrl(), folderName, true);
- m_commandStack->push(command);
+ m_commandStack->push(command);*/
+}
+
+void ProjectList::slotAddClip(DocClipBase *clip)
+{
+ ProjectItem *item = new ProjectItem(listView, clip);
+ listView->setCurrentItem(item);
+ /*
+ if (clip->clipType() != COLOR) {
+ Nepomuk::Resource f( clip->fileURL().path() );
+ QString annotation = f.description();
+ if (!annotation.isEmpty()) item->setText(2, annotation);
+ }*/
+ emit getFileProperties(clip->toXML(), clip->getId());
}
void ProjectList::slotAddClip(QUrl givenUrl, const QString &group)
else list.append(givenUrl);
if (list.isEmpty()) return;
KUrl::List::Iterator it;
- KUrl url;
-// ProjectItem *item;
for (it = list.begin(); it != list.end(); it++) {
- QStringList itemEntry;
- QDomDocument doc;
- QDomElement prod = doc.createElement("producer");
- prod.setAttribute("resource", (*it).path());
- itemEntry.append(QString::null);
- itemEntry.append((*it).fileName());
- KMimeType::Ptr type = KMimeType::findByUrl(*it);
- if (type->name().startsWith("image/")) {
- prod.setAttribute("type", (int) IMAGE);
- prod.setAttribute("in", "0");
- prod.setAttribute("out", m_timecode.getFrameCount(KdenliveSettings::image_duration(), m_fps));
- }
- AddClipCommand *command = new AddClipCommand(this, itemEntry, prod, m_clipIdCounter++, *it, group, true);
- m_commandStack->push(command);
- //item = new ProjectItem(listView, itemEntry, QDomElement());
- //item->setData(1, FullPathRole, (*it).path());
+ m_doc->slotAddClipFile(*it, group);
}
- //listView->setCurrentItem(item);
}
void ProjectList::slotAddColorClip()
dia_ui->clip_duration->setText(KdenliveSettings::color_duration());
if (dia->exec() == QDialog::Accepted)
{
- QDomDocument doc;
- QDomElement element = doc.createElement("producer");
- element.setAttribute("mlt_service", "colour");
QString color = dia_ui->clip_color->color().name();
color = color.replace(0, 1, "0x") + "ff";
- element.setAttribute("colour", color);
- element.setAttribute("type", (int) COLOR);
- element.setAttribute("in", "0");
- element.setAttribute("out", m_timecode.getFrameCount(dia_ui->clip_duration->text(), m_fps));
- element.setAttribute("name", dia_ui->clip_name->text());
- QStringList itemEntry;
- itemEntry.append(QString::null);
- itemEntry.append(dia_ui->clip_name->text());
- AddClipCommand *command = new AddClipCommand(this, itemEntry, element, m_clipIdCounter++, KUrl(), QString::null, true);
- m_commandStack->push(command);
- // ProjectItem *item = new ProjectItem(listView, itemEntry, element, m_clipIdCounter++);
- /*QPixmap pix(60, 40);
- pix.fill(dia_ui->clip_color->color());
- item->setIcon(0, QIcon(pix));*/
- //listView->setCurrentItem(item);
-
+ m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), QString::null);
}
delete dia_ui;
delete dia;
m_fps = doc->fps();
m_timecode = doc->timecode();
m_commandStack = doc->commandStack();
+ m_doc = doc;
QDomNodeList prods = doc->producersList();
int ct = prods.count();
kDebug()<<"//////////// SETTING DOC, FOUND CLIPS: "<<prods.count();
void addProducer(QDomElement producer, int parentId = -1);
void slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h);
void slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
+ void slotAddClip(DocClipBase *clip);
private:
QAction *m_editAction;
QAction *m_deleteAction;
ItemDelegate *m_listViewDelegate;
+ KdenliveDoc *m_doc;
private slots:
void slotAddClip(QUrl givenUrl = QUrl(), const QString &group = QString::null);
QDomDocument doc;
QList <QTreeWidgetItem *> list;
list = selectedItems ();
+ QStringList ids;
foreach (QTreeWidgetItem *item, list) {
// TODO allow dragging of folders
if (!((ProjectItem *) item)->isGroup())
- doc.appendChild(doc.importNode(((ProjectItem *) item)->toXml(), true));
+ ids.append(QString::number(((ProjectItem *) item)->clipId()));
}
//QByteArray data;
//data.append(doc.toString().toUtf8());
//mimeData->setData("kdenlive/westley",data );
- mimeData->setText(doc.toString());
+ mimeData->setText(ids.join(";")); //doc.toString());
//mimeData->setImageData(image);
drag->setMimeData(mimeData);
drag->setPixmap(clickItem->icon(0).pixmap(50 *16/9.0, 50));