]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Fix indent, use const'ref, use explicit when necessary
[kdenlive] / src / clipitem.cpp
index 01e195c81ef2169121f9a15118f94a9bc47da16e..b2af83a82cbf8552f6c3c34078bc212dca212ba3 100644 (file)
@@ -42,7 +42,7 @@
 
 static int FRAME_SIZE;
 
-ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, int strobe, int frame_width, bool generateThumbs) :
+ClipItem::ClipItem(DocClipBase *clip, const ItemInfo& info, double fps, double speed, int strobe, int frame_width, bool generateThumbs) :
         AbstractClipItem(info, QRectF(), fps),
         m_clip(clip),
         m_startFade(0),
@@ -90,7 +90,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     setAcceptDrops(true);
     m_audioThumbReady = m_clip->audioThumbCreated();
     //setAcceptsHoverEvents(true);
-    connect(this , SIGNAL(prepareAudioThumb(double, int, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, int, int, int, int)));
+    connect(this , SIGNAL(prepareAudioThumb(double,int,int,int,int)) , this, SLOT(slotPrepareAudioThumb(double,int,int,int,int)));
 
     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
         m_baseColor = QColor(141, 166, 215);
@@ -100,7 +100,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
             connect(&m_startThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetStartThumb()));
             m_endThumbTimer.setSingleShot(true);
             connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
-            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int,QImage)), this, SLOT(slotThumbReady(int,QImage)));
             connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
             if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
         }
@@ -112,7 +112,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     } else if (m_clipType == IMAGE || m_clipType == TEXT) {
         m_baseColor = QColor(141, 166, 215);
         if (m_clipType == TEXT) {
-            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int,QImage)), this, SLOT(slotThumbReady(int,QImage)));
         }
         //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
     } else if (m_clipType == AUDIO) {
@@ -128,15 +128,16 @@ ClipItem::~ClipItem()
     blockSignals(true);
     m_endThumbTimer.stop();
     m_startThumbTimer.stop();
-    if (scene()) scene()->removeItem(this);
+    if (scene())
+        scene()->removeItem(this);
     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
-        //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+        //disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int,QImage)), this, SLOT(slotThumbReady(int,QImage)));
         //disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
     delete m_timeLine;
 }
 
-ClipItem *ClipItem::clone(ItemInfo info) const
+ClipItem *ClipItem::clone(const ItemInfo &info) const
 {
     ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed, m_strobe, FRAME_SIZE);
     if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
@@ -155,12 +156,12 @@ ClipItem *ClipItem::clone(ItemInfo info) const
     return duplicate;
 }
 
-void ClipItem::setEffectList(const EffectsList effectList)
+void ClipItem::setEffectList(const EffectsList &effectList)
 {
     m_effectList.clone(effectList);
     m_effectNames = m_effectList.effectNames().join(" / ");
     if (!m_effectList.isEmpty()) {
-        for (int i = 0; i < m_effectList.count(); i++) {
+        for (int i = 0; i < m_effectList.count(); ++i) {
            QDomElement effect = m_effectList.at(i);
             QString effectId = effect.attribute("id");
             // check if it is a fade effect
@@ -238,7 +239,7 @@ void ClipItem::initEffect(QDomElement effect, int diff, int offset)
 
     // Init parameter value & keyframes if required
     QDomNodeList params = effect.elementsByTagName("parameter");
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
 
         if (e.isNull())
@@ -337,15 +338,15 @@ void ClipItem::initEffect(QDomElement effect, int diff, int offset)
     }
 }
 
-const QString ClipItem::adjustKeyframes(QString keyframes, int offset)
+const QString ClipItem::adjustKeyframes(const QString &keyframes, int offset)
 {
     QStringList result;
     // Simple keyframes
     const QStringList list = keyframes.split(';', QString::SkipEmptyParts);
     foreach(const QString &keyframe, list) {
-       int pos = keyframe.section(':', 0, 0).toInt() - offset;
-       QString newKey = QString::number(pos) + ":" + keyframe.section(':', 1);
-       result.append(newKey);
+        int pos = keyframe.section(':', 0, 0).toInt() - offset;
+        QString newKey = QString::number(pos) + ":" + keyframe.section(':', 1);
+        result.append(newKey);
     }
     return result.join(";");
 }
@@ -426,14 +427,14 @@ bool ClipItem::checkKeyFrames(int width, int height, int previousDuration, int c
     return clipEffectsModified;
 }
 
-void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
+void ClipItem::setKeyframes(const int ix, const QStringList &keyframes)
 {
     QDomElement effect = m_effectList.at(ix);
     if (effect.attribute("disable") == "1") return;
     QLocale locale;
     QDomNodeList params = effect.elementsByTagName("parameter");
     int keyframeParams = 0;
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && (!e.hasAttribute("intimeline") || e.attribute("intimeline") == "1")) {
             e.setAttribute("keyframes", keyframes.at(keyframeParams));
@@ -470,7 +471,7 @@ void ClipItem::setSelectedEffect(const int ix)
     QDomElement effect = effectAtIndex(m_selectedEffect);
     if (!effect.isNull() && effect.attribute("disable") != "1") {
         QDomNodeList params = effect.elementsByTagName("parameter");
-        for (int i = 0; i < params.count(); i++) {
+        for (int i = 0; i < params.count(); ++i) {
             QDomElement e = params.item(i).toElement();
             if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && (!e.hasAttribute("intimeline") || e.attribute("intimeline") == "1")) {
                 m_keyframes.clear();
@@ -510,7 +511,7 @@ void ClipItem::resizeGeometries(const int index, int width, int height, int prev
     QDomElement effect = m_effectList.at(index);
     QDomNodeList params = effect.elementsByTagName("parameter");
 
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull() && e.attribute("type") == "geometry") {
             geom = e.attribute("value");
@@ -526,7 +527,7 @@ QStringList ClipItem::keyframes(const int index)
     QDomElement effect = m_effectList.at(index);
     QDomNodeList params = effect.elementsByTagName("parameter");
 
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe"))
             result.append(e.attribute("keyframes"));
@@ -648,7 +649,7 @@ void ClipItem::slotGetEndThumb()
 }
 
 
-void ClipItem::slotSetStartThumb(QImage img)
+void ClipItem::slotSetStartThumb(const QImage &img)
 {
     if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
         QPixmap pix = QPixmap::fromImage(img);
@@ -659,7 +660,7 @@ void ClipItem::slotSetStartThumb(QImage img)
     }
 }
 
-void ClipItem::slotSetEndThumb(QImage img)
+void ClipItem::slotSetEndThumb(const QImage &img)
 {
     if (!img.isNull() && img.format() == QImage::Format_ARGB32) {
         QPixmap pix = QPixmap::fromImage(img);
@@ -670,7 +671,7 @@ void ClipItem::slotSetEndThumb(QImage img)
     }
 }
 
-void ClipItem::slotThumbReady(int frame, QImage img)
+void ClipItem::slotThumbReady(int frame, const QImage &img)
 {
     if (scene() == NULL) return;
     QRectF r = boundingRect();
@@ -690,12 +691,12 @@ void ClipItem::slotThumbReady(int frame, QImage img)
     }
 }
 
-void ClipItem::slotSetStartThumb(const QPixmap pix)
+void ClipItem::slotSetStartThumb(const QPixmap &pix)
 {
     m_startPix = pix;
 }
 
-void ClipItem::slotSetEndThumb(const QPixmap pix)
+void ClipItem::slotSetEndThumb(const QPixmap &pix)
 {
     m_endPix = pix;
 }
@@ -857,7 +858,7 @@ void ClipItem::paint(QPainter *painter,
             QPointF startPos = mapped.topLeft();
             int startOffset = m_info.cropStart.frames(m_fps);
             if (clipType() == IMAGE || clipType() == TEXT) {
-                for (int i = left; i <= right; i++) {
+                for (int i = left; i <= right; ++i) {
                     painter->drawPixmap(startPos + QPointF(FRAME_SIZE *(i - startOffset), 0), m_startPix);
                 }
             }
@@ -869,7 +870,7 @@ void ClipItem::paint(QPainter *painter,
                     QPen pen(Qt::white);
                     pen.setStyle(Qt::DotLine);
                     QList <int> missing;
-                    for (int i = left; i <= right; i++) {
+                    for (int i = left; i <= right; ++i) {
                         img = m_clip->thumbProducer()->findCachedThumb(path + QString::number(i));
                         QPointF xpos = startPos + QPointF(FRAME_SIZE *(i - startOffset), 0);
                         if (img.isNull()) missing << i;
@@ -931,8 +932,8 @@ void ClipItem::paint(QPainter *painter,
     }
     
     if (m_isMainSelectedClip) {
-       framePen.setColor(Qt::red);
-       textBgColor = Qt::red;
+        framePen.setColor(Qt::red);
+        textBgColor = Qt::red;
     }
 
     // only paint details if clip is big enough
@@ -1057,7 +1058,7 @@ void ClipItem::paint(QPainter *painter,
 }
 
 
-OPERATIONTYPE ClipItem::operationMode(QPointF pos)
+OPERATIONTYPE ClipItem::operationMode(const QPointF &pos)
 {
     if (isItemLocked()) return NONE;
     const double scale = projectScene()->scale().x();
@@ -1081,7 +1082,7 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
        if (parentItem()) {
            QGraphicsItemGroup *dragGroup = static_cast <QGraphicsItemGroup *>(parentItem());
            QList<QGraphicsItem *> list = dragGroup->childItems();
-           for (int i = 0; i < list.count(); i++) {
+           for (int i = 0; i < list.count(); ++i) {
                if (list.at(i)->type() == AVWIDGET) {
                    ClipItem *c = static_cast <ClipItem*>(list.at(i));
                    if (c->startPos() != startPos()) return MOVE;
@@ -1096,7 +1097,7 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos)
        if (parentItem()) {
            QGraphicsItemGroup *dragGroup = static_cast <QGraphicsItemGroup *>(parentItem());
            QList<QGraphicsItem *> list = dragGroup->childItems();
-           for (int i = 0; i < list.count(); i++) {
+           for (int i = 0; i < list.count(); ++i) {
                if (list.at(i)->type() == AVWIDGET) {
                    ClipItem *c = static_cast <ClipItem*>(list.at(i));
                    if (c->endPos() != endPos()) return MOVE;
@@ -1131,7 +1132,7 @@ QList <GenTime> ClipItem::snapMarkers() const
     QList < GenTime > markers = m_clip->snapMarkers();
     GenTime pos;
 
-    for (int i = 0; i < markers.size(); i++) {
+    for (int i = 0; i < markers.size(); ++i) {
         pos = GenTime((int)(markers.at(i).frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
         if (pos > GenTime()) {
             if (pos > cropDuration()) break;
@@ -1148,7 +1149,7 @@ QList <CommentedTime> ClipItem::commentedSnapMarkers() const
     QList < CommentedTime > markers = m_clip->commentedSnapMarkers();
     GenTime pos;
 
-    for (int i = 0; i < markers.size(); i++) {
+    for (int i = 0; i < markers.size(); ++i) {
         pos = GenTime((int)(markers.at(i).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart();
         if (pos > GenTime()) {
             if (pos > cropDuration()) break;
@@ -1194,7 +1195,7 @@ void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, in
         
         QPainter pixpainter(&m_audioThumbCachePic[startCache]);
 
-       for (int i = 0; i < channels; i++) {
+       for (int i = 0; i < channels; ++i) {
            if (simplifiedAudio) {
                positiveChannelPaths[i].moveTo(-1, channelHeight);
            }
@@ -1252,7 +1253,7 @@ void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, in
            pixpainter.setBrush(Qt::NoBrush);
        }
        pixpainter.setRenderHint(QPainter::Antialiasing, false);
-        for (int i = 0; i < channels; i++) {
+        for (int i = 0; i < channels; ++i) {
             if (fullAreaDraw) {
                 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths.value(i)));
             } else
@@ -1419,7 +1420,7 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value)
         bool forwardMove = newPos.x() > pos().x();
         int offset = 0;
         if (!items.isEmpty()) {
-            for (int i = 0; i < items.count(); i++) {
+            for (int i = 0; i < items.count(); ++i) {
                 if (!items.at(i)->isEnabled()) continue;
                 if (items.at(i)->type() == type()) {
                     // Collision!
@@ -1639,7 +1640,7 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool /*animate*/)
         }*/
     }
 
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull()) {
             if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
@@ -1789,7 +1790,7 @@ const ItemInfo ClipItem::speedIndependantInfo() const
 int ClipItem::nextFreeEffectGroupIndex() const
 {
     int freeGroupIndex = 0;
-    for (int i = 0; i < m_effectList.count(); i++) {
+    for (int i = 0; i < m_effectList.count(); ++i) {
         QDomElement effect = m_effectList.at(i);
        EffectInfo effectInfo;
        effectInfo.fromString(effect.attribute("kdenlive_info"));
@@ -1814,7 +1815,7 @@ void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event)
            QDomNodeList effectlist = e.elementsByTagName("effect");
            int freeGroupIndex = nextFreeEffectGroupIndex();
            EffectInfo effectInfo;
-           for (int i = 0; i < effectlist.count(); i++) {
+           for (int i = 0; i < effectlist.count(); ++i) {
                QDomElement effect = effectlist.at(i).toElement();
                effectInfo.fromString(effect.attribute("kdenlive_info"));
                effectInfo.groupIndex = freeGroupIndex;
@@ -1895,7 +1896,7 @@ void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
     effect.setAttribute("active_keyframe", pos);
     m_editedKeyframe = pos;
     QDomNodeList params = effect.elementsByTagName("parameter");
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             QString kfr = e.attribute("keyframes");
@@ -1935,7 +1936,7 @@ void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double
     QDomNodeList params = effect.elementsByTagName("parameter");
     int start = cropStart().frames(m_fps);
     int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
-    for (int i = 0; i < params.count(); i++) {
+    for (int i = 0; i < params.count(); ++i) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             QString kfr = e.attribute("keyframes");
@@ -1995,7 +1996,7 @@ Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
 QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
 {
     QMap<int, QDomElement> effects;
-    for (int i = 0; i < m_effectList.count(); i++) {
+    for (int i = 0; i < m_effectList.count(); ++i) {
         QDomElement effect = m_effectList.at(i);
 
         if (effect.attribute("id").startsWith("fade")) {