]> git.sesse.net Git - kdenlive/blobdiff - src/onmonitoritems/onmonitorpathitem.cpp
const'ify. Remove unimplemented function. Fix indent. Optimization
[kdenlive] / src / onmonitoritems / onmonitorpathitem.cpp
index 97e7ac99fcc618a921615c75987e62ff143a2402..c3b79df524fbeb6cd08d452f4b14f56afb573fd7 100644 (file)
@@ -59,7 +59,8 @@ void OnMonitorPathItem::setPoints(Mlt::Geometry *geometry)
     rebuildShape();
 }
 
-void OnMonitorPathItem::rebuildShape() {
+void OnMonitorPathItem::rebuildShape()
+{
     if (m_activePoint > m_points.count()) m_activePoint = -1;
     QPainterPath p;
     QPainterPath shape;
@@ -70,24 +71,25 @@ void OnMonitorPathItem::rebuildShape() {
        shape.addRect(r);
        
        p.moveTo(m_points.at(0));
-       for (int i = 1; i < m_points.count(); i++) {
+       for (int i = 1; i < m_points.count(); ++i) {
            p.lineTo(m_points.at(i));
            r.moveCenter(m_points.at(i));
            shape.addRect(r);
        }
     }
+    prepareGeometryChange();
     m_shape = shape;
     setPath(p);
 }
 
-void OnMonitorPathItem::getMode(QPointF pos)
+void OnMonitorPathItem::getMode(const QPointF &pos)
 {
     double dist  = 8;
     if (getView()) {
         dist /= m_view->matrix().m11();
     }
     // Item mapped coordinates
-    for (int i = 0; i < m_points.count(); i++) {
+    for (int i = 0; i < m_points.count(); ++i) {
        if ((pos - m_points.at(i)).manhattanLength() <= dist) {
            m_activePoint = i;
            return;
@@ -181,7 +183,7 @@ void OnMonitorPathItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
     }
 
     QRectF handle(0, 0, w, h);
-    for (int i = 0; i < m_points.count(); i++) {
+    for (int i = 0; i < m_points.count(); ++i) {
        handle.moveCenter(m_points.at(i));
         painter->fillRect(handle, m_activePoint == i ? Qt::blue : pen().color());
     }
@@ -192,8 +194,8 @@ bool OnMonitorPathItem::getView()
     if (m_view)
         return true;
 
-    if (scene() && scene()->views().count()) {
-        m_view = scene()->views()[0];
+    if (scene() && !scene()->views().isEmpty()) {
+        m_view = scene()->views().first();
         return true;
     } else {
         return false;