]> git.sesse.net Git - kdenlive/commitdiff
Fix group move, should solve:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 9 Dec 2008 22:10:06 +0000 (22:10 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 9 Dec 2008 22:10:06 +0000 (22:10 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=417
http://www.kdenlive.org:80/mantis/view.php?id=421

svn path=/branches/KDE4/; revision=2772

src/customtrackview.cpp
src/customtrackview.h
src/definitions.h

index a9938cb9642b108cda3daab079921433600881be..a24be28629af7cdbb882926be16dbbaabc5c16d7 100644 (file)
@@ -517,6 +517,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) {
     if (event->button() == Qt::MidButton) {
         m_document->renderer()->switchPlay();
         m_blockRefresh = false;
+        m_operationMode = NONE;
         return;
     }
 
@@ -527,6 +528,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) {
         setDragMode(QGraphicsView::ScrollHandDrag);
         QGraphicsView::mousePressEvent(event);
         m_blockRefresh = false;
+        m_operationMode = NONE;
         return;
     }
 
@@ -534,6 +536,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) {
         setDragMode(QGraphicsView::RubberBandDrag);
         QGraphicsView::mousePressEvent(event);
         m_blockRefresh = false;
+        m_operationMode = RUBBERSELECTION;
         return;
     }
 
@@ -645,26 +648,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) {
         resetSelectionGroup();
         if (event->modifiers() != Qt::ControlModifier) m_scene->clearSelection();
         m_dragItem->setSelected(!m_dragItem->isSelected());
-        QList<QGraphicsItem *> selection = m_scene->selectedItems();
-        if (selection.count() > 1) {
-            m_selectionGroup = new AbstractGroupItem(m_document->fps());
-            scene()->addItem(m_selectionGroup);
-            for (int i = 0; i < selection.count(); i++) {
-                if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
-                    m_selectionGroup->addToGroup(selection.at(i));
-                    selection.at(i)->setFlags(QGraphicsItem::ItemIsSelectable);
-                }
-            }
-        }
-        if (m_selectionGroup) {
-            QPointF top = m_selectionGroup->boundingRect().topLeft();
-            const int width = m_selectionGroup->boundingRect().width();
-            const int height = m_selectionGroup->boundingRect().height();
-            m_selectionGroup->setPos(top);
-            m_selectionGroup->translate(-top.x(), -top.y() + 1);
-            m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
-            m_selectionGroupInfo.track = m_selectionGroup->track();
-        }
+        groupSelectedItems();
     }
 
     m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
@@ -750,6 +734,30 @@ void CustomTrackView::resetSelectionGroup() {
     }
 }
 
+void CustomTrackView::groupSelectedItems() {
+    QList<QGraphicsItem *> selection = m_scene->selectedItems();
+    if (selection.count() > 1) {
+        m_selectionGroup = new AbstractGroupItem(m_document->fps());
+        scene()->addItem(m_selectionGroup);
+        for (int i = 0; i < selection.count(); i++) {
+            if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) {
+                m_selectionGroup->addToGroup(selection.at(i));
+                selection.at(i)->setFlags(QGraphicsItem::ItemIsSelectable);
+            }
+        }
+
+        if (m_selectionGroup) {
+            QPointF top = m_selectionGroup->boundingRect().topLeft();
+            const int width = m_selectionGroup->boundingRect().width();
+            const int height = m_selectionGroup->boundingRect().height();
+            m_selectionGroup->setPos(top);
+            m_selectionGroup->translate(-top.x(), -top.y() + 1);
+            m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
+            m_selectionGroupInfo.track = m_selectionGroup->track();
+        }
+    }
+}
+
 void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event) {
     kDebug() << "++++++++++++ DBL CLK";
     if (m_dragItem && m_dragItem->hasKeyFrames()) {
@@ -1583,6 +1591,7 @@ void CustomTrackView::checkScrolling() {
 }
 
 void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
+    kDebug() << "// MOUSE RELEASED, MODE: " << m_moveOpMode;
     if (m_moveOpMode == SEEK) m_moveOpMode = NONE;
     QGraphicsView::mouseReleaseEvent(event);
     if (m_scrollTimer.isActive()) m_scrollTimer.stop();
@@ -1615,6 +1624,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
         m_document->renderer()->mltInsertSpace(GenTime(mappedClick, m_document->fps()), track, GenTime(diff, m_document->fps()));
         resetSelectionGroup();
         m_operationMode = NONE;
+    } else if (m_operationMode == RUBBERSELECTION) {
+        resetSelectionGroup();
+        groupSelectedItems();
+        m_operationMode = NONE;
     }
 
     if (m_dragItem == NULL && m_selectionGroup == NULL) {
index c56cf2acbafaf0082da22947b1d893e8cf1f26aa..9c6a91ec8e715d76f78c500fb5af6bf5e105639c 100644 (file)
@@ -213,6 +213,7 @@ private:
     ClipItem *getMainActiveClip() const;
     bool insertPossible(AbstractGroupItem *group, const QPoint &pos) const;
     void resetSelectionGroup();
+    void groupSelectedItems();
 
 private slots:
     void slotRefreshGuides();
index b99863f40805e2a076e8a827caaf5150a478b1b7..56cfc369970ce38881574783127fe6ccd3f79dd5 100644 (file)
@@ -28,7 +28,7 @@
 const int FRAME_SIZE = 90;
 const int MAXCLIPDURATION = 15000;
 
-enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11};
+enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11, RUBBERSELECTION = 12};
 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9, FOLDER = 10};
 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET  , GROUPWIDGET};