]> git.sesse.net Git - kdenlive/blob - src/clipitem.cpp
Disable (until fixed) show frame on mouse move with razor tool. Fixes crash on clip...
[kdenlive] / src / clipitem.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21
22 #include <QPainter>
23 #include <QTimer>
24 #include <QStyleOptionGraphicsItem>
25 #include <QGraphicsScene>
26 #include <QGraphicsView>
27 #include <QScrollBar>
28 #include <QMimeData>
29 #include <QApplication>
30
31 #include <KDebug>
32
33 #include "clipitem.h"
34 #include "customtrackview.h"
35 #include "renderer.h"
36 #include "docclipbase.h"
37 #include "transition.h"
38 #include "events.h"
39 #include "kdenlivesettings.h"
40 #include "kthumb.h"
41
42 ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps)
43         : AbstractClipItem(info, QRectF(), fps), m_clip(clip), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_hasThumbs(false), startThumbTimer(NULL), endThumbTimer(NULL), m_effectsCounter(1), audioThumbWasDrawn(false), m_opacity(1.0), m_timeLine(0), m_thumbsRequested(2), m_startFade(0), m_endFade(0), m_hover(false), m_selectedEffect(-1), m_speed(1.0), framePixelWidth(0) {
44     setRect(0, 0, (qreal)(info.endPos - info.startPos).frames(fps) * scale - .5, (qreal)(KdenliveSettings::trackheight() - 1));
45     setPos((qreal) info.startPos.frames(fps) * scale, (qreal)(info.track * KdenliveSettings::trackheight()) + 1);
46     kDebug() << "// ADDing CLIP TRK HGTH: " << KdenliveSettings::trackheight();
47
48     m_clipName = clip->name();
49     m_producer = clip->getId();
50     m_clipType = clip->clipType();
51     m_cropStart = info.cropStart;
52     m_maxDuration = clip->maxDuration();
53     setAcceptDrops(true);
54     audioThumbReady = clip->audioThumbCreated();
55
56     /*
57       m_cropStart = xml.attribute("in", 0).toInt();
58       m_maxDuration = xml.attribute("duration", 0).toInt();
59       if (m_maxDuration == 0) m_maxDuration = xml.attribute("out", 0).toInt() - m_cropStart;
60
61       if (duration != -1) m_cropDuration = duration;
62       else m_cropDuration = m_maxDuration;*/
63
64
65     setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
66     setAcceptsHoverEvents(true);
67     connect(this , SIGNAL(prepareAudioThumb(double, QPainterPath, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, QPainterPath, int, int, int)));
68
69     setBrush(QColor(141, 166, 215));
70     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW) {
71         m_hasThumbs = true;
72         connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
73         connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
74         connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
75         QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
76
77         startThumbTimer = new QTimer(this);
78         startThumbTimer->setSingleShot(true);
79         connect(startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
80         endThumbTimer = new QTimer(this);
81         endThumbTimer->setSingleShot(true);
82         connect(endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
83     } else if (m_clipType == COLOR) {
84         QString colour = clip->getProperty("colour");
85         colour = colour.replace(0, 2, "#");
86         setBrush(QColor(colour.left(7)));
87     } else if (m_clipType == IMAGE || m_clipType == TEXT) {
88         m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(50 * KdenliveSettings::project_display_ratio()), 50);
89         m_endPix = m_startPix;
90     } else if (m_clipType == AUDIO) {
91         connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
92     }
93 }
94
95
96 ClipItem::~ClipItem() {
97     if (startThumbTimer) delete startThumbTimer;
98     if (endThumbTimer) delete endThumbTimer;
99     if (m_timeLine) m_timeLine;
100 }
101
102 ClipItem *ClipItem::clone(double scale, ItemInfo info) const {
103     ClipItem *duplicate = new ClipItem(m_clip, info, scale, m_fps);
104     if (info.cropStart == cropStart()) duplicate->slotThumbReady(info.cropStart.frames(m_fps), m_startPix);
105     if (info.cropStart + (info.endPos - info.startPos) == m_cropStart + m_cropDuration) duplicate->slotThumbReady((m_cropStart + m_cropDuration).frames(m_fps) - 1, m_endPix);
106     kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
107     duplicate->setEffectList(m_effectList);
108     duplicate->setSpeed(m_speed);
109     return duplicate;
110 }
111
112 void ClipItem::setEffectList(const EffectsList effectList) {
113     m_effectList = effectList;
114     m_effectNames = m_effectList.effectNames().join(" / ");
115 }
116
117 const EffectsList ClipItem::effectList() {
118     return m_effectList;
119 }
120
121 int ClipItem::selectedEffectIndex() const {
122     return m_selectedEffect;
123 }
124
125 void ClipItem::initEffect(QDomElement effect) {
126     // the kdenlive_ix int is used to identify an effect in mlt's playlist, should
127     // not be changed
128     if (effect.attribute("kdenlive_ix").toInt() == 0)
129         effect.setAttribute("kdenlive_ix", QString::number(effectsCounter()));
130     // init keyframes if required
131     QDomNodeList params = effect.elementsByTagName("parameter");
132     for (int i = 0; i < params.count(); i++) {
133         QDomElement e = params.item(i).toElement();
134         if (!e.isNull() && e.attribute("type") == "keyframe") {
135             QString def = e.attribute("default");
136             // Effect has a keyframe type parameter, we need to set the values
137             if (e.attribute("keyframes").isEmpty()) {
138                 e.setAttribute("keyframes", QString::number(m_cropStart.frames(m_fps)) + ":" + def + ";" + QString::number((m_cropStart + m_cropDuration).frames(m_fps)) + ":" + def);
139                 //kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
140                 break;
141             }
142         }
143     }
144 }
145
146 void ClipItem::setKeyframes(const int ix, const QString keyframes) {
147     QDomElement effect = effectAt(ix);
148     if (effect.attribute("disabled") == "1") return;
149     QDomNodeList params = effect.elementsByTagName("parameter");
150     for (int i = 0; i < params.count(); i++) {
151         QDomElement e = params.item(i).toElement();
152         if (!e.isNull() && e.attribute("type") == "keyframe") {
153             e.setAttribute("keyframes", keyframes);
154             if (ix == m_selectedEffect) {
155                 m_keyframes.clear();
156                 double max = e.attribute("max").toDouble();
157                 double min = e.attribute("min").toDouble();
158                 m_keyframeFactor = 100.0 / (max - min);
159                 m_keyframeDefault = e.attribute("default").toDouble();
160                 // parse keyframes
161                 const QStringList keyframes = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
162                 foreach(const QString str, keyframes) {
163                     int pos = str.section(":", 0, 0).toInt();
164                     double val = str.section(":", 1, 1).toDouble();
165                     m_keyframes[pos] = val;
166                 }
167                 update();
168                 return;
169             }
170             break;
171         }
172     }
173 }
174
175
176 void ClipItem::setSelectedEffect(const int ix) {
177     m_selectedEffect = ix;
178     QDomElement effect = effectAt(m_selectedEffect);
179     QDomNodeList params = effect.elementsByTagName("parameter");
180     if (effect.attribute("disabled") != "1")
181         for (int i = 0; i < params.count(); i++) {
182             QDomElement e = params.item(i).toElement();
183             if (!e.isNull() && e.attribute("type") == "keyframe") {
184                 m_keyframes.clear();
185                 double max = e.attribute("max").toDouble();
186                 double min = e.attribute("min").toDouble();
187                 m_keyframeFactor = 100.0 / (max - min);
188                 m_keyframeDefault = e.attribute("default").toDouble();
189                 // parse keyframes
190                 const QStringList keyframes = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
191                 foreach(const QString str, keyframes) {
192                     int pos = str.section(":", 0, 0).toInt();
193                     double val = str.section(":", 1, 1).toDouble();
194                     m_keyframes[pos] = val;
195                 }
196                 update();
197                 return;
198             }
199         }
200     if (!m_keyframes.isEmpty()) {
201         m_keyframes.clear();
202         update();
203     }
204 }
205
206 QString ClipItem::keyframes(const int index) {
207     QString result;
208     QDomElement effect = effectAt(index);
209     QDomNodeList params = effect.elementsByTagName("parameter");
210
211     for (int i = 0; i < params.count(); i++) {
212         QDomElement e = params.item(i).toElement();
213         if (!e.isNull() && e.attribute("type") == "keyframe") {
214             result = e.attribute("keyframes");
215             break;
216         }
217     }
218     return result;
219 }
220
221 void ClipItem::updateKeyframeEffect() {
222     // regenerate xml parameter from the clip keyframes
223     QDomElement effect = effectAt(m_selectedEffect);
224     if (effect.attribute("disabled") == "1") return;
225     QDomNodeList params = effect.elementsByTagName("parameter");
226
227     for (int i = 0; i < params.count(); i++) {
228         QDomElement e = params.item(i).toElement();
229         if (!e.isNull() && e.attribute("type") == "keyframe") {
230             QString keyframes;
231             if (m_keyframes.count() > 1) {
232                 QMap<int, double>::const_iterator i = m_keyframes.constBegin();
233                 double x1;
234                 double y1;
235                 while (i != m_keyframes.constEnd()) {
236                     keyframes.append(QString::number(i.key()) + ":" + QString::number(i.value()) + ";");
237                     ++i;
238                 }
239             }
240             // Effect has a keyframe type parameter, we need to set the values
241             //kDebug() << ":::::::::::::::   SETTING EFFECT KEYFRAMES: " << keyframes;
242             e.setAttribute("keyframes", keyframes);
243             break;
244         }
245     }
246 }
247
248 QDomElement ClipItem::selectedEffect() {
249     if (m_selectedEffect == -1 || m_effectList.isEmpty()) return QDomElement();
250     return effectAt(m_selectedEffect);
251 }
252
253 void ClipItem::resetThumbs() {
254     m_startPix = QPixmap();
255     m_endPix = QPixmap();
256     m_thumbsRequested = 2;
257     slotFetchThumbs();
258     audioThumbCachePic.clear();
259 }
260
261
262 void ClipItem::refreshClip() {
263     m_maxDuration = m_clip->maxDuration();
264     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW) slotFetchThumbs();
265     else if (m_clipType == COLOR) {
266         QString colour = m_clip->getProperty("colour");
267         colour = colour.replace(0, 2, "#");
268         setBrush(QColor(colour.left(7)));
269     } else if (m_clipType == IMAGE || m_clipType == TEXT) {
270         m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(50 * KdenliveSettings::project_display_ratio()), 50);
271         m_endPix = m_startPix;
272     }
273 }
274
275 void ClipItem::slotFetchThumbs() {
276     if (m_endPix.isNull() && m_startPix.isNull()) {
277         emit getThumb((int)m_cropStart.frames(m_fps), (int)(m_cropStart + m_cropDuration).frames(m_fps) - 1);
278     } else {
279         if (m_endPix.isNull()) slotGetEndThumb();
280         if (m_startPix.isNull()) slotGetStartThumb();
281     }
282 }
283
284 void ClipItem::slotGetStartThumb() {
285     emit getThumb((int)m_cropStart.frames(m_fps), -1);
286 }
287
288 void ClipItem::slotGetEndThumb() {
289     emit getThumb(-1, (int)(m_cropStart + m_cropDuration).frames(m_fps) - 1);
290 }
291
292 void ClipItem::slotThumbReady(int frame, QPixmap pix) {
293     if (frame == m_cropStart.frames(m_fps)) {
294         m_startPix = pix;
295         QRectF r = sceneBoundingRect();
296         r.setRight(pix.width() + 2);
297         update(r);
298         m_thumbsRequested--;
299     } else if (frame == (m_cropStart + m_cropDuration).frames(m_fps) - 1) {
300         m_endPix = pix;
301         QRectF r = sceneBoundingRect();
302         r.setLeft(r.right() - pix.width() - 2);
303         update(r);
304         m_thumbsRequested--;
305     }
306     if (m_thumbsRequested == 0) {
307         // Ok, we have out start and end thumbnails...
308         disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
309     }
310 }
311
312 void ClipItem::slotGotAudioData() {
313     audioThumbReady = true;
314     if (m_clipType == AV) {
315         QRectF r = boundingRect();
316         r.setTop(r.top() + r.height() / 2 - 1);
317         update(r);
318     } else update();
319 }
320
321 int ClipItem::type() const {
322     return AVWIDGET;
323 }
324
325 DocClipBase *ClipItem::baseClip() const {
326     return m_clip;
327 }
328
329 QDomElement ClipItem::xml() const {
330     return m_clip->toXML();
331 }
332
333 int ClipItem::clipType() const {
334     return m_clipType;
335 }
336
337 QString ClipItem::clipName() const {
338     return m_clipName;
339 }
340
341 int ClipItem::clipProducer() const {
342     return m_producer;
343 }
344
345 void ClipItem::flashClip() {
346     if (m_timeLine == 0) {
347         m_timeLine = new QTimeLine(750, this);
348         m_timeLine->setCurveShape(QTimeLine::EaseInOutCurve);
349         connect(m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animate(qreal)));
350     }
351     m_timeLine->start();
352 }
353
354 void ClipItem::animate(qreal value) {
355     QRectF r = boundingRect();
356     r.setHeight(20);
357     update(r);
358 }
359
360 // virtual
361 void ClipItem::paint(QPainter *painter,
362                      const QStyleOptionGraphicsItem *option,
363                      QWidget *) {
364     painter->setOpacity(m_opacity);
365     QBrush paintColor = brush();
366     if (isSelected()) paintColor = QBrush(QColor(79, 93, 121));
367     QRectF br = rect();
368     const double itemWidth = br.width();
369     const double itemHeight = br.height();
370     kDebug() << "/// ITEM RECT: " << br << ", EPXOSED: " << option->exposedRect;
371     double scale = itemWidth / (double) m_cropDuration.frames(m_fps);
372
373     // kDebug()<<"///   EXPOSED RECT: "<<option->exposedRect.x()<<" X "<<option->exposedRect.right();
374
375     double startpixel = option->exposedRect.x(); // - pos().x();
376
377     if (startpixel < 0)
378         startpixel = 0;
379     double endpixel = option->exposedRect.right();
380     if (endpixel < 0)
381         endpixel = 0;
382
383     //painter->setRenderHints(QPainter::Antialiasing);
384
385     QPainterPath roundRectPathUpper = upperRectPart(br), roundRectPathLower = lowerRectPart(br);
386     painter->setClipRect(option->exposedRect);
387
388     // build path around clip
389     QPainterPath resultClipPath = roundRectPathUpper.united(roundRectPathLower);
390     painter->fillPath(resultClipPath, paintColor);
391
392     painter->setClipPath(resultClipPath, Qt::IntersectClip);
393
394     // draw thumbnails
395     if (KdenliveSettings::videothumbnails()) {
396         if (m_clipType == IMAGE && !m_startPix.isNull()) {
397             painter->drawPixmap(QPointF(itemWidth - m_startPix.width(), 0), m_startPix);
398             QLine l(itemWidth - m_startPix.width(), 0, itemWidth - m_startPix.width(), itemHeight);
399             painter->drawLine(l);
400         }
401         else if (!m_endPix.isNull()) {
402             painter->drawPixmap(QPointF(itemWidth - m_endPix.width(), 0), m_endPix);
403             QLine l(itemWidth - m_endPix.width(), 0, itemWidth - m_endPix.width(), itemHeight);
404             painter->drawLine(l);
405         }
406         if (!m_startPix.isNull()) {
407             painter->drawPixmap(QPointF(0, 0), m_startPix);
408             QLine l2(m_startPix.width(), 0, 0 + m_startPix.width(), itemHeight);
409             painter->drawLine(l2);
410         }
411     }
412
413     // draw audio thumbnails
414     if (KdenliveSettings::audiothumbnails() && ((m_clipType == AV && option->exposedRect.bottom() > (itemHeight / 2)) || m_clipType == AUDIO) && audioThumbReady) {
415
416         QPainterPath path = m_clipType == AV ? roundRectPathLower : resultClipPath;
417         if (m_clipType == AV) painter->fillPath(path, QBrush(QColor(200, 200, 200, 140)));
418
419         int channels = baseClip()->getProperty("channels").toInt();
420         if (scale != framePixelWidth)
421             audioThumbCachePic.clear();
422         double cropLeft = m_cropStart.frames(m_fps) * scale;
423         emit prepareAudioThumb(scale, path, startpixel + cropLeft, endpixel + cropLeft, channels);//200 more for less missing parts before repaint after scrolling
424         int newstart = startpixel + cropLeft;
425         for (int startCache = newstart - (newstart) % 100; startCache < endpixel + cropLeft; startCache += 100) {
426             if (audioThumbCachePic.contains(startCache) && !audioThumbCachePic[startCache].isNull())
427                 painter->drawPixmap((int)(startCache - cropLeft), (int)(path.boundingRect().y()), audioThumbCachePic[startCache]);
428         }
429     }
430
431     // draw markers
432     QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
433     QList < CommentedTime >::Iterator it = markers.begin();
434     GenTime pos;
435     double framepos;
436     const int markerwidth = 4;
437     QBrush markerBrush;
438     markerBrush = QBrush(QColor(120, 120, 0, 100));
439     QPen pen = painter->pen();
440     pen.setColor(QColor(255, 255, 255, 200));
441     pen.setStyle(Qt::DotLine);
442     painter->setPen(pen);
443     for (; it != markers.end(); ++it) {
444         pos = (*it).time() - cropStart();
445         if (pos > GenTime()) {
446             if (pos > duration()) break;
447             framepos = scale * pos.frames(m_fps);
448             QLineF l(framepos, 5, framepos, itemHeight - 5);
449             painter->drawLine(l);
450             if (KdenliveSettings::showmarkers()) {
451                 const QRectF txtBounding = painter->boundingRect(framepos + 1, 10, itemWidth - framepos - 2, itemHeight - 10, Qt::AlignLeft | Qt::AlignTop, " " + (*it).comment() + " ");
452                 QPainterPath path;
453                 path.addRoundedRect(txtBounding, 3, 3);
454                 painter->fillPath(path, markerBrush);
455                 painter->drawText(txtBounding, Qt::AlignCenter, (*it).comment());
456             }
457             //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
458         }
459     }
460     pen.setColor(Qt::black);
461     pen.setStyle(Qt::SolidLine);
462     painter->setPen(pen);
463
464     // draw start / end fades
465     QBrush fades;
466     if (isSelected()) {
467         fades = QBrush(QColor(200, 50, 50, 150));
468     } else fades = QBrush(QColor(200, 200, 200, 200));
469
470     if (m_startFade != 0) {
471         QPainterPath fadeInPath;
472         fadeInPath.moveTo(0, 0);
473         fadeInPath.lineTo(0, itemHeight);
474         fadeInPath.lineTo(m_startFade * scale, itemHeight);
475         fadeInPath.closeSubpath();
476         painter->fillPath(fadeInPath/*.intersected(resultClipPath)*/, fades);
477         if (isSelected()) {
478             QLineF l(m_startFade * scale, 0, 0, itemHeight);
479             painter->drawLine(l);
480         }
481     }
482     if (m_endFade != 0) {
483         QPainterPath fadeOutPath;
484         fadeOutPath.moveTo(itemWidth, 0);
485         fadeOutPath.lineTo(itemWidth, itemHeight);
486         fadeOutPath.lineTo(itemWidth - m_endFade * scale, 0);
487         fadeOutPath.closeSubpath();
488         painter->fillPath(fadeOutPath/*.intersected(resultClipPath)*/, fades);
489         if (isSelected()) {
490             QLineF l(itemWidth - m_endFade * scale, 0, itemWidth, itemHeight);
491             painter->drawLine(l);
492         }
493     }
494
495     // Draw effects names
496     if (!m_effectNames.isEmpty() && itemWidth > 30) {
497         QRectF txtBounding = painter->boundingRect(br, Qt::AlignLeft | Qt::AlignTop, m_effectNames);
498         txtBounding.setRight(txtBounding.right() + 15);
499         painter->setPen(Qt::white);
500         QBrush markerBrush(Qt::SolidPattern);
501         if (m_timeLine && m_timeLine->state() == QTimeLine::Running) {
502             qreal value = m_timeLine->currentValue();
503             txtBounding.setWidth(txtBounding.width() * value);
504             markerBrush.setColor(QColor(50 + 200 * (1.0 - value), 50, 50, 100 + 50 * value));
505         } else markerBrush.setColor(QColor(50, 50, 50, 150));
506         QPainterPath path;
507         path.addRoundedRect(txtBounding, 4, 4);
508         painter->fillPath(path/*.intersected(resultClipPath)*/, markerBrush);
509         painter->drawText(txtBounding, Qt::AlignCenter, m_effectNames);
510         painter->setPen(Qt::black);
511     }
512
513     // Draw clip name
514     QRectF txtBounding = painter->boundingRect(br, Qt::AlignHCenter | Qt::AlignTop, " " + m_clipName + " ");
515     //painter->fillRect(txtBounding, QBrush(QColor(255, 255, 255, 150)));
516     painter->setPen(QColor(0, 0, 0, 180));
517     painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
518     txtBounding.translate(QPointF(1, 1));
519     painter->setPen(QColor(255, 255, 255, 255));
520     painter->drawText(txtBounding, Qt::AlignCenter, m_clipName);
521     // draw frame around clip
522     if (isSelected()) {
523         pen.setColor(Qt::red);
524         //pen.setWidth(2);
525     } else {
526         pen.setColor(Qt::black);
527         //pen.setWidth(1);
528     }
529
530
531     // draw effect or transition keyframes
532     if (itemWidth > 20) drawKeyFrames(painter, option->exposedRect);
533
534     // draw clip border
535     painter->setClipRect(option->exposedRect);
536     painter->setPen(pen);
537     //painter->setClipRect(option->exposedRect);
538     painter->drawPath(resultClipPath);
539
540     if (m_hover && itemWidth > 30) {
541         painter->setBrush(QColor(180, 180, 50, 180)); //gradient);
542
543         // draw transitions handles
544         QPainterPath transitionHandle;
545         const int handle_size = 4;
546         transitionHandle.moveTo(0, 0);
547         transitionHandle.lineTo(handle_size, handle_size);
548         transitionHandle.lineTo(handle_size * 2, 0);
549         transitionHandle.lineTo(handle_size * 3, handle_size);
550         transitionHandle.lineTo(handle_size * 2, handle_size * 2);
551         transitionHandle.lineTo(handle_size * 3, handle_size * 3);
552         transitionHandle.lineTo(0, handle_size * 3);
553         transitionHandle.closeSubpath();
554         int pointy = (int)(itemHeight / 2);
555         int pointx1 = 10;
556         int pointx2 = (int)(itemWidth - (10 + handle_size * 3));
557 #if 0
558         painter->setPen(QPen(Qt::black));
559         painter->setBrush(QBrush(QColor(50, 50, 0)));
560 #else
561         /*QRadialGradient gradient(pointx1 + 5, pointy + 5 , 5, 2, 2);
562         gradient.setColorAt(0.2, Qt::white);
563         gradient.setColorAt(0.8, Qt::yellow);
564         gradient.setColorAt(1, Qt::black);*/
565
566 #endif
567         painter->translate(pointx1, pointy);
568         painter->drawPath(transitionHandle); //Ellipse(0, 0 , 10, 10);
569         painter->translate(-pointx1, -pointy);
570
571         /*        QRadialGradient gradient1(pointx2 + 5, pointy + 5 , 5, 2, 2);
572                 gradient1.setColorAt(0.2, Qt::white);
573                 gradient1.setColorAt(0.8, Qt::yellow);
574                 gradient1.setColorAt(1, Qt::black);
575                 painter->setBrush(gradient1);*/
576         painter->translate(pointx2, pointy);
577         QMatrix m;
578         m.scale(-1.0, 1.0);
579         //painter->setMatrix(m);
580         painter->drawPath(transitionHandle); // Ellipse(0, 0, 10, 10);
581         //painter->setMatrix(m);
582         painter->translate(- pointx2, -pointy);
583     }
584 }
585
586
587 OPERATIONTYPE ClipItem::operationMode(QPointF pos, double scale) {
588     if (isSelected()) {
589         m_editedKeyframe = mouseOverKeyFrames(pos);
590         if (m_editedKeyframe != -1) return KEYFRAME;
591     }
592     QRectF rect = sceneBoundingRect();
593     if (qAbs((int)(pos.x() - (rect.x() + scale * m_startFade))) < 6 && qAbs((int)(pos.y() - rect.y())) < 6) {
594         if (m_startFade == 0) setToolTip(i18n("Add audio fade"));
595         else setToolTip(i18n("Audio fade duration: %1s", GenTime(m_startFade, m_fps).seconds()));
596         return FADEIN;
597     } else if (qAbs((int)(pos.x() - rect.x())) < 6) {
598         setToolTip(i18n("Crop from start: %1s", cropStart().seconds()));
599         return RESIZESTART;
600     } else if (qAbs((int)(pos.x() - (rect.x() + rect.width() - scale * m_endFade))) < 6 && qAbs((int)(pos.y() - rect.y())) < 6) {
601         if (m_endFade == 0) setToolTip(i18n("Add audio fade"));
602         else setToolTip(i18n("Audio fade duration: %1s", GenTime(m_endFade, m_fps).seconds()));
603         return FADEOUT;
604     } else if (qAbs((int)(pos.x() - (rect.x() + rect.width()))) < 6) {
605         setToolTip(i18n("Clip duration: %1s", duration().seconds()));
606         return RESIZEEND;
607     } else if (qAbs((int)(pos.x() - (rect.x() + 16))) < 10 && qAbs((int)(pos.y() - (rect.y() + rect.height() / 2 + 5))) < 8) {
608         setToolTip(i18n("Add transition"));
609         return TRANSITIONSTART;
610     } else if (qAbs((int)(pos.x() - (rect.x() + rect.width() - 21))) < 10 && qAbs((int)(pos.y() - (rect.y() + rect.height() / 2 + 5))) < 8) {
611         setToolTip(i18n("Add transition"));
612         return TRANSITIONEND;
613     }
614     setToolTip(QString());
615     return MOVE;
616 }
617
618 QList <GenTime> ClipItem::snapMarkers() const {
619     QList < GenTime > snaps;
620     QList < GenTime > markers = baseClip()->snapMarkers();
621     GenTime pos;
622     double framepos;
623
624     for (int i = 0; i < markers.size(); i++) {
625         pos = markers.at(i) - cropStart();
626         if (pos > GenTime()) {
627             if (pos > duration()) break;
628             else snaps.append(pos + startPos());
629         }
630     }
631     return snaps;
632 }
633
634 QList <CommentedTime> ClipItem::commentedSnapMarkers() const {
635     QList < CommentedTime > snaps;
636     QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
637     GenTime pos;
638     double framepos;
639
640     for (int i = 0; i < markers.size(); i++) {
641         pos = markers.at(i).time() - cropStart();
642         if (pos > GenTime()) {
643             if (pos > duration()) break;
644             else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment()));
645         }
646     }
647     return snaps;
648 }
649
650 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, QPainterPath path, int startpixel, int endpixel, int channels) {
651
652     QRectF re = path.boundingRect();
653     kDebug() << "// PREP AUDIO THMB FRMO : " << startpixel << ", to: " << endpixel;
654     //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
655
656     for (int startCache = startpixel - startpixel % 100;startCache + 100 < endpixel + 100;startCache += 100) {
657         //kDebug() << "creating " << startCache;
658         //if (framePixelWidth!=pixelForOneFrame  ||
659         if (framePixelWidth == pixelForOneFrame && audioThumbCachePic.contains(startCache))
660             continue;
661         if (audioThumbCachePic[startCache].isNull() || framePixelWidth != pixelForOneFrame) {
662             audioThumbCachePic[startCache] = QPixmap(100, (int)(re.height()));
663             audioThumbCachePic[startCache].fill(QColor(200, 200, 200, 0));
664         }
665         bool fullAreaDraw = pixelForOneFrame < 10;
666         QMap<int, QPainterPath > positiveChannelPaths;
667         QMap<int, QPainterPath > negativeChannelPaths;
668         QPainter pixpainter(&audioThumbCachePic[startCache]);
669         QPen audiopen;
670         audiopen.setWidth(0);
671         pixpainter.setPen(audiopen);
672         //pixpainter.setRenderHint(QPainter::Antialiasing,true);
673         //pixpainter.drawLine(0,0,100,re.height());
674         int channelHeight = audioThumbCachePic[startCache].height() / channels;
675
676         for (int i = 0;i < channels;i++) {
677
678             positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
679             negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
680         }
681
682         for (int samples = 0;samples <= 100;samples++) {
683             double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
684             int sample = (int)((frame - (int)(frame)) * 20);   // AUDIO_FRAME_SIZE
685             if (frame < 0 || sample < 0 || sample > 19)
686                 continue;
687             QMap<int, QByteArray> frame_channel_data = baseClip()->audioFrameChache[(int)frame];
688
689             for (int channel = 0;channel < channels && frame_channel_data[channel].size() > 0;channel++) {
690
691                 int y = channelHeight * channel + channelHeight / 2;
692                 int delta = (int)(frame_channel_data[channel][sample] - 127 / 2)  * channelHeight / 64;
693                 if (fullAreaDraw) {
694                     positiveChannelPaths[channel].lineTo(samples, 0.1 + y + qAbs(delta));
695                     negativeChannelPaths[channel].lineTo(samples, 0.1 + y - qAbs(delta));
696                 } else {
697                     positiveChannelPaths[channel].lineTo(samples, 0.1 + y + delta);
698                     negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
699                 }
700             }
701             for (int channel = 0;channel < channels ;channel++)
702                 if (fullAreaDraw && samples == 100) {
703                     positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
704                     negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
705                     positiveChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
706                     negativeChannelPaths[channel].lineTo(0, channelHeight*channel + channelHeight / 2);
707                 }
708
709         }
710         if (m_clipType != AV) pixpainter.setBrush(QBrush(QColor(200, 200, 100)));
711         else {
712             pixpainter.setPen(QPen(QColor(0, 0, 0)));
713             pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
714         }
715         for (int i = 0;i < channels;i++) {
716             if (fullAreaDraw) {
717                 //pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
718                 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
719             } else
720                 pixpainter.drawPath(positiveChannelPaths[i]);
721         }
722     }
723     //audioThumbWasDrawn=true;
724     framePixelWidth = pixelForOneFrame;
725
726     //}
727 }
728
729 uint ClipItem::fadeIn() const {
730     return m_startFade;
731 }
732
733 uint ClipItem::fadeOut() const {
734     return m_endFade;
735 }
736
737
738 void ClipItem::setFadeIn(int pos, double scale) {
739     int oldIn = m_startFade;
740     if (pos < 0) pos = 0;
741     if (pos > m_cropDuration.frames(m_fps)) pos = (int)(m_cropDuration.frames(m_fps) / 2);
742     m_startFade = pos;
743     QRectF rect = boundingRect();
744     update(rect.x(), rect.y(), qMax(oldIn, pos) * scale, rect.height());
745 }
746
747 void ClipItem::setFadeOut(int pos, double scale) {
748     int oldOut = m_endFade;
749     if (pos < 0) pos = 0;
750     if (pos > m_cropDuration.frames(m_fps)) pos = (int)(m_cropDuration.frames(m_fps) / 2);
751     m_endFade = pos;
752     QRectF rect = boundingRect();
753     update(rect.x() + rect.width() - qMax(oldOut, pos) * scale, rect.y(), pos * scale, rect.height());
754
755 }
756
757 // virtual
758 void ClipItem::mousePressEvent(QGraphicsSceneMouseEvent * event) {
759     /*m_resizeMode = operationMode(event->pos());
760     if (m_resizeMode == MOVE) {
761       m_maxTrack = scene()->sceneRect().height();
762       m_grabPoint = (int) (event->pos().x() - rect().x());
763     }*/
764     QGraphicsRectItem::mousePressEvent(event);
765 }
766
767 // virtual
768 void ClipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) {
769     m_resizeMode = NONE;
770     QGraphicsRectItem::mouseReleaseEvent(event);
771 }
772
773 //virtual
774 void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *) {
775     m_hover = true;
776     QRectF r = boundingRect();
777     qreal width = qMin(25.0, r.width());
778     update(r.x(), r.y(), width, r.height());
779     update(r.right() - width, r.y(), width, r.height());
780 }
781
782 //virtual
783 void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
784     m_hover = false;
785     QRectF r = boundingRect();
786     qreal width = qMin(25.0, r.width());
787     update(r.x(), r.y(), width, r.height());
788     update(r.right() - width, r.y(), width, r.height());
789 }
790
791 void ClipItem::resizeStart(int posx, double scale) {
792     const int min = (startPos() - cropStart()).frames(m_fps);
793     if (posx < min) posx = min;
794     if (posx == startPos().frames(m_fps)) return;
795     const int previous = cropStart().frames(m_fps);
796     AbstractClipItem::resizeStart(posx, scale);
797     checkEffectsKeyframesPos(previous, cropStart().frames(m_fps), true);
798     if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
799         m_thumbsRequested++;
800         connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
801         startThumbTimer->start(100);
802     }
803 }
804
805 void ClipItem::resizeEnd(int posx, double scale) {
806     const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps) + 1;
807     if (posx > max) posx = max;
808     if (posx == endPos().frames(m_fps)) return;
809     const int previous = (cropStart() + duration()).frames(m_fps);
810     AbstractClipItem::resizeEnd(posx, scale);
811     checkEffectsKeyframesPos(previous, (cropStart() + duration()).frames(m_fps), false);
812     if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
813         m_thumbsRequested++;
814         connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
815         endThumbTimer->start(100);
816     }
817 }
818
819
820 void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, bool fromStart) {
821     for (int i = 0; i < m_effectList.size(); i++) {
822         QDomElement effect = m_effectList.at(i);
823         QDomNodeList params = effect.elementsByTagName("parameter");
824         for (int j = 0; j < params.count(); j++) {
825             QDomElement e = params.item(i).toElement();
826             if (e.attribute("type") == "keyframe") {
827                 // parse keyframes and adjust values
828                 const QStringList keyframes = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
829                 QMap <int, double> kfr;
830                 foreach(const QString str, keyframes) {
831                     int pos = str.section(":", 0, 0).toInt();
832                     double val = str.section(":", 1, 1).toDouble();
833                     if (pos == previous) kfr[current] = val;
834                     else {
835                         if (fromStart && pos >= current) kfr[pos] = val;
836                         else if (!fromStart && pos <= current) kfr[pos] = val;
837                     }
838                 }
839                 QString newkfr;
840                 QMap<int, double>::const_iterator k = kfr.constBegin();
841                 while (k != kfr.constEnd()) {
842                     newkfr.append(QString::number(k.key()) + ":" + QString::number(k.value()) + ";");
843                     ++k;
844                 }
845                 e.setAttribute("keyframes", newkfr);
846                 break;
847             }
848         }
849     }
850     if (m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect);
851 }
852
853
854 // virtual
855 /*void ClipItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
856 }*/
857
858 int ClipItem::effectsCounter() {
859     return m_effectsCounter++;
860 }
861
862 int ClipItem::effectsCount() {
863     return m_effectList.size();
864 }
865
866 QStringList ClipItem::effectNames() {
867     return m_effectList.effectNames();
868 }
869
870 QDomElement ClipItem::effectAt(int ix) {
871     if (ix > m_effectList.count() - 1 || ix < 0) return QDomElement();
872     return m_effectList.at(ix);
873 }
874
875 void ClipItem::setEffectAt(int ix, QDomElement effect) {
876     kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
877     m_effectList.insert(ix, effect);
878     m_effectList.removeAt(ix + 1);
879     m_effectNames = m_effectList.effectNames().join(" / ");
880     if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fadeout") update(boundingRect());
881     else {
882         QRectF r = boundingRect();
883         r.setHeight(20);
884         update(r);
885     }
886 }
887
888 QMap <QString, QString> ClipItem::addEffect(QDomElement effect, bool animate) {
889     QMap <QString, QString> effectParams;
890     bool needRepaint = false;
891     /*QDomDocument doc;
892     doc.appendChild(doc.importNode(effect, true));
893     kDebug() << "///////  CLIP ADD EFFECT: "<< doc.toString();*/
894     m_effectList.append(effect);
895     effectParams["tag"] = effect.attribute("tag");
896     QString effectId = effect.attribute("id");
897     if (effectId.isEmpty()) effectId = effect.attribute("tag");
898     effectParams["id"] = effectId;
899     effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
900     QString state = effect.attribute("disabled");
901     if (!state.isEmpty()) effectParams["disabled"] = state;
902     QDomNodeList params = effect.elementsByTagName("parameter");
903     int fade = 0;
904     for (int i = 0; i < params.count(); i++) {
905         QDomElement e = params.item(i).toElement();
906         if (!e.isNull()) {
907             if (e.attribute("type") == "keyframe") {
908                 effectParams["keyframes"] = e.attribute("keyframes");
909                 effectParams["min"] = e.attribute("min");
910                 effectParams["max"] = e.attribute("max");
911                 effectParams["factor"] = e.attribute("factor", "1");
912                 effectParams["starttag"] = e.attribute("starttag", "start");
913                 effectParams["endtag"] = e.attribute("endtag", "end");
914             }
915
916             double f = e.attribute("factor", "1").toDouble();
917
918             if (f == 1) {
919                 effectParams[e.attribute("name")] = e.attribute("value");
920                 // check if it is a fade effect
921                 if (effectId == "fadein") {
922                     needRepaint = true;
923                     if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
924                     else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
925                 } else if (effectId == "fadeout") {
926                     needRepaint = true;
927                     if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
928                     else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
929                 }
930             } else {
931                 effectParams[e.attribute("name")] =  QString::number(effectParams[e.attribute("name")].toDouble() / f);
932             }
933         }
934     }
935     m_effectNames = m_effectList.effectNames().join(" / ");
936     if (fade > 0) m_startFade = fade;
937     else if (fade < 0) m_endFade = -fade;
938     if (needRepaint) update(boundingRect());
939     if (animate) {
940         flashClip();
941     } else if (!needRepaint) {
942         QRectF r = boundingRect();
943         r.setHeight(20);
944         update(r);
945     }
946     if (m_selectedEffect == -1) {
947         m_selectedEffect = 0;
948         setSelectedEffect(m_selectedEffect);
949     }
950     return effectParams;
951 }
952
953 QMap <QString, QString> ClipItem::getEffectArgs(QDomElement effect) {
954     QMap <QString, QString> effectParams;
955     effectParams["tag"] = effect.attribute("tag");
956     effectParams["kdenlive_ix"] = effect.attribute("kdenlive_ix");
957     effectParams["id"] = effect.attribute("id");
958     QString state = effect.attribute("disabled");
959     if (!state.isEmpty()) effectParams["disabled"] = state;
960     QDomNodeList params = effect.elementsByTagName("parameter");
961     for (int i = 0; i < params.count(); i++) {
962         QDomElement e = params.item(i).toElement();
963         kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
964         if (e.attribute("type") == "keyframe") {
965             kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
966             effectParams["keyframes"] = e.attribute("keyframes");
967             effectParams["max"] = e.attribute("max");
968             effectParams["min"] = e.attribute("min");
969             effectParams["factor"] = e.attribute("factor", "1");
970             effectParams["starttag"] = e.attribute("starttag", "start");
971             effectParams["endtag"] = e.attribute("endtag", "end");
972         } else if (e.attribute("namedesc").contains(";")) {
973             QString format = e.attribute("format");
974             QStringList separators = format.split("%d", QString::SkipEmptyParts);
975             QStringList values = e.attribute("value").split(QRegExp("[,:;x]"));
976             QString neu;
977             QTextStream txtNeu(&neu);
978             if (values.size() > 0)
979                 txtNeu << (int)values[0].toDouble();
980             for (int i = 0;i < separators.size() && i + 1 < values.size();i++) {
981                 txtNeu << separators[i];
982                 txtNeu << (int)(values[i+1].toDouble());
983             }
984             effectParams["start"] = neu;
985         } else {
986             if (e.attribute("factor", "1") != "1")
987                 effectParams[e.attribute("name")] =  QString::number(e.attribute("value").toDouble() / e.attribute("factor").toDouble());
988             else effectParams[e.attribute("name")] = e.attribute("value");
989         }
990     }
991     return effectParams;
992 }
993
994 void ClipItem::deleteEffect(QString index) {
995     bool needRepaint = false;
996     for (int i = 0; i < m_effectList.size(); ++i) {
997         if (m_effectList.at(i).attribute("kdenlive_ix") == index) {
998             if (m_effectList.at(i).attribute("id") == "fadein") {
999                 m_startFade = 0;
1000                 needRepaint = true;
1001             } else if (m_effectList.at(i).attribute("id") == "fadeout") {
1002                 m_endFade = 0;
1003                 needRepaint = true;
1004             }
1005             m_effectList.removeAt(i);
1006             break;
1007         }
1008     }
1009     m_effectNames = m_effectList.effectNames().join(" / ");
1010     if (needRepaint) update(boundingRect());
1011     flashClip();
1012 }
1013
1014 double ClipItem::speed() const {
1015     return m_speed;
1016 }
1017
1018 void ClipItem::setSpeed(const double speed) {
1019     m_speed = speed;
1020     if (m_speed == 1.0) m_clipName = baseClip()->name();
1021     else m_clipName = baseClip()->name() + " - " + QString::number(speed * 100, 'f', 0) + "%";
1022     update();
1023 }
1024
1025 GenTime ClipItem::maxDuration() const {
1026     return m_maxDuration / m_speed;
1027 }
1028
1029 //virtual
1030 void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event) {
1031     QString effects = QString(event->mimeData()->data("kdenlive/effectslist"));
1032     QDomDocument doc;
1033     doc.setContent(effects, true);
1034     QDomElement e = doc.documentElement();
1035     CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1036     if (view) view->slotAddEffect(e, m_startPos, track());
1037 }
1038
1039 //virtual
1040 void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
1041     event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist"));
1042 }
1043
1044 void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) {
1045     Q_UNUSED(event);
1046 }
1047 void ClipItem::addTransition(Transition* t) {
1048     m_transitionsList.append(t);
1049     CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
1050     QDomDocument doc;
1051     QDomElement e = doc.documentElement();
1052     //if (view) view->slotAddTransition(this, t->toXML() , t->startPos(), track());
1053 }
1054 // virtual
1055 /*
1056 void CustomTrackView::mousePressEvent ( QMouseEvent * event )
1057 {
1058   int pos = event->x();
1059   if (event->modifiers() == Qt::ControlModifier)
1060     setDragMode(QGraphicsView::ScrollHandDrag);
1061   else if (event->modifiers() == Qt::ShiftModifier)
1062     setDragMode(QGraphicsView::RubberBandDrag);
1063   else {
1064     QGraphicsItem * item = itemAt(event->pos());
1065     if (item) {
1066     }
1067     else emit cursorMoved((int) mapToScene(event->x(), 0).x());
1068   }
1069   kDebug()<<pos;
1070   QGraphicsView::mousePressEvent(event);
1071 }
1072
1073 void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event )
1074 {
1075   QGraphicsView::mouseReleaseEvent(event);
1076   setDragMode(QGraphicsView::NoDrag);
1077 }
1078 */
1079
1080 #include "clipitem.moc"