]> git.sesse.net Git - kdenlive/commitdiff
edit and delete markers
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 28 May 2008 21:05:14 +0000 (21:05 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 28 May 2008 21:05:14 +0000 (21:05 +0000)
svn path=/branches/KDE4/; revision=2203

src/clipitem.cpp
src/clipitem.h
src/customtrackview.cpp
src/customtrackview.h
src/docclipbase.cpp
src/kdenliveui.rc
src/mainwindow.cpp
src/mainwindow.h

index 76eb5e0874302c7f069094fd68a8fc7f3d06f250..9cf740992765905d0b2411aa004b715fbb518ed0 100644 (file)
@@ -188,7 +188,6 @@ void ClipItem::paint(QPainter *painter,
                      QWidget *widget) {
     painter->setOpacity(m_opacity);
     QBrush paintColor = brush();
-
     if (isSelected()) paintColor = QBrush(QColor(79, 93, 121));
     QRectF br = rect();
     double scale = br.width() / m_cropDuration.frames(m_fps);
@@ -431,6 +430,22 @@ OPERATIONTYPE ClipItem::operationMode(QPointF pos, double scale) {
     return MOVE;
 }
 
+QList <GenTime> ClipItem::snapMarkers() {
+    QList < GenTime > snaps;
+    QList < GenTime > markers = baseClip()->snapMarkers();
+    GenTime pos;
+    double framepos;
+
+    for (int i = 0; i < markers.size(); i++) {
+        pos = markers.at(i) - cropStart();
+        if (pos > GenTime()) {
+            if (pos > duration()) break;
+            else snaps.append(pos + startPos());
+        }
+    }
+    return snaps;
+}
+
 void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, QPainterPath path, int startpixel, int endpixel) {
     int channels = 2;
 
index 7703bfdf3d400ac2d63eba2e1f62a0d0f496c96f..9bfc054802cc33b0b6de6845ec1fa09fb23ca68b 100644 (file)
@@ -77,6 +77,8 @@ public:
     void resetThumbs();
     /** update clip properties from base clip */
     void refreshClip();
+    /** Returns a list of times for this clip's markers */
+    QList <GenTime> snapMarkers();
 
 protected:
     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
index 3997b9f26758fd410d6f627142447f96793de833..6bbd28060cb8e4eeea94d848063a4e880d66fb31 100644 (file)
@@ -1062,6 +1062,12 @@ void CustomTrackView::updateSnapPoints(AbstractClipItem *selected) {
             GenTime end = item->endPos();
             m_snapPoints.append(start);
             m_snapPoints.append(end);
+            QList < GenTime > markers = item->snapMarkers();
+            for (int i = 0; i < markers.size(); ++i) {
+                GenTime t = markers.at(i);
+                m_snapPoints.append(t);
+                if (t > offset) m_snapPoints.append(t - offset);
+            }
             if (offset != GenTime()) {
                 if (start > offset) m_snapPoints.append(start - offset);
                 if (end > offset) m_snapPoints.append(end - offset);
@@ -1129,6 +1135,46 @@ void CustomTrackView::slotAddClipMarker() {
     m_commandStack->push(command);
 }
 
+void CustomTrackView::slotDeleteClipMarker() {
+    QList<QGraphicsItem *> itemList = scene()->selectedItems();
+    if (itemList.count() != 1) {
+        kDebug() << "// CANNOT DELETE MARKER IF MORE TAN ONE CLIP IS SELECTED....";
+        return;
+    }
+    AbstractClipItem *item = (AbstractClipItem *)itemList.at(0);
+    if (item->type() != AVWIDGET) return;
+    GenTime pos = GenTime(m_cursorPos, m_document->fps());
+    if (item->startPos() > pos || item->endPos() < pos) return;
+    ClipItem *clip = (ClipItem *) item;
+    int id = clip->baseClip()->getId();
+    GenTime position = pos - item->startPos() + item->cropStart();
+    QString comment = clip->baseClip()->markerComment(position);
+    if (comment.isEmpty()) return;
+    AddMarkerCommand *command = new AddMarkerCommand(this, comment, QString(), id, position, true);
+    m_commandStack->push(command);
+}
+
+void CustomTrackView::slotEditClipMarker() {
+    QList<QGraphicsItem *> itemList = scene()->selectedItems();
+    if (itemList.count() != 1) {
+        kDebug() << "// CANNOT DELETE MARKER IF MORE TAN ONE CLIP IS SELECTED....";
+        return;
+    }
+    AbstractClipItem *item = (AbstractClipItem *)itemList.at(0);
+    if (item->type() != AVWIDGET) return;
+    GenTime pos = GenTime(m_cursorPos, m_document->fps());
+    if (item->startPos() > pos || item->endPos() < pos) return;
+    ClipItem *clip = (ClipItem *) item;
+    int id = clip->baseClip()->getId();
+    GenTime position = pos - item->startPos() + item->cropStart();
+    QString oldcomment = clip->baseClip()->markerComment(position);
+    if (oldcomment.isEmpty()) return;
+    QString comment = QInputDialog::getText(this, i18n("Add Marker"), i18n("Enter text for marker on clip <b>%1</b>", clip->clipName()), QLineEdit::Normal, oldcomment);
+    if (comment.isEmpty()) return;
+    AddMarkerCommand *command = new AddMarkerCommand(this, oldcomment, comment, id, position, true);
+    m_commandStack->push(command);
+}
+
 void CustomTrackView::addMarker(const int id, const GenTime &pos, const QString comment) {
     DocClipBase *base = m_document->clipManager()->getClipById(id);
     if (!comment.isEmpty()) base->addSnapMarker(pos, comment);
index 3f7e3bec1c82f7ba80201c0bb4e0d57c5503f922..0ef150224f77f9afeda8a0882948e3e48385a344 100644 (file)
@@ -53,6 +53,8 @@ public:
     void addClip(QDomElement xml, int clipId, ItemInfo info);
     void deleteClip(ItemInfo info);
     void slotAddClipMarker();
+    void slotEditClipMarker();
+    void slotDeleteClipMarker();
     void addMarker(const int id, const GenTime &pos, const QString comment);
     void setScale(double scaleFactor);
     void deleteClip(int clipId);
index d0ac46166d4869e58283856edd1ea52b648c1016..f2d8722791f7cabbf317d39ef9376bbd0ae83588 100644 (file)
@@ -195,8 +195,7 @@ createClip(KdenliveDoc *doc, const QDomElement & element) {
     node.normalize();
     if (element.tagName() != "kdenliveclip") {
         kWarning() <<
-        "DocClipBase::createClip() element has unknown tagName : " <<
-        element.tagName() << endl;
+        "DocClipBase::createClip() element has unknown tagName : " << element.tagName();
         return 0;
     }
 
@@ -221,8 +220,7 @@ createClip(KdenliveDoc *doc, const QDomElement & element) {
         n = n.nextSibling();
     }
     if (clip == 0) {
-        kWarning() << "DocClipBase::createClip() unable to create clip" <<
-        endl;
+        kWarning() << "DocClipBase::createClip() unable to create clip";
     } else {
         // setup DocClipBase specifics of the clip.
         QMap <QString, QString> props;
@@ -282,9 +280,8 @@ void DocClipBase::addSnapMarker(const GenTime & time, QString comment) {
     }
 
     if ((it != m_snapMarkers.end()) && ((*it).time() == time)) {
-        kError() <<
-        "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo"
-        << endl;
+        (*it).setComment(comment);
+        //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo";
     } else {
         CommentedTime t(time, comment);
         m_snapMarkers.insert(it, t);
@@ -301,8 +298,7 @@ void DocClipBase::editSnapMarker(const GenTime & time, QString comment) {
     if (it != m_snapMarkers.end()) {
         (*it).setComment(comment);
     } else {
-        kError() <<
-        "trying to edit Snap Marker that does not already exists"  << endl;
+        kError() << "trying to edit Snap Marker that does not already exists";
     }
 }
 
index 30047475f0420be7808efb50238db913902da0de..302bbc6f42000be95e109c375ad22423f8468f86 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="15">
+<gui name="kdenlive" version="16">
   <ToolBar name="extraToolBar" >
     <text>Extra Toolbar</text>
     <Action name="clear" />
     <Menu name="timeline" ><text>Timeline</text>
       <Action name="cut_timeline_clip" />
       <Action name="delete_timeline_clip" />
-      <Action name="add_clip_marker" />
+      <Menu name="marker_menu" ><text>Markers</text>
+               <Action name="add_clip_marker" />
+               <Action name="edit_clip_marker" />
+               <Action name="delete_clip_marker" />
+      </Menu>
       <Menu name="video_effects_menu" ><text>Add Video Effect</text>
       </Menu>
       <Menu name="audio_effects_menu" ><text>Add Audio Effect</text>
index 78a99d8518950b506357cb22e0cc042bce003595..e629649edcca3e05d0760c1d3514604dd406ddc1 100644 (file)
@@ -218,8 +218,8 @@ MainWindow::MainWindow(QWidget *parent)
 
     action = actionCollection()->action("delete_timeline_clip");
     m_timelineContextClipMenu->addAction(action);
-    action = actionCollection()->action("add_clip_marker");
-    m_timelineContextClipMenu->addAction(action);
+    QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
+    m_timelineContextClipMenu->addMenu(markersMenu);
     m_timelineContextClipMenu->addMenu(videoEffectsMenu);
     m_timelineContextClipMenu->addMenu(audioEffectsMenu);
     m_timelineContextClipMenu->addMenu(customEffectsMenu);
@@ -498,6 +498,14 @@ void MainWindow::setupActions() {
     actionCollection()->addAction("add_clip_marker", addClipMarker);
     connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
 
+    KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
+    actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
+    connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
+
+    KAction* editClipMarker = new KAction(KIcon("edit-delete"), i18n("Edit Marker"), this);
+    actionCollection()->addAction("edit_clip_marker", editClipMarker);
+    connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
+
     KStandardAction::quit(this, SLOT(queryQuit()),
                           actionCollection());
 
@@ -951,6 +959,20 @@ void MainWindow::slotAddClipMarker() {
     }
 }
 
+void MainWindow::slotDeleteClipMarker() {
+    TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
+    if (currentTab) {
+        currentTab->projectView()->slotDeleteClipMarker();
+    }
+}
+
+void MainWindow::slotEditClipMarker() {
+    TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
+    if (currentTab) {
+        currentTab->projectView()->slotEditClipMarker();
+    }
+}
+
 void MainWindow::slotCutTimelineClip() {
     TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
     if (currentTab) {
index ac499b23028348ba1dbf8c948196d5084c8172de..1e0af42f28b0bce6dd68a0c3e7c7d712eee4e1a4 100644 (file)
@@ -171,6 +171,8 @@ private slots:
     void slotRemoveTab();
     void slotDeleteTimelineClip();
     void slotAddClipMarker();
+    void slotDeleteClipMarker();
+    void slotEditClipMarker();
     void slotCutTimelineClip();
     void slotAddVideoEffect(QAction *result);
     void slotAddAudioEffect(QAction *result);