Mercurial > hg > svgui
comparison layer/TimeInstantLayer.cpp @ 76:45ba0b381c5d
* Fix long-standing off-by-1 bug in WaveFileModel that was getting us the wrong
values for almost all audio data when merging channels (channel == -1)
* Implement cut, copy and paste
* Make draw mode work properly in time value layer
* Minor fixes to CSV import
author | Chris Cannam |
---|---|
date | Fri, 07 Apr 2006 17:50:33 +0000 |
parents | bf306158803d |
children | 19bf27e4fb29 |
comparison
equal
deleted
inserted
replaced
75:dfdbf336bb37 | 76:45ba0b381c5d |
---|---|
17 | 17 |
18 #include "base/Model.h" | 18 #include "base/Model.h" |
19 #include "base/RealTime.h" | 19 #include "base/RealTime.h" |
20 #include "base/View.h" | 20 #include "base/View.h" |
21 #include "base/Profiler.h" | 21 #include "base/Profiler.h" |
22 #include "base/Clipboard.h" | |
22 | 23 |
23 #include "model/SparseOneDimensionalModel.h" | 24 #include "model/SparseOneDimensionalModel.h" |
24 | 25 |
25 #include "widgets/ItemEditDialog.h" | 26 #include "widgets/ItemEditDialog.h" |
26 | 27 |
687 if (s.contains(i->frame)) command->deletePoint(*i); | 688 if (s.contains(i->frame)) command->deletePoint(*i); |
688 } | 689 } |
689 | 690 |
690 command->finish(); | 691 command->finish(); |
691 } | 692 } |
692 | 693 |
694 void | |
695 TimeInstantLayer::copy(Selection s, Clipboard &to) | |
696 { | |
697 SparseOneDimensionalModel::PointList points = | |
698 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | |
699 | |
700 for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); | |
701 i != points.end(); ++i) { | |
702 if (s.contains(i->frame)) { | |
703 Clipboard::Point point(i->frame, i->label); | |
704 to.addPoint(point); | |
705 } | |
706 } | |
707 } | |
708 | |
709 void | |
710 TimeInstantLayer::paste(const Clipboard &from, int frameOffset) | |
711 { | |
712 const Clipboard::PointList &points = from.getPoints(); | |
713 | |
714 SparseOneDimensionalModel::EditCommand *command = | |
715 new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); | |
716 | |
717 for (Clipboard::PointList::const_iterator i = points.begin(); | |
718 i != points.end(); ++i) { | |
719 | |
720 if (!i->haveFrame()) continue; | |
721 size_t frame = 0; | |
722 if (frameOffset > 0 || -frameOffset < i->getFrame()) { | |
723 frame = i->getFrame() + frameOffset; | |
724 } | |
725 SparseOneDimensionalModel::Point newPoint(frame); | |
726 if (i->haveLabel()) newPoint.label = i->getLabel(); | |
727 | |
728 command->addPoint(newPoint); | |
729 } | |
730 | |
731 command->finish(); | |
732 } | |
693 | 733 |
694 QString | 734 QString |
695 TimeInstantLayer::toXmlString(QString indent, QString extraAttributes) const | 735 TimeInstantLayer::toXmlString(QString indent, QString extraAttributes) const |
696 { | 736 { |
697 return Layer::toXmlString(indent, extraAttributes + | 737 return Layer::toXmlString(indent, extraAttributes + |