comparison layer/FlexiNoteLayer.cpp @ 1414:fa986b91d77f

Merge from branch fix-static-analysis
author Chris Cannam
date Wed, 09 Jan 2019 15:24:51 +0000
parents c8a6fd3f9dff
children 62e908518c71
comparison
equal deleted inserted replaced
1413:0930a27ebea2 1414:fa986b91d77f
60 // m_editingCommand(0), 60 // m_editingCommand(0),
61 // m_verticalScale(AutoAlignScale), 61 // m_verticalScale(AutoAlignScale),
62 // m_scaleMinimum(0), 62 // m_scaleMinimum(0),
63 // m_scaleMaximum(0) 63 // m_scaleMaximum(0)
64 64
65 m_model(0), 65 m_model(nullptr),
66 m_editing(false), 66 m_editing(false),
67 m_intelligentActions(true), 67 m_intelligentActions(true),
68 m_dragPointX(0), 68 m_dragPointX(0),
69 m_dragPointY(0), 69 m_dragPointY(0),
70 m_dragStartX(0), 70 m_dragStartX(0),
71 m_dragStartY(0), 71 m_dragStartY(0),
72 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), 72 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")),
73 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), 73 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")),
74 m_greatestLeftNeighbourFrame(0), 74 m_greatestLeftNeighbourFrame(0),
75 m_smallestRightNeighbourFrame(0), 75 m_smallestRightNeighbourFrame(0),
76 m_editingCommand(0), 76 m_editingCommand(nullptr),
77 m_verticalScale(AutoAlignScale), 77 m_verticalScale(AutoAlignScale),
78 m_editMode(DragNote), 78 m_editMode(DragNote),
79 m_scaleMinimum(34), 79 m_scaleMinimum(34),
80 m_scaleMaximum(77) 80 m_scaleMaximum(77)
81 { 81 {
385 } 385 }
386 386
387 RangeMapper * 387 RangeMapper *
388 FlexiNoteLayer::getNewVerticalZoomRangeMapper() const 388 FlexiNoteLayer::getNewVerticalZoomRangeMapper() const
389 { 389 {
390 if (!m_model) return 0; 390 if (!m_model) return nullptr;
391 391
392 RangeMapper *mapper; 392 RangeMapper *mapper;
393 393
394 double min, max; 394 double min, max;
395 bool logarithmic; 395 bool logarithmic;
396 QString unit; 396 QString unit;
397 getValueExtents(min, max, logarithmic, unit); 397 getValueExtents(min, max, logarithmic, unit);
398 398
399 if (min == max) return 0; 399 if (min == max) return nullptr;
400 400
401 if (logarithmic) { 401 if (logarithmic) {
402 mapper = new LogRangeMapper(0, 100, min, max, unit); 402 mapper = new LogRangeMapper(0, 100, min, max, unit);
403 } else { 403 } else {
404 mapper = new LinearRangeMapper(0, 100, min, max, unit); 404 mapper = new LinearRangeMapper(0, 100, min, max, unit);
1015 FlexiNoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) 1015 FlexiNoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *)
1016 { 1016 {
1017 // SVDEBUG << "FlexiNoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; 1017 // SVDEBUG << "FlexiNoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl;
1018 if (!m_model || !m_editing) return; 1018 if (!m_model || !m_editing) return;
1019 finish(m_editingCommand); 1019 finish(m_editingCommand);
1020 m_editingCommand = 0; 1020 m_editingCommand = nullptr;
1021 m_editing = false; 1021 m_editing = false;
1022 } 1022 }
1023 1023
1024 void 1024 void
1025 FlexiNoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) 1025 FlexiNoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e)
1028 1028
1029 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; 1029 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return;
1030 1030
1031 if (m_editingCommand) { 1031 if (m_editingCommand) {
1032 finish(m_editingCommand); 1032 finish(m_editingCommand);
1033 m_editingCommand = 0; 1033 m_editingCommand = nullptr;
1034 } 1034 }
1035 1035
1036 m_editing = true; 1036 m_editing = true;
1037 } 1037 }
1038 1038
1055 m_editingCommand = new FlexiNoteModel::EditCommand(m_model, tr("Erase Point")); 1055 m_editingCommand = new FlexiNoteModel::EditCommand(m_model, tr("Erase Point"));
1056 1056
1057 m_editingCommand->deletePoint(m_editingPoint); 1057 m_editingCommand->deletePoint(m_editingPoint);
1058 1058
1059 finish(m_editingCommand); 1059 finish(m_editingCommand);
1060 m_editingCommand = 0; 1060 m_editingCommand = nullptr;
1061 m_editing = false; 1061 m_editing = false;
1062 } 1062 }
1063 1063
1064 void 1064 void
1065 FlexiNoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) 1065 FlexiNoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e)
1079 } 1079 }
1080 m_dragPointY = getYForValue(v, m_editingPoint.value); 1080 m_dragPointY = getYForValue(v, m_editingPoint.value);
1081 1081
1082 if (m_editingCommand) { 1082 if (m_editingCommand) {
1083 finish(m_editingCommand); 1083 finish(m_editingCommand);
1084 m_editingCommand = 0; 1084 m_editingCommand = nullptr;
1085 } 1085 }
1086 1086
1087 m_editing = true; 1087 m_editing = true;
1088 m_dragStartX = e->x(); 1088 m_dragStartX = e->x();
1089 m_dragStartY = e->y(); 1089 m_dragStartY = e->y();
1225 1225
1226 m_editingCommand->setName(newName); 1226 m_editingCommand->setName(newName);
1227 finish(m_editingCommand); 1227 finish(m_editingCommand);
1228 } 1228 }
1229 1229
1230 m_editingCommand = 0; 1230 m_editingCommand = nullptr;
1231 m_editing = false; 1231 m_editing = false;
1232 } 1232 }
1233 1233
1234 void 1234 void
1235 FlexiNoteLayer::splitStart(LayerGeometryProvider *v, QMouseEvent *e) 1235 FlexiNoteLayer::splitStart(LayerGeometryProvider *v, QMouseEvent *e)
1244 // m_dragPointX = v->getXForFrame(m_editingPoint.frame); 1244 // m_dragPointX = v->getXForFrame(m_editingPoint.frame);
1245 // m_dragPointY = getYForValue(v, m_editingPoint.value); 1245 // m_dragPointY = getYForValue(v, m_editingPoint.value);
1246 1246
1247 if (m_editingCommand) { 1247 if (m_editingCommand) {
1248 finish(m_editingCommand); 1248 finish(m_editingCommand);
1249 m_editingCommand = 0; 1249 m_editingCommand = nullptr;
1250 } 1250 }
1251 1251
1252 m_editing = true; 1252 m_editing = true;
1253 m_dragStartX = e->x(); 1253 m_dragStartX = e->x();
1254 m_dragStartY = e->y(); 1254 m_dragStartY = e->y();
1274 } 1274 }
1275 1275
1276 void 1276 void
1277 FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame) 1277 FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame)
1278 { 1278 {
1279 splitNotesAt(v, frame, 0); 1279 splitNotesAt(v, frame, nullptr);
1280 } 1280 }
1281 1281
1282 void 1282 void
1283 FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame, QMouseEvent *e) 1283 FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame, QMouseEvent *e)
1284 { 1284 {
1378 return model; 1378 return model;
1379 } 1379 }
1380 } 1380 }
1381 } 1381 }
1382 cerr << "FlexiNoteLayer::getAssociatedPitchModel: failed to find a model" << endl; 1382 cerr << "FlexiNoteLayer::getAssociatedPitchModel: failed to find a model" << endl;
1383 return 0; 1383 return nullptr;
1384 } 1384 }
1385 1385
1386 void 1386 void
1387 FlexiNoteLayer::snapSelectedNotesToPitchTrack(LayerGeometryProvider *v, Selection s) 1387 FlexiNoteLayer::snapSelectedNotesToPitchTrack(LayerGeometryProvider *v, Selection s)
1388 { 1388 {