1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
24 #include <QStyleOptionGraphicsItem>
25 #include <QGraphicsScene>
26 #include <QGraphicsView>
30 #include <mlt++/Mlt.h>
34 #include "kdenlivesettings.h"
36 ClipItem::ClipItem(DocClipBase *clip, int track, int startpos, const QRectF & rect, int duration)
37 : 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), m_effectsCounter(0),audioThumbWasDrawn(false),audioThumbReady(false)
40 kDebug()<<"******* CREATING NEW TML CLIP, DUR: "<<duration;
41 m_xml = clip->toXML();
42 m_clipName = clip->name();
43 m_producer = clip->getId();
44 m_clipType = clip->clipType();
46 m_maxDuration = duration;
47 if (duration != -1) m_cropDuration = duration;
48 else m_cropDuration = m_maxDuration;
51 m_cropStart = xml.attribute("in", 0).toInt();
52 m_maxDuration = xml.attribute("duration", 0).toInt();
53 if (m_maxDuration == 0) m_maxDuration = xml.attribute("out", 0).toInt() - m_cropStart;
55 if (duration != -1) m_cropDuration = duration;
56 else m_cropDuration = m_maxDuration;*/
59 setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
60 connect (this , SIGNAL (prepareAudioThumb(double,QPainterPath,int,int)) , this, SLOT (slotPrepareAudioThumb(double,QPainterPath,int,int)));
61 setBrush(QColor(100, 100, 150));
62 if (m_clipType == VIDEO || m_clipType == AV) {
64 connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
65 connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
66 connect(clip, SIGNAL (gotAudioData()), this, SLOT (slotGotAudioData()));
67 QTimer::singleShot(300, this, SLOT(slotFetchThumbs()));
69 startThumbTimer = new QTimer(this);
70 startThumbTimer->setSingleShot(true);
71 connect(startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
72 endThumbTimer = new QTimer(this);
73 endThumbTimer->setSingleShot(true);
74 connect(endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
77 else if (m_clipType == COLOR) {
78 QString colour = m_xml.attribute("colour");
79 colour = colour.replace(0, 2, "#");
80 setBrush(QColor(colour.left(7)));
82 else if (m_clipType == IMAGE) {
83 m_startPix = KThumb::getImage(KUrl(m_xml.attribute("resource")), 50 * KdenliveSettings::project_display_ratio(), 50);
90 if (startThumbTimer) delete startThumbTimer;
91 if (endThumbTimer) delete endThumbTimer;
94 void ClipItem::slotFetchThumbs()
96 emit getThumb(m_cropStart, m_cropStart + m_cropDuration);
99 void ClipItem::slotGetStartThumb()
101 emit getThumb(m_cropStart, -1);
104 void ClipItem::slotGetEndThumb()
106 emit getThumb(-1, m_cropStart + m_cropDuration);
109 void ClipItem::slotThumbReady(int frame, QPixmap pix)
111 if (frame == m_cropStart) m_startPix = pix;
116 void ClipItem::slotGotAudioData(){
117 audioThumbReady=true;
121 int ClipItem::type () const
126 DocClipBase *ClipItem::baseClip()
131 QDomElement ClipItem::xml() const
136 int ClipItem::clipType()
141 QString ClipItem::clipName()
146 int ClipItem::clipProducer()
151 int ClipItem::maxDuration()
153 return m_maxDuration;
156 int ClipItem::duration()
158 return m_cropDuration;
161 int ClipItem::startPos()
166 int ClipItem::cropStart()
171 int ClipItem::endPos()
173 return m_startPos + m_cropDuration;
177 void ClipItem::paint(QPainter *painter,
178 const QStyleOptionGraphicsItem *option,
182 QRect rectInView;//this is the rect that is visiable by the user
183 if (scene()->views().size()>0){
184 rectInView=scene()->views()[0]->viewport()->rect();
185 rectInView.moveTo(scene()->views()[0]->horizontalScrollBar()->value(),scene()->views()[0]->verticalScrollBar()->value());
186 rectInView.adjust(-10,-10,10,10);//make view rect 10 pixel greater on each site, or repaint after scroll event
187 //kDebug() << scene()->views()[0]->viewport()->rect() << " " << scene()->views()[0]->horizontalScrollBar()->value();
189 if (rectInView.isNull())
191 QPainterPath clippath;
192 clippath.addRect(rectInView);
193 int startpixel=rectInView.x()-rect().x();//start and endpixel that is viewable from rect()
196 int endpixel=rectInView.width()+rectInView.x();
200 painter->setRenderHints(QPainter::Antialiasing);
201 QPainterPath roundRectPathUpper,roundRectPathLower;
202 double roundingY = 20;
203 double roundingX = 20;
205 painter->setClipRect(option->exposedRect);
206 if (roundingX > br.width() / 2) roundingX = br.width() / 2;
207 //kDebug()<<"-----PAINTING, SCAL: "<<scale<<", height: "<<br.height();
208 roundRectPathUpper.moveTo(br.x() + br .width() - offset, br.y() + br.height()/2 - offset);
209 roundRectPathUpper.arcTo(br.x() + br .width() - roundingX - offset, br.y(), roundingX, roundingY, 0.0, 90.0);
210 roundRectPathUpper.lineTo(br.x() + roundingX, br.y());
211 roundRectPathUpper.arcTo(br.x() + offset, br.y(), roundingX, roundingY, 90.0, 90.0);
212 roundRectPathUpper.lineTo(br.x() + offset, br.y() + br.height()/2 - offset);
213 roundRectPathUpper.closeSubpath();
215 roundRectPathLower.moveTo(br.x() + offset, br.y() + br.height()/2 - offset);
216 roundRectPathLower.arcTo(br.x() + offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 180.0, 90.0);
217 roundRectPathLower.lineTo(br.x() + br .width() - roundingX, br.y() + br.height() - offset);
218 roundRectPathLower.arcTo(br.x() + br .width() - roundingX - offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 270.0, 90.0);
219 roundRectPathLower.lineTo(br.x() + br .width() - offset, br.y()+ br.height()/2 - offset);
220 roundRectPathLower.closeSubpath();
222 painter->setClipPath(roundRectPathUpper.united(roundRectPathLower).intersected(clippath), Qt::IntersectClip);
223 //painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red)));
224 painter->fillRect(br.intersected(rectInView), brush());
225 //painter->fillRect(QRectF(br.x() + br.width() - m_endPix.width(), br.y(), m_endPix.width(), br.height()), QBrush(QColor(Qt::black)));
228 if (!m_startPix.isNull()) {
229 if (m_clipType == IMAGE) {
230 painter->drawPixmap(QPointF(br.x() + br.width() - m_startPix.width(), br.y()), m_startPix);
231 QLineF l(br.x() + br.width() - m_startPix.width(), br.y(), br.x() + br.width() - m_startPix.width(), br.y() + br.height());
232 painter->drawLine(l);
234 painter->drawPixmap(QPointF(br.x() + br.width() - m_endPix.width(), br.y()), m_endPix);
235 QLineF l(br.x() + br.width() - m_endPix.width(), br.y(), br.x() + br.width() - m_endPix.width(), br.y() + br.height());
236 painter->drawLine(l);
239 painter->drawPixmap(QPointF(br.x(), br.y()), m_startPix);
240 QLineF l2(br.x() + m_startPix.width(), br.y(), br.x() + m_startPix.width(), br.y() + br.height());
241 painter->drawLine(l2);
243 if ( ( m_clipType == AV || m_clipType==AUDIO ||true) && audioThumbReady ){
245 QPainterPath path= m_clipType==AV ? roundRectPathLower : roundRectPathUpper.united(roundRectPathLower);
246 painter->fillPath(path,QBrush(QColor(200,200,200,127)));
249 double pixelForOneFrame=(double)br.width()/duration();
251 emit prepareAudioThumb(pixelForOneFrame,path,startpixel,endpixel+200);//200 more for less missing parts before repaint after scrolling
253 for (int startCache=startpixel-startpixel%100; startCache < endpixel+300;startCache+=100){
254 if (audioThumbCachePic.contains(startCache) && !audioThumbCachePic[startCache].isNull() )
255 painter->drawPixmap(path.boundingRect().x()+startCache,path.boundingRect().y(),audioThumbCachePic[startCache]);
260 // draw start / end fades
261 double scale = br.width() / m_cropDuration;
264 fades = QBrush(QColor(200, 50, 50, 150));
266 else fades = QBrush(QColor(200, 200, 200, 200));
268 if (m_startFade != 0) {
269 QPainterPath fadeInPath;
270 fadeInPath.moveTo(br.x() - offset, br.y());
271 fadeInPath.lineTo(br.x() - offset, br.y() + br.height());
272 fadeInPath.lineTo(br.x() + m_startFade * scale, br.y());
273 fadeInPath.closeSubpath();
274 painter->fillPath(fadeInPath, fades);
276 QLineF l(br.x() + m_startFade * scale, br.y(), br.x(), br.y() + br.height());
277 painter->drawLine(l);
280 if (m_endFade != 0) {
281 QPainterPath fadeOutPath;
282 fadeOutPath.moveTo(br.x() + br.width(), br.y());
283 fadeOutPath.lineTo(br.x() + br.width(), br.y() + br.height());
284 fadeOutPath.lineTo(br.x() + br.width() - m_endFade * scale, br.y());
285 fadeOutPath.closeSubpath();
286 painter->fillPath(fadeOutPath, fades);
288 QLineF l(br.x() + br.width() - m_endFade * scale, br.y(), br.x() + br.width(), br.y() + br.height());
289 painter->drawLine(l);
293 QPen pen = painter->pen();
294 pen.setColor(Qt::white);
295 //pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
297 QString effects = effectNames().join(" / ");
298 if (!effects.isEmpty()) {
299 painter->setPen(pen);
300 QFont font = painter->font();
301 QFont smallFont = font;
302 smallFont.setPointSize(8);
303 painter->setFont(smallFont);
304 QRectF txtBounding = painter->boundingRect(br, Qt::AlignLeft | Qt::AlignTop, " " + effects + " ");
305 painter->fillRect(txtBounding, QBrush(QColor(0,0,0,150)));
306 painter->drawText(txtBounding, Qt::AlignCenter, effects);
307 pen.setColor(Qt::black);
308 painter->setPen(pen);
309 painter->setFont(font);
312 pen.setColor(Qt::red);
313 //pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine);
314 if (isSelected()) painter->setPen(pen);
315 painter->setClipRect(option->exposedRect);
316 painter->drawPath(roundRectPathUpper.united(roundRectPathLower).intersected(clippath));
318 QRectF txtBounding = painter->boundingRect(br, Qt::AlignCenter, " " + m_clipName + " ");
319 painter->fillRect(txtBounding, QBrush(QColor(255,255,255,150)));
320 painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
323 //painter->fillRect(startpixel,0,startpixel+endpixel,(int)br.height(), QBrush(QColor(255,255,255,150)));
324 //painter->fillRect(QRect(br.x(), br.y(), roundingX, roundingY), QBrush(QColor(Qt::green)));
326 /*QRectF recta(rect().x(), rect().y(), scale,rect().height());
327 painter->drawRect(recta);
328 painter->drawLine(rect().x() + 1, rect().y(), rect().x() + 1, rect().y() + rect().height());
329 painter->drawLine(rect().x() + rect().width(), rect().y(), rect().x() + rect().width(), rect().y() + rect().height());
330 painter->setPen(QPen(Qt::black, 1.0));
331 painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());
332 painter->drawLine(rect().x(), rect().y() + rect().height(), rect().x() + rect().width(), rect().y() + rect().height());*/
334 //QGraphicsRectItem::paint(painter, option, widget);
335 //QPen pen(Qt::green, 1.0 / size.x() + 0.5);
336 //painter->setPen(pen);
337 //painter->drawLine(rect().x(), rect().y(), rect().x() + rect().width(), rect().y());
338 //kDebug()<<"ITEM REPAINT RECT: "<<boundingRect().width();
339 //painter->drawText(rect(), Qt::AlignCenter, m_name);
340 // painter->drawRect(boundingRect());
341 //painter->drawRoundRect(-10, -10, 20, 20);
345 OPERATIONTYPE ClipItem::operationMode(QPointF pos, double scale)
347 if (abs(pos.x() - (rect().x() + scale * m_startFade)) < 6 && abs(pos.y() - rect().y()) < 6) return FADEIN;
348 else if (abs(pos.x() - rect().x()) < 6) return RESIZESTART;
349 else if (abs(pos.x() - (rect().x() + rect().width() - scale * m_endFade)) < 6 && abs(pos.y() - rect().y()) < 6) return FADEOUT;
350 else if (abs(pos.x() - (rect().x() + rect().width())) < 6) return RESIZEEND;
354 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame,QPainterPath path,int startpixel, int endpixel){
357 QRectF re=path.boundingRect();
359 //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
361 for (int startCache=startpixel-startpixel%100;startCache+100<endpixel ;startCache+=100){
362 //kDebug() << "creating " << startCache;
363 //if (framePixelWidth!=pixelForOneFrame ||
364 if (framePixelWidth==pixelForOneFrame && audioThumbCachePic.contains(startCache))
366 if (audioThumbCachePic[startCache].isNull() || framePixelWidth!=pixelForOneFrame){
367 audioThumbCachePic[startCache]=QPixmap(100,re.height());
368 audioThumbCachePic[startCache].fill(QColor(200,200,200,127));
370 bool fullAreaDraw=pixelForOneFrame<10;
371 QMap<int,QPainterPath > positiveChannelPaths;
372 QMap<int,QPainterPath > negativeChannelPaths;
373 QPainter pixpainter(&audioThumbCachePic[startCache]);
375 audiopen.setWidth(0);
376 pixpainter.setPen(audiopen);
377 pixpainter.setRenderHint(QPainter::Antialiasing,true);
378 //pixpainter.drawLine(0,0,100,re.height());
379 int channelHeight=audioThumbCachePic[startCache].height()/channels;
381 for (int i=0;i<channels;i++){
383 positiveChannelPaths[i].moveTo(0,channelHeight*i+ channelHeight/2);
384 negativeChannelPaths[i].moveTo(0,channelHeight*i+ channelHeight/2);
387 for (int samples=0;samples<=100;samples++){
388 double frame=(double)(samples+startCache-0)/pixelForOneFrame;
389 int sample=(frame-(int)(frame))*20 ;// AUDIO_FRAME_SIZE
390 if (frame<0 || sample< 0 || sample>19 )
392 QMap<int,QByteArray> frame_channel_data=baseClip()->audioFrameChache[(int)frame];
394 for (int channel=0;channel<channels && frame_channel_data[channel].size()> 0;channel++){
396 int y=channelHeight*channel+ channelHeight/2;
397 int delta=(int)(frame_channel_data[channel][sample] -127/2 ) * channelHeight/ 64;
399 positiveChannelPaths[channel].lineTo(samples,0.1+y+qAbs( delta ));
400 negativeChannelPaths[channel].lineTo(samples,0.1+y-qAbs( delta ));
402 positiveChannelPaths[channel].lineTo(samples,0.1+y+delta);
403 negativeChannelPaths[channel].lineTo(samples,0.1+y-delta);
407 for (int i=0;i<channels;i++){
409 pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
410 pixpainter.setBrush(QBrush(QColor(200,200,100,200)));
411 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
413 pixpainter.drawPath(positiveChannelPaths[i]);
416 //audioThumbWasDrawn=true;
417 framePixelWidth=pixelForOneFrame;
422 int ClipItem::fadeIn() const
427 int ClipItem::fadeOut() const
432 void ClipItem::setFadeIn(int pos, double scale)
434 int oldIn = m_startFade;
435 if (pos < 0) pos = 0;
436 if (pos > m_cropDuration) pos = m_cropDuration / 2;
438 if (oldIn > pos) update(rect().x(), rect().y(), oldIn * scale, rect().height());
439 else update(rect().x(), rect().y(), pos * scale, rect().height());
442 void ClipItem::setFadeOut(int pos, double scale)
444 int oldOut = m_endFade;
445 if (pos < 0) pos = 0;
446 if (pos > m_cropDuration) pos = m_cropDuration / 2;
448 if (oldOut > pos) update(rect().x() + rect().width() - pos * scale, rect().y(), pos * scale, rect().height());
449 else update(rect().x() + rect().width() - oldOut * scale, rect().y(), oldOut * scale, rect().height());
455 void ClipItem::mousePressEvent ( QGraphicsSceneMouseEvent * event )
457 /*m_resizeMode = operationMode(event->pos());
458 if (m_resizeMode == MOVE) {
459 m_maxTrack = scene()->sceneRect().height();
460 m_grabPoint = (int) (event->pos().x() - rect().x());
462 QGraphicsRectItem::mousePressEvent(event);
466 void ClipItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
469 QGraphicsRectItem::mouseReleaseEvent(event);
472 void ClipItem::moveTo(int x, double scale, double offset, int newTrack)
474 double origX = rect().x();
475 double origY = rect().y();
478 setRect(x * scale, origY + offset, rect().width(), rect().height());
479 QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
480 if (collisionList.size() == 0) m_track = newTrack;
481 for (int i = 0; i < collisionList.size(); ++i) {
482 QGraphicsItem *item = collisionList.at(i);
483 if (item->type() == 70000)
487 QRectF other = ((QGraphicsRectItem *)item)->rect();
488 if (x < m_startPos) {
489 kDebug()<<"COLLISION, MOVING TO------";
490 m_startPos = ((ClipItem *)item)->endPos() + 1;
491 origX = m_startPos * scale;
494 kDebug()<<"COLLISION, MOVING TO+++";
495 m_startPos = ((ClipItem *)item)->startPos() - m_cropDuration;
496 origX = m_startPos * scale;
499 setRect(origX, origY, rect().width(), rect().height());
510 /* QList <QGraphicsItem *> childrenList = QGraphicsItem::children();
511 for (int i = 0; i < childrenList.size(); ++i) {
512 childrenList.at(i)->moveBy(rect().x() - origX , offset);
516 void ClipItem::resizeStart(int posx, double scale)
518 int durationDiff = posx - m_startPos;
519 if (durationDiff == 0) return;
520 kDebug()<<"-- RESCALE: CROP="<<m_cropStart<<", DIFF = "<<durationDiff;
521 if (m_cropStart + durationDiff < 0) {
522 durationDiff = -m_cropStart;
524 else if (durationDiff >= m_cropDuration) {
525 durationDiff = m_cropDuration - 3;
527 m_startPos += durationDiff;
528 m_cropStart += durationDiff;
529 m_cropDuration -= durationDiff;
530 setRect(m_startPos * scale, rect().y(), m_cropDuration * scale, rect().height());
531 QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
532 for (int i = 0; i < collisionList.size(); ++i) {
533 QGraphicsItem *item = collisionList.at(i);
534 if (item->type() == 70000)
536 int diff = ((ClipItem *)item)->endPos() + 1 - m_startPos;
537 setRect((m_startPos + diff) * scale, rect().y(), (m_cropDuration - diff) * scale, rect().height());
540 m_cropDuration -= diff;
544 if (m_hasThumbs) startThumbTimer->start(100);
547 void ClipItem::resizeEnd(int posx, double scale)
549 int durationDiff = posx - endPos();
550 if (durationDiff == 0) return;
551 kDebug()<<"-- RESCALE: CROP="<<m_cropStart<<", DIFF = "<<durationDiff;
552 if (m_cropDuration + durationDiff <= 0) {
553 durationDiff = - (m_cropDuration - 3);
555 else if (m_cropDuration + durationDiff >= m_maxDuration) {
556 durationDiff = m_maxDuration - m_cropDuration;
558 m_cropDuration += durationDiff;
559 setRect(m_startPos * scale, rect().y(), m_cropDuration * scale, rect().height());
560 QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
561 for (int i = 0; i < collisionList.size(); ++i) {
562 QGraphicsItem *item = collisionList.at(i);
563 if (item->type() == 70000)
565 int diff = ((ClipItem *)item)->startPos() - 1 - startPos();
566 m_cropDuration = diff;
567 setRect(m_startPos * scale, rect().y(), m_cropDuration * scale, rect().height());
571 if (m_hasThumbs) endThumbTimer->start(100);
575 void ClipItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event )
579 int ClipItem::track()
584 void ClipItem::setTrack(int track)
589 int ClipItem::effectsCounter()
591 return m_effectsCounter++;
594 int ClipItem::effectsCount()
596 return m_effectList.size();
599 QStringList ClipItem::effectNames()
601 return m_effectList.effectNames();
604 QDomElement ClipItem::effectAt(int ix)
606 return m_effectList.at(ix);
609 void ClipItem::setEffectAt(int ix, QDomElement effect)
611 kDebug()<<"CHange EFFECT AT: "<<ix<<", CURR: "<<m_effectList.at(ix).attribute("tag")<<", NEW: "<<effect.attribute("tag");
612 m_effectList.insert(ix, effect);
613 m_effectList.removeAt(ix + 1);
614 update(boundingRect());
617 QMap <QString, QString> ClipItem::addEffect(QDomElement effect)
619 QMap <QString, QString> effectParams;
620 m_effectList.append(effect);
621 effectParams["tag"] = effect.attribute("tag");
622 effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
623 QDomNodeList params = effect.elementsByTagName("parameter");
624 for (int i = 0; i < params.count(); i++) {
625 QDomElement e = params.item(i).toElement();
627 effectParams[e.attribute("name")] = e.attribute("value");
629 update(boundingRect());
633 QMap <QString, QString> ClipItem::getEffectArgs(QDomElement effect)
635 QMap <QString, QString> effectParams;
636 effectParams["tag"] = effect.attribute("tag");
637 effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
638 QDomNodeList params = effect.elementsByTagName("parameter");
639 for (int i = 0; i < params.count(); i++) {
640 QDomElement e = params.item(i).toElement();
642 effectParams[e.attribute("name")] = e.attribute("value");
647 void ClipItem::deleteEffect(QString index)
649 for (int i = 0; i < m_effectList.size(); ++i) {
650 if (m_effectList.at(i).attribute("kdenlive_ix") == index) {
651 m_effectList.removeAt(i);
655 update(boundingRect());
661 void CustomTrackView::mousePressEvent ( QMouseEvent * event )
663 int pos = event->x();
664 if (event->modifiers() == Qt::ControlModifier)
665 setDragMode(QGraphicsView::ScrollHandDrag);
666 else if (event->modifiers() == Qt::ShiftModifier)
667 setDragMode(QGraphicsView::RubberBandDrag);
669 QGraphicsItem * item = itemAt(event->pos());
672 else emit cursorMoved((int) mapToScene(event->x(), 0).x());
675 QGraphicsView::mousePressEvent(event);
678 void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
680 QGraphicsView::mouseReleaseEvent(event);
681 setDragMode(QGraphicsView::NoDrag);
685 #include "clipitem.moc"