]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
[PATCH 2/2] Ensure that all member variables have an m_ prefix
[kdenlive] / src / customtrackview.cpp
index 30b0b42ad8f0b440a722a20e629b77e1136f7360..fd3ac7ae0796bc60ab20e1aa6a5ddd01e4801c37 100644 (file)
 
 CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscene, QWidget *parent) :
         QGraphicsView(projectscene, parent),
-        m_scene(projectscene),
+        m_tracksHeight(KdenliveSettings::trackheight()),
+        m_projectDuration(0),
         m_cursorPos(0),
+        m_document(doc),
+        m_scene(projectscene),
         m_cursorLine(NULL),
         m_operationMode(NONE),
+        m_moveOpMode(NONE),
         m_dragItem(NULL),
+        m_dragGuide(NULL),
         m_visualTip(NULL),
-        m_moveOpMode(NONE),
         m_animation(NULL),
-        m_projectDuration(0),
-        m_clickPoint(QPoint()),
-        m_document(doc),
+        m_clickPoint(),
         m_autoScroll(KdenliveSettings::autoscroll()),
-        m_tracksHeight(KdenliveSettings::trackheight()),
-        m_tool(SELECTTOOL),
-        m_dragGuide(NULL),
-        m_findIndex(0),
-        m_menuPosition(QPoint()),
-        m_blockRefresh(false),
-        m_selectionGroup(NULL),
-        m_selectedTrack(0),
-        m_copiedItems(QList<AbstractClipItem *> ()),
-        m_scrollOffset(0),
         m_changeSpeedAction(NULL),
         m_pasteEffectsAction(NULL),
         m_ungroupAction(NULL),
-        m_clipDrag(false)
+        m_scrollOffset(0),
+        m_clipDrag(false),
+        m_findIndex(0),
+        m_tool(SELECTTOOL),
+        m_copiedItems(),
+        m_menuPosition(),
+        m_blockRefresh(false),
+        m_selectionGroup(NULL)
 {
     if (doc) m_commandStack = doc->commandStack();
     else m_commandStack = NULL;
@@ -135,7 +134,8 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
     KIcon spacerIcon("kdenlive-spacer-tool");
     m_spacerCursor = QCursor(spacerIcon.pixmap(22, 22));
     verticalScrollBar()->setTracking(true);
-    connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
+    // Line below was supposed to scroll guides label with scrollbar, not implemented yet
+    //connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
     connect(&m_scrollTimer, SIGNAL(timeout()), this, SLOT(slotCheckMouseScrolling()));
     m_scrollTimer.setInterval(100);
     m_scrollTimer.setSingleShot(true);
@@ -218,13 +218,6 @@ void CustomTrackView::checkTrackHeight()
     update();
 }
 
-// virtual
-void CustomTrackView::resizeEvent(QResizeEvent * event)
-{
-    QGraphicsView::resizeEvent(event);
-}
-
-// virtual
 /** Zoom or move viewport on mousewheel
  *
  * If mousewheel+Ctrl, zooms in/out on the timeline.
@@ -332,15 +325,15 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                 m_dragItem->updateKeyFramePos(keyFramePos, pos);
             }
 
-            if (m_animation) delete m_animation;
+            delete m_animation;
             m_animation = NULL;
-            if (m_visualTip) delete m_visualTip;
+            delete m_visualTip;
             m_visualTip = NULL;
             return;
         } else if (m_operationMode == MOVEGUIDE) {
-            if (m_animation) delete m_animation;
+            delete m_animation;
             m_animation = NULL;
-            if (m_visualTip) delete m_visualTip;
+            delete m_visualTip;
             m_visualTip = NULL;
             QGraphicsView::mouseMoveEvent(event);
             return;
@@ -391,7 +384,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             return;
         } else {
             if (m_visualTip) {
-                if (m_animation) delete m_animation;
+                delete m_animation;
                 m_animation = NULL;
                 m_animationTimer->stop();
                 delete m_visualTip;
@@ -552,7 +545,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
             slotCheckPositionScrolling();
         } else m_moveOpMode = NONE;
         if (m_visualTip) {
-            if (m_animation) delete m_animation;
+            delete m_animation;
             m_animationTimer->stop();
             m_animation = NULL;
             delete m_visualTip;
@@ -1666,6 +1659,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             m_document->renderer()->mltInsertClip(info, item->xml(), item->baseClip()->producer(item->track()));
             item->setSelected(true);
         }
+        m_document->setModified(true);
         m_changeSpeedAction->setEnabled(hasVideoClip);
         m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
         groupSelectedItems(true);
@@ -2287,8 +2281,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                     m_commandStack->push(moveCommand);
                 } else {
                     // undo last move and emit error message
-                    MoveClipCommand *command = new MoveClipCommand(this, info, m_dragItemInfo, true);
-                    m_commandStack->push(command);
+                    bool snap = KdenliveSettings::snaptopoints();
+                    KdenliveSettings::setSnaptopoints(false);
+                    item->setPos((int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItemInfo.track * m_tracksHeight + 1));
+                    KdenliveSettings::setSnaptopoints(snap);
                     emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(m_dragItemInfo.startPos.frames(m_document->fps()))), ErrorMessage);
                 }
                 m_document->setModified(true);
@@ -3483,8 +3479,7 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q
         bool found = false;
         for (int i = 0; i < m_guides.count(); i++) {
             if (m_guides.at(i)->position() == oldPos) {
-                Guide *item = m_guides.takeAt(i);
-                delete item;
+                delete m_guides.takeAt(i);
                 found = true;
                 break;
             }
@@ -3583,14 +3578,10 @@ void CustomTrackView::setScale(double scaleFactor)
     m_scene->setScale(scaleFactor);
     //scale(scaleFactor, 1);
     m_animationTimer->stop();
-    if (m_visualTip) {
-        delete m_visualTip;
-        m_visualTip = NULL;
-    }
-    if (m_animation) {
-        delete m_animation;
-        m_animation = NULL;
-    }
+    delete m_visualTip;
+    m_visualTip = NULL;
+    delete m_animation;
+    m_animation = NULL;
 
     //setSceneRect(0, 0, m_projectDuration + 100 * scaleFactor, sceneRect().height());
     setMatrix(matrix);
@@ -3700,9 +3691,8 @@ void CustomTrackView::clearSearchStrings()
 
 void CustomTrackView::copyClip()
 {
-    while (m_copiedItems.count() > 0) {
-        delete m_copiedItems.takeFirst();
-    }
+    qDeleteAll(m_copiedItems);
+    m_copiedItems.clear();
     QList<QGraphicsItem *> itemList = scene()->selectedItems();
     if (itemList.count() == 0) {
         emit displayMessage(i18n("Select a clip before copying"), ErrorMessage);