]> git.sesse.net Git - kdenlive/commitdiff
some fixes for guides
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 25 Jun 2008 15:17:16 +0000 (15:17 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 25 Jun 2008 15:17:16 +0000 (15:17 +0000)
svn path=/branches/KDE4/; revision=2275

src/customtrackview.cpp
src/customtrackview.h
src/editguidecommand.cpp

index 60af8b521f329c5492f01be64fd9751dd047b5a5..8866ce5be7360eed4fbeb4707deda5cd00087f9b 100644 (file)
@@ -1485,7 +1485,7 @@ void CustomTrackView::addMarker(const int id, const GenTime &pos, const QString
 
 
 void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const QString &comment) {
-    if (oldPos != GenTime() && pos != GenTime()) {
+    if (oldPos > GenTime() && pos > GenTime()) {
         // move guide
         for (int i = 0; i < m_guides.count(); i++) {
             kDebug() << "// LOOKING FOR GUIDE (" << i << "): " << m_guides.at(i)->position().frames(25) << ", LOOK: " << oldPos.frames(25) << "x" << pos.frames(25);
@@ -1496,7 +1496,7 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q
                 break;
             }
         }
-    } else if (pos != GenTime()) addGuide(pos, comment);
+    } else if (pos > GenTime()) addGuide(pos, comment);
     else {
         // remove guide
                bool found = false;
@@ -1512,17 +1512,24 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q
     }
 }
 
-void 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) {
+                       emit displayMessage(i18n("A guide already exists at that position"), ErrorMessage);
+                       return false;
+               }
+    }
     Guide *g = new Guide(this, pos, comment, m_scale, m_document->fps(), m_tracksHeight * m_tracksList.count());
     scene()->addItem(g);
     m_guides.append(g);
+       return true;
 }
 
 void CustomTrackView::slotAddGuide() {
-    addGuide(GenTime(m_cursorPos, m_document->fps()), i18n("guide"));
-    EditGuideCommand *command = new EditGuideCommand(this, GenTime(), QString(), GenTime(m_cursorPos, m_document->fps()), i18n("guide"), false);
-    m_commandStack->push(command);
-
+    if (addGuide(GenTime(m_cursorPos, m_document->fps()), i18n("guide"))) {
+               EditGuideCommand *command = new EditGuideCommand(this, GenTime(), QString(), GenTime(m_cursorPos, m_document->fps()), i18n("guide"), false);
+               m_commandStack->push(command);
+       }
 }
 
 void CustomTrackView::slotDeleteGuide() {
index 8394ca0dc3c0caae7007e1cb2a9193f4b6f13ca0..76352ac6bcc76d9fadd16fe83a3110269776c807 100644 (file)
@@ -102,7 +102,7 @@ public slots:
     void slotSwitchTrackVideo(int ix);
     void slotUpdateClip(int clipId);
     void slotAddClipMarker(int id, GenTime t, QString c);
-    void addGuide(const GenTime pos, const QString &comment);
+    bool addGuide(const GenTime pos, const QString &comment);
     void slotAddGuide();
     void slotDeleteGuide();
     void editGuide(const GenTime oldPos, const GenTime pos, const QString &comment);
index 946d61686dd0122bfb7cc9c9d5707d6fc9a84905..d614d407c0057355579231771383c1ee9fe7a52e 100644 (file)
@@ -22,6 +22,7 @@
 EditGuideCommand::EditGuideCommand(CustomTrackView *view, const GenTime oldPos, const QString &oldcomment, const GenTime pos, const QString &comment, bool doIt) : m_view(view), m_oldPos(oldPos), m_oldcomment(oldcomment), m_pos(pos), m_comment(comment), m_doIt(doIt) {
     if (m_oldcomment.isEmpty()) setText(i18n("Add guide"));
     else if (m_oldPos == m_pos) setText(i18n("Edit guide"));
+       else if (m_pos <= GenTime()) setText(i18n("Delete guide"));
     else setText(i18n("Move guide"));
     kDebug() << "///  CREATE GUIDE COMMAND, TIMES: " << m_oldPos.frames(25) << "x" << m_pos.frames(25);
 }