1 /**************************1*************************************************
2 DocClipBase.cpp - description
4 begin : Fri Apr 12 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
20 #include "docclipbase.h"
21 /*#include "docclipavfile.h"
22 #include "doccliptextfile.h"
23 #include "docclipproject.h"
24 #include "doctrackbase.h"*/
26 DocClipBase::DocClipBase():
27 m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false)
32 DocClipBase::~DocClipBase()
34 //delete thumbCreator;
37 void DocClipBase::setName(const QString name)
42 const QString & DocClipBase::name() const
47 uint DocClipBase::getId() const
52 void DocClipBase::setId( const uint &newId)
57 void DocClipBase::setProjectThumbFrame( const uint &ix)
59 m_projectThumbFrame = ix;
62 uint DocClipBase::getProjectThumbFrame() const
64 return m_projectThumbFrame;
67 void DocClipBase::setDescription(const QString & description)
69 m_description = description;
72 const QString & DocClipBase::description() const
78 QDomDocument DocClipBase::toXML() const
82 QDomElement clip = doc.createElement("kdenliveclip");
83 QDomText text = doc.createTextNode(description());
84 clip.appendChild(text);
85 doc.appendChild(clip);
90 DocClipBase *DocClipBase::
91 createClip(KdenliveDoc *doc, const QDomElement & element)
93 DocClipBase *clip = 0;
95 QDomNode node = element;
97 if (element.tagName() != "kdenliveclip") {
99 "DocClipBase::createClip() element has unknown tagName : " <<
100 element.tagName() << endl;
104 QDomNode n = element.firstChild();
106 while (!n.isNull()) {
107 QDomElement e = n.toElement();
109 QString tagName = e.tagName();
110 if (e.tagName() == "avfile") {
111 // clip = DocClipAVFile::createClip(e);
112 } else if (e.tagName() == "DocTrackBaseList") {
113 // clip = DocClipProject::createClip(doc, e);
116 QDomText text = n.toText();
117 if (!text.isNull()) {
118 description = text.nodeValue();
125 kWarning() << "DocClipBase::createClip() unable to create clip" <<
128 // setup DocClipBase specifics of the clip.
129 clip->setDescription(description);
130 clip->setAudioThumbCreated(false);
135 void DocClipBase::setAudioThumbCreated(bool isDone)
137 audioThumbCreated = isDone;
141 QDomDocument DocClipBase::generateSceneList(bool, bool) const
145 void DocClipBase::setThumbnail(const QPixmap & pixmap)
147 m_thumbnail = pixmap;
150 const QPixmap & DocClipBase::thumbnail() const
155 void DocClipBase::updateAudioThumbnail(QMap<int,QMap<int,QByteArray> > data)
157 audioFrameChache = data;
158 audioThumbCreated = true;
161 QList < GenTime > DocClipBase::snapMarkers() const
163 QList < GenTime > markers;
165 for (uint count = 0; count < m_snapMarkers.count(); ++count) {
166 markers.append(m_snapMarkers[count].time());
172 QList < CommentedTime > DocClipBase::commentedSnapMarkers() const
174 return m_snapMarkers;
177 void DocClipBase::setSnapMarkers(QList < CommentedTime > markers)
179 m_snapMarkers = markers;
182 void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
184 QList < CommentedTime >::Iterator it = m_snapMarkers.begin();
185 for ( it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it ) {
186 if ((*it).time() >= time)
190 if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
192 "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo"
195 CommentedTime t(time, comment);
196 m_snapMarkers.insert(it, t);
201 void DocClipBase::editSnapMarker(const GenTime & time, QString comment)
203 QList < CommentedTime >::Iterator it;
204 for ( it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it ) {
205 if ((*it).time() == time)
208 if (it != m_snapMarkers.end()) {
209 (*it).setComment(comment);
212 "trying to edit Snap Marker that does not already exists" << endl;
216 QString DocClipBase::deleteSnapMarker(const GenTime & time)
218 QString result = i18n("Marker");
219 QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
221 while (itt != m_snapMarkers.end()) {
222 if ((*itt).time() == time)
227 if ((itt != m_snapMarkers.end()) && ((*itt).time() == time)) {
228 result = (*itt).comment();
229 m_snapMarkers.erase(itt);
235 GenTime DocClipBase::hasSnapMarkers(const GenTime & time)
237 QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
239 while (itt != m_snapMarkers.end()) {
240 if ((*itt).time() == time)
248 GenTime DocClipBase::findPreviousSnapMarker(const GenTime & currTime)
251 for ( it = 0; it < m_snapMarkers.count(); it++ ) {
252 if (m_snapMarkers[it].time() >= currTime)
255 if (it == 0) return GenTime();
256 else if (it == m_snapMarkers.count() - 1 && m_snapMarkers[it].time() < currTime)
257 return m_snapMarkers[it].time();
258 else return m_snapMarkers[it-1].time();
261 GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime)
264 for ( it = 0; it < m_snapMarkers.count(); it++ ) {
265 if (m_snapMarkers[it].time() > currTime)
268 if (it < m_snapMarkers.count() && m_snapMarkers[it].time() > currTime) return m_snapMarkers[it].time();
272 QString DocClipBase::markerComment(GenTime t)
274 QList < CommentedTime >::Iterator itt = m_snapMarkers.begin();
276 while (itt != m_snapMarkers.end()) {
277 if ((*itt).time() == t)
278 return (*itt).comment();
281 return QString::null;
285 QString DocClipBase::getTypeName(CLIPTYPE type)
290 result = i18n("Video Clip");
293 result = i18n("Color Clip");
296 result = i18n("Playlist Clip");
299 result = i18n("Image Clip");
302 result = i18n("Slideshow Clip");
305 result = i18n("Virtual Clip");
308 result = i18n("Audio Clip");
311 result = i18n("Mute Video Clip");
314 result = i18n("Text Clip");
317 result = i18n("None");