]> git.sesse.net Git - kdenlive/commitdiff
Fix editing guide at position 0 deletes it:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 26 Dec 2012 14:48:57 +0000 (15:48 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 26 Dec 2012 14:48:57 +0000 (15:48 +0100)
http://www.kdenlive.org/mantis/view.php?id=2901

src/commands/editguidecommand.cpp
src/customtrackview.cpp

index 20933a3c8e760fe06e0b7b04b4e8cdd7cd765ae5..30398da8e7c32fa7d5a83dcee6798963c4c02243 100644 (file)
@@ -30,9 +30,12 @@ EditGuideCommand::EditGuideCommand(CustomTrackView *view, const GenTime oldPos,
         m_pos(pos),
         m_doIt(doIt)
 {
-    if (m_oldcomment.isEmpty()) setText(i18n("Add guide"));
+    if (m_oldcomment.isEmpty()) {
+       setText(i18n("Add guide"));
+       m_oldPos = GenTime(-1);
+    }
     else if (m_oldPos == m_pos) setText(i18n("Edit guide"));
-    else if (m_pos <= GenTime()) setText(i18n("Delete guide"));
+    else if (m_pos < GenTime() && m_comment.isEmpty()) setText(i18n("Delete guide"));
     else setText(i18n("Move guide"));
 }
 
index d1c81c33ff03becf609dfd75a2b171642417585a..50a617b6ddc78280a7a745bd7974c3751136df46 100644 (file)
@@ -5591,28 +5591,29 @@ void CustomTrackView::buildGuidesMenu(QMenu *goMenu) const
 
 void CustomTrackView::editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment)
 {
-    if (oldPos > GenTime() && pos > GenTime()) {
-        // move guide
+    if (comment.isEmpty() && pos < GenTime()) {
+       // Delete guide
+       bool found = false;
         for (int i = 0; i < m_guides.count(); i++) {
             if (m_guides.at(i)->position() == oldPos) {
-                Guide *item = m_guides.at(i);
-                item->updateGuide(pos, comment);
+                delete m_guides.takeAt(i);
+                found = true;
                 break;
             }
         }
-    } else if (pos > GenTime()) addGuide(pos, comment);
-    else {
-        // remove guide
-        bool found = false;
+        if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
+    }
+    
+    else if (oldPos >= GenTime()) {
+        // move guide
         for (int i = 0; i < m_guides.count(); i++) {
             if (m_guides.at(i)->position() == oldPos) {
-                delete m_guides.takeAt(i);
-                found = true;
+                Guide *item = m_guides.at(i);
+                item->updateGuide(pos, comment);
                 break;
             }
         }
-        if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
-    }
+    } else addGuide(pos, comment);
     qSort(m_guides.begin(), m_guides.end(), sortGuidesList);
     m_document->syncGuides(m_guides);
 }
@@ -5702,7 +5703,7 @@ void CustomTrackView::slotDeleteGuide(int guidePos)
     bool found = false;
     for (int i = 0; i < m_guides.count(); i++) {
         if (m_guides.at(i)->position() == pos) {
-            EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true);
+            EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(-1), QString(), true);
             m_commandStack->push(command);
             found = true;
             break;
@@ -5715,7 +5716,7 @@ void CustomTrackView::slotDeleteGuide(int guidePos)
 void CustomTrackView::slotDeleteTimeLineGuide()
 {
     if (m_dragGuide == NULL) return;
-    EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(), QString(), true);
+    EditGuideCommand *command = new EditGuideCommand(this, m_dragGuide->position(), m_dragGuide->label(), GenTime(-1), QString(), true);
     m_commandStack->push(command);
 }
 
@@ -5725,7 +5726,7 @@ void CustomTrackView::slotDeleteAllGuides()
     QUndoCommand *deleteAll = new QUndoCommand();
     deleteAll->setText("Delete all guides");
     for (int i = 0; i < m_guides.count(); i++) {
-        new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true, deleteAll);
+        new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(-1), QString(), true, deleteAll);
     }
     m_commandStack->push(deleteAll);
 }