]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
Move undo commands to their own subdirectory
[kdenlive] / src / customtrackview.cpp
index 7faf8a2a8bdbfe4e5b4aee56cb1123daf2d01f1e..35b11c21c9910934a8899d04f904da7d742f2ee8 100644 (file)
 #include "docclipbase.h"
 #include "clipitem.h"
 #include "definitions.h"
-#include "moveclipcommand.h"
-#include "movetransitioncommand.h"
-#include "resizeclipcommand.h"
-#include "editguidecommand.h"
-#include "addtimelineclipcommand.h"
-#include "addeffectcommand.h"
-#include "editeffectcommand.h"
-#include "moveeffectcommand.h"
-#include "addtransitioncommand.h"
-#include "edittransitioncommand.h"
-#include "editkeyframecommand.h"
-#include "changespeedcommand.h"
-#include "addmarkercommand.h"
-#include "razorclipcommand.h"
+#include "commands/moveclipcommand.h"
+#include "commands/movetransitioncommand.h"
+#include "commands/resizeclipcommand.h"
+#include "commands/editguidecommand.h"
+#include "commands/addtimelineclipcommand.h"
+#include "commands/addeffectcommand.h"
+#include "commands/editeffectcommand.h"
+#include "commands/moveeffectcommand.h"
+#include "commands/addtransitioncommand.h"
+#include "commands/edittransitioncommand.h"
+#include "commands/editkeyframecommand.h"
+#include "commands/changespeedcommand.h"
+#include "commands/addmarkercommand.h"
+#include "commands/razorclipcommand.h"
 #include "kdenlivesettings.h"
 #include "transition.h"
 #include "clipmanager.h"
 #include "ui_keyframedialog_ui.h"
 #include "clipdurationdialog.h"
 #include "abstractgroupitem.h"
-#include "insertspacecommand.h"
+#include "commands/insertspacecommand.h"
 #include "spacerdialog.h"
-#include "addtrackcommand.h"
-#include "movegroupcommand.h"
+#include "commands/addtrackcommand.h"
+#include "commands/movegroupcommand.h"
 #include "ui_addtrack_ui.h"
 #include "initeffects.h"
-#include "locktrackcommand.h"
-#include "groupclipscommand.h"
-#include "splitaudiocommand.h"
-#include "changecliptypecommand.h"
+#include "commands/locktrackcommand.h"
+#include "commands/groupclipscommand.h"
+#include "commands/splitaudiocommand.h"
+#include "commands/changecliptypecommand.h"
 #include "trackdialog.h"
 #include "tracksconfigdialog.h"
-#include "configtrackscommand.h"
-#include "rebuildgroupcommand.h"
-#include "razorgroupcommand.h"
+#include "commands/configtrackscommand.h"
+#include "commands/rebuildgroupcommand.h"
+#include "commands/razorgroupcommand.h"
 #include "profilesdialog.h"
 
 #include <KDebug>
@@ -262,14 +262,35 @@ void CustomTrackView::checkAutoScroll()
     return m_scene->m_tracksList;
 }*/
 
-void CustomTrackView::checkTrackHeight()
+
+int CustomTrackView::getFrameWidth()
 {
-    if (m_tracksHeight == KdenliveSettings::trackheight()) return;
+    return (int) (m_tracksHeight * m_document->mltProfile().display_aspect_num / m_document->mltProfile().display_aspect_den + 0.5);
+}
+
+void CustomTrackView::updateSceneFrameWidth()
+{
+    int frameWidth = getFrameWidth();
+    QList<QGraphicsItem *> itemList = items();
+    ClipItem *item;
+    for (int i = 0; i < itemList.count(); i++) {
+        if (itemList.at(i)->type() == AVWIDGET) {
+            item = (ClipItem*) itemList.at(i);
+            item->resetFrameWidth(frameWidth);
+            item->resetThumbs(true);
+        }
+    }
+}
+
+bool CustomTrackView::checkTrackHeight()
+{
+    if (m_tracksHeight == KdenliveSettings::trackheight()) return false;
     m_tracksHeight = KdenliveSettings::trackheight();
     emit trackHeightChanged();
     QList<QGraphicsItem *> itemList = items();
     ClipItem *item;
     Transition *transitionitem;
+    int frameWidth = getFrameWidth();
     bool snap = KdenliveSettings::snaptopoints();
     KdenliveSettings::setSnaptopoints(false);
     for (int i = 0; i < itemList.count(); i++) {
@@ -277,6 +298,7 @@ void CustomTrackView::checkTrackHeight()
             item = (ClipItem*) itemList.at(i);
             item->setRect(0, 0, item->rect().width(), m_tracksHeight - 1);
             item->setPos((qreal) item->startPos().frames(m_document->fps()), (qreal) item->track() * m_tracksHeight + 1);
+            item->resetFrameWidth(frameWidth);
             item->resetThumbs(true);
         } else if (itemList.at(i)->type() == TRANSITIONWIDGET) {
             transitionitem = (Transition*) itemList.at(i);
@@ -297,6 +319,7 @@ void CustomTrackView::checkTrackHeight()
 //     verticalScrollBar()->setMaximum(m_tracksHeight * m_document->tracksCount());
     KdenliveSettings::setSnaptopoints(snap);
     viewport()->update();
+    return true;
 }
 
 /** Zoom or move viewport on mousewheel
@@ -584,7 +607,14 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             event->accept();
             return;
         }
-        opMode = clip->operationMode(mapToScene(event->pos()));
+
+        if (m_selectionGroup && clip->parentItem() == m_selectionGroup) {
+            // all other modes break the selection, so the user probably wants to move it
+            opMode = MOVE;
+        } else {
+            opMode = clip->operationMode(mapToScene(event->pos()));
+        }
+
         const double size = 5;
         if (opMode == m_moveOpMode) {
             QGraphicsView::mouseMoveEvent(event);
@@ -701,7 +731,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
 
     m_blockRefresh = true;
     m_dragGuide = NULL;
-    bool collision = false;
 
     if (m_tool != RAZORTOOL) activateMonitor();
     else if (m_document->renderer()->playSpeed() != 0.0) {
@@ -712,7 +741,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
 
     // check item under mouse
     QList<QGraphicsItem *> collisionList = items(m_clickEvent);
-
     if (event->modifiers() == Qt::ControlModifier && m_tool != SPACERTOOL && collisionList.count() == 0) {
         // Pressing Ctrl + left mouse button in an empty area scrolls the timeline
         setDragMode(QGraphicsView::ScrollHandDrag);
@@ -729,7 +757,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
             m_dragGuide = (Guide *) collisionList.at(i);
             if (event->button() == Qt::LeftButton) { // move it
                 m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, true);
-                collision = true;
                 m_operationMode = MOVEGUIDE;
                 // deselect all clips so that only the guide will move
                 m_scene->clearSelection();
@@ -900,7 +927,8 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
         } else {
             setCursorPos((int)(mapToScene(event->x(), 0).x()));
         }
-        QGraphicsView::mousePressEvent(event);
+        //QGraphicsView::mousePressEvent(event);
+        event->ignore();
         return;
     }
 
@@ -969,7 +997,12 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
     if (event->modifiers() != Qt::ControlModifier && m_operationMode == NONE) QGraphicsView::mousePressEvent(event);
 
     m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
-    m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
+    if (m_selectionGroup && m_dragItem->parentItem() == m_selectionGroup) {
+        // all other modes break the selection, so the user probably wants to move it
+        m_operationMode = MOVE;
+    } else {
+        m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
+    }
     m_controlModifier = (event->modifiers() == Qt::ControlModifier);
 
     // Update snap points
@@ -1361,7 +1394,7 @@ void CustomTrackView::editItemDuration()
     }
 }
 
-void CustomTrackView::editKeyFrame(const GenTime /*pos*/, const int /*track*/, const int /*index*/, const QString /*keyframes*/)
+void CustomTrackView::editKeyFrame(const GenTime & /*pos*/, const int /*track*/, const int /*index*/, const QString & /*keyframes*/)
 {
     /*ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
     if (clip) {
@@ -1446,7 +1479,7 @@ void CustomTrackView::insertClipCut(DocClipBase *clip, int in, int out)
         splitAudio();
 }
 
-bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
+bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos)
 {
     if (data->hasFormat("kdenlive/clip")) {
         m_clipDrag = true;
@@ -1458,7 +1491,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
             return false;
         }
-        if (clip->producer() == NULL) {
+        if (clip->getProducer() == NULL) {
             emit displayMessage(i18n("Clip not ready"), ErrorMessage);
             return false;
         }
@@ -1481,7 +1514,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             return true;
         }
         m_selectionGroup = new AbstractGroupItem(m_document->fps());
-        ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1);
+        ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth());
         m_selectionGroup->addToGroup(item);
         item->setFlag(QGraphicsItem::ItemIsMovable, false);
 
@@ -1513,7 +1546,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
                 kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
                 return false;
             }
-            if (clip->producer() == NULL) {
+            if (clip->getProducer() == NULL) {
                 emit displayMessage(i18n("Clip not ready"), ErrorMessage);
                 return false;
             }
@@ -1539,7 +1572,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             info.track = 0;
             start += info.cropDuration;
             offsetList.append(start);
-            ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, false);
+            ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth(), false);
             item->setFlag(QGraphicsItem::ItemIsMovable, false);
             m_selectionGroup->addToGroup(item);
             if (!clip->isPlaceHolder()) m_waitingThumbs.append(item);
@@ -1591,7 +1624,7 @@ void CustomTrackView::slotRefreshEffects(ClipItem *clip)
 {
     int track = m_document->tracksCount() - clip->track();
     GenTime pos = clip->startPos();
-    if (!m_document->renderer()->mltRemoveEffect(track, pos, "-1", false, false)) {
+    if (!m_document->renderer()->mltRemoveEffect(track, pos, -1, false, false)) {
         emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
         return;
     }
@@ -1607,6 +1640,11 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
 {
     if (pos < GenTime()) {
         // Add track effect
+        if (effect.attribute("id") == "speed") {
+            // TODO: uncomment after 0.8.2 release
+            // emit displayMessage(i18n("Cannot add speed effect to track"));
+            return;
+        }
         clearSelection();
         m_document->addTrackEffect(track - 1, effect);
         m_document->renderer()->mltAddTrackEffect(track, getEffectArgs(effect));
@@ -1622,7 +1660,8 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
                 emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
                 return;
             }
-            double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+            QLocale locale;
+            double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
             int strobe = EffectsList::parameter(effect, "strobe").toInt();
             if (strobe == 0) strobe = 1;
             doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, 1.0, strobe, clip->baseClip()->getId());
@@ -1643,7 +1682,7 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect)
     QString index = effect.attribute("kdenlive_ix");
     if (pos < GenTime()) {
         // Delete track effect
-        if (m_document->renderer()->mltRemoveTrackEffect(track, index, true)) {
+        if (m_document->renderer()->mltRemoveTrackEffect(track, index.toInt(), true)) {
            m_document->removeTrackEffect(track - 1, effect);
        }
        else emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
@@ -1658,11 +1697,11 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect)
             doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
             clip->deleteEffect(index);
             emit clipItemSelected(clip);
-            m_document->renderer()->mltRemoveEffect(track, pos, index, true);
+            m_document->renderer()->mltRemoveEffect(track, pos, index.toInt(), true);
             return;
         }
     }
-    if (!m_document->renderer()->mltRemoveEffect(track, pos, index, true)) {
+    if (!m_document->renderer()->mltRemoveEffect(track, pos, index.toInt(), true)) {
         kDebug() << "// ERROR REMOV EFFECT: " << index << ", DISABLE: " << effect.attribute("disable");
         emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
         return;
@@ -1679,8 +1718,8 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem *
     QList<QGraphicsItem *> itemList = group->childItems();
     QUndoCommand *effectCommand = new QUndoCommand();
     QString effectName;
-    QDomNode namenode = effect.elementsByTagName("name").item(0);
-    if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+    QDomElement namenode = effect.firstChildElement("name");
+    if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
     else effectName = i18n("effect");
     effectCommand->setText(i18n("Add %1", effectName));
     int count = 0;
@@ -1704,13 +1743,6 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem *
             }
             item->initEffect(effect);
 
-            // Old LADSPA filter, deprecated
-            /*
-            if (effect.attribute("tag") == "ladspa") {
-                QString ladpsaFile = m_document->getLadspaFile();
-                initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-                effect.setAttribute("src", ladpsaFile);
-            }*/
             new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
             count++;
         }
@@ -1726,8 +1758,8 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track)
     QList<QGraphicsItem *> itemList;
     QUndoCommand *effectCommand = new QUndoCommand();
     QString effectName;
-    QDomNode namenode = effect.elementsByTagName("name").item(0);
-    if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+    QDomElement namenode = effect.firstChildElement("name");
+    if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
     else effectName = i18n("effect");
     effectCommand->setText(i18n("Add %1", effectName));
 
@@ -1783,13 +1815,6 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track)
             } else {
                 item->initEffect(effect);
             }
-            // Old LADSPA filter, deprecated
-            /* if (effect.attribute("tag") == "ladspa") {
-                QString ladpsaFile = m_document->getLadspaFile();
-                initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-                effect.setAttribute("src", ladpsaFile);
-            }
-            */
             new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
         }
     }
@@ -1828,8 +1853,8 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef
         QList<QGraphicsItem *> items = m_selectionGroup->childItems();
         QUndoCommand *delCommand = new QUndoCommand();
         QString effectName;
-        QDomNode namenode = effect.elementsByTagName("name").item(0);
-        if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+        QDomElement namenode = effect.firstChildElement("name");
+        if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
         else effectName = i18n("effect");
         delCommand->setText(i18n("Delete %1", effectName));
 
@@ -1876,11 +1901,6 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
     if (pos < GenTime()) {
         // editing a track effect
         EffectsParameterList effectParams = getEffectArgs(effect);
-        // Old LADSPA filter, deprecated
-        /*if (effect.attribute("tag") == "ladspa") {
-            // Update the ladspa affect file
-            initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-        }*/
         // check if we are trying to reset a keyframe effect
         /*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
             clip->initEffect(effect);
@@ -1901,7 +1921,8 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
             if (effect.attribute("disable") == "1") {
                 doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
             } else {
-                double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+                QLocale locale;
+                double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
                 int strobe = EffectsList::parameter(effect, "strobe").toInt();
                 if (strobe == 0) strobe = 1;
                 doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
@@ -1916,11 +1937,6 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
         }
 
         EffectsParameterList effectParams = getEffectArgs(effect);
-        // Old LADSPA filter, deprecated
-        /*if (effect.attribute("tag") == "ladspa") {
-            // Update the ladspa affect file
-            initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-        }*/
         // check if we are trying to reset a keyframe effect
         if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
             clip->initEffect(effect);
@@ -2404,7 +2420,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             ItemInfo clipInfo = info;
             clipInfo.track = m_document->tracksCount() - item->track();
 
-            int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+            int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->getProducer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
             if (worked == -1) {
                 emit displayMessage(i18n("Cannot insert clip in timeline"), ErrorMessage);
                 brokenClips.append(item);
@@ -2647,6 +2663,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix)
         m_selectionGroup->translate(0, m_tracksHeight);
 
         // adjust track number
+        Mlt::Tractor *tractor = m_document->renderer()->lockService();
         QList<QGraphicsItem *> children = m_selectionGroup->childItems();
         for (int i = 0; i < children.count(); i++) {
             if (children.at(i)->type() == GROUPWIDGET) {
@@ -2664,7 +2681,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix)
                 // We add a move clip command so that we get the correct producer for new track number
                 if (clip->clipType() == AV || clip->clipType() == AUDIO) {
                     Mlt::Producer *prod = clip->getProducer(clipinfo.track);
-                    if (m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod) == false) {
+                    if (m_document->renderer()->mltUpdateClipProducer(tractor, (int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod) == false) {
                         // problem updating clip
                         emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
                     }
@@ -2678,6 +2695,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix)
             }
         }
         resetSelectionGroup(false);
+        m_document->renderer()->unlockService(tractor);
     }
 
     int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
@@ -2719,6 +2737,7 @@ void CustomTrackView::removeTrack(int ix)
     // Move graphic items
     qreal ydiff = 0 - (int) m_tracksHeight;
     m_selectionGroup->translate(0, ydiff);
+    Mlt::Tractor *tractor = m_document->renderer()->lockService();
 
     // adjust track number
     QList<QGraphicsItem *> children = m_selectionGroup->childItems();
@@ -2736,7 +2755,7 @@ void CustomTrackView::removeTrack(int ix)
             // We add a move clip command so that we get the correct producer for new track number
             if (clip->clipType() == AV || clip->clipType() == AUDIO || clip->clipType() == PLAYLIST) {
                 Mlt::Producer *prod = clip->getProducer(clipinfo.track);
-                if (prod == NULL || !m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) {
+                if (prod == NULL || !m_document->renderer()->mltUpdateClipProducer(tractor, (int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
                 }
             }
@@ -2751,6 +2770,7 @@ void CustomTrackView::removeTrack(int ix)
         }
     }
     resetSelectionGroup(false);
+    m_document->renderer()->unlockService(tractor);
 
     int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
     for (int i = 0; i < m_guides.count(); i++) {
@@ -2903,9 +2923,16 @@ void CustomTrackView::slotRemoveSpace()
     int track = 0;
     if (m_menuPosition.isNull()) {
         pos = GenTime(cursorPos(), m_document->fps());
-        bool ok;
-        track = QInputDialog::getInteger(this, i18n("Remove Space"), i18n("Track"), 0, 0, m_document->tracksCount() - 1, 1, &ok);
-        if (!ok) return;
+
+        TrackDialog d(m_document, parentWidget());
+        d.comboTracks->setCurrentIndex(m_selectedTrack);
+        d.label->setText(i18n("Track"));
+        d.before_select->setHidden(true);
+        d.setWindowTitle(i18n("Remove Space"));
+        d.video_track->setHidden(true);
+        d.audio_track->setHidden(true);
+        if (d.exec() != QDialog::Accepted) return;
+        track = d.comboTracks->currentIndex();
     } else {
         pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
         track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight);
@@ -2922,7 +2949,6 @@ void CustomTrackView::slotRemoveSpace()
         return;
     }
     int length = m_document->renderer()->mltGetSpaceLength(pos, m_document->tracksCount() - track, true);
-    //kDebug() << "// GOT LENGT; " << length;
     if (length <= 0) {
         emit displayMessage(i18n("You must be in an empty space to remove space (time: %1, track: %2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage);
         return;
@@ -2954,6 +2980,38 @@ void CustomTrackView::slotRemoveSpace()
         }
     }
 
+    if (!transitionsToMove.isEmpty()) {
+        // Make sure that by moving the items, we don't get a transition collision
+        // Find first transition
+        ItemInfo info = transitionsToMove.at(0);
+        for (int i = 1; i < transitionsToMove.count(); i++)
+            if (transitionsToMove.at(i).startPos < info.startPos) info = transitionsToMove.at(i);
+
+        // make sure there are no transitions on the way
+        QRectF rect(info.startPos.frames(m_document->fps()) - length, track * m_tracksHeight + m_tracksHeight / 2, length - 1, m_tracksHeight / 2 - 2);
+        items = scene()->items(rect);
+        int transitionCorrection = -1;
+        for (int i = 0; i < items.count(); i++) {
+            if (items.at(i)->type() == TRANSITIONWIDGET) {
+                // There is a transition on the way
+                AbstractClipItem *item = static_cast <AbstractClipItem *>(items.at(i));
+                int transitionEnd = item->endPos().frames(m_document->fps());
+                if (transitionEnd > transitionCorrection) transitionCorrection = transitionEnd;
+            }
+        }
+
+        if (transitionCorrection > 0) {
+            // We need to fix the move length
+            length = info.startPos.frames(m_document->fps()) - transitionCorrection;
+        }
+            
+        // Make sure we don't send transition before 0
+        if (info.startPos.frames(m_document->fps()) < length) {
+            // reduce length to maximum possible
+            length = info.startPos.frames(m_document->fps());
+        }           
+    }
+
     InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, GenTime(-length, m_document->fps()), true);
     updateTrackDuration(track, command);
     m_commandStack->push(command);
@@ -3019,7 +3077,7 @@ void CustomTrackView::slotInsertSpace()
     }
 }
 
-void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime duration, const GenTime offset)
+void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime &duration, const GenTime &offset)
 {
     int diff = duration.frames(m_document->fps());
     resetSelectionGroup();
@@ -3769,7 +3827,6 @@ void CustomTrackView::deleteSelectedClips()
     scene()->clearSelection();
     QUndoCommand *deleteSelected = new QUndoCommand();
 
-    bool resetGroup = false;
     int groupCount = 0;
     int clipCount = 0;
     int transitionCount = 0;
@@ -3780,7 +3837,6 @@ void CustomTrackView::deleteSelectedClips()
             QList<QGraphicsItem *> children = itemList.at(i)->childItems();
             QList <ItemInfo> clipInfos;
             QList <ItemInfo> transitionInfos;
-            GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
             for (int j = 0; j < children.count(); j++) {
                 if (children.at(j)->type() == AVWIDGET) {
                     AbstractClipItem *clip = static_cast <AbstractClipItem *>(children.at(j));
@@ -3806,7 +3862,6 @@ void CustomTrackView::deleteSelectedClips()
         if (itemList.at(i)->type() == AVWIDGET) {
             clipCount++;
             ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
-            if (item->parentItem()) resetGroup = true;
             //kDebug()<<"// DELETE CLP AT: "<<item->info().startPos.frames(25);
             new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteSelected);
             emit clipItemSelected(NULL);
@@ -3814,7 +3869,6 @@ void CustomTrackView::deleteSelectedClips()
             transitionCount++;
             Transition *item = static_cast <Transition *>(itemList.at(i));
             //kDebug()<<"// DELETE TRANS AT: "<<item->info().startPos.frames(25);
-            if (item->parentItem()) resetGroup = true;
             new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, true, deleteSelected);
             emit transitionItemSelected(NULL);
         }
@@ -3832,6 +3886,7 @@ void CustomTrackView::deleteSelectedClips()
 
 void CustomTrackView::changeClipSpeed()
 {
+  // TODO: remove after string freeze
     QList<QGraphicsItem *> itemList = scene()->selectedItems();
     if (itemList.count() == 0) {
         emit displayMessage(i18n("Select clip to change speed"), ErrorMessage);
@@ -3845,7 +3900,6 @@ void CustomTrackView::changeClipSpeed()
     for (int i = 0; i < itemList.count(); i++) {
         if (itemList.at(i)->type() == AVWIDGET) {
             ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
-            ItemInfo info = item->info();
             if (percent == -1) percent = QInputDialog::getInteger(this, i18n("Edit Clip Speed"), i18n("New speed (percents)"), item->speed() * 100, 1, 10000, 1, &ok);
             if (!ok) break;
             double speed = (double) percent / 100.0;
@@ -3995,7 +4049,6 @@ void CustomTrackView::groupClips(bool group)
     QList<QGraphicsItem *> itemList = scene()->selectedItems();
     QList <ItemInfo> clipInfos;
     QList <ItemInfo> transitionInfos;
-    GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
 
     // Expand groups
     int max = itemList.count();
@@ -4074,18 +4127,18 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
         return;
     }
 
-    if (baseclip->producer() == NULL) {
+    if (baseclip->getProducer() == NULL) {
         // If the clip has no producer, we must wait until it is created...
         m_mutex.lock();
         emit displayMessage(i18n("Waiting for clip..."), InformationMessage);
         emit forceClipProcessing(clipId);
         qApp->processEvents();
         for (int i = 0; i < 3; i++) {
-            if (baseclip->producer() == NULL) {
+            if (baseclip->getProducer() == NULL) {
                 m_producerNotReady.wait(&m_mutex, 500 + 500 * i);
             } else break;
         }
-        if (baseclip->producer() == NULL) {
+        if (baseclip->getProducer() == NULL) {
             emit displayMessage(i18n("Cannot insert clip..."), ErrorMessage);
             m_mutex.unlock();
             return;
@@ -4094,7 +4147,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
         m_mutex.unlock();
     }
 
-    ClipItem *item = new ClipItem(baseclip, info, m_document->fps(), xml.attribute("speed", "1").toDouble(), xml.attribute("strobe", "1").toInt());
+    ClipItem *item = new ClipItem(baseclip, info, m_document->fps(), xml.attribute("speed", "1").toDouble(), xml.attribute("strobe", "1").toInt(), getFrameWidth());
     item->setEffectList(effects);
     if (xml.hasAttribute("audio_only")) item->setAudioOnly(true);
     else if (xml.hasAttribute("video_only")) item->setVideoOnly(true);
@@ -4122,19 +4175,25 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
 
 void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
 {
+    QMutexLocker locker(&m_mutex);
     QList<QGraphicsItem *> list = scene()->items();
     QList <ClipItem *>clipList;
     ClipItem *clip = NULL;
+    DocClipBase *baseClip = NULL;
+    Mlt::Tractor *tractor = m_document->renderer()->lockService();
     for (int i = 0; i < list.size(); ++i) {
         if (list.at(i)->type() == AVWIDGET) {
             clip = static_cast <ClipItem *>(list.at(i));
             if (clip->clipProducer() == clipId) {
+                if (baseClip == NULL) {
+                    baseClip = clip->baseClip();
+                }
                 ItemInfo info = clip->info();
                 Mlt::Producer *prod = NULL;
-                if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track);
-                else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
-                else prod = clip->baseClip()->producer(info.track);
-                if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), prod)) {
+                if (clip->isAudioOnly()) prod = baseClip->audioProducer(info.track);
+                else if (clip->isVideoOnly()) prod = baseClip->videoProducer();
+                else prod = baseClip->getProducer(info.track);
+                if (reload && !m_document->renderer()->mltUpdateClip(tractor, info, clip->xml(), prod)) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
                 else clipList.append(clip);
@@ -4143,6 +4202,7 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
     }
     for (int i = 0; i < clipList.count(); i++)
         clipList.at(i)->refreshClip(true, true);
+    m_document->renderer()->unlockService(tractor);
 }
 
 ClipItem *CustomTrackView::getClipItemAtEnd(GenTime pos, int track)
@@ -4249,7 +4309,7 @@ Transition *CustomTrackView::getTransitionItemAtStart(GenTime pos, int track)
     return clip;
 }
 
-void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool refresh)
+void CustomTrackView::moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh)
 {
     if (m_selectionGroup) resetSelectionGroup(false);
     ClipItem *item = getClipItemAt((int) start.startPos.frames(m_document->fps()), start.track);
@@ -4292,7 +4352,7 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool re
     if (refresh) m_document->renderer()->doRefresh();
 }
 
-void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
+void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime &offset, const int trackOffset, bool reverseMove)
 {
     // Group Items
     resetSelectionGroup();
@@ -4410,7 +4470,7 @@ void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> sta
     } else kDebug() << "///////// WARNING; NO GROUP TO MOVE";
 }
 
-void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, bool m_refresh)
+void CustomTrackView::moveTransition(const ItemInfo &start, const ItemInfo &end, bool refresh)
 {
     Transition *item = getTransitionItemAt(start.startPos, start.track);
     if (!item) {
@@ -4454,11 +4514,11 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, b
         }
         emit transitionItemSelected(item, getPreviousVideoTrack(item->track()), p);
     }
-    if (m_refresh) m_document->renderer()->doRefresh();
+    if (refresh) m_document->renderer()->doRefresh();
     setDocumentModified();
 }
 
-void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool dontWorry)
+void CustomTrackView::resizeClip(const ItemInfo &start, const ItemInfo &end, bool dontWorry)
 {
     bool resizeClipStart = (start.startPos != end.startPos);
     ClipItem *item = getClipItemAtStart(start.startPos, start.track);
@@ -4962,7 +5022,7 @@ void CustomTrackView::slotDeleteAllClipMarkers(const QString &id)
     m_commandStack->push(deleteMarkers);
 }
 
-void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString comment)
+void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString &comment)
 {
     DocClipBase *base = m_document->clipManager()->getClipById(id);
     if (!comment.isEmpty()) base->addSnapMarker(pos, comment);
@@ -4994,7 +5054,7 @@ void CustomTrackView::buildGuidesMenu(QMenu *goMenu) const
     goMenu->setEnabled(!m_guides.isEmpty());
 }
 
-void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const QString &comment)
+void CustomTrackView::editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment)
 {
     if (oldPos > GenTime() && pos > GenTime()) {
         // move guide
@@ -5022,7 +5082,7 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q
     m_document->syncGuides(m_guides);
 }
 
-bool CustomTrackView::addGuide(const GenTime pos, const QString &comment)
+bool CustomTrackView::addGuide(const GenTime &pos, const QString &comment)
 {
     for (int i = 0; i < m_guides.count(); i++) {
         if (m_guides.at(i)->position() == pos) {
@@ -5812,27 +5872,7 @@ void CustomTrackView::autoTransition()
     setDocumentModified();
 }
 
-
-QStringList CustomTrackView::getLadspaParams(QDomElement effect) const
-{
-    QStringList result;
-    QLocale locale;
-    QDomNodeList params = effect.elementsByTagName("parameter");
-    for (int i = 0; i < params.count(); i++) {
-        QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && e.attribute("type") == "constant") {
-            if (e.hasAttribute("factor")) {
-                double factor = e.attribute("factor").toDouble();
-                double value = e.attribute("value").toDouble();
-                value = value / factor;
-                result.append(locale.toString(value));
-            } else result.append(e.attribute("value"));
-        }
-    }
-    return result;
-}
-
-void CustomTrackView::clipNameChanged(const QString id, const QString name)
+void CustomTrackView::clipNameChanged(const QString &id, const QString &name)
 {
     QList<QGraphicsItem *> list = scene()->items();
     ClipItem *clip = NULL;
@@ -5879,7 +5919,7 @@ void CustomTrackView::getTransitionAvailableSpace(AbstractClipItem *item, GenTim
     }
 }
 
-void CustomTrackView::loadGroups(const QDomNodeList groups)
+void CustomTrackView::loadGroups(const QDomNodeList &groups)
 {
     for (int i = 0; i < groups.count(); i++) {
         QDomNodeList children = groups.at(i).childNodes();
@@ -5917,7 +5957,9 @@ void CustomTrackView::splitAudio()
                 if (clip->parentItem()) {
                     emit displayMessage(i18n("Cannot split audio of grouped clips"), ErrorMessage);
                 } else {
-                    new SplitAudioCommand(this, clip->track(), clip->startPos(), splitCommand);
+                    EffectsList effects;
+                    effects.clone(clip->effectList());
+                    new SplitAudioCommand(this, clip->track(), clip->startPos(), effects, splitCommand);
                 }
             }
         }
@@ -5928,7 +5970,7 @@ void CustomTrackView::splitAudio()
     }
 }
 
-void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
+void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split)
 {
     ClipItem *clip = getClipItemAt(pos, track);
     if (clip == NULL) {
@@ -5964,15 +6006,31 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
             clip->setSelected(true);
             ClipItem *audioClip = getClipItemAt(start, info.track);
             if (audioClip) {
+                Mlt::Tractor *tractor = m_document->renderer()->lockService();
                 clip->setVideoOnly(true);
-                if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
+                if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
                 }
-                if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) {
+                if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, info.track), ErrorMessage);
                 }
+                m_document->renderer()->unlockService(tractor);
                 audioClip->setSelected(true);
                 audioClip->setAudioOnly(true);
+
+                // keep video effects, move audio effects to audio clip
+                int videoIx = 0;
+                int audioIx = 0;
+                for (int i = 0; i < effects.count(); ++i) {
+                    if (effects.at(i).attribute("type") == "audio") {
+                        deleteEffect(m_document->tracksCount() - track, pos, clip->effectAt(videoIx));
+                        audioIx++;
+                    } else {
+                        deleteEffect(freetrack, pos, audioClip->effectAt(audioIx));
+                        videoIx++;
+                    }
+                }
+
                 groupSelectedItems(false, true);
             }
         }
@@ -5994,9 +6052,19 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
                 ItemInfo info = clip->info();
                 deleteClip(clp->info());
                 clip->setVideoOnly(false);
-                if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->producer(info.track))) {
+                Mlt::Tractor *tractor = m_document->renderer()->lockService();
+                if (!m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->getProducer(info.track))) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
+                m_document->renderer()->unlockService(tractor);
+
+                // re-add audio effects
+                for (int i = 0; i < effects.count(); ++i) {
+                    if (effects.at(i).attribute("type") == "audio") {
+                        addEffect(m_document->tracksCount() - track, pos, effects.at(i));
+                    }
+                }
+
                 break;
             }
         }
@@ -6088,28 +6156,30 @@ void CustomTrackView::doChangeClipType(const GenTime &pos, int track, bool video
         kDebug() << "// Cannot find clip to split!!!";
         return;
     }
+    Mlt::Tractor *tractor = m_document->renderer()->lockService();
     if (videoOnly) {
         int start = pos.frames(m_document->fps());
         clip->setVideoOnly(true);
         clip->setAudioOnly(false);
-        if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
+        if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
             emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
         }
     } else if (audioOnly) {
         int start = pos.frames(m_document->fps());
         clip->setAudioOnly(true);
         clip->setVideoOnly(false);
-        if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->audioProducer(track)) == false) {
+        if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->audioProducer(track)) == false) {
             emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
         }
     } else {
         int start = pos.frames(m_document->fps());
         clip->setAudioOnly(false);
         clip->setVideoOnly(false);
-        if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->producer(track)) == false) {
+        if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->getProducer(track)) == false) {
             emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
         }
     }
+    m_document->renderer()->unlockService(tractor);
     clip->update();
     setDocumentModified();
 }
@@ -6528,7 +6598,7 @@ bool CustomTrackView::hasAudio(int track) const
     return false;
 }
 
-void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix)
+void CustomTrackView::slotAddTrackEffect(const QDomElement &effect, int ix)
 {
     AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - ix, GenTime(-1), effect, true);
     m_commandStack->push(command);
@@ -6536,7 +6606,7 @@ void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix)
 }
 
 
-EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
+EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement &effect)
 {
     EffectsParameterList parameters;
     QLocale locale;
@@ -6560,9 +6630,10 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
 
             QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
             double factor = e.attribute("factor", "1").toDouble();
+            double offset = e.attribute("offset", "0").toDouble();
             for (int j = 0; j < values.count(); j++) {
                 QString pos = values.at(j).section(':', 0, 0);
-                double val = values.at(j).section(':', 1, 1).toDouble() / factor;
+                double val = (values.at(j).section(':', 1, 1).toDouble() - offset) / factor;
                 values[j] = pos + "=" + locale.toString(val);
             }
             // kDebug() << "/ / / /SENDING KEYFR:" << values;
@@ -6577,6 +6648,7 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
             parameters.addParam("max", e.attribute("max"));
             parameters.addParam("min", e.attribute("min"));
             parameters.addParam("factor", e.attribute("factor", "1"));
+            parameters.addParam("offset", e.attribute("offset", "0"));
             parameters.addParam("starttag", e.attribute("starttag", "start"));
             parameters.addParam("endtag", e.attribute("endtag", "end"));
         } else if (e.attribute("namedesc").contains(';')) {
@@ -6593,12 +6665,15 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
             }
             parameters.addParam("start", neu);
         } else {
-            if (e.attribute("factor", "1") != "1") {
+            if (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0") {
                 double fact;
                 if (e.attribute("factor").contains('%')) {
                     fact = ProfilesDialog::getStringEval(m_document->mltProfile(), e.attribute("factor"));
-                } else fact = e.attribute("factor", "1").toDouble();
-                parameters.addParam(e.attribute("name"), locale.toString(e.attribute("value").toDouble() / fact));
+                } else {
+                    fact = e.attribute("factor", "1").toDouble();
+                }
+                double offset = e.attribute("offset", "0").toDouble();
+                parameters.addParam(e.attribute("name"), locale.toString((e.attribute("value").toDouble() - offset) / fact));
             } else {
                 parameters.addParam(e.attribute("name"), e.attribute("value"));
             }