diff layer/FlexiNoteLayer.cpp @ 810:b68af2be4545 tonioni

Merge from branch warnfix_no_size_t
author Chris Cannam
date Wed, 18 Jun 2014 13:42:25 +0100
parents 40c6c9344ff6
children a9731b49745a
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp	Mon Jun 16 12:50:27 2014 +0100
+++ b/layer/FlexiNoteLayer.cpp	Wed Jun 18 13:42:25 2014 +0100
@@ -61,14 +61,14 @@
 
     m_model(0),
     m_editing(false),
+    m_intelligentActions(true),
     m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")),
     m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")),
     m_editingCommand(0),
     m_verticalScale(AutoAlignScale),
     m_editMode(DragNote),
     m_scaleMinimum(34), 
-    m_scaleMaximum(77),
-    m_intelligentActions(true)
+    m_scaleMaximum(77)
 {
 }
 
@@ -403,7 +403,7 @@
 {
     if (!m_model) return FlexiNoteModel::PointList();
 
-    long frame = v->getFrameForX(x);
+    int frame = v->getFrameForX(x);
 
     FlexiNoteModel::PointList onPoints =
         m_model->getPoints(frame);
@@ -421,11 +421,11 @@
 
     if (prevPoints.empty()) {
         usePoints = nextPoints;
-    } else if (long(prevPoints.begin()->frame) < v->getStartFrame() &&
+    } else if (prevPoints.begin()->frame < v->getStartFrame() &&
                !(nextPoints.begin()->frame > v->getEndFrame())) {
         usePoints = nextPoints;
-    } else if (long(nextPoints.begin()->frame) - frame <
-               frame - long(prevPoints.begin()->frame)) {
+    } else if (nextPoints.begin()->frame - frame <
+               frame - prevPoints.begin()->frame) {
         usePoints = nextPoints;
     }
 
@@ -446,7 +446,7 @@
 {
     if (!m_model) return false;
 
-    long frame = v->getFrameForX(x);
+    int frame = v->getFrameForX(x);
 
     FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
     if (onPoints.empty()) return false;
@@ -475,7 +475,7 @@
     // GF: find the note that is closest to the cursor
     if (!m_model) return false;
 
-    long frame = v->getFrameForX(x);
+    int frame = v->getFrameForX(x);
 
     FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
     if (onPoints.empty()) return false;
@@ -588,7 +588,7 @@
 
 bool
 FlexiNoteLayer::snapToFeatureFrame(View *v, int &frame,
-                                   size_t &resolution,
+                                   int &resolution,
                                    SnapType snap) const
 {
     if (!m_model) {
@@ -798,8 +798,8 @@
 //    Profiler profiler("FlexiNoteLayer::paint", true);
 
     int x0 = rect.left(), x1 = rect.right();
-    long frame0 = v->getFrameForX(x0);
-    long frame1 = v->getFrameForX(x1);
+    int frame0 = v->getFrameForX(x0);
+    int frame1 = v->getFrameForX(x1);
 
     FlexiNoteModel::PointList points(m_model->getPoints(frame0, frame1));
     if (points.empty()) return;
@@ -820,7 +820,6 @@
     FlexiNoteModel::Point illuminatePoint(0);
     bool shouldIlluminate = false;
 
-
     if (v->shouldIlluminateLocalFeatures(this, localPos)) {
         shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(),
                                           illuminatePoint);
@@ -950,7 +949,7 @@
 
     if (!m_model) return;
 
-    long frame = v->getFrameForX(e->x());
+    int frame = v->getFrameForX(e->x());
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
@@ -974,14 +973,14 @@
 
     if (!m_model || !m_editing) return;
 
-    long frame = v->getFrameForX(e->x());
+    int frame = v->getFrameForX(e->x());
     if (frame < 0) frame = 0;
     frame = frame / m_model->getResolution() * m_model->getResolution();
 
     float newValue = getValueForY(v, e->y());
 
-    long newFrame = m_editingPoint.frame;
-    long newDuration = frame - newFrame;
+    int newFrame = m_editingPoint.frame;
+    int newDuration = frame - newFrame;
     if (newDuration < 0) {
         newFrame = frame;
         newDuration = -newDuration;
@@ -1022,7 +1021,7 @@
 }
 
 void
-FlexiNoteLayer::eraseDrag(View *v, QMouseEvent *e)
+FlexiNoteLayer::eraseDrag(View *, QMouseEvent *)
 {
 }
 
@@ -1073,11 +1072,11 @@
     m_dragStartX = e->x();
     m_dragStartY = e->y();
     
-    long onset = m_originalPoint.frame;
-    long offset = m_originalPoint.frame + m_originalPoint.duration - 1;
+    int onset = m_originalPoint.frame;
+    int offset = m_originalPoint.frame + m_originalPoint.duration - 1;
     
     m_greatestLeftNeighbourFrame = -1;
-    m_smallestRightNeighbourFrame = std::numeric_limits<long>::max();
+    m_smallestRightNeighbourFrame = std::numeric_limits<int>::max();
     
     for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin();
          i != m_model->getPoints().end(); ++i) {
@@ -1110,7 +1109,7 @@
     int newx = m_dragPointX + xdist;
     int newy = m_dragPointY + ydist;
 
-    long dragFrame = v->getFrameForX(newx);
+    int dragFrame = v->getFrameForX(newx);
     if (dragFrame < 0) dragFrame = 0;
     dragFrame = dragFrame / m_model->getResolution() * m_model->getResolution();
     
@@ -1155,6 +1154,8 @@
         m_editingPoint.value = value;
         break;
     }
+    case SplitNote: // nothing
+        break;
     }
     updateNoteValue(v, m_editingPoint);
     m_editingCommand->addPoint(m_editingPoint);
@@ -1163,7 +1164,7 @@
 }
 
 void
-FlexiNoteLayer::editEnd(View *v, QMouseEvent *e)
+FlexiNoteLayer::editEnd(View *, QMouseEvent *e)
 {
 //    SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl;
     std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl;
@@ -1230,7 +1231,7 @@
         return; 
     }
 
-    long frame = v->getFrameForX(e->x());
+    int frame = v->getFrameForX(e->x());
 
     splitNotesAt(v, frame, e);
 }
@@ -1287,15 +1288,15 @@
     std::cerr << "addNote" << std::endl;
     if (!m_model) return;
 
-    long duration = 10000;
+    int duration = 10000;
     
-    long frame = v->getFrameForX(e->x());
+    int frame = v->getFrameForX(e->x());
     float value = getValueForY(v, e->y());
     
     FlexiNoteModel::PointList noteList = m_model->getPoints();
 
     if (m_intelligentActions) {
-        long smallestRightNeighbourFrame = 0;
+        int smallestRightNeighbourFrame = 0;
         for (FlexiNoteModel::PointList::const_iterator i = noteList.begin();
              i != noteList.end(); ++i) {
             FlexiNote currentNote = *i;
@@ -1453,7 +1454,7 @@
     if (pitchValues.empty()) return false;
 
     sort(pitchValues.begin(), pitchValues.end());
-    size_t size = pitchValues.size();
+    int size = pitchValues.size();
     double median;
 
     if (size % 2 == 0) {
@@ -1568,7 +1569,7 @@
 }
 
 void
-FlexiNoteLayer::moveSelection(Selection s, size_t newStartFrame)
+FlexiNoteLayer::moveSelection(Selection s, int newStartFrame)
 {
     if (!m_model) return;
 
@@ -1697,7 +1698,7 @@
 }
 
 bool
-FlexiNoteLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */)
+FlexiNoteLayer::paste(View *v, const Clipboard &from, int /*frameOffset */, bool /* interactive */)
 {
     if (!m_model) return false;
 
@@ -1729,7 +1730,7 @@
          i != points.end(); ++i) {
         
         if (!i->haveFrame()) continue;
-        size_t frame = 0;
+        int frame = 0;
 
         if (!realign) {
             
@@ -1754,7 +1755,7 @@
         if (i->haveLevel()) newPoint.level = i->getLevel();
         if (i->haveDuration()) newPoint.duration = i->getDuration();
         else {
-            size_t nextFrame = frame;
+            int nextFrame = frame;
             Clipboard::PointList::const_iterator j = i;
             for (; j != points.end(); ++j) {
                 if (!j->haveFrame()) continue;
@@ -1778,13 +1779,13 @@
 }
 
 void
-FlexiNoteLayer::addNoteOn(long frame, int pitch, int velocity)
+FlexiNoteLayer::addNoteOn(int frame, int pitch, int velocity)
 {
     m_pendingNoteOns.insert(FlexiNote(frame, pitch, 0, float(velocity) / 127.0, ""));
 }
 
 void
-FlexiNoteLayer::addNoteOff(long frame, int pitch)
+FlexiNoteLayer::addNoteOff(int frame, int pitch)
 {
     for (FlexiNoteSet::iterator i = m_pendingNoteOns.begin();
          i != m_pendingNoteOns.end(); ++i) {
@@ -1833,13 +1834,14 @@
 {
     SingleColourLayer::setProperties(attributes);
 
-    bool ok, alsoOk;
+    bool ok;
     VerticalScale scale = (VerticalScale)
         attributes.value("verticalScale").toInt(&ok);
     if (ok) setVerticalScale(scale);
 
-    float min = attributes.value("scaleMinimum").toFloat(&ok);
-    float max = attributes.value("scaleMaximum").toFloat(&alsoOk);
+//    bool alsoOk;
+//    float min = attributes.value("scaleMinimum").toFloat(&ok);
+//    float max = attributes.value("scaleMaximum").toFloat(&alsoOk);
 //    if (ok && alsoOk && min != max) setDisplayExtents(min, max);
 }