comparison layer/TimeValueLayer.cpp @ 376:e1a9e478b7f2

* juggle some files around in order to free audioio, base, and system libraries from dependency on QtGui
author Chris Cannam
date Wed, 12 Mar 2008 17:42:56 +0000
parents 67f82da3d29c
children 1304dbe4542e
comparison
equal deleted inserted replaced
375:daaf1c435d98 376:e1a9e478b7f2
17 17
18 #include "data/model/Model.h" 18 #include "data/model/Model.h"
19 #include "base/RealTime.h" 19 #include "base/RealTime.h"
20 #include "base/Profiler.h" 20 #include "base/Profiler.h"
21 #include "base/LogRange.h" 21 #include "base/LogRange.h"
22 #include "base/ColourDatabase.h" 22 #include "ColourDatabase.h"
23 #include "view/View.h" 23 #include "view/View.h"
24 24
25 #include "data/model/SparseTimeValueModel.h" 25 #include "data/model/SparseTimeValueModel.h"
26 #include "data/model/Labeller.h" 26 #include "data/model/Labeller.h"
27 27
28 #include "widgets/ItemEditDialog.h" 28 #include "widgets/ItemEditDialog.h"
29 #include "widgets/ListInputDialog.h" 29 #include "widgets/ListInputDialog.h"
30 30
31 #include "SpectrogramLayer.h" // for optional frequency alignment 31 #include "SpectrogramLayer.h" // for optional frequency alignment
32 #include "base/ColourMapper.h" 32 #include "ColourMapper.h"
33 33
34 #include <QPainter> 34 #include <QPainter>
35 #include <QPainterPath> 35 #include <QPainterPath>
36 #include <QMouseEvent> 36 #include <QMouseEvent>
37 #include <QRegExp> 37 #include <QRegExp>
873 (frame, value, tr("New Point")); 873 (frame, value, tr("New Point"));
874 } 874 }
875 875
876 m_originalPoint = m_editingPoint; 876 m_originalPoint = m_editingPoint;
877 877
878 if (m_editingCommand) m_editingCommand->finish(); 878 if (m_editingCommand) finish(m_editingCommand);
879 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, 879 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model,
880 tr("Draw Point")); 880 tr("Draw Point"));
881 if (!havePoint) { 881 if (!havePoint) {
882 m_editingCommand->addPoint(m_editingPoint); 882 m_editingCommand->addPoint(m_editingPoint);
883 } 883 }
940 void 940 void
941 TimeValueLayer::drawEnd(View *, QMouseEvent *) 941 TimeValueLayer::drawEnd(View *, QMouseEvent *)
942 { 942 {
943 // std::cerr << "TimeValueLayer::drawEnd(" << e->x() << "," << e->y() << ")" << std::endl; 943 // std::cerr << "TimeValueLayer::drawEnd(" << e->x() << "," << e->y() << ")" << std::endl;
944 if (!m_model || !m_editing) return; 944 if (!m_model || !m_editing) return;
945 m_editingCommand->finish(); 945 finish(m_editingCommand);
946 m_editingCommand = 0; 946 m_editingCommand = 0;
947 m_editing = false; 947 m_editing = false;
948 } 948 }
949 949
950 void 950 void
956 if (points.empty()) return; 956 if (points.empty()) return;
957 957
958 m_editingPoint = *points.begin(); 958 m_editingPoint = *points.begin();
959 959
960 if (m_editingCommand) { 960 if (m_editingCommand) {
961 m_editingCommand->finish(); 961 finish(m_editingCommand);
962 m_editingCommand = 0; 962 m_editingCommand = 0;
963 } 963 }
964 964
965 m_editing = true; 965 m_editing = true;
966 } 966 }
985 m_editingCommand = new SparseTimeValueModel::EditCommand 985 m_editingCommand = new SparseTimeValueModel::EditCommand
986 (m_model, tr("Erase Point")); 986 (m_model, tr("Erase Point"));
987 987
988 m_editingCommand->deletePoint(m_editingPoint); 988 m_editingCommand->deletePoint(m_editingPoint);
989 989
990 m_editingCommand->finish(); 990 finish(m_editingCommand);
991 m_editingCommand = 0; 991 m_editingCommand = 0;
992 m_editing = false; 992 m_editing = false;
993 } 993 }
994 994
995 void 995 void
1004 1004
1005 m_editingPoint = *points.begin(); 1005 m_editingPoint = *points.begin();
1006 m_originalPoint = m_editingPoint; 1006 m_originalPoint = m_editingPoint;
1007 1007
1008 if (m_editingCommand) { 1008 if (m_editingCommand) {
1009 m_editingCommand->finish(); 1009 finish(m_editingCommand);
1010 m_editingCommand = 0; 1010 m_editingCommand = 0;
1011 } 1011 }
1012 1012
1013 m_editing = true; 1013 m_editing = true;
1014 } 1014 }
1056 } else { 1056 } else {
1057 newName = tr("Change Point Value"); 1057 newName = tr("Change Point Value");
1058 } 1058 }
1059 1059
1060 m_editingCommand->setName(newName); 1060 m_editingCommand->setName(newName);
1061 m_editingCommand->finish(); 1061 finish(m_editingCommand);
1062 } 1062 }
1063 1063
1064 m_editingCommand = 0; 1064 m_editingCommand = 0;
1065 m_editing = false; 1065 m_editing = false;
1066 } 1066 }
1095 1095
1096 SparseTimeValueModel::EditCommand *command = 1096 SparseTimeValueModel::EditCommand *command =
1097 new SparseTimeValueModel::EditCommand(m_model, tr("Edit Point")); 1097 new SparseTimeValueModel::EditCommand(m_model, tr("Edit Point"));
1098 command->deletePoint(point); 1098 command->deletePoint(point);
1099 command->addPoint(newPoint); 1099 command->addPoint(newPoint);
1100 command->finish(); 1100 finish(command);
1101 } 1101 }
1102 1102
1103 delete dialog; 1103 delete dialog;
1104 return true; 1104 return true;
1105 } 1105 }
1125 command->deletePoint(*i); 1125 command->deletePoint(*i);
1126 command->addPoint(newPoint); 1126 command->addPoint(newPoint);
1127 } 1127 }
1128 } 1128 }
1129 1129
1130 command->finish(); 1130 finish(command);
1131 } 1131 }
1132 1132
1133 void 1133 void
1134 TimeValueLayer::resizeSelection(Selection s, Selection newSize) 1134 TimeValueLayer::resizeSelection(Selection s, Selection newSize)
1135 { 1135 {
1160 command->deletePoint(*i); 1160 command->deletePoint(*i);
1161 command->addPoint(newPoint); 1161 command->addPoint(newPoint);
1162 } 1162 }
1163 } 1163 }
1164 1164
1165 command->finish(); 1165 finish(command);
1166 } 1166 }
1167 1167
1168 void 1168 void
1169 TimeValueLayer::deleteSelection(Selection s) 1169 TimeValueLayer::deleteSelection(Selection s)
1170 { 1170 {
1183 if (s.contains(i->frame)) { 1183 if (s.contains(i->frame)) {
1184 command->deletePoint(*i); 1184 command->deletePoint(*i);
1185 } 1185 }
1186 } 1186 }
1187 1187
1188 command->finish(); 1188 finish(command);
1189 } 1189 }
1190 1190
1191 void 1191 void
1192 TimeValueLayer::copy(View *v, Selection s, Clipboard &to) 1192 TimeValueLayer::copy(View *v, Selection s, Clipboard &to)
1193 { 1193 {
1399 1399
1400 prevPoint = newPoint; 1400 prevPoint = newPoint;
1401 command->addPoint(newPoint); 1401 command->addPoint(newPoint);
1402 } 1402 }
1403 1403
1404 command->finish(); 1404 finish(command);
1405 return true; 1405 return true;
1406 } 1406 }
1407 1407
1408 void 1408 void
1409 TimeValueLayer::toXml(QTextStream &stream, 1409 TimeValueLayer::toXml(QTextStream &stream,