Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 360:d58701996fae
* Update remaining editable layers to support proper realignment on copy/paste
* Permit pasting when no suitable layer is current: create a new layer on paste
* Add preference for showing the splash screen or not
* Rename spectrogram smoothing prefs (partly following Craig's suggestions)
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 14:15:09 +0000 |
parents | 020c485aa7e0 |
children | 098c568dc76b |
comparison
equal
deleted
inserted
replaced
359:020c485aa7e0 | 360:d58701996fae |
---|---|
34 #include <QPainter> | 34 #include <QPainter> |
35 #include <QPainterPath> | 35 #include <QPainterPath> |
36 #include <QMouseEvent> | 36 #include <QMouseEvent> |
37 #include <QRegExp> | 37 #include <QRegExp> |
38 #include <QTextStream> | 38 #include <QTextStream> |
39 #include <QMessageBox> | |
39 #include <QInputDialog> | 40 #include <QInputDialog> |
40 | 41 |
41 #include <iostream> | 42 #include <iostream> |
42 #include <cmath> | 43 #include <cmath> |
43 | 44 |
1194 | 1195 |
1195 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1196 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1196 i != points.end(); ++i) { | 1197 i != points.end(); ++i) { |
1197 if (s.contains(i->frame)) { | 1198 if (s.contains(i->frame)) { |
1198 Clipboard::Point point(i->frame, i->value, i->label); | 1199 Clipboard::Point point(i->frame, i->value, i->label); |
1199 point.setReferenceFrame(m_model->alignToReference(i->frame)); | 1200 point.setReferenceFrame(alignToReference(v, i->frame)); |
1200 to.addPoint(point); | 1201 to.addPoint(point); |
1201 } | 1202 } |
1202 } | 1203 } |
1203 } | 1204 } |
1204 | 1205 |
1207 bool interactive) | 1208 bool interactive) |
1208 { | 1209 { |
1209 if (!m_model) return false; | 1210 if (!m_model) return false; |
1210 | 1211 |
1211 const Clipboard::PointList &points = from.getPoints(); | 1212 const Clipboard::PointList &points = from.getPoints(); |
1213 | |
1214 bool realign = false; | |
1215 | |
1216 if (clipboardHasDifferentAlignment(v, from)) { | |
1217 | |
1218 QMessageBox::StandardButton button = | |
1219 QMessageBox::question(v, tr("Re-align pasted items?"), | |
1220 tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), | |
1221 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, | |
1222 QMessageBox::Yes); | |
1223 | |
1224 if (button == QMessageBox::Cancel) { | |
1225 return false; | |
1226 } | |
1227 | |
1228 if (button == QMessageBox::Yes) { | |
1229 realign = true; | |
1230 } | |
1231 } | |
1212 | 1232 |
1213 SparseTimeValueModel::EditCommand *command = | 1233 SparseTimeValueModel::EditCommand *command = |
1214 new SparseTimeValueModel::EditCommand(m_model, tr("Paste")); | 1234 new SparseTimeValueModel::EditCommand(m_model, tr("Paste")); |
1215 | 1235 |
1216 enum ValueAvailability { | 1236 enum ValueAvailability { |
1322 | 1342 |
1323 for (Clipboard::PointList::const_iterator i = points.begin(); | 1343 for (Clipboard::PointList::const_iterator i = points.begin(); |
1324 i != points.end(); ++i) { | 1344 i != points.end(); ++i) { |
1325 | 1345 |
1326 if (!i->haveFrame()) continue; | 1346 if (!i->haveFrame()) continue; |
1347 | |
1327 size_t frame = 0; | 1348 size_t frame = 0; |
1328 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | 1349 |
1329 frame = i->getFrame() + frameOffset; | 1350 if (!realign) { |
1330 } | 1351 |
1352 frame = i->getFrame(); | |
1353 | |
1354 } else { | |
1355 | |
1356 if (i->haveReferenceFrame()) { | |
1357 frame = i->getReferenceFrame(); | |
1358 frame = alignFromReference(v, frame); | |
1359 } else { | |
1360 frame = i->getFrame(); | |
1361 } | |
1362 } | |
1363 | |
1331 SparseTimeValueModel::Point newPoint(frame); | 1364 SparseTimeValueModel::Point newPoint(frame); |
1332 | 1365 |
1333 if (i->haveLabel()) { | 1366 if (i->haveLabel()) { |
1334 newPoint.label = i->getLabel(); | 1367 newPoint.label = i->getLabel(); |
1335 } else if (i->haveValue()) { | 1368 } else if (i->haveValue()) { |
1347 command->addPoint(newPoint); | 1380 command->addPoint(newPoint); |
1348 } | 1381 } |
1349 | 1382 |
1350 command->finish(); | 1383 command->finish(); |
1351 return true; | 1384 return true; |
1352 } | 1385 } |
1353 | 1386 |
1354 void | 1387 void |
1355 TimeValueLayer::toXml(QTextStream &stream, | 1388 TimeValueLayer::toXml(QTextStream &stream, |
1356 QString indent, QString extraAttributes) const | 1389 QString indent, QString extraAttributes) const |
1357 { | 1390 { |